Getting Started with OASConfig
The OASConfig component is used to programmatically configure a local or remote OAS instance. All configurations can be programmatically defined. This would include:
- Tags
- Data Logging
- Alarm Logging
- Alarm Notification
- Recipes
- Security
- Server Options
The OASConfig .NET Standard 2.0 component and OPCSystems component for .NET Framework 4.0 applications are free to use and can be included in Windows Services, Web Services, ASP.NET Web Applications, WinForm Applications, and WPF Applications. They are 100% managed code components and can be used to communicate and set up both local and remote services.
With the release of the OAS Platform v12, the .NET programmatic interface for server configuration is based on .NET Standard 2.0 with the OASConfig component. This allows you to configure an OAS server from an application that can be deployed to any supported OS, including Linux, Mac, Android, and iOS.
Requirements
For all .NET development, Microsoft Visual Studio 2015+ is recommended. For developing cross-platform .NET Standard or .NET Core solutions, Visual Studio 2019+ is recommended. For developing Android and/or iOS solutions, be sure to include Xamarin extensions to Visual Studio. With the exception of Xamarin apps which require C#, all code can be written in either VB.NET or C#.
Step 1: Include the OASConfig Assembly
After creating a new Visual Studio project, add a reference to the OASConfig assembly, found in the OAS installation directory. This is typically:
C:\Program Files\Open Automation Software\OAS\Controls\NetStandard\OASConfig
- .NET 5 or greater
- .NET Core 2.0 or greater
- .NET Framework 4.61 or greater
- Xamarin.iOS 10.14 or greater
- Xamarin.Android 8.0 or greater
- UWP 1.0.0.16299 or greater
For .NET Framework 4.6.0 or less it is typically C:\Program Files\Open Automation Software\OAS\Controls\NetFramework\OPCSystems
Step 2: Include a single instance of OASConfig
Your application typically does not need more than one instance of the OASConfig.Config class. So, this can be created when your application starts.
The following is an example of a console application using a single static instance of the OASConfig.Config class which will be available and shared by all other members of the application.
VB
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Namespace OASConfigSample
Class Program
Shared oasc As OASConfig.Config = New OASConfig.Config()
Public Shared Sub Main(ByVal args As String())
Dim v As Integer = oasc.GetVersion()
If v <= 0 Then
Console.WriteLine("Cannot connect to OAS Server")
Else
Dim groups As String() = oasc.GetGroupNames()
For Each g As String In groups
Console.WriteLine(g)
Next
End If
Console.ReadLine()
End Sub
End Class
End Namespace
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OASConfigSample
{
class Program
{
static OASConfig.Config oasc = new OASConfig.Config();
static void Main(string[] args)
{
// simple call to test connectivity
int v = oasc.GetVersion();
if (v <= 0) {
Console.WriteLine("Cannot connect to OAS Server");
}
else
{
// retrieve all Tag Group names at the root
string[] groups = oasc.GetGroupNames();
foreach (string g in groups)
{
Console.WriteLine(g);
}
}
Console.ReadLine();
}
}
}
Step 3: Explore the API
Explore the OASConfig API for the specific operations you require to automate the creation or modification of OAS Server configurations.