scripting

This is an old revision of the document!


Scripting

The Devices version of TransSECS (TransSECS Devices) enables java scripting on the data sources, messages, and message data.

Look at the sample scripts on the messages and data sources in the sample PLCTool.

Common Problems

if you see an error such as: TypeError: null has no such function “someFunctionName”, this usually means you forgot to add an import for a class which has method “someFunctionName”. For example: TypeError: null has no such function “findController” is commonly due to forgetting to do this:

var TransSecsController = Java.type("com.ergotech.transsecs.secs.TransSecsController"); 

before you do this:

secsInterface=TransSecsController.findController("PLCTool"); 

where “PLCTool” is the name of your tool definition.

Register to Receive All Events in a TransSECS host application

This snippet registers a notification of any event received.

// register to be notified of any event received.
var evntHandler  = new EventListener() {
    eventReceived : function(ceid,reports) {
        time=java.lang.System.currentTimeMillis(); 
        id=ceid.getId();
        print ("Event " + id + " received at" + time );
        if (id==129) {//port1 loaded
            //  handle the port loaded event   
        }
     } 
}
  • scripting.1591731876.txt.gz
  • Last modified: 2020/06/09 14:44
  • by wikiadmin