Echelon LonTal Stack User Manual

Page 129

Advertising
background image

LonTalk Stack Developer’s Guide

117

Do not handle an update failure with a repeated propagation; the LonTalk host

stack automatically retries a number of times based on the network variable’s
retry count. A completion failure generally indicates a problem that should be

signaled to the user interface (if any), flagged by an error or alarm output

network variable (if any), or by signaled as a comm_failure error through the
nvoStatus network variable of the Node Object functional block (if there is one).
Example: The following model file defines the device interface for a simple
power converter. This converter accepts current and voltage inputs on its

nviAmpere and nviVolt input network variables. It computes the power and
sends the value on its nvoWatt output network variable:

network input SNVT_amp

nviAmpere;

network input SNVT_volt

nviVolt;

network output SNVT_power

nvoWatt;


fblock UFPTpowerConverter {

nvoWatt

implements nvoPower;

nviAmpere implements nviCurrent;

nviVolt

implements nviVoltage;

} powerConverter;

The following code fragment, implemented in your application’s code, uses the
data most recently received by either of the two input network variables,

computes the product, and stores the result in the nvoWatt output network

variable. It then calls the LonPropagateNv() function to send the computed
value.

#include "FtxlDev.h"

void myController(void)
{

nvoWatt = nviAmpere * nviVolt;

if (LonPropagateNv(LonNvIndexNvoWatt)!= LonApiNoError) {

// handle propagation error here

// such as lack of buffers or validation

...
}
}

Receiving a Network Variable Update from the
Network

When the LonTalk host stack receives a network variable update from the

network, it enqueues the event and signals the arrival of the event by calling the
LonEventReady() callback handler function. When the application calls the

LonEventPump() function, the LonTalk host stack writes the update to your
network variable (by using the variable’s address stored in the network variable

table), and then calls the LonNvUpdateOccurred() event handler function to

inform your application that the update occurred. The application can read the
current value of any input network variable by reading the value of the variable

declared in the FtxlDev.c file.
If a network variable update is received while the LonTalk Stack device is offline,
the value of the network variable is updated, but the LonNvUpdateOccurred()

event handler function is not called.

Advertising