devices_scripting

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
devices_scripting [2020/06/09 15:17]
wikiadmin
devices_scripting [2025/01/03 10:02] (current)
wikiadmin
Line 1: Line 1:
-**Scripting with TransSECS Devices**+====Scripting with TransSECS Devices====
  
-To write a value to a server in the devices the format is:+[[Scripting for PLC Servers]] 
 +(Read/Write values to PLCs)
  
 +[["incomingValue" and Server Values]]
 +(Setting Server outputs and values)
  
-''/Devices/[DeviceNodeName]_Servers/[ServerName]->[setValue]''+[[Checking Quality on an incomingValue Triggering a Script]]
  
 +[[devices_databases|Scripting for Databases]]
 +(Recipe Management)
  
-For example, to set the integer value 2 to a server called ModbusWord under the ModbusTCP node use: +[[Scripting to Handle Host Messages in TransSECS Devices]]
-<code javascript> +
-/Devices/ModbusTCP_Servers/ModbusWord->setIntValue(2); +
-</code>+
  
-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.+[[Setting the System Date from PLC Registers]]
  
-<code javascript> +[[Storing Reports and Events to a Log File]]
-var Thread = Java.type("java.lang.Thread"); +
-var Runnable = Java.type("java.lang.Runnable");+
  
-// declare our thread +[[FTP File Upload Example]]
-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(); +
-</code> +
- +
-**Register for Connection Status Notification in TransSECS Host Application** +
- +
-In a GEMHost application the TransSECS controller publishes the status of the connection. +
- +
-To register for this, add a "Startup Trigger" from the "Demo Servers"  +
- +
-{{:pasted:20200609-150214.png}} +
- +
-Register for the notification in the "script" field.  Here the notification is just printed to the display.  +
- +
-<code javascript> +
-var TransSecsController = Java.type("com.ergotech.transsecs.secs.TransSecsController"); +
-var ConnectionStatusListener = Java.type("com.ergotech.transsecs.secs.host.ConnectionStatusListener"); +
- +
-print("Startup Trigger"); +
- +
-host=TransSecsController.findController("GEMHost"); +
- +
-// create the connection status listener +
-var connectionStatusListener = new ConnectionStatusListener() { +
- +
-   connectionStatusChanged : function (connectionStatus, comment) { +
-       print ("Current Connection Status " + connectionStatus + " Status String \"" + comment + "\"");         +
-   } +
-}; +
-   +
-// add this to the host   +
-host.addConnectionStatusListener(connectionStatusListener); +
-print("Connection Status Trigger Registered"); +
-</code> +
- +
-The details of the connection status are [[programmatic_host_connection_status|described here]]+
  • devices_scripting.1591733844.txt.gz
  • Last modified: 2020/06/09 15:17
  • by wikiadmin