Echelon NodeBuilder FX/PL Examples User Manual
Page 37
NodeBuilder FX/PL Examples Guide
29
&&
(current.hour
==
RealTimeKeeper::nviAlarmTime.hour)
)
{
//
raise
alarm
rtc_alarmstate
=
rtc_alarm_alarm;
RealTimeKeeper::nviAlarmState.state
=
SWITCH_ON;
}
break;
case
rtc_alarm_alarm:
//
alarm
currently
visible/audible,
//
awaiting
acknowledgement
break;
}
}
rtc_coretick
= RealTimeKeeper::nvoTimeDate::cpRtcUpdRate * 100UL;
}
void RealTimeKeeperDirector(unsigned uFblockIndex, int iCommand)
This code controls timer processing.
18. Still in RealTimeKeeper.nc, add the following code in bold:
void RealTimeKeeperprocessNV(void)
{
if (deviceState.nvIndex
==
nv_table_index(RealTimeKeeper::nviAlarmAck))
{
//
alarm
acknowledgement:
if (rtc_alarmstate == rtc_alarm_alarm) {
rtc_alarmstate
=
rtc_alarm_armed;
RealTimeKeeper::nvoAlarmState.state
=
SWITCH_OFF;
}
} else if (deviceState.nvIndex
==
nv_table_index(RealTimeKeeper::nviAlarmTime))
{
//
alarm
spec:
if ((RealTimeKeeper::nviAlarmTime.year == 0)
&&
(RealTimeKeeper::nviAlarmTime.month
==
0)
&& (RealTimeKeeper::nviAlarmTime.day == 0)) {
//
stop
the
nonsense!
rtc_alarmstate
=
rtc_alarm_idle;
}
else
{
//
start/restart
the
nonsense
rtc_alarmstate
=
rtc_alarm_armed;
}
} else if (deviceState.nvIndex
==
nv_table_index(RealTimeKeeper::nviTimeSet))
{
//
set
time:
GizmoSetTime(&RealTimeKeeper::nviTimeSet);
}
}
#endif //_HAS_INPUT_NV_
This code processes input network variable updates to the network variable handler function. This
can be implemented in a number of ways. The solution presented here minimizes the number of
when statements and thereby limits the scheduler latency. This is at the expense of extra
processing time when the event occurs, since the function has to find out what network variable
generated the event.
Other ways to approach the problem would be processing both input network variables at all times
(for example, whenever either one of them has been updated, or implementing one when
(nv_update_occurs(....))
step for each input network variable. To implement the latter
solution, you would have to remove or comment out the Code Wizard start/end tags around the
existing when statement. The following code shows how this would be implemented:
//--{{NodeBuilder Code Wizard Start
// disabled the above to prevent CodeWizard from re-generating
// the associated code
// the NodeBuilder Code Wizard will add and remove code here.
// DO NOT EDIT the NodeBuilder Code Wizard generated code in these blocks!