beautypg.com

Writing the fpm driver work() routine, Writing the fpm driver ontimer() routine – Echelon i.LON SmartServer 2.0 User Manual

Page 101

background image

i.LON SmartServer 2.0 Programming Tools User’s Guide

87

Line1.SetDpProperty(FPM::Dp::cfgUCPTpersist,

bValue);

//write

data point poll rate in milliseconds

Line1.SetDpProperty(FPM::Dp::cfgUCPTpollRate,

nValue);

//

write data point unit string

Line1.

SetDpProperty(FPM::Dp::cfgUCPTunit, pszValue);

The following code demonstrates the methods you can create in the Initialize() routine in an
FPM driver for the RS-232 interface:

CFPM_Timer m_oDisplay_InputTimer; //declare timer in header file
............

DECLARE(_0000000000000000_0_::SNVT_str_asc, Line1, INPUT_DP)
DECLARE(_0000000000000000_0_::SNVT_switch, F1_Pressed, OUTPUT_DP)

int RS232_fd = -1;

void

CUFPT_Display::Initialize()

{

// start timer

m_oDisplay_InputTimer.Start(FPM_TF_REPEAT,

10000);

// open the RS232 interface

RS232_fd

=

rs232_open(RS232_DEFAULT_BAUDRATE);

//set Line1 DP poll rate

F1_Pressed.SetDpProperty(FPM::Dp::cfgUCPTpollRate,

800);

}

See the Programmer’s Reference in Appendix A for more information on writing the RS-232 and RS-
485 interface methods and writing timer methods.

Writing the FPM Driver Work() Routine

The Work() routine is executed when one or more data points declared in the FPM driver are
updated. In the Work() routine, you write one or more IF-THEN(-ELSE) statements that use the
Changed()

method to evaluate whether the data points in the FPM driver have been updated.

If a data point has been updated, you initialize communication between your FPM and the devices
connected to the RS-232 and RS-485 serial interfaces. You can initialize communication with the RS-
232 serial interface using the rs232_ioctl()method. You can initialize communication with the
RS-485 serial port using the rs485_setparams()and rs485_ioctl()methods.

Once you initialize communication, you can directly write to the RS-232 and RS-485 serial interfaces
without using any additional methods. You can also read data point properties using the methods
described in Writing the FPM Application Work() Routine.

void CUFPT_Display::Work()
{

if (Changed (Line1))

{

printf("update for Line1 (%s)\n", Line1->ascii);

//write Line 1 text to RS-232 interface
rs232_write(RS232_fd, (Byte *)Line1->ascii,

strlen((char*)Line1->ascii));

}

}

Writing the FPM Driver 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 initialize communication between your