SPONSORED BY: SOFTWARE TOOLBOX
Accessing various industrial data, especially OPC UA data sources, via RESTful web services has become increasingly necessary over the past decade. From devices with self-hosted web services to relevant market data such as weather information and pricing for commodities and energy, there is a host of relevant data to be integrated to and from such web services.
The OPC Router is a flexible platform for moving data from point A to point B, while transforming, analyzing, and acting on that data. OPC Router can easily source data from OPC UA Servers, databases, and more, and push that data to RESTful web services, or read data from RESTful web services and push that data to OPC UA servers, databases, and more. The OPC Router can even be setup as a RESTful web service, and thus expose any OPC UA or other data in OPC Router via an API you define using REST triggers.
What follows is an excerpt from the guide:
Specifically, this document will discuss the following scenario.
- The OPC UA Server is monitoring the speeds for two systems, each with two running machines.
- When the HTTP Client does a request, it will be passing (as Query Parameters) the system and machine numbers for which it would like to know the current speed.
- When the HTTP Client does a GET Request the OPC Router will (based on the system and machine numbers that are passed as query parameters) query a SQL Server database to determine the product ID currently running on the requested system and machine.
The resulting HTTP Response will contain the system and machine numbers (contain in the HTTP Request), the Product ID that was queried from SQL, and the current speed of the specified machine/system that was read from the OPC UA Server.
Creating the Plug-Ins
As a first step the various plug-ins – that define data sources and destinations with which the OPC Router will be interacting – must be defined. With this scenarios this is made up of three plug-ins; an OPC UA plug-in to read the machine speed from the OPC UA Server, a Microsoft SQL Server plug-in to query the current product ID being produced, and a REST/HTTP API Endpoint which will be used to expose the product data to the outside world using HTTP.
The OPC UA Plug-In
The OPC UA Server from which the machine data is being read is the TOP Server, which is exposing an OPC UA endpoint to extract data. Because the TOP Server UA Endpoint is accepting localhost connections only – the connection will not be secured and encrypted – in production environments it is recommended to follow IT best practices to keep data and machines secure. The exact steps to configure the OPC UA Server endpoints will vary with server and is outside the scope of this document – please refer to the appropriate server documentation.
The SQL Server Plug-In
The SQL Server Plug-In is needed to be able to query the product ID from the SQL Database table. When configuring the OPC Router MS SQL Plug-In there is no need (or place) to configure the table and/or database columns. At this point in the configuration the plug-in simply represents a Microsoft SQL Server Database which contains the table that will later be queried.
The REST API Plug-In
Arguably the most important plug-in in this configuration is the REST API Plug-in. This plug-in will not only be used to expose the RESTful webservice endpoint (from the OPC Router to the rest of the world) that will be used to query the data out of the OPC Router, but will serve as the ‘data flow’ trigger to set the connection in motion.…