devices_scripting

This is an old revision of the document!


!%blue%Scripting with TransSECS Devices

To write a value to a server in the devices the format is:

%%/Devices/[DeviceNodeName]_Servers/[ServerName]→[setValue]

For example, to set the integer value 2 to a server called ModbusWord under the ModbusTCP node use:

/Devices/ModbusTCP_Servers/ModbusWord->setIntValue(2);

TransSECS is thread safe and so you can create threads in a script. Here's an example that creates a thread before setting the value of a Modbus server.

var Thread = Java.type("java.lang.Thread");
var Runnable = Java.type("java.lang.Runnable");
 
// declare our thread
this.thread = new Thread(new Runnable(){
  run: function () {
      /Devices/ModbusTCP_Servers/ModbusWord->setIntValue(2);
      print("printed from a separate thread");
  }
});
 
// start our thread
this.thread.start();
  • devices_scripting.1589336116.txt.gz
  • Last modified: 2020/05/12 21:15
  • by wikiadmin