// This example shows all information available about OPC servers.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
using System;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;
namespace DocExamples._ServerElement
{
class General
{
public static void Main1()
{
// Instantiate the client object.
var client = new EasyDAClient();
ServerElementCollection serverElements;
try
{
serverElements = client.BrowseServers();
}
catch (OpcException opcException)
{
Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
return;
}
foreach (ServerElement serverElement in serverElements)
{
Console.WriteLine($"Information about server \"{serverElement}\":");
Console.WriteLine($" .ServerClass: {serverElement.ServerClass}");
Console.WriteLine($" .ClsidString: {serverElement.ClsidString}");
Console.WriteLine($" .ProgId: {serverElement.ProgId}");
Console.WriteLine($" .Description: {serverElement.Description}");
Console.WriteLine($" .Vendor: {serverElement.Vendor}");
Console.WriteLine($" .ServerCategories: {serverElement.ServerCategories}");
Console.WriteLine($" .VersionIndependentProgId: {serverElement.VersionIndependentProgId}");
}
// Example output:
//
//Information about server "opcda:OPCLabs.KitServer.2%7Bc8a12f17-1e03-401e-b53d-6c654dd576da%7D":
// .ServerClass: OPCLabs.KitServer.2
// .ClsidString: c8a12f17-1e03-401e-b53d-6c654dd576da
// .ProgId: OPCLabs.KitServer.2
// .Description: OPC Labs Kit Server
// .Vendor: OPC Labs, http://www.opclabs.com
// .ServerCategories: (OpcDataAccess10, OpcDataAccess20, OpcDataAccess30)
// .VersionIndependentProgId: OPCLabs.KitServer
}
}
}
# This example shows all information available about OPC servers.
#
# 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 .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc
# Import .NET namespaces.
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *
# Instantiate the client object.
client = EasyDAClient()
try:
serverElements = IEasyDAClientExtension.BrowseServers(client)
except OpcException as opcException:
print('*** Failure: ' + opcException.GetBaseException().Message)
exit()
# Display results
for serverElement in serverElements:
print('Information about server ', serverElement, ':', sep='')
print(' .ServerClass: ', serverElement.ServerClass, sep='')
print(' .ClsidString: ', serverElement.ClsidString, sep='')
print(' .ProgId: ', serverElement.ProgId, sep='')
print(' .Description: ', serverElement.Description, sep='')
print(' .Vendor: ', serverElement.Vendor, sep='')
print(' .ServerCategories: ', serverElement.ServerCategories, sep='')
print(' .VersionIndependentProgId: ', serverElement.VersionIndependentProgId, sep='')
' This example shows all information available about OPC servers.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Imports OpcLabs.EasyOpc
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel
Namespace _ServerElement
Partial Friend Class General
Shared Sub Main1()
' Instantiate the client object.
Dim client = New EasyDAClient()
Dim serverElements As ServerElementCollection
Try
serverElements = client.BrowseServers("")
Catch opcException As OpcException
Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
Exit Sub
End Try
For Each serverElement In serverElements
Console.WriteLine($"Information about server ""{serverElement}"":")
Console.WriteLine($" .ServerClass: {serverElement.ServerClass}")
Console.WriteLine($" .ClsidString: {serverElement.ClsidString}")
Console.WriteLine($" .ProgId: {serverElement.ProgId}")
Console.WriteLine($" .Description: {serverElement.Description}")
Console.WriteLine($" .Vendor: {serverElement.Vendor}")
Console.WriteLine($" .ServerCategories: {serverElement.ServerCategories}")
Console.WriteLine($" .VersionIndependentProgId: {serverElement.VersionIndependentProgId}")
Next serverElement
End Sub
' Example output
'
'Information about server "opcda:OPCLabs.KitServer.2%7Bc8a12f17-1e03-401e-b53d-6c654dd576da%7D":
' .ServerClass OPCLabs.KitServer.2
' .ClsidString: c8a12f17-1e03-401e-b53d-6c654dd576da
' .ProgId: OPCLabs.KitServer.2
' .Description: OPC Labs Kit Server
' .Vendor: OPC Labs, http : 'www.opclabs.com
' .ServerCategories: (OpcDataAccess10, OpcDataAccess20, OpcDataAccess30)
' .VersionIndependentProgId: OPCLabs.KitServer
End Class
End Namespace