Fpm application, Fpm driver – Echelon i.LON SmartServer 2.0 User Manual
Page 221

i.LON SmartServer 2.0 Programming Tools User’s Guide
207
For an FPM application, you can also use the OnTimer() routine to start and stop timers, and you
can use it to read and write to data point properties. For an FPM driver, you can use the OnTimer()
routine to read and write to the RS-232 and RS-485 interfaces.
FPM Application
The following code demonstrates code you could use in the OnTimer() routine in an FPM
application. In this example, the m_oTimer.Expired()method valuates which of two timers has
expired and performs some tasks upon their expiration. If m_oTimer1 expires, the OnTimer()
routine checks whether the status of a data point is AL_ALM_CONDITION. If m_oTimer2 expires,
the OnTimer() routine re-starts the timer.
CFPM_Timer m_oTimer1; //declared in header file
CFPM_Timer m_oTimer2; //declared in header file
m_oTimer1.Start(FPM_TF_REPEAT, 2000);
m_oTimer2.Start(FPM_TF_ONETIME, 0);
void CUFPT_FPM_Application::OnTimer()
{
if (m_oTimer1.Expired())
{
//check status of a data point
nviTemp_status =
nviTemp.GetDpPropertyAsPointStatus(FPM::Dp::dataUCPTstatus);
if (nviTemp_status == AL_ALM_CONDITION)
{
//perform algorithm if nviTemp status is AL_ALM_CONDITION
}
}
if (m_oTimer2.Expired())
{
//restart a timer
m_oTimer2.Start(FPM_TF_ONETIME, 1000);
}
}
FPM Driver
The following example demonstrates code you could use in the OnTimer()routine of an FPM driver.
In this example, a custom timer handler method evaluates whether a timer started with the
START_TIMER method has expired. If the timer has expired, the custom timer handler method read
and writes to the RS-232 interface.
CFPM_Timer m_oTimer3; //declared in header file
START_TIMER(m_oTimer3, FPM_TF_REPEAT, 10000, RS_232_Timer);
void CUFPT_FPM_Driver::RS_232_Timer()
{
if (rs232_read(RS232_fd, Line1, 1) == 1)
{
rs232_write(RS232_fd, (Byte *)"F1", strlen("F1"));
}
}