Writing the fpm application ontimer() routine – Echelon i.LON SmartServer 2.0 User Manual
Page 98

84
Creating Freely Programmable Modules
Writing to Enumerated Data Points
To write to an enumerated data point, you need to use the values of the corresponding enumeration
type. The following code demonstrates how to write to an hvac_t enumeration in the standard.h
file in the LonWorks\iLON\Development\include folder:
DECLARE(_0000000000000000_0_::SNVT_hvac_mode, nvoHVACMode, OUTPUT_DP)
.........
void CUFPTHVACController::Work()
{
SNVT_switch ACSwitch;
SNVT_switch
FurnaceSwitch;
ACSwitch.state = nviACSwitch->state;
FurnaceSwitch.state = nviFurnaceSwitch->state;
if ((tmpACSwitch.state == 1) &&
(tmpFurnaceSwitch.state == 0))
{
nvoHVACMode = hvac_t::HVAC_COOL;
printf ("HVAC MODE = %i \n", *nvoHVACMode);
}
}
Writing the FPM Application OnTimer() Routine
The OnTimer() routine is executed when a timer started with the Start() method in the
Initialize()
routine expires. You can use this routine to read the properties of the data points
declared in the FPM application. This is useful for implementing tasks that need to be performed
regularly such as checking data point status and sending data point updates (heartbeats). For more
information on reading data point properties in an FPM application, see the previous section, Writing
the FPM Application Work() Routine.
Note that if you started more than one timer using the Start() method of the CFPM_Timer class,
you must first identify the timer that expired using the m_oTimer.Expired() method.
The following code demonstrates how to create an OnTimer() routine that handles the expiration of
a single timer started with the Start() method of the CFPM_Timer class.
void CUFPTHVACController::Initialize()
{
m_oTimer1.Start(FPM_TF_REPEAT, 2000);
}
void
CUFPTHVACController::OnTimer()
{
//check for data point alarm conditions
if (nviSetPoint_status == FPM::Dp::AL_ALM_CONDITION)
{
printf ("SetPoint status = %d", nviSetPoint_status);
nviSetPoint = 20.28;
}
if (nviTemp_status == FPM::Dp::AL_ALM_CONDITION)
{
printf ("Temp status = %d", nviTemp_status);
nvoHVACMode = hvac_t::HVAC_COOL;
}
}