|
Compounds |
| union | MIXED_str |
| struct | plc_str |
| struct | readGroup_str |
| struct | writeGroup_str |
Defines |
| #define | VERSION __DATE__ |
| #define | INVALID_SOCKET (-1) |
| #define | ERROR (-1) |
| #define | MAX_PLC 5 |
| #define | MAX_REQUEST 500 |
| #define | MAX_READ_POINTS 125 |
| #define | MAX_WRITE_POINTS 500 |
| #define | MAX_MEM 10000 |
| #define | TIMEHISTLENGTH 200 |
| #define | MAX_REPORTGROUPS 20 |
| #define | FAST_CYCLE 20 |
| #define | SLOW_CYCLE 2000 |
| #define | DELAY_RW 330 |
| #define | DELAY_WATCHDOG 5000 |
| #define | logMsg printf |
Typedefs |
| typedef MIXED_str | MIXED |
| typedef plc_str | plc_t |
| typedef readGroup_str | readGroup_t |
| typedef writeGroup_str | writeGroup_t |
Enumerations |
| enum | radix_t { RAD_dec = 0,
RAD_hex
} |
Functions |
| void | setEpicsVariables (void) |
| int | modtcpCheckLimits (PLC_ID pPlc, int start, int length, int offset, int maxp) |
| | Checks the limits of the parameters to ensure no overflows possible.
|
| int | modtcpInitWriteData (PLC_ID pPLC, WRITEGROUP_ID pGr) |
| int | modtcpEncodeRead_rq (int function, int start, int points, char *readRequest) |
| int | modtcpEncodeWrite_rq (int function, int reg, int value, char *readRequest) |
| int | modtcpStoreData (PLC_ID pPlc, READGROUP_ID pGr, char *readReply) |
| | Takes the read reply from the PLC and decomposes into the shared memory pool at the proper location.
|
| void | modtcpCounterInit (PLC_ID pPlc) |
| | Initializes the statistics counters for the specified PLC.
|
| void | modtcpReadCount (PLC_ID pPlc, int ok) |
| | Increments the read statistics counter.
|
| void | modtcpWriteCount (PLC_ID pPlc, int ok) |
| | Increments the write statistics counter.
|
| void | modtcpUnpackResponse (char *msg, int start) |
| void | plcRead (PLC_ID pPlc) |
| | This function continuously reads the PLC read registers and loads the data into the local data structure.
|
| void | plcWrite (PLC_ID pPlc) |
| | This function continuously monitors the local data structure and sends.
|
| void | plcWatch (PLC_ID pPlc) |
| | The watchdog task for the PLC.
|
| int | modtcpUser (char *cmd) |
| | This is the console based user interface tool.
|
| int | modtcpDrvCreate (char *name, int tcpPort, char *inet_address, int mem_length) |
| | Creates the data structures, initializes values and prepares all socket information for the connection to a PLC.
|
| long | modtcpInit () |
| | Initializes all defined PLCs.
|
| long | modtcpInitPlc (int index) |
| | Starts the processes that will read and write via sockets to the PLC.
|
| long | modtcpAbort (int index) |
| | Shuts down the tasks/threads associated with a particular PLC.
|
| void | modtcpRecover (int index) |
| | Attempts to recover the system by restarting the system.
|
| int | modtcpWrite (int index, int addr, unsigned short mask, unsigned short *pData) |
| | Writes the passed value to the requested register in the PLC.
|
| int | modtcpRead (int index, int addr, unsigned short mask, unsigned short *pData) |
| | Reads the current value of the requested register in the PLC.
|
| int | modtcpInitRead (int index, int addr, unsigned short mask, unsigned short *pData) |
| | EPICS device support access function for PLC reads at record initialization time.
|
| int | modtcpCheckParams (int plcindex, int addr) |
| | Checks the bounds of the passed address to ensure it is valid for the specified PLC.
|
| int | modtcpDrvReadGroup (char *name, unsigned short start, unsigned short length, unsigned int offset, int read_once) |
| | Create a read group for the PLC read thread to scan on a regular basis.
|
| int | modtcpDrvWriteGroup (char *name, unsigned short start, unsigned short length, unsigned int offset) |
| | Create a write group for the PLC write thread to update whenever there are changes.
|
| void | modtcpWatchdog (char *plcname, int address) |
| | Define the location of the Watchdog register in the PLC.
|
| void | modtcpKeepalive (char *plcname, int address) |
| | Define the location of the Keepalive register in the PLC.
|
| long | modtcpReport (int level) |
| | Displays information for each PLC adn the associated read and write groups.
|
| void | modtcpGetTimes () |
| | Displays timing statistics.
|
| int | modtcpSetDelay (int delay) |
| | Sets delay value for the read task loop time.
|
| int | modtcpSetWatchdogDelay (int delay) |
| | Sets delay value for the watchdog task loop time.
|
| void | modtcpNoisy (int noisy) |
| | Enabled or disables noisy presentation.
|
| int | modtcpIsNoisy () |
| | Tests value of noisy flag.
|
| PLC_ID | plcOpen (char *name) |
| | Find the PLC by name in the linked list.
|
| int | plcIndex (char *name) |
| | Find the index of the PLC by name in the linked list.
|
| char * | plcName (int index) |
| | Find the index of the PLC by name in the linked list.
|
| void | modtcpStartHist (int plcindex) |
| | Starts logging of activity for diagnostics.
|
| void | modtcpStopHist (int plcindex) |
| | Stops the histogram system.
|
| void | modtcpPrintHist (int plcindex) |
| | Displays the histogram information.
|
| int | setplc (char *name) |
| int | setplcindex (int index) |
| int | rplc (int start, int regs) |
| int | dplc (int start, int regs) |
| int | dgrp (int index, char typ) |
| int | mplc (int addr, int data) |
| void | modreport (int mode) |
| | Change the reporting mode for the screen and slow down the rate to make viewing of info easier.
|
| void | plchex () |
| void | plcdec () |
Variables |
| int | drvModtcpNoisy = 1 |
| int | drvModtcpDebug = 0 |
| int | modprot = 0 |
| int | modRecoverId = 0 |
| unsigned long | modtcpMaxread = 0 |
| unsigned long | modtcpMaxwrite = 0 |
| int | modtcpDebugReadRequest = 0 |
| int | modtcpDebugReadOk = 0 |
| long | moddelay = DELAY_RW |
| long | modwatch = DELAY_WATCHDOG |
| long | modwatch_disconnect = 1 |
| long | max_noupd_count = 2 |
| long | plc0_read_ok |
| long | plc0_write_ok |
| long | plc0_read_bad |
| long | plc0_write_bad |
| long | plc0_enbHist |
| long | plc0_timeLong |
| long | plc0_readTicks |
| long | plc0_timeHist [TIMEHISTLENGTH] |
| long | plc0_groupTime [MAX_REPORTGROUPS] |
| PLC_ID | Plcs [MAX_PLC] |
| PLC_ID | pFirstPlc |
| PLC_ID | diagPlc |
| int | no_of_plcs |
| char * | driver = "drvModtcp" |
| const unsigned short | mbapListenPort = 502 |
| const int | modbusEncoding = 0 |
| int | modreadrep = 0 |
| int | modwriterep = 0 |
| int | moddogrep = 0 |
| radix_t | radix |
Functions are provided for defining read and write registers in the PLC which are mapped to a shared memory space and updated on a regular basis. Single writes to the shared memory are sent to the PLC.
The following example shows what calls to make to setup the driver.
modtcpDrvCreate("theplc", 502, "xx.xx.xx.xx", 1024);
modtcpDrvReadGroup("theplc", 101, 1, 101, 1);
modtcpDrvReadGroup("theplc", 100, 1, 100, 0);
modtcpDrvReadGroup("theplc", 103, 1, 103, 0);
modtcpDrvWriteGroup("theplc", 101, 1, 101);
modtcpDrvWriteGroup("theplc", 104, 1, 104);
modtcpWatchdog("theplc", 103);
modtcpKeepalive("theplc", 104);