Echelon FTXL User Manual

Page 99

Advertising
background image

FTXL User’s Guide

87

This example extends the previous example and shows how your application can

be notified of an update to either network variable. To receive notification of a
network variable update, modify the LonNvUpdateOccurred() callback function.
In FtxlHandlers.c:

extern void myController(void);

void LonNvUpdateCompleted(unsigned index, const LonBool

success)

{

switch (index) {

case LonNvIndexNviAmpere: /* fall through */

case

LonNvIndexNviVolt:

myController();
break;

default:

/* handle other NV updates (if any) */

}

}

In your application source file:

#include "FtxlDev.h"

void myController(void) {

// nvoWatt = nviAmpere * nviVolt;

LON_SET_UNSIGNED_WORD(nvoWatt,

LON_GET_UNSIGNED_WORD(nviAmpere)

*

LON_GET_UNSIGNED_WORD(nviVolt));

if (LonPropagateNv(LonNvIndexNvoWatt) != LonApiNoError)

{

// handle propagation error here

...
}

}

This modification calls the myController() function defined in the example in the
previous section,

Sending a Network Variable Update

, on page 83. Because

network variable types are defined as type LonWord, this example uses the
LON_GET_UNSIGNED_WORD macros to get the nviAmpere and nviVolt

network variable values, and LON_SET_UNSIGNED_WORD to set the value for

the nvoWatt network variable.

Example 2:
This example adds a configuration network variable to Example 1. A SCPTgain

configuration property is added to the device interface in the model file:

network input SNVT_amp

nviAmpere;

network input SNVT_volt

nviVolt;

network output SNVT_power

nvoWatt;

network input cp SCPTgain nciGain;

fblock UFPTpowerConverter {

nvoWatt

implements nvoPower;

nviAmpere implements nviCurrent;

nviVolt

implements nviVoltage;

} powerConverter fb_properties {

Advertising