Echelon LonTal Stack User Manual

Page 132

Advertising
background image

120

Developing a LonTalk Stack Device Application

{

// nvoWatt = nviAmpere * nviVolt * nciGain.multiplier;

LON_SET_UNSIGNED_WORD(nvoWatt,

LON_GET_UNSIGNED_WORD(nviAmpere)
*

LON_GET_UNSIGNED_WORD(nviVolt)

*

LON_GET_UNSIGNED_WORD(nciGain.multiplier));

//

nvoWatt /= nciGain.divider;

LON_SET_UNSIGNED_WORD(nvoWatt,

LON_GET_UNSIGNED_WORD(nvoWatt)

/ LON_GET_UNSIGNED_WORD(nciGain. divider));

if (LonPropagateNv(LonNvIndexNvoWatt) != LonApiNoError)

{

// handle propagation error here

...
}
}

Configuration network variables must be persistent, that is, their values must

withstand a power outage.

Handling a Network Variable Poll Request from the
Network

Devices on the network can request the current value of a network variable on
your device by polling or fetching the network variable. The LonTalk host stack

responds to poll of fetch requests by sending the current value of the requested
network variable.

Handling Changes to Changeable-Type Network
Variables

When a network management tool plug-in or the OpenLNS CT Browser changes

the type of a changeable-type network variable, it informs your application of the
change by describing the new type in the SCPTnvType configuration property

that is associated with the network variable.
When your application detects a change to the SCPTnvType value:

• It determines if the change is valid.
• If the change is valid, it processes the change.
• If the change is not valid, it reports an error.

Valid type changes are those that the application can support. For example, an
implementation of a generic PID controller might accept any numerical

floating-point typed network variables (such as SNVT_temp_f, SNVT_rpm_f, or
SNVT_volt_f), but can reject other types of network variables. Or a data logger

device might support all types that are less than 16 bytes in size, and so on.
See The Dynamic Interface Example Application for an example application that
handles changeable-type network variables.

Advertising