Leveraging Visual Studio for Efficient OPC Router Scripting

3 min read

Jun 1, 2023 2:00:00 PM

OPC Router is a standards based tool for data integration from the shop floor through all levels even up to ERP systems, with a visual workflow engine, scalable configuration templates, and integration to many OT and IT systems. Leveraging OPC UA, REST, SOAP, MQTT and more, it can be an essential enabling tool for your Industry 4.0 applications. Solutions can be extended using C# scripting, and this blog shows a live built example of how to efficiently use Visual Studio to build those scripts. 

Although not required for powerful OPC Router implementations, including REST and SQL integration like shown in this blog, sometimes applications have some unique need that wasn't considered in the product. Rather than write full custom software applications, with their risk and high total cost of ownership, system integrators and power users can extend the functionality of OPC Router using C# based scripting. Those scripts can be configured right in the OPC Router configuration user interface; however, Visual Studio takes things to a whole other level.  In this post, I will cover step by step how to leverage Visual Studio to efficiently develop OPC Router C# Scripts. 

Visual Studio is an integrated development environment (IDE) created by Microsoft. It is predominantly employed for the purpose of developing software applications, websites, and other digital solutions. It supports variety of programming languages and includes tools that enable developers to write, debug, and deploy their code with efficiency and effectiveness. Within Visual Studio, you'll find a diverse array of features at your disposal. These include code editing with IntelliSense for auto-completion and code suggestions, powerful debugging capabilities, seamless integration with version control systems like Git, efficient project management tools, and an expansive ecosystem of extensions designed to enhance the overall functionality of the platform.

In this video, we will use OPC Router in the following way: 

  1. Request a JSON payload from a REST Webservice.    
  2. Process that JSON payload using an OPC Router Script Transfer Object:
    1. Use .NET libraries to help us serialize and deserialize the JSON file.
    2. Extract the Data we need out the JSON file using those libraries.
    3. Generate a table of information using arrays.
  3. Log the Tag information into a Log Table in MSSQL. 

Please note that the focus of the video will be on how to use Visual Studio to develop the script for the example above. If you have questions on how to configure REST or Database Connections, I suggest taking a look at the OPC Router product focus page resources section. 

 

In this video, I’ve shown you:

  1. Where to find more information about Visual Studio
  2. How to create a simple console application using Visual Studio
  3. How to leverage Visual Studio features, such as IntelliSense and Debugger, to make our scripting development much more efficient.
  4. How to implement the Developed Script into OPC Router

Please feel free to contact our support team with any questionsAnd don't forget to subscribe to our blog to find out about the latest updates regarding OPC Router and for other how-to-videos on using OPC Router.  Try OPC Router on your own connectivity and integration projects with the fully functional free trial.

Click to Download OPC Router Free Trial

Topics: OPC Router REST

Rodrigo Restrepo
Written by Rodrigo Restrepo

Software Toolbox Technical Blog

We're engineers like you, so this blog focuses on "How to" appnotes, videos, tech team tips, product update announcements, user case studies, and other technical updates.  Subscribe to updates below. Your feedback and questions on posts are always welcomed - just use the area at the bottom of any post.

Subscribe to our Blog

Recent Posts

Posts by Topic

See all