Owner manual

NodeBuilder FX/PL Examples Guide 33
// Manage the throttle preferences. Note the throttle tick
// counter is maintained by the WheelTimer routine.
if (ulMinSendT >= Cp2Tick(&Wheel::nvoValue::cpWhMinSendT)) {
ulMinSendT = 0;
ulMaxSendT = 0;
nvoWheel = lWheelValue;
}
}
25. Still in wheel.nc, add the following function to handle the network variable heartbeat:
when (timer_expires(WheelTimer)) {
// update throttle timer:
if (ulMinSendT < Cp2Tick(&Wheel::nvoValue::cpWhMinSendT)) {
++ulMinSendT;
}
// manage heartbeats:
if (ulMaxSendT < Cp2Tick(&Wheel::nvoValue::cpWhMaxSendT)) {
++ulMaxSendT;
} else {
// propagate the latest value. Note that we should not use
// the propagate() function here, as propagate() would only
// re-propagate the last NV value. There could have been
// value updates internally since then, which have not made
// it into the NV value due to the throttle. We do
// therefore use an internal mirror of the truly most
// recent value:
Wheel::nvoValue = lWheelValue;
ulMaxSendT = 0L;
}
}
26. Still in wheel.nc, implement the override behavior by adding the following code in bold to the
wheelDirector() function's FBC_OVERRIDE else/if statement:
else if ((TFblock_command)iCommand == FBC_OVERRIDE)
setFblockOverride( uFblockIndex, TRUE );
switch (Wheel::cpWhOvrBehave) {
case OV_RETAIN: // do nothing, keep last value
break;
case OV_SPECIFIED:
// override with specified override value. We
// still must honor heartbeats, but we must
// switch to override value immediately
// (ignoring throttle preferences)
nvoWheel = lWheelValue =
Wheel::nvoValue::cpWhOvrValue;
break;
case OV_DEFAULT:
// override with sensor-specific default value
// (zero). We must continue to honour
// heartbeats, but we must switch to override
// value immediately (ignoring throttle
// preferences)
nvoWheel = lWheelValue = 0L;
ulMinSendT = ulMaxSendT = 0L;
break;
}
27. Complete the implementation of the override behavior by adding the following code in bold to the
wheelDirector() function’s FBC_RMV_OVERRIDE else-if statement:
else if ((TFblock_command)iCommand == FBC_RMV_OVERRIDE)
setFblockOverride(uFblockIndex, FALSE);
nvoWheel = lWheelValue = lWheelPhysical;
// ignore throttle but re-start heartbeat:
ulMinSendT = ulMaxSendT = 0L;