31 lines
1.0 KiB
Smalltalk
31 lines
1.0 KiB
Smalltalk
(* Bench test: create PROGRAM PLC_PRG, ST language. Add the SysTime library.
|
|
Add CmpAtomModbus as a library; qualify atMbCall_cext with its namespace if
|
|
the Library Manager requires it. Paste this in the DECLARATION pane. *)
|
|
PROGRAM PLC_PRG
|
|
VAR
|
|
run : BOOL := FALSE; (* Set TRUE in watch window to start. FALSE closes. *)
|
|
ipAddress : DWORD := 16#C0A80132; (* EDIT: 192.168.1.50 *)
|
|
tcpPort : UINT := 502;
|
|
unitId : BYTE := 1;
|
|
startAddress : UINT := 0; (* Zero-based wire address, not 40001. *)
|
|
registers : ARRAY[0..9] OF WORD;
|
|
status : ARRAY[0..23] OF UDINT;
|
|
handle : UDINT := 0; (* Do NOT retain/persist this. *)
|
|
command : UDINT := 0;
|
|
callResult : UDINT;
|
|
timeResult : UDINT;
|
|
nowUs : SYSTIME;
|
|
nowMs : ULINT;
|
|
lastReadMs : ULINT;
|
|
readDone : BOOL;
|
|
requestError : BOOL;
|
|
hasValidData : BOOL;
|
|
dataStale : BOOL := TRUE;
|
|
lastRequestResult : UDINT;
|
|
lastException : UDINT;
|
|
lastSocketError : UDINT;
|
|
requestErrorCount : UDINT;
|
|
successfulReadCount : UDINT;
|
|
pollDelay : TON;
|
|
END_VAR
|