Application-specific utility functions, Callback handler function, Application-specific – Echelon FTXL User Manual

Page 225: Utility functions, 213 to ma

Advertising
background image

FTXL User’s Guide

213

Application-Specific Utility Functions

The dynamic interface example application includes the following application-

specific utility functions:

• ProcessNviVoltUpdate(): Performs range checking for the network

variables, sets the output network variable to double the value of the
input network variable, and propagates the output network variable to

the network.

• ProcessOnlineEvent(): Calls the ProcessNviVoltUpdate() function when

the device goes online.

• ProcessTypeChange(): For each type change to the nviVolt or nvoVoltFb

network variables, this function processes the type change. It checks

that the type change is valid (from SNVT_volt to SNVT_volt_mil or from

SNVT_volt_mil to SNVT_volt), converts the network variable’s value to
match the new type, stores the type and value in the nciNvType

configuration property network variable, and stores the value in non-
volatile memory.

• UpdateCircuitMap(): As dynamic network variables are added,

modified, or deleted from the logical circuits defined for the device, this
function updates the circuit map table. This function verifies that the

update is for a vaid circuit, that the network variables use the proscribed

naming convention, and calls the UpdateCircuitOutput() function.

• UpdateCircuitOutput(): This function reads the circuit map table to

calculate the sum of the input dynamic network variables for each
output dynamic network variable, and then propagates the output

dynamic network variable to the network.

These functions are defined in the main.c file.

Callback Handler Function

To signal to the main application the occurrence of certain types of events, the

FTXL LonTalk API calls specific callback handler functions. For the dynamic

interface example application, only one of the API’s callback handler functions
has been implemented to provide application-specific behavior.
The FtxlHandlers.c file contains the modified LonEventReady() function, which is
called when the FTXL LonTalk protocol stack receives a network event. This

function simply calls the myEventReady() function in the main.c file that

provides the application-specific behavior. This functional separation approach
keeps changes to the LonTalk Interface Developer utility-generated files to a

minimum. For a production-level application, you can place application-specific

code wherever your application design requires it.

The myEventReady() function calls the FTXL OSAL OsalSetEvent() function to

signal the application task so that it can process the network event.
The myEventReady() function is shown below.

/* This function is called by the FTXL LonEventReady
* callback, signaling that an event is ready to be

* processed.
*/

Advertising