User Manual

i.LON SmartServer 2.0 Programming Tools User’s Guide 79
In the algorithm, you can directly read and write values to the data points declared in your FPM
application without using any additional methods. In addition, you can read the statuses, names, and
times of last update of the data points using a collection of data point property methods, and you can
start and stop timers. For more information on starting timers, see the previous section,
Writing the
FPM Application Initialize() Routine.
The following code demonstrates how you can create a Work()routine in your FPM application. In
this example, the Work()routine first checks whether the data points declared in the FPM application
have been updated. If one of the data points has been updated, the Work()routine gets the statuses
the data points, checks whether the data points are in normal condition, and then reads and writes
values to them if they are in normal condition.
void CUFPTHVACController::Work()
{
SNVT_switch tempAirConditioner;
if ((Changed( nviSetPoint ) || Changed( nviTemp )) &&
(nviHVACMode == hvac_t::HVAC_COOL))
{
nviSetPoint_status =
nviSetPoint.GetDpPropertyAsPointStatus(FPM::Dp::dataUCPTstatus);
printf ("nviSetPoint_status = %d", nviSetPoint_status);
nviTemp_status =
nviTemp.GetDpPropertyAsPointStatus(FPM::Dp::dataUCPTstatus);
printf ("nviTemp_status = %d", nviTemp_status);
if (nviSetPoint_status == FPM::Dp::AL_NO_CONDITION) &&
(nviTemp_status == FPM::Dp::AL_NO_CONDITION)
{
if (nviTemp > (nviSetPoint + nciHysteresis))
{
nvoAirConditioner_OnOff->value = 200;
nvoAirConditioner_OnOff->state = 1;
PROPAGATE (nvoAirConditioner_OnOff);
printf ("Temp = %f, SetPoint=%f, AC is
ON \n", *nviTemp, *nviSetPoint);
}
}
}
}
Checking for Data Point Value Updates
You can use the Changed() method in the Work() routine to determine whether the value of a data
point has changed. This method takes a data point declared in the FPM application. If the value of the
data point has changed, it returns TRUE; otherwise, it returns FALSE. The following example
demonstrates how you can use the Changed()method to check whether the values of the data points
in your FPM application have changed.
if (Changed(x) || Changed(y))
{
//execute some algorithm if the values of x or y have changed
}