<< Click to Display Table of Contents >> Navigation: Modbus Universal MasterOPC Server > Description of the Mod_RSSim Simulator > Script Automation > Simulator API |
GetRegisterValue (REG_TYPE as long , ADDRESS as long) As int
SetRegisterValue (REG_TYPE as long, ADDRESS as long, REGISTERVALUE as long) As none
DisableStation (STATIONID as int) As none
EnableStation (STATIONID as int) As None
StationEnabled (STATIONID as int) As long
AddDebugString (STATIONID as string) As None
In addition to general functions (see Language Help ), the following API simulator functions may be used in a script.
GetRegisterValue (REG_TYPE as long , ADDRESS as long) As int
Returns the current value in the Modbus/AB register specified:
REG_TYPE = register type 0=input, 1=output, 2=analog in, 3=holding reg. 4=extended reg. (For AB, this is the file #.)
ADDRESS = register or I/O point number (Zero always corresponds to the first item.)
E.g. 0 is similar to 40001 if REG_TYPE is 3
E.g. 63 would be 64th output coil if REG_TYPE=1
SetRegisterValue (REG_TYPE as long, ADDRESS as long, REGISTERVALUE as long) As none
Set the value in the Modbus/AB register specified.
REG_TYPE = register type 0=input, 1=output, 2=analog in, 3=holding reg. 4=extended reg. (For AB, this is the file #.)
ADDRESS = register or I/O point number (Zero always corresponds to the first item.)
E.g. 0 is similar to 40001 if REG_TYPE is 3
E.g. 63 would be 64th output coil if REG_TYPE=1
REGISTERVALUE = register value, permitted range (-32767 to +32767) other values are clipped, and thus undefined
DisableStation (STATIONID as int) As none
Disable a Modbus slave station. This function can be used to take the station out of the ring, as if it was not present in the system/network
STATIONID = Modbus station number (valid values 0 to 255; 0 = broadcast station)
EnableStation (STATIONID as int) As None
Enable a Modbus slave station. This function can be used to restore a station to the ring (see also DisableStation (STATIONID as int) As none ).
STATIONID = Modbus station number (valid values 0 to 255; 0 = broadcast station)
Display the application about box (see Built-In Help ), the script is suspended until the "About" window is closed by the user.
Return the duration in milliseconds that it took for the last execution of the script. This value will be -1 on the first script execution, or if the scrip fails to execute to completion without errors.
StationEnabled (STATIONID as int) As long
Return the enable state of the station (0=disabled, 1=enabled).
STATIONID = Modbus station number (valid values 0 to 255; 0 = broadcast station)
TransmitRegisters (STATIONSRC as int, STATIONDEST as int, REG_TYPE as long, ADDRESS as long, REGISTERS as long) As long
Sends a value to the desired slave PLC (simulation must be in and support master mode.)
This function is currently not supported on MODBUS.
STATIONSRC = Allen-Bradley Source station (ignored for Modbus protocol).
STATIONDEST = destination or target station ID register type 0=input, 1=output,2=analog in, 3=holding reg. 4=extended reg. (For AB, this is the file #)
REG_TYPE = register type 0=input, 1=output, 2=analog in, 3=holding reg. 4=extended reg. (For AB, this is the file #)
ADDRESS = register or I/O point number (Zero always corresponds to the first item.)
E.g. 0 is similar to 40001 if REG_TYPE is 3
E.g. 63 would be 64th output coil if REG_TYPE=1
REGISTERS = number of registers to transmit, protocol specific framing or PDU limits are not tested before sending.
AddDebugString (STATIONID as string) As None
Sends text to the communications debugger, the text will appear with a double hash ## in front of it.
Returns TRUE if this simulation device supports master-mode, and is busy with a transaction at this time.
The sample code illustrates how to increment a few registers, and also turn the communication for the 1st 12 stations on and off continuously. The script runs on every animation update.
dim x
dim n
dim runtime
dim station
n=0
for n=0 to 240
x = getregistervalue(3,n)
SetRegisterValue 3, n, x+1
next
runtime = Getlastruntime
SetRegisterValue 3, 241, runtime
if (StationEnabled (station)) then
Disablestation station
else
enablestation station
end if
SetRegisterValue 3, 242, station
station = station + 1
if station > 12 then station = 0