Example Source Code

Download Source Code Examples

If you are are looking for programmatic examples on access configuration, realtime, or historical data refer to the Programmatic Interface section.  The .NET WinForm VB and C# examples below also demonstrate all of these methods.
Note: You may need to Unblock the zip file before extracting. To Unblock a file right click in Windows Explorer and select Properties. If Unblock is shown in the lower right select it and Apply.

Web & REST API

Web HMI Demo – Web HTML source of online example at www.opcweb.com

Web HMI Image Example   – Web HTML source of image example demonstrating how to incorporate graphics in a web application.  See Web HMI Graphics on the step by step instructions

Web HMI Basic Examples – Web HTML examples of HMI, trend, and alarm

Web HMI Security Example for ASP.NET/C# – A simple ASP.NET example in C# demonstrating how to build a login page that persists your authentication token between page views.

Web HMI Security Example for ASP.NET/VB – A simple ASP.NET example in VB demonstrating how to build a login page that persists your authentication token between page views.

Web HMI Security Example for ASP.NET/Javascript – A simple HTML and Javascript example demonstrating how to build a login page that persists your authentication token between page views.

REST API Sample Client (Web) – A sample client that demonstrates how to use JQuery to make calls and receive data from the OAS REST API

How To Use the OAS REST API: Read and Write Live Data, Trend Real-Time and Historical Data and Alarming – HTML and JQuery example interfaces that demonstrate how to Read and Write Live Data (see tutorial), Trend Real-Time and Historical Data and Alarming with the OAS REST API.

.NET

Read Data Asynchronously – C# – C# .NET Core Console App code example for realtime data access.

Read Data Asynchronously – VB – Visual Basic .NET Core Console App code example for realtime data access.

OAS Demo Service Realtime Data Access – VB and C# – .NET Core Console App and Windows Service code examples for programmatic tag creation and realtime data access.

Universal Driver Interface Driver – VB and C# – Example source code to create a driver for OAS

Open Weather Map Example Driver – VB and C# – Example source code for Open Weather Map UDI

REST API Sample Client (WPF) – A sample client that demonstrates how to use .NET and WPF to make calls and receive data from the OAS REST API

Visual Basic WinForm Example Code for realtime data access and all configurations access

C# WinForm Example Code for realtime data access and all configurations access

Automated HMI – WPF example of automated setup and self adapting client

Tanks Demo – WPF Tanks Demo with graphic, trend, and alarm

.NET Examples Launcher (WPF) – An application that will launch other example applications

One Click HMI – WPF application that automatically displays all tag values

Navigation – WPF example of all WPF HMI controls

Conveyor App – WPF example of 3D model

WPF Dashboard – WPF application demonstrating common dashboard controls

WPF Radial Gauge – WPF application demonstrating radial gauge

WPF Radial Gauges – WPF application demonstrating multiple radial gauges

WPF Linear Gauges – WPF application demonstrating multiple linear gauges

Storyboard – WPF application demonstrating storyboard animation

Symbols – WPF application demonstrating use of HMI symbols

PLC Simulation – WPF application simulating PLC I/O

C# WPF Tabbed application

VB WPF Tabbed application

WPF Custom Open Automation Software Tag Browser – Demonstrates adding a tag browser editor to a custom WPF control

WinForm Custom Open Automation Software Tag Browser – Demonstrates adding a tag browser editor to a custom WinForm control

WPF Redundancy Client Example – Demonstrates automated switch to data servers

Save Trend Config – Demonstrates how to Save and Load a trend configuration

Multi Line Tab – Creating a WPF application with Multiline Tabs

Pens Visibility – How to hide and show pen line in an Open Automation Software Trend

Trend History Select – How to programmatically display historical data on an Open Automation Software Trend

Content Control – A demonstration of how to use the events in an Open Automation Software Content Control

Alarms Added – How to use the Open Automation Software Alarm control to fire an event for every new alarm and display that alarm

Alarms Data Only Example – How to use the Open Automation Software Alarm Data Only control to fire an event for every new alarm and display that alarm and use GetAlarmDataTable to return a DataTable of current alarms

Add Pens – Programmatically Adding Pens to an Open Automation Software Trend (VB)

Add Pen C Sharp – C# example of programmatically adding pens to an Open Automation Software Trend

Tree View Trend – Example of displaying all Open Automation Software Tags in a tree view and adding / removing tags on an OPC Trend Control.

Array Data Emulator – VB – Simulation of logging buffered data from a controller.

iOS/Android

Xamarin OAS Tanks Example – Source code of the iOS and Android demo app displaying real time Tanks and Pumps.

Node Red

Node Red Flow and Dashboard – Example of a Node Red Flow and Dashboard reading from and writing to the OAS MQTT Broker.

Videos – One Click HMI

One Click SCADA

Automatically setup Tags, Alarm Limits, Data Logging, Trending, Alarming, and HMI Smart Client in one step.

One Click HMI

Smart Client application that will display all data from any Open Automation Software data service.

One-Click HMI

Visit www.automatedhmi.com for a quick review of the Automated HMI feature.

  1. Can use any Graphics Builder (Some of our Customers use (AutoCAD, Solidworks, Coral Draw, Expression Blend, Blender 3D. and many more). Build as realistic graphic as you want and then make it come to life with 1 click
  2. Converts 1,000 clicks into 1 click.
  3. With 1 click you can assemble (HMI, Alarm Screens, Trend Screens, and Data Logging).

Frequently Asked Questions – Trend and Alarm Dashboard

Can I run the Trend and Alarm Dashboard application on remote PCs?
Yes, you can choose a custom install of Open Automation Software and just install the Trend and Alarm Dashboard. For trend Pens include the network node name, IP Address, or registered domain name in the Tag path. For alarms set the AlarmNetworkNodes property to include the service where the alarms are hosted.

Videos – Trend and Alarm Dashboard

Trend and Alarm Historian

How to use the Trend and Alarm Historian container. Pre-built application to run locally and remotely.

  • 0:00 – Introduction
  • 0:06 – what’s Trend and Alarm Historian Application
  • 0:30 – Pens Groups
  • 0:41 – Trend Windows
  • 0:51 – Include Pens to Trend Window
  • 1:13 – Pens Properties
  • 1:27 – Trend Type
  • 1:34 – Time Frame
  • 2:04 – Stack Chart Mode
  • 2:28 – View
  • 2:52 – Trend Window – Workspace
  • 3:09 – Pens Group
  • 3:16 – Add Pen Group
  • 4:08 – Duplicate Pen Group
  • 4:31 – How to use the Pens
  • 4:39 – Create a new Window without pens
  • 5:34 – Alarms Panel
  • 5:41 – Activate Alarms Windows
  • 6:24 – Customize Alarm Window
  • 6:55 – Modifying Attributes
  • 8:21 – Docking Panels
  • 8:33 – More Questions – Contact Us
  • 9:05 – Training Page – more videos

Getting Started – Trend and Alarm Dashboard

NOTE: If you want to visualize your data in a desktop or mobile browser with zero programming, you may be interested in the OAS Open UIEngine .
The UIEngine is a robust no-code web application and HMI builder for developing rich user interfaces in a browser-based development environment.
See the UIEngine Documentation to learn more.

You can view Trends and Alarms Dashboard video to review the steps of using this application.

  • 0:00 – Introduction
  • 0:06 – what’s Trend and Alarm Historian Application
  • 0:30 – Pens Groups
  • 0:41 – Trend Windows
  • 0:51 – Include Pens to Trend Window
  • 1:13 – Pens Properties
  • 1:27 – Trend Type
  • 1:34 – Time Frame
  • 2:04 – Stack Chart Mode
  • 2:28 – View
  • 2:52 – Trend Window – Workspace
  • 3:09 – Pens Group
  • 3:16 – Add Pen Group
  • 4:08 – Duplicate Pen Group
  • 4:31 – How to use the Pens
  • 4:39 – Create a new Window without pens
  • 5:34 – Alarms Panel
  • 5:41 – Activate Alarms Windows
  • 6:24 – Customize Alarm Window
  • 6:55 – Modifying Attributes
  • 8:21 – Docking Panels
  • 8:33 – More Questions – Contact Us
  • 9:05 – Training Page – more videos

Menu

Trend and Alarm Menu 482

  • File-New: Clears all trend, pen groups, and alarm windows and starts with a blank configuration.
  • File-Open: Opens an existing configuration previously saved.
  • File-Save: Saves the current configuration with the existing file name.  This will save the list of Trend, Pen Groups, and Alarm Windows and the current list of Windows in the View Window.
  • File-Save As: Saves the current configuration and with a desired file name.
  • File-Exit: Exit the application.

Trend Navigator Bar

Trend Navigator Bar 483

Trend Navigator Bar 484

The Trend Navigator Bar is used to add, modify, and delete Trend Windows that can be selected to be added to the current view configuration.

To view the list of Trends select the Trends button at the bottom of the Navigator Bar.

Add Trend:

Add ReportSelect the Add button to add a Trend Window to the configuration. This will display the Trend Window setup form.

You can define a list of pens to be used with the trend on startup or use the Pen Groups feature and leave the list of Pens blank.

Networking:

If you will be deploying the Trends and Alarms Dashboard configuration to remote PCs or using the application on a different PC than where the OAS Engine resides implement either Basic Networking syntax or Live Data Cloud Networking syntax by entering the IP Address or Network Node in the Network Node field and click Select or optionally select the Live Data Cloud node where the tags are hosted.

Local Tag

myGroup.myTag.Value

Basic Networking

\\192.168.0.1\myGroup.myTag.Value

Live Data Cloud Networking from local OAS Engine

RemoteSCADAHosting.myLiveDataCloudNode.myGroup.myTag.Value

Live Data Cloud Networking though remote OAS Engine

\\192.168.0.1\RemoteSCADAHosting.myLiveDataCloudNode.myGroup.myTag.Value

Trend Navigator Bar 485

Enter the desired Trend Window Name that will identify the Trend Window in the configuration. You must use a unique name that does not already exist.

Select OK to accept the changes or Cancel to abort the recent changes to the window.

Make sure to select File-Save if you add a Trend Window.

Edit Trend:

Edit Trend 486

Select an existing Trend Window from the Trend List and then Modify button to modify the Trend Window. This will display the Trend Window setup form.

Remove Trend:

Remove Trend 487

Select one or more existing Trend Windows from the Trend List and then the Remove button to remove the Trend Windows from the configuration.

Make sure to select File-Save if you remove a Trend Window.

Activate Trend Window:

Activate Trend 488

Select a Trend Window from the Trend List and then the Activate Trend Window button or simply drag the Trend Window name into the main application to add the Trend Window to the view screen. You can add the same Trend Window more than once if you desire as you can make on-line modifications.

Once the Trend Window is activated the window can be left as free floating to any size or location or it can be docked within the main docking area.

Trend Navigator Bar 489

Select File-Save after the Trend Window is docked or placed into the location you would like it to be.

Pens Navigator Bar

Pens Navigator Bar 490

Pens Navigator Bar 491

The Pens Navigator Bar is used to add, modify, and delete Pen Groups that can define a list of pens to add to an existing Trend Window that is activated.

To view the list of Pen Groups select the Pens button at the bottom of the Navigator Bar or select Edit-Pens.

Add Pens:

Add Report

Select the Add button to add a Pen Group to the configuration. This will display the Pens setup form.

Pens Navigator Bar 492

Enter the desired Pen Group Name that will identify the list of Pens in the configuration. You must use a unique name that does not already exist.

Select OK to accept the changes or Cancel to abort the recent changes to the Pen Group.

Make sure to select File-Save if you add a Pen Group.

Edit Pens:

Edit Trend 486

Select an existing Pen Group from the Pens List and then Edit button to modify the Pen Group.  This will display the Pens setup form.

You can use the Edit function to also clone an existing Pen Group to a new Pen Group simply by specifying a Pen Group name in the pens properties dialog.

Select OK to accept the changes or Cancel to abort the recent changes to the Pen Group.

Make sure to select File-Save if you modify the Pen Group.

Remove Pens:

Remove Trend 487

Select an existing Group from the Pens List and then the Remove button to remove the Pen Group from the configuration.

Make sure to select File-Save if you delete a Pen Group.

Activate Pens:

Activate Trend 488

Select an existing Pen Group from the Pens List and then drag the pen name to one of the trend windows that are currently activated.

Pens Navigator Bar 493

Select File-Save after the Pens have been activated to a trend window.

Alarm Navigator Bar

Alarm Navigation 195

Alarm Navigator Bar 494

The Alarm Navigator Bar is used to add, modify, and delete Alarm Windows that can be selected to be added to the current view configuration.

To view the list of Alarms select the Alarms button at the bottom of the Navigator Bar or select Edit-Alarms.

Add Alarm:

Add Report

Select the Add button to add an Alarm Window to the configuration. This will display the Alarm Window setup form.

Add Alarm 495

Networking:

If you will be deploying the Trends and Alarms Dashboard configuration to remote PCs or using the application on a different PC than where the OAS Engine resides use the Networking tag to select all remote nodes where the alarms will be hosted from.

Enter the desired Alarm Window Name that will identify the Alarm Window in the configuration. You must use a unique name that does not already exist.

Select OK to accept the changes or Cancel to abort the recent changes to the window.

Make sure to select File-Save if you add an Alarm Window.

Edit Alarm:

Edit Trend 486

Select an existing Alarm Window from the Alarm List and then Edit button to modify the Alarm Window. This will display the Alarm Window setup form.

You can use the Edit function to also clone an existing alarm window to a new alarm window simply by specifying a new window name in the alarm properties dialog.

Select OK to accept the changes or Cancel to abort the recent changes to the window.

Make sure to select File-Save if you modify the Alarm Window.

Remove Alarm:

Remove Trend 487

Select an existing Alarm Window from the Alarm List and then the Remove button to remove the Alarm Window from the configuration.

Make sure to select File-Save if you delete an Alarm Window.

Activate Alarm Window:

Activate Trend 488

Select an existing Alarm Window from the Alarm List and then the Activate button to add the Alarm Window to the view screen. You can add the same Alarm Window more than once if you desire as you can make on-line modifications.

Once the Trend Window is activated the window can be left as free floating to any size or location or it can be docked within the main docking area.

Add Alarm 496

Select File-Save after the Alarm Window is docked or placed into the location you would like it to be.

Trend and Alarm Dashboard

Trend and Alarm Dashboard 481

Overview – Trend and Alarm Dashboard

Trend and Alarm Dashboard 480

This application is used to view trend and alarm windows without creating an application with Visual Studio. It provides the ability to configure trend windows, alarm windows, and pen groups.  The windows can be docked or be free floating and state of each window and the configurations can be saved to a file to be loaded on the same or different PC.

To launch the Trends and Alarms application select Trends and Alarms from the Program Group of Open Automation Software.

Overview – Additional Applications

The following are more fully-featured applications and utilities available to assist with getting started more quickly with OAS. These applications serve a variety of functions, from rapidly starting up dashboards, demonstrating OAS Platform capabilities, and acting is simple administrative tools.

NOTE: If you want to visualize your data in a desktop or mobile browser with zero programming, you may be interested in the OAS Open UIEngine .
The UIEngine is a robust no-code web application and HMI builder for developing rich user interfaces in a browser-based development environment.
See the UIEngine Documentation to learn more.

Redundant Data Logging to the Same Table from Multiple Services

IIoT Server Redundancy

You can setup OAS Data Logging and Alarm Logging to from multiple services to the same table. The following is a guideline of parameters to set to enable easy and reliable logging from multiple services to the same database table.

In the following example we will describe the steps to setup both double and triple redundancy when logging data from OPC Servers.

  • Server A will be the primary server. If its data quality is good it will be the master.
    Its IP Address will be 192.168.0.1
  • Server B will be the secondary server. If Server A data quality is bad and its own data quality is good it will be the active logging server.
    Its IP Address will be 192.168.0.2
  • Server C will be the tertiary server. If Server A and Server B data quality is bad and it own data quality is good it will be the active logging server.
    Its IP Address will be 192.168.0.3

Tags – Server A

In Server A create two (2) Tags as follows, one to an OPC Item in the OPC Server that is the primary data source. For each OPC Server in Server A define one item.

  1. TagName: OPCServer01.
    DataSource: OPC Item
    DataType: Set the same as the data type of the item you are monitoring in the server.
    OPC Item: OPC Server and OPC Item path of the local OPC Server Item.
  2. TagName: EnableLogging.
    DataSource: Calculation
    DataType: Boolean.
    Calculation: [OPCServer01.Quality]
    Note: This Tag is created just to make it possible so the Logging Groups in all servers can have the same Tag Name on the Data Logging Groups to make them Active.

Tags – Server B

In Server B create two (2) Tags as follows:

  1. TagName: OPCServer01.
    DataSource: OPC Item
    DataType: Set the same as the data type of the item you are monitoring in the server.
    OPC Item: OPC Server and OPC Item path of the local OPC Server Item.
  2. TagName: EnableLogging.
    DataSource: Calculation
    DataType: Boolean.
    Calculation: ![\ 192.168.0.1 OPCServer01.Quality] & [OPCServer01.Quality]
    The Calculation is Not of Server A quality And local OPC Server 01 quality is good.
    Source When Bad: Set Sources To Default Value
    Default Value: False

Tags – Server C

As an option you can enable a third Server C with the following tags:

  1. TagName: OPCServer01.
    DataSource: OPC Item
    DataType: Set the same as the data type of the item you are monitoring in the server.
    OPC Item: OPC Server and OPC Item path of the local OPC Server Item.
  2. TagName: EnableLogging.
    DataSource: Calculation
    DataType: Boolean.
    Calculation: ![\ 192.168.0.1 OPCServer01.Quality] & ![\ 192.168.0.2 OPCServer01.Quality] & [OPCServer01.Quality]
    The Calculation is Not of Server A quality And Not of Server B quality And local OPC Server 01 quality is good.
    Source When Bad: Set Sources To Default Value
    Default Value: False

Note: If you have multiple OPC Servers on each server PC you can create a master EnableLogging Tag that ANDs all of the .Quality parameters of each OPCServer##Quality Tag.

The safest implementation is to create separate groups of tags for each OPC Server and log the values from each OPC Server in their own separate Data Logging Groups.

So in same active states data logging from some OPC Server items will be logged from Server A, some from Server B, and if a tertiary is used possible the remaining in Server C.

Data Logging Groups

In each Data Logging Group enable the property Activate Logging With Tag.

Set the Tag for Activate Logging to EnableLogging.Value.

Enable the property Do Not Buffer When Nulls Are Not Allowed In Database.

Enable the property Do Not Buffer On Primary Index Failure

Log the OPCServer01.Value Tag value in each Logging Group.

Tables

For each database table make sure there is a Primary Index on the DateAndTime field.

Set the field for the OPCServer01.Value Tag to not allow nulls in the database. Only this one field needs to be set this way along with the DateAndTime.  All others can be left to allow nulls.

Make sure the enable Store Data Logging Buffer To Disk on each Server under Configure-Options-Data Buffer.