Echelon Mini FX User Manual

Page 100

Advertising
background image

Mini FX User's Guide

87

SFPTopenLoopActuator, where each functional block encapsulates the network

variable and configuration property for each lamp.

Following the declaration of the input network variables and configuration properties,

the fblock construct defines the functional block, and it describes how locally
implemented network variables and configuration properties map to the definitions in

the SFPTopenLoopActuator functional profile instantiated by the functional block.
The first element of the nviSwitch network variable array implements the profile’s
nviValue member (and subsequent members of this network variable array are

distributed among the other elements of the fblock array). Similarly, the first element of
the lamp[0] fblock array uses the first element of the nciLocation configuration

property array.

#include "io.nc"

#pragma num_alias_table_entries 2 // required by compiler

//
// Input network variable declaration. For multiple lamps
// of the same characteristic, it is best to declare the
// related network variables as an array:
//
network input SNVT_switch nviSwitch[2];

//
// Configuration network variables are used just like any
// other network variable, but are updated very infrequently,
// and their values reside in non-volatile memory (e.g. EEPROM
// or flash memory)
//
network input cp SCPTlocation nciLocation[2];

//
// Functional blocks group network variables, configuration
// properties and other aspects of a logical unit within a
// device's application together. Similar to other data items,
// functional blocks can also be implemented as arrays:
//
fblock SFPTopenLoopActuator {
nviSwitch[0] implements nviValue;
} lamp[2] fb_properties {
nciLocation[0]
};

//
// when(nv_update_occurs) executes when the referenced input network
// variable receives a new value:
//
when(nv_update_occurs(nviSwitch))
{
SetLeds(nviSwitch[0].state, nviSwitch[1].state);
}

void OnButtonPressed(void)
{
// Do nothing in this application
}

when(reset) {
InitializeIO();

LcdDisplayString(0,0, "Second Digital");
LcdDisplayString(1,0, "Actuator Example");
LcdDisplayString(2,0, "-+-+-+-+-+-+-+-+-+-+");
LcdDisplayString(3,0, "nviSwitch drives LED");
}

Advertising