Application-specific utility functions – Echelon FTXL User Manual
Page 212
![background image](/manuals/735717/212/background.png)
200
Example FTXL Applications
The FtxlHandlers.c file contains the modified LonNvUpdateOccurred() function,
which is called when the host processor receives a network-variable update. This
function simply calls the myNvUpdateOccurred() 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 myNvUpdateOccurred() function contains a C switch statement, which
contains a single case statement because the VoltActuator functional block
includes only a single input network variable, nviVolt.
The case statement for the nviVolt network variable (specified by the
LonNvIndexNviVolt network variable index) calls the ProcessNviVoltUpdate()
utility function to perform the following tasks:
• Perform range checking for the network variable
• Set the output network variable to double the value of the input network
variable
• Propagate the output network variable to the network
The two network variables are defined in the model file, which is described in
on page 201.
The myNvUpdateOccurred() function is shown below.
/*
* This function is called by the FTXL LonNvUpdateOccurred
* event handler, indicating that a network variable input
* has arrived.
*/
void myNvUpdateOccurred(const unsigned nvIndex,
const LonReceiveAddress* const pNvInAddr) {
switch (nvIndex) {
case LonNvIndexNviVolt:
{
/* process update to nviVolt. */
ProcessNviVoltUpdate();
break;
}
/* Add more input NVs here, if any */
default:
break;
}
}
Application-Specific Utility Functions
The simple 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.