beautypg.com

Callback handler function, Model file – Echelon FTXL User Manual

Page 213

background image

FTXL User’s Guide

201

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

the device goes online.

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 simple

voltage actuator 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.

*/

void myEventReady(void) {
/* Signal application task so that it can process the

* event. */

OsalSetEvent(eventReadyHandle);
}

Model File

The model file, Simple Example.nc, defines the L

ON

W

ORKS

interface for the

example FTXL device.
The model file defines one functional block, VoltActuator. The VoltActuator

functional block includes two network variables, nviVolt and nvoVoltFb. The
functionality for these network variables is implemented in the

myNvUpdateOccurred() function described in

Event Handler Function

on page

199.
The model file is shown below.

#pragma enable_sd_nv_names


network input SNVT_volt nviVolt;

network output SNVT_volt bind_info(unackd) nvoVoltFb;


fblock SFPTclosedLoopActuator {

nviVolt implements nviValue;

nvoVoltFb implements nvoValueFb;

} VoltActuator
external_name("VoltActuator");