_data This is the data structure for variables that must be linked_init This is the code that must be called after the DLL is loaded but before _code is called for the first time. This must return the number of seconds before the first call to _code _code This is the code that must be called each time to PLC syncs. This must return the number of seconds before the next sync.The data structure must conform to the following structure:
struct { char *name; enum {DT_INTEGER=6, DT_DOUBLE=1} type; void *addr; } data[];
NULL name (this is very important).
The compiler will automatically create a conforming DLL from a .plc file having the following typical structure
See Machine Implementation for an example of PLC code
Modules | |
| Communication networks (comm) | |
| Messages are sent from one PLC object to another using PLC code. | |
| Machine implementation | |
| The machine object implements the PLC code. | |
Functions | |
| int | plc::create () |
| Create a new object. | |
| EXPORT int | create_plc (OBJECT **obj, OBJECT *parent) |
| int | plc::init (OBJECT *parent) |
| Initialize the new object. | |
| EXPORT int | init_plc (OBJECT *obj) |
| plc::plc (MODULE *mod) | |
| Register the new object class and construct the default object properties. | |
| TIMESTAMP | plc::sync (TIMESTAMP t0, TIMESTAMP t1) |
| Synchronize the object. | |
| EXPORT TIMESTAMP | sync_plc (OBJECT *obj, TIMESTAMP t0) |
Variables | |
| static plc * | plc::defaults = NULL |
| a pointer to the default values for new objects | |
| static CLASS * | plc::oclass = NULL |
| a pointer to the registered object class definition | |