Editor

In addition to standard operating functions (copy, paste, cut, undo, save), the editor offers several special functions:
- "File – Save externally" menu: Saves the script as an XML file with header data, code, and parameter definitions. It is also possible to open such XML files and thus 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 plug-in's script list.
- "F6" key: Compiles and tests the program for errors.
In the right-hand part of the window, you will find a graphical programming aid for OPC accesses, variables from the OPC router configuration, log messages, and parameters.
- Double-click on an entry and the corresponding prepared code line is inserted. Entries can be written as strings (in quotation marks) or as predefined variables.
Notes on OPC zero values
If you have checked the "Transfer OPC zero 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 runs into an error.
If the checkbox is not selected and the "Quality" of the data point 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 value 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: none
- dicItemsToWrite: Dictionary with items and values
- OPCServerName: Name of the OPC connection in the router project
OpcAccess.Browse
Provides the option 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: Specifies 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 the full path.
OpcAccess.Browse(ItemPath, ServerName).Select(e => e.HasChildren).ToArray()
- Return: Returns whether the tags still have subobjects (children).
Important: To search for OPC objects, "Using System.Linq;" and the assembly reference "System.Core.dll" must be specified for the usings.
VariablesAccess.Read
Reads the value of a variable from the OPC router project. This refers only to variables that were created using the variable plug-in, i.e., no placeholders in templates, mail objects, etc. If the variable does not exist, NULL is returned.
Object <myvalue\> = VariablesAccess.Read("<variablename\>")
- Return: Object
- VariableName: Variable name in the OPC Router project
VariablesAccess.Write
Assigns a value to a variable in the OPC Router project. This refers only to variables that were created using the Variables plug-in, i.e., no placeholders in templates, mail objects, or similar. If the variable does not exist, it is created.
VariablesAccess.Write("<variablename\>", Value)
- Return: none
- VariableName: Variable name in the OPC Router project
- Value: Value to be assigned, Object
Log
Writes a message to the log file
Log("<strmessage\>", MessageType.<loglevel\>)
- Return: none
- strMessage: message to be written
- LogLevel: log level to be written. If the corresponding log level is deactivated, nothing is recorded.
MessageType.Alllogs in any case, regardless of the router configuration.