// This example shows all information available about OPC servers.
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.
# 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='')