Skip to main content
Version: 5.6

Editor

Script Editor

In addition to standard editing functions (Copy, Paste, Cut, Undo, Save), the editor offers several special features:

  • "File – Save Externally" menu: Saves the script as an XML file containing header data, code, and parameter definitions. You can also open such XML files to import scripts.
  • "Settings – Manage Parameters" menu: Here you can create the necessary parameters and variables (see Transfer Object Scripts and Trigger Scripts).
  • "Settings – Edit Comment" menu: The comment is displayed in the plugin’s script list.
  • "F6" key: Compiles and tests the program for errors.

In the right pane, you will find a graphical programming aid for OPC accesses, variables from the OPC router configuration, log messages, and parameters.

  • Double-click an entry, and the corresponding prepared line of code is inserted. Entries can be written as a string (in quotation marks) or as a predefined variable.

Notes on OPC Null Values

If you have checked the "Transfer OPC null values" box in the OPC UA plug-in, the corresponding values of the data points are always transferred when they are zero.

If the box is not checked and the "Quality" of the data point is not "Good," then the value is not transferred and the connection fails.

If the checkbox is not selected, the data point’s “Quality” is “Good,” and the value is zero, then zero is transferred.

OpcAccess.Read

Reads the value of an OPC item.

Object <myvalue\> = OpcAccess.Read("<itempath\>", "<opcservername\>")
  • Return: Object
  • ItemPath: Access path and name of the item
  • OPCServerName: Name of the OPC connection in the router project

OpcAccess.ReadMultiple

Reads the values of multiple OPC items.

List<string> <litemnames\> = new List<string> ();

<litemnames\>.Add ("<itempath.itemname1\>");
<litemnames\>.Add ("<itempath.itemname2\>");
...

Dictionary<string,object> <myvalues\> = OpcAccess.ReadMultiple(<litemnames\>, "<opcservername\>");
  • Return: Dictionary <string>
  • lItemNames: Access paths and names of the items as a list
  • OPCServerName: Name of the OPC connection in the router project

OpcAccess.Write

Writes a value to an OPC item.

OpcAccess.Write ("<itempath\>", <objvalue\>, "<opcservername\>")
  • Return: none
  • ItemPath: Access path and name of the item
  • objValue: Value to be written
  • OPCServerName: Name of the OPC connection in the router project

OpcAccess.WriteMultiple

Writes multiple values to multiple OPC items.

Dictionary<string,object> <dicitemstowrite\> = new Dictionary<string,object> ();
<dicitemstowrite\>.Add("<itempath.itemname1\>", <value1\>);
<dicitemstowrite\>.Add("<itempath.itemname2\>", <value2\>);
...
OpcAccess.WriteMultiple(<dicitemstowrite\>, "<opcservername\>")
  • Return value: None
  • dicItemsToWrite: Dictionary containing items and values
  • OPCServerName: Name of the OPC connection in the router project

OpcAccess.Browse

Provides the ability to perform a browse (object search) for OPC DA and UA connections.

ItemPath: Access path and name of the item

ServerName: Name of the OPC connection in the router project

Various queries are available:

OpcAccess.Browse(ItemPath, ServerName).Select(e => e.DisplayName).ToArray()
  • Return: Returns the names of the tags from this OPC path.
OpcAccess.Browse(ItemPath, ServerName).Select(e => e.NodeKind.ToString()).ToArray()
  • Return: Returns the types of the tags from this OPC path.
OpcAccess.Browse(ItemPath, ServerName).Select(e => e.Identifier).ToArray()
  • Return: Returns the names of the tags with their full paths.
OpcAccess.Browse(ItemPath, ServerName).Select(e => e.HasChildren).ToArray()
  • Return value: Returns whether the tags still have child objects.
warning

Important: To search for OPC objects, the "Using System.Linq;" directive and the assembly reference "System.Core.dll" must be specified.

OpcAccess.Reset

Resets the OPCAccess so that it is reinitialized on the next call.

OpcAccess.Reset()
  • Return value: None
  • Input parameters: None

OpcAccess.Decode

Decodes a value from an OPC UA server and returns a .NET object that can contain all possible variable types.

object <myvalue\> = OpcAccess.Decode("<opcservername\>", <objvalue\>)
  • Return value: Object
  • OPCServerName: Name of the OPC server from which the value is to be decoded.
  • objValue: The value to be decoded.

The return value can contain all native data types. In addition, the following properties may be contained in the .NET object.

IUaStructureTypeDescription <myvalue\> = TypeDescription
  • Return value: The type description of type IUaStructureTypeDescription.
  • This function is a property. Therefore, it has no parameters and no parentheses.
CopyTo(<dest\>)
  • Return value: None
  • dest: Destination of type IEncodeable
CopyValuesFrom(<objvalue\>)
  • Return value: None
  • objValue: Source of the values to be copied.
T <myvalue\> = GetValue<t>("<property\>")
  • Return value: A value of a generic type.
  • property: The property to be read.
bool <myresult\> = TryGetValue("<field\>", out <objvallue\>)
  • Return value: Whether the corresponding value was found.
  • field: The name of the variable to be read.
  • objValue: The actual value returned to the user via the out parameter.
WriteField<t>("<property\>", <genericvalue\>);
  • Return: None
  • property: The variable name to be written to.
  • genericValue: A value of a generic type to be written to the variable.
bool <myresult\> = TryGetFieldInfo("<field\>", out <fieldinfo\>)
  • Return: Indicates whether the corresponding variable information was found.
  • field: The name of the variable to be read.
  • fieldInfo: The variable information of type IFieldType, which is returned to the user via the out parameter.
IEnumerable<keyvaluepair<string, object="">> <myvalues\> = GetValues()
  • Return value: All values, stored in an IEnumerable of type KeyValuePair, which contains the types String and object.
  • Input parameters: None.
ExpandedNodeId <mytypeid\> = TypeId
  • Return value: The node ID of the type to be encoded.
  • This function is a property. Therefore, it has no input parameters and no parentheses.
ExpandedNodeId <mybinaryencodingid\> = BinaryEncodingId
  • Return value: The node ID of the binary type to be encoded.
  • This function is a property. Therefore, it has no input parameters and no parentheses.
ExpandedNodeId <myxmlencodingid\> = XmlEncodingId
  • Return value: The node ID of the XML data type to be encoded.
  • This function is a property. Therefore, it has no input parameters and no parentheses.

VariablesAccess.Read

Reads the value of a global variable in the OPC router project. This refers only to variables created via the Variables plug-in, i.e., not placeholders in templates, mail objects, or similar. If the variable does not exist, NULL is returned.

Object <myvalue\> = VariablesAccess.Read("<variablename\>")
  • Return value: Object
  • VariableName: Variable name in the OPC Router project

VariablesAccess.ReadLocal

Reads the value of a local variable in the OPC Router project. This refers only to variables created via the Variables plugin, i.e., not placeholders in templates, mail objects, etc. If the variable does not exist, NULL is returned.

Object <myvalue\> = VariablesAccess.ReadLocal("<variablename\>", "<connectionid\>")
  • Return: Object
  • VariableName: Variable name in the OPC Router project
  • connectionId: ID of the connection from which the variable is to be read.

VariablesAccess.Write

Assigns a value to a global variable in the OPC Router project. This refers only to variables created via the Variables plugin, i.e., not placeholders in templates, mail objects, or similar. If the variable does not exist, it is created.

VariablesAccess.Write("<variablename\>", Value)
  • Return value: none
  • VariableName: Variable name in the OPC Router project
  • Value: Value to be assigned, Object

VariablesAccess.WriteLocal

Assigns a value to a local variable in the OPC Router project. This refers only to variables created via the Variables plug-in, i.e., not placeholders in templates, mail objects, or similar. If the variable does not exist, it is created.

VariablesAccess.WriteLocal("<variablename\>", Value, "<connectionid\>")
  • Return value: None
  • VariableName: Variable name in the OPC Router project
  • Value: Value to be assigned, Object
  • connectionId: ID of the connection from which the variable is to be read.

ConnectionParameters.GetConnectionName

Returns the name of the current connection.

string "<myconnectionname\>" = ConnectionParameters.GetConnectionName()
  • Return value: The name of the current connection.
  • Input parameters: None

ConnectionParameters.GetConnectionId

Returns the connection ID of the current connection.

string "<myconnectionid\>" = ConnectionParameters.GetConnectionId()
  • Return value: The ID of the current connection.
  • Input parameters: none

PlugInAccess.GetStatus

Returns the current status of a plug-in. The plug-in can be identified by an ID or a name, and optionally by a type.

PlugInStatus <mystatus\> = PlugInAccess.GetStatus("<pluginid\>")
PlugInStatus <mystatus\> = PlugInAccess.GetStatus("<pluginname\>", "<plugintype\>")
  • Return value: The current status of the selected plug-in of type PlugInStatus.
  • plugInId: ID of the desired plug-in for identification.
  • plugInName: Name of the desired plug-in for identification.
  • plugInType: Type of the desired plug-in for identification.

The possible statuses from the PlugInStatus type are as follows:

  • Unknown = 0
  • Stopped = 1
  • Starting = 2
  • Running = 3
  • Stopping = 4
  • Faulted = 5
  • NoLicense = 6

PlugInAccess.RequestRestart

Requests that a plug-in be restarted. The plug-in can be identified by an ID or a name, and optionally by a type.

PlugInAccess.RequestRestart("<pluginid\>")
PlugInAccess.RequestRestart("<pluginname\>", "<plugintype\>")
  • Return value: none
  • plugInId: ID of the desired plug-in for identification.
  • plugInName: Name of the desired plug-in for identification.
  • plugInType: Type of the desired plug-in for identification.

Log

Writes a message to the log file

Log("<strmessage\>", MessageType.<loglevel\>)
  • Return value: none
  • strMessage: Message to be written
  • LogLevel: Log level to be written. If the corresponding log level is disabled, the message will not be logged. MessageType.All logs in all cases, regardless of the router configuration.

AbortTransfer

Aborts a data transfer with a passed message.

AbortTransfer(<mymessage\>)
  • Return value: none
  • myMessage: Abort message for the interrupted data transfer.