Basic Script Tags

Script code can be defined within Tags in Movicon.NExT.  This will allow them to be run in the I/O Data Server and therefore independently from any Clients present.

 

The scripts defined in Tags are all run in one thread for default.

Please take into account that when the project contains more than one Tag defined with one script, the scripts will not be run in parallel with each other.

When you need to run the Script of a Tag in a separate thread, you will need to enable the Tag's  "Use Script in separate thread" property.

 

 

In order to define a Script within a Tag, you will need to open the I/O Data Server's Tag List and select the Tag within which to define the Script code and open the Script Explorer window.  At this point, in order to associated a subroutine to an event, simply select the object from the "Object:" combobox menu and then the relative event from the "Proc." combobox menu which will automatically generate the subroutine within which it will be possible to edit the script code.

The screen shot below shows a script which has been defined in the StateChanged event of the  "Variable" tag's DataItemState object.

 

 

The events to associate a Script in a Tag are:

 

DataItemState/AnalogItemStateDocument > StateChanged

The subroutine associated to this event executes when the value of the TimeStamp or Tag's Quality changes.

 

For the StateChanged event to function, the Tag must be in use! To force a Tag as always in used, simply set the Tag's "Always in Use" property to True.

 

 

ServerScriptManager > Init

The subroutine associated to this event is executed when the Tag is initialized, meaning at the startup of the I/O Data Server

 

ServerScriptManager > DoEvents

The subroutine associated to this event is executed around every 500ms.

 

The cycle time of 500ms is not deterministic.

 

 

ServerScriptManager > InUseTag

The subroutine associated to this event is exectuced when the Tag becomes "Active" therefore "In Use".

 

ServerScriptManager > TerminateTag

The subroutine associated to this event is executed when the Tag is removed when the I/O Data Server is turned off.

 

If you set a breakpoint in the Tag's code, the debug window will open at server startup even when the method has not yet been called.

 

The length of the script code that can be inserted inside a Tag cannot be more than 32767 characters.