scripting
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| scripting [2020/06/09 15:44] – wikiadmin | scripting [2025/05/20 11:12] (current) – wikiadmin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | **Scripting** | + | **TransSECS |
| + | |||
| + | See also: [[TransSECScriptingMethodList | Common TransSECS JavaScript Methods List]] | ||
| + | |||
| + | Also see: Why you need to [[add_incomingValue_last_lineofscript|add " | ||
| 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(" | ||
| + | |||
| + | |||
| + | <code javascript> | ||
| + | var TransSecsController = Java.type(" | ||
| + | |||
| + | secsInterface=TransSecsController.findController(" | ||
| + | </ | ||
| + | |||
| + | where " | ||
| + | |||
| + | <code javascript> | ||
| + | var TransSecsController = Java.type(" | ||
| + | |||
| + | secsInterface=TransSecsController.getSingleController(); | ||
| + | </ | ||
| + | |||
| **Common Problems** | **Common Problems** | ||
| Line 10: | Line 34: | ||
| TypeError: null has no such function " | TypeError: null has no such function " | ||
| For example: | For example: | ||
| - | TypeError: null has no such function " | + | TypeError: null has no such function " |
| <code javascript> | <code javascript> | ||
| var TransSecsController = Java.type(" | var TransSecsController = Java.type(" | ||
| </ | </ | ||
| - | before you do this: | ||
| - | < | ||
| - | secsInterface=TransSecsController.findController(" | ||
| - | </ | ||
| - | |||
| - | where " | ||
| - | |||
| **Register to Receive All Events in a TransSECS host application** | **Register to Receive All Events in a TransSECS host application** | ||
| Line 40: | Line 57: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | **Trigger Events in a Tool** | ||
| + | |||
| + | In this example there is one data source which triggers two events, a cassette placed event and a cassette lifted event. If the value is 0, the cassette was lifted, if it is 1, the cassette was placed | ||
| + | |||
| + | <code javascript> | ||
| + | var TransSecsController = Java.type(" | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | try { | ||
| + | | ||
| + | | ||
| + | |||
| + | | ||
| + | |||
| + | |||
| + | //if state=0, cassette has been lifted,if state=1 then it has been placed | ||
| + | if (state==0) { | ||
| + | // | ||
| + | | ||
| + | | ||
| + | } else { | ||
| + | // | ||
| + | placedEvent.setIntValue(1); | ||
| + | } | ||
| + | } catch(e) { | ||
| + | print(" | ||
| + | print(e); | ||
| + | |||
| + | } | ||
| + | </ | ||
| + | |||
scripting.1591731876.txt.gz · Last modified: by wikiadmin
