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
scripting [2020/09/17 00:02]
wikiadmin
scripting [2024/11/17 13:17] (current)
wikiadmin
Line 1: Line 1:
-**Scripting**+**TransSECS Scripting Guide** 
 + 
 +See also: [[TransSECScriptingMethodList | Common TransSECS JavaScript Methods List]]
  
 The Devices version of TransSECS (TransSECS Devices) enables java scripting on the data sources, messages, and message data. 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. Look at the sample scripts on the messages and data sources in the sample PLCTool.
 +
 +**Controller Reference**
 +
 +For all scripts where you need a reference to the tool interface (or host definition) you will need to get this interface using TransSECSController.getSingleController() or TransSECSController.findController("XXXXX") where XXXXX is a specific tool interface. If you only have one interface in your project the preferred way to access the interface is using the getSingleController() method without using a specific tool interface name.
 +
 +
 +<code javascript>
 +var TransSecsController = Java.type("com.ergotech.transsecs.secs.TransSecsController"); 
 +
 +secsInterface=TransSecsController.findController("PLCTool"); 
 +</code>
 +
 +where "PLCTool" is the name of your tool definition. The preferred way to get a single controller reference when you only have one interface defined in the project (which is most common) is:
 +
 +<code javascript>
 +var TransSecsController = Java.type("com.ergotech.transsecs.secs.TransSecsController"); 
 +
 +secsInterface=TransSecsController.getSingleController();
 +</code>
 +
  
 **Common Problems** **Common Problems**
Line 10: Line 32:
 TypeError: null has no such function "someFunctionName", this usually means you forgot to add an import for a class which has method "someFunctionName". 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: For example:
-TypeError: null has no such function "findController" is commonly due to forgetting to do this:+TypeError: null has no such function "findController" or TypeError: null has no such function "getSingleController" is commonly due to forgetting to do this to import the TransSECSController class:
  
 <code javascript> <code javascript>
 var TransSecsController = Java.type("com.ergotech.transsecs.secs.TransSecsController");  var TransSecsController = Java.type("com.ergotech.transsecs.secs.TransSecsController"); 
 </code> </code>
-before you do this: 
-<code> 
-secsInterface=TransSecsController.findController("PLCTool");  
-</code> 
- 
-where "PLCTool" is the name of your tool definition. 
- 
  
 **Register to Receive All Events in a TransSECS host application** **Register to Receive All Events in a TransSECS host application**
Line 48: Line 63:
 var TransSecsController = Java.type("com.ergotech.transsecs.secs.TransSecsController"); var TransSecsController = Java.type("com.ergotech.transsecs.secs.TransSecsController");
  
- tool=TransSecsController.findController("GEMTool");+ tool=TransSecsController.getSingleController();
  gemHandler =  tool.getGemHandler();  gemHandler =  tool.getGemHandler();
  print(gemHandler);  print(gemHandler);
  • scripting.1600318929.txt.gz
  • Last modified: 2020/09/17 00:02
  • by wikiadmin