The nv_update_completes event, Synchronous network variables, 53 describes the behavior of – Echelon Neuron C User Manual

Page 65

Advertising
background image

Neuron C Programmer’s Guide

53

heater_failed = FALSE;
// heater device received update
}

The nv_update_completes Event

The nv_update_completes event evaluates to TRUE whenever an output network
variable update or poll either succeeds or fails. An example of testing for

network variable update completion is shown below:

#include <io_types.h>
#define C_TO_K 2740
IO_7 input ontime invert clock(2) io_temperature_sensor;
network output SNVT_temp nvoCurrentTemp;
when (nv_update_completes(nvoCurrentTemp))
{ // latest temperature has been sent out
ontime_t

sensor_value;


// send another update

sensor_value = io_in(io_temperature_sensor);

nvoCurrentTemp = (sensor_value * 221) / 642

+

211

+

C_TO_K;

// tenths of a degree,C

}

If a program checks for nv_update_completes or nv_update_succeeds for any

network variable, the program is said to use comprehensive completion event

testing. See

Comprehensive Completion Event Testing

on page 55 for the rules

you should follow.

Synchronous Network Variables

When an output network variable is updated, the Neuron firmware ensures that

the most recent value assigned to an output is propagated and received as an
event by any connected input network variables. Thus, if multiple updates are

made to an output network variable within the same critical section, only the last
value assigned is ensured to be propagated and received as an event at the input

network variables.
A critical section is defined by the boundaries of the executing when task. After
the when task completes, the most recent value is scheduled for propagation.
You can specify that

all

updates to an output network variable (within the critical

section) must be propagated and received as events by using the

synchronous

subclass of network variables.
However, for a synchronous output network variable, each updated value is

immediately scheduled for propagation, which requires an application output
buffer for each scheduled update. If all output buffers are already in use when an

update to a synchronous output network variable is scheduled, the Neuron

firmware enters preemption mode to attempt to complete pending transactions
and thus free in-use application output buffers.
As a result, updating synchronous output network variables can cause your when
task to execute in a non-deterministic fashion. See

Preemption Mode

on page 55

for more information about buffers and preemption mode.

Advertising