User`s guide
204  Appendix A - Programmer’s Reference 
Overview 
This chapter provides details you will need when programming your module. It includes the following 
sections: 
• 
Template Files. This section describes the template files you will use to create your module. 
• 
Routines. This section describes the four main routines you will need to implement within your 
custom module: Initialize(), Work(), OnTimer(), and Shutdown(). 
• 
Methods. This section describes the data point, timer, RS-232 interface, RS-485 interface, and file 
access methods you can call from the four main routines. 
Template Files 
When you create an FPM, the following template files are generated for your module. 
•  .cpp file. This C++ source file contains the Initialize(), Work(), OnTimer(), and 
Shutdown() routines that specify the behavior of your FPM. 
•  .h file. This C header template file contains all the routine and method definitions for your FPMs. 
•  _Utils.cpp file. This C++ source file contains all the helper routines called by the 
Initialize(), Work(), OnTimer(), and Shutdown() routines. 
Routines 
The behavior of an FPM is defined by the Initialize(), Work(), OnTimer(), and 
Shutdown()routines that are called from the .cpp file. The following table displays when these 
routines are executed and the type of functions performed in each of these routines for an FPM 
application and an FPM driver. 
Functions to be Performed in FPM 
Routine 
When Routine 
is Executed 
FPM Application  FPM Driver 
Initialize() 
FPM is started 
or enabled 
1.  Set initial data point 
values. 
2.  Start timers. 
1.  Open RS-232 or RS-485 
interface. 
2.  Start timers. 
3.  Write data point 
properties. 
Work() 
Data point value 
changes 
1.  Execute an algorithm. 
2.  Start and stop timers. 
3.  Read data point 
properties. 
1.  Initialize RS-232 or RS-
485 interface. 
2.  Write to the RS-232 or RS-
485 interface. 
OnTimer() 
Timer expires  1.  Perform routine tasks 
such as reading data 
point status. 
2.  Read other data point 
properties. 
3.  Start and stop timers. 
1.  Initialize RS-232 or RS-
485 interface. 
2.  Read and write to RS-232 
or RS-485 interface. 
3.  Write values to data points. 
Shutdown() 
FPM is stopped 
or disabled 
1.  Stop timers.  1.  Stop timers. 
2.  Close RS-232 or RS-485 
connection. 










