OPC Client
Macula servers can act as OPC clients and connect to different OPC servers, which communicate with various industrial hardware devices. In this way, Macula servers support thousands of devices from different manufactures without even knowing what those devices and their models are at any particular moment of time: OPC servers take care of that. Once the connection is established, Macula can receive data from OPC servers, compare it to pre-defined values and trigger events based on specific changes in these values; also, Macula can send commands to change the data on the OPC servers, which, in their turn, pass the commands to the hardware devices.
This topic describes how OPC client functionality is configured and used within Macula.
OPC Functionality
Any Macula server can connect to a third-party OPC server, thus acting as an OPC client. These connections are then used within the E&A Configurator to create events and actions based on OPC data (variables): events compare the variable contents to pre-defined values in a specified way; actions change the variable contents to a predefined value.
Communication with OPC servers can be maintained in one of two ways: synchronous and asynchronous. When in synchronous mode, Macula server polls an OPC server and receives updates with the latest data set as a result; this happens every few seconds. In the asynchronous mode, Macula server "subscribes" to the updates and then waits for a list of updated items from the OPC server.
Before getting to OPC setup on the Macula side, install and configure your OPC server with hardware devices, and adjust Windows settings (if required). Configuration instructions below imply that you have done so and a remote OPC server with some data is reachable and operational.
Create and Manage OPC Client
OPC client configurations are located in this section as main OPC integration purpose is event and action scenarios (rules). In your Macula Console, switch to the Events & Actions section and choose OPC in the list on the left.
To add a new configuration, click the + New OPC client configuration button in the upper panel.

The table below details the available settings.
Title
User-defined configuration name
[none]
Server*
Macula server that will act as OPC client
[none]
Host
OPC server host name or IP address
[none]
Prog ID**
OPC server program ID, vendor-specific
[none]
Username
User name to connect to the OPC server
[none]
Password
Password to connect to the OPC server
[none]
Fill in the settings and click OK to close the configuration dialog box and save.
*Once you assign the OPC client configuration to a server, the Server field will become grayed out, meaning that you cannot change this setting anymore. In other words, it is impossible to move an OPC client configuration between servers. To do this, you will need to create a new OPC connection for another server.
The newly created profile will appear in the list. Select it and hit the Test button on the panel above to validate the configuration; the following responses may be received:
OPC client test passed: asynchronous connection with the configured OPC server has been successfully established
Code 22020100 (asynchronous data mode not available): connection established successfully but only synchronous mode is available
Code -2147023174 (RPC server is unavailable): connection unavailable due to invalid OPC client settings (e.g., incorrect target host name or IP), Windows settings or connectivity issues
Code -2147024809 (parameter is incorrect): incorrect OPC client configuration (e.g., no username was entered while expected)
Code -2147024891 (access denied): OPC server denied connection due to lack of permissions (e.g., invalid user name and/or password was used)
Code -2147221164 (class not registered) or code -2147221005 (invalid class string): typically, incorrect program ID format or program ID itself
The first two responses indicate successful connection with synchronous or asynchronous read/write mode; other codes mean no connection has been established so it is necessary to review the settings and troubleshoot. Other codes may appear as well in case of miscellaneous Windows configuration and/or connectivity issues.

Use the Disable/Enable button on the upper panel to disable the OPC client temporarily and then enable it again: this is useful when OPC server is offline so Macula audit log is not flooded with errors. You can create any number of OPC clients and any number of events and actions based on them.
Events and Actions
Once you have created an OPC server connection, Macula server can retrieve the list of existing data items (nodes) from the OPC server and work with it. All the available nodes, their attributes and their values are listed when you create an event or an action of the OPC Client type.
Events allow you to create conditions - react to specific changes in the node values by applying conditional operators: for example, if variable type is boolean, you can check if it is equal to 1 (=true) or 0 (=false). For other variable types, there are other (corresponding) conditional operators.

Actions triggered from Macula servers send write commands to the OPC server, in this way replacing the node value with the pre-defined one. Value of the nodes, which have non-compatible types or do not have the write permission, cannot be changed.
For detailed information on the creation of events and actions, please refer to the corresponding topics of this document.
Last updated