The DrvOPC driver is used to communicate with control systems either through an OPC server (OPC-DA) or directly (OPC-UA).
OPC which stands for OLE for Process Control and is a standard for communication between computers and / or embedded systems. OPC has been adopted as international standard IEC 62541 and as Swedish standard SS-EN 62541.
NOTE!
To run OPC-UA, the Web Port needs to be started with administrator privileges!
This document is used in conjunction with Chapter "IO-devices" of the Web Port manual.
To use DrvOPC, an IO device is first created which is then used to communicate with the desired OPC server / device. Tags are then configured to read / write desired values from the OPC server to Web Port.
Installation
The installation of DrvOPC is done by selecting DrvOPC when installing the Web Port. See "Installation" for more information on the installation process.
IO-device
To use DrvOPC, an IO device is created according to chapter "IO-devices" of the manual.
Information
Normally, only one IO device is needed to connect to an OPC server. However, several can be created if different update time is desired, different namespaces or if a Watchdog is to be used for each control system that is connected via OPC.
In addition to general settings (see "general settings" in IO-devices), the following settings are available for an IO device of type DrvOPC:
| Setting: | Description: |
| OPC server |
The name of the OPC server. If the OPC server is on another computer, this is indicated by \\computer name\opcserver To connect to an OPC-UA device, enter the address in the following format: "ua:protocol://server address: port". Example "ua:opc.tcp://ua-device:48010" |
| Disable tag on fail |
Specifies whether tags should be disabled if the tag gives an error reading. This is desirable so as not to block other tags. By default, tags are disabled. |
| Refresh rate | Refresh rate for the group created when connecting to the OPC server. |
| Subscribe to alarm/trend changes |
Alarms and trends are placed in an OPC group that subscribes to changes instead of polling. Note! OPC servers may have a limit on the number of values allowed for such a group (tags will then be disabled). |
| Use timestamp from OPC | Specifies that the timestamp of the tag value should be taken from the OPC object instead of from the Web Port server. |
| (UA) Namespace |
After connecting to the OPC-UA device, available namespaces are listed in the drop-down menu. Select which one to connect to the IO device. |
| (UA) Namespaceindex | Displays the server index for the selected namespace. |
| Username/Password | Ev. username and password |
For more information on how to create, edit and delete IO devices, see "IO-devices" of the manual.
Certificate for OPC-UA
Web Port accepts server certificates without manual confirmation and will prioritize the lowest possible level of security that server allows.
If you want to manually control how the certificates are handled, you can edit WebPortServer.Ua.Config.Xml, which can be found in Web Port's project directory \assets\import\drvopc\devices.
Web Port saves the certificates in Window certmgr by default according to the structure specified in the above-mentioned .XML.
Tags
To read and write values from an OPC server, tags must be created in the Web Port and addressed to the desired OPC tags. For more information on how to create tag lists and tags, see chapter "Tags" of the manual.
TIP!
Create a tag list for each IO device. This is to get a good structure and easily find tags in the lists.
Tags associated with a DrvOPC IO device may have the following data types:
| Data type in OPC | Data type in Web Port |
| VT_BOOL | DIGITAL |
| VT_I1, VT_I2 | INT |
| VT_I4 | LONG |
| VT_U1, VT_U2 | UINT |
| VT_U4 | ULONG |
| VT_R4 | REAL |
| VT_R8 | DOUBLE |
| VT_BSTR | STRING |
| VT_DATE | DATE |
| ARRAY |
Arrays are addressed by entering after the address! [I], where i is the desired index. If you want to read/write the entire array to a tag, then use datatype JSON. See more info below. |
JSON datatype for arrays
Arrays can be read and written using the JSON datatype in Web Port.
-
When reading, all array elements are combined into a serialized JSON string.
-
When writing, the JSON string is split into individual elements and each element is converted back to its original data type according to the OPC definition before being written.
Example format:
[element1, element2, element3,...]
This format can be used for both reading and writing array tags.
Information
The address field indicates the tag name used in the OPC server and may vary by brand. However, they are often called NodeID or ItemID. Tag names are most easily viewed through an OPC browser. An example of such for OPCDA is Matrikon OPC Explorer and for OPCUA, Unified Automation UaExpert.
To read and write values from an OPC server, tags must be created in the Web Port and addressed to the desired OPC tags.
Example OPCDA: AirConditioner_10_Humidity
Example OPCUA: ns = 3; s = AirConditioner_10.Humidity
If you have entered a namespace for the IO device, it is sufficient to enter NodeId without ns = *; s = *.
Example: AirConditioner_10.Humidity
Information
For both OPC-UA and OPC-DA, it is possible to import tags.
For OPCDA use import script (/assets/import/drvopc) example.js
For OPCUA use import script (/assets/import/drvopc) uaexample.js
The script should be seen as an example of the implementation and will differ depending on the OPC server and implementation.
Branch provides the opportunity to start an import deeper into the tree.
Enter start address example ns = 3; s = AirConditioner_10 or AirConditioner_10
Filters allow you to browse and import only elements that match the filter.
Example:
Hum * to import the elements beginning with Hum
* um * to import the elements that contain um.
Reading OPC Quality
To retrieve the OPC Quality of a tag, you can add !Q at the end of the address. This allows you to fetch the status of an OPC tag and ensure that the value is valid.
- Create a new tag with the same address as the one you want to check
- Add !Q at the end of the address