Up | AccessControl | Shutdown | Profile | Backup | Curves | Delay | LogMsg | Console | QAlarm | QAlarmReset | RefCmds | InitSaveImage | SaveImage | Script | Start | Statistics | Stop | WebBrowser

 

  

 
Script
The Script command is used to run scripts and access plugins defined in the Service-Advanced panel Central. Note the difference between calling plugin methods and pure python scripts and also the difference between calling scripts via the communication components RS232 and TCP/IP.

Plugin Syntax from Actions:

Command   : Script;
Parameters : <plugin>.<method>;<parameter=value>;...;<parameter=value>

Note that parameters must be in TdvCmd format.

Example:

Command:   Script
Parameters: Calendar.SetDay;Value=14

Command:   Script
Parameters: Calendar.AboutBox

Script Syntax from Actions:

Command   : Script
Parameters : Scriptname(parameters)

Note that parameters must be in Python syntax

Example:

The following function is defined in Central.Scripts :

def IncTag(tag): 
   val=GetValue(tag) 
   val=val+1 
   SetValue(tag,val)

The function is accessed using the following syntax:

Command:    Script
Parameters:  IncTag("Test.Value")

Test.Value is defined in the toolbox and the function increments Test.Value by one

An eventhandler Curves.OnNormal is executed with the following syntax:

Script; Handle_Curves_OnNormal("demo")

Running scripts in a command sequence the following screenshot explains the syntax to call python methods.

The example will execute the method SetTrigger(1)

Script syntax with pure Python code

Any valid python expression may be executed in the script command

example:

  • Script; print 'DEMO MODE'                            #prints a static string
  • Script; if a<10: a+=1                                  #a is a python variable in the python namespace
  • Script; if PLCError(): ExecuteCmd('stop','')    #PLCError() is a function in the python namespace

Script syntax via TdvCmd communication components RS232 and TCP/IP:

Both Plugin- and Python- scripts must follow the TdvCmd format when calling scripts from the outside via the RS232 or TCP/IP communication components. The plugin name or the scriptname must be prefixed by 'Name=', see the below examples.

  • Script;Name=<plugin>.<method>;<parameter=value>;<parameter=value>
  • Script;Name=scriptName(<parameters>)

Syntax for the above examples when called over TdvCmd : 

Script;Name=Calendar.SetDay;Value=19
Script;Name=Calendar.AboutBox
Script;Name=IncTag('Test.Value')
 

Scorpion Vision Version XV  : Build 764 - Date: 20200529
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2020 Tordivel AS.