Skip to main content
Version: 5.3

Editor

Script editor

In addition to standard operating functions (copy, paste, cut, undo, save), the editor offers some special functions:

  • Menu “File – Save externally”: Saves the script as an XML file with header data, code, and parameter definitions. Opening such XML files and thus importing scripts is also possible.
note

Note: If you want to use the assemblies in the scripts, they must still be included in the code with using.

  • Menu “Settings – Edit parameter”: Here you create required parameters and variables (s. Transfer object script und Trigger).
  • Menu “Settings – Edit comment”: The comment is displayed in the script list of the plug-in.
  • “F6” key compiles and tests the program for errors.

The right-hand part of the window contains a graphic programming aid for OPC access, variables from the OPC Router configuration, log messages and parameters.

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

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 out the value of several 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 several values ​​into several 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

Offers the possibility 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 at your disposal:

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: The type of tags from this OPC path.
OpcAccess.Browse(ItemPath, ServerName).Select(e => e.Identifier).ToArray()
  • Return: The name of the tags with full path.
OpcAccess.Browse(ItemPath, ServerName).Select(e => e.HasChildren).ToArray()
  • Return: If the tags still have child objects.

VariablesAccess.Read

Reads out the value of a variable of the OPC Router project. What is meant here are only variables created via the variable plug-in, ie no placeholders in templates, mail objects or similar. 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 tag of the OPC Router project. What is meant here are only variables created via the variable plug-in, ie no placeholders in templates, mail objects or similar. If the variable does not exist, it will be recreated.

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

Log

Schreibt eine Nachricht in die Logdatei

Log("<strMessage\>", MessageType.<LogLevel\>)
  • Return: none
  • strMessage: message to be written
  • LogLevel: to be written log level. If the corresponding log level is deactivated, it will not be recorded either. MessageType.All logs in any case, regardless of the router configuration.