// This example shows all information available about categories that particular OPC servers do support.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
using System;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.AlarmsAndEvents;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;
namespace DocExamples._ServerCategories
{
class General
{
public static void Main1()
{
// Instantiate the OPC-DA client object.
var daClient = new EasyDAClient();
Console.WriteLine();
Console.WriteLine("OPC DATA ACCESS");
ServerElementCollection daServerElements;
try
{
daServerElements = daClient.BrowseServers();
}
catch (OpcException opcException)
{
Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
return;
}
DumpServerElements(daServerElements);
// Instantiate the OPC-A&E client object.
var aeClient = new EasyAEClient();
Console.WriteLine();
Console.WriteLine("OPC ALARMS AND EVENTS");
ServerElementCollection aeServerElements;
try
{
aeServerElements = aeClient.BrowseServers();
}
catch (OpcException opcException)
{
Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
return;
}
DumpServerElements(aeServerElements);
}
private static void DumpServerElements(ServerElementCollection serverElements)
{
foreach (ServerElement serverElement in serverElements)
{
Console.WriteLine($"Categories of \"{serverElement.ProgId}\":");
ServerCategories serverCategories = serverElement.ServerCategories;
Console.WriteLine($" .OpcAlarmsAndEvents10: {serverCategories.OpcAlarmsAndEvents10}");
Console.WriteLine($" .OpcDataAccess10: {serverCategories.OpcDataAccess10}");
Console.WriteLine($" .OpcDataAccess20: {serverCategories.OpcDataAccess20}");
Console.WriteLine($" .OpcDataAccess30: {serverCategories.OpcDataAccess30}");
Console.WriteLine($" .ToString(): {serverCategories}");
}
}
// Example output:
//
//OPC DATA ACCESS
//Categories of "OPCLabs.KitServer.2":
// .OpcAlarmsAndEvents10: False
// .OpcDataAccess10: True
// .OpcDataAccess20: True
// .OpcDataAccess30: True
// .ToString(): (OpcDataAccess10, OpcDataAccess20, OpcDataAccess30)
//
//OPC ALARMS AND EVENTS
//Categories of "OPCLabs.KitEventServer.2":
// .OpcAlarmsAndEvents10: True
// .OpcDataAccess10: False
// .OpcDataAccess20: False
// .OpcDataAccess30: False
// .ToString(): (OpcAlarmsAndEvents10)
}
}
' This example shows all information available about categories that particular OPC servers do support.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.
Imports OpcLabs.EasyOpc
Imports OpcLabs.EasyOpc.AlarmsAndEvents
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel
Namespace _ServerCategories
Partial Friend Class General
Shared Sub Main1()
' Instantiate the OPC-DA client object.
Dim daClient = New EasyDAClient()
Console.WriteLine()
Console.WriteLine("OPC DATA ACCESS")
Dim daServerElements As ServerElementCollection
Try
daServerElements = daClient.BrowseServers("")
Catch opcException As OpcException
Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
Exit Sub
End Try
DumpServerElements(daServerElements)
' Instantiate the OPC-A&E client object.
Dim aeClient = New EasyAEClient()
Console.WriteLine()
Console.WriteLine("OPC ALARMS AND EVENTS")
Dim aeServerElements As ServerElementCollection
Try
aeServerElements = aeClient.BrowseServers("")
Catch opcException As OpcException
Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
Exit Sub
End Try
DumpServerElements(aeServerElements)
End Sub
Private Shared Sub DumpServerElements(serverElements As ServerElementCollection)
For Each serverElement In serverElements
Console.WriteLine($"Categories of ""{serverElement.ProgId}"":")
Dim serverCategories As ServerCategories = serverElement.ServerCategories
Console.WriteLine($" .OpcAlarmsAndEvents10: {serverCategories.OpcAlarmsAndEvents10}")
Console.WriteLine($" .OpcDataAccess10: {serverCategories.OpcDataAccess10}")
Console.WriteLine($" .OpcDataAccess20: {serverCategories.OpcDataAccess20}")
Console.WriteLine($" .OpcDataAccess30: {serverCategories.OpcDataAccess30}")
Console.WriteLine($" .ToString(): {serverCategories}")
Next serverElement
End Sub
' Example output
'
'OPC DATA ACCESS
'Categories of "OPCLabs.KitServer.2":
' .OpcAlarmsAndEvents10 False
' .OpcDataAccess10: True
' .OpcDataAccess20: True
' .OpcDataAccess30: True
' .ToString(): (OpcDataAccess10, OpcDataAccess20, OpcDataAccess30)
'
'OPC ALARMS AND EVENTS
'Categories of "OPCLabs.KitEventServer.2":
' .OpcAlarmsAndEvents10 True
' .OpcDataAccess10: False
' .OpcDataAccess20: False
' .OpcDataAccess30: False
' .ToString(): (OpcAlarmsAndEvents10)
End Class
End Namespace
Rem This example shows all information available about categories that particular OPC servers do support.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.
Option Explicit
Sub DumpServerElements(ByVal ServerElements)
Dim ServerElement: For Each ServerElement In ServerElements
WScript.Echo "Categories of """ & ServerElement.ProgID & """:"
With ServerElement.ServerCategories
WScript.Echo Space(4) & ".OpcAlarmsAndEvents10: " & .OpcAlarmsAndEvents10
WScript.Echo Space(4) & ".OpcDataAccess10: " & .OpcDataAccess10
WScript.Echo Space(4) & ".OpcDataAccess20: " & .OpcDataAccess20
WScript.Echo Space(4) & ".OpcDataAccess30: " & .OpcDataAccess30
WScript.Echo Space(4) & ".ToString(): " & .ToString()
End With
Next
End Sub
Dim DAClient: Set DAClient = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
WScript.Echo
WScript.Echo "OPC DATA ACCESS"
On Error Resume Next
Dim DAServerElements: Set DAServerElements = DAClient.BrowseServers("")
If Err.Number <> 0 Then
WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
WScript.Quit
End If
On Error Goto 0
DumpServerElements DAServerElements
Dim AEClient: Set AEClient = CreateObject("OpcLabs.EasyOpc.AlarmsAndEvents.EasyAEClient")
WScript.Echo
WScript.Echo "OPC ALARMS AND EVENTS"
On Error Resume Next
Dim AEServerElements: Set AEServerElements = AEClient.BrowseServers("")
If Err.Number <> 0 Then
WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
WScript.Quit
End If
On Error Goto 0
DumpServerElements AEServerElements
# This example shows all information available about categories that particular OPC servers do support.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc
# Import .NET namespaces.
from OpcLabs.EasyOpc.AlarmsAndEvents import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *
def dumpServerElements(serverElements):
for serverElement in serverElements:
print('Categories of ', serverElement.ProgId, ':', sep='')
serverCategories = serverElement.ServerCategories
print(' .OpcAlarmsAndEvents10: ', serverCategories.OpcAlarmsAndEvents10, sep='')
print(' .OpcDataAccess10: ', serverCategories.OpcDataAccess10, sep='')
print(' .OpcDataAccess20: ', serverCategories.OpcDataAccess20, sep='')
print(' .OpcDataAccess30: ', serverCategories.OpcDataAccess30, sep='')
print(' .ToString(): ', serverCategories, sep='')
# Instantiate the OPC-DA client object.
daClient = EasyDAClient()
print()
print('OPC DATA ACCESS')
try:
daServerElements = IEasyDAClientExtension.BrowseServers(daClient)
except OpcException as opcException:
print('*** Failure: ' + opcException.GetBaseException().Message)
exit()
dumpServerElements(daServerElements)
# Instantiate the OPC-A&E client object.
aeClient = EasyAEClient()
print()
print('OPC ALARMS AND EVENTS')
try:
aeServerElements = IEasyAEClientExtension.BrowseServers(aeClient)
except OpcException as opcException:
print('*** Failure: ' + opcException.GetBaseException().Message)
exit()
dumpServerElements(aeServerElements)