
'Declaration
<CLSCompliantAttribute(True)> <ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.ComTypes._ServerElement)> <ComVisibleAttribute(True)> <FacetAttribute("OpcLabs.EasyOpc.Forms.Implementation.ServerElementContent, OpcLabs.EasyOpcForms, Version=5.72.465.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", OpcLabs.BaseLib.Media.IContent, "{A1DB0591-3E22-43A2-A072-2B76C04BE0C0}")> <GuidAttribute("A1CE98D7-BA96-4572-9E44-BC2655161D14")> <TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)> <ValueControlAttribute("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.72.465.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", DefaultReadWrite=False, Export=True, PageId=10001)> <SerializableAttribute()> Public NotInheritable Class ServerElement Inherits OpcLabs.BaseLib.Info Implements LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.Text.IStringListSerializable, OpcLabs.EasyOpc.ComTypes._ServerElement, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
'Usage
Dim instance As ServerElement
[CLSCompliant(true)] [ComDefaultInterface(OpcLabs.EasyOpc.ComTypes._ServerElement)] [ComVisible(true)] [Facet("OpcLabs.EasyOpc.Forms.Implementation.ServerElementContent, OpcLabs.EasyOpcForms, Version=5.72.465.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", OpcLabs.BaseLib.Media.IContent, "{A1DB0591-3E22-43A2-A072-2B76C04BE0C0}")] [Guid("A1CE98D7-BA96-4572-9E44-BC2655161D14")] [TypeConverter(System.ComponentModel.ExpandableObjectConverter)] [ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.72.465.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", DefaultReadWrite=false, Export=true, PageId=10001)] [Serializable()] public sealed class ServerElement : OpcLabs.BaseLib.Info, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.Text.IStringListSerializable, OpcLabs.EasyOpc.ComTypes._ServerElement, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
[CLSCompliant(true)] [ComDefaultInterface(OpcLabs.EasyOpc.ComTypes._ServerElement)] [ComVisible(true)] [Facet("OpcLabs.EasyOpc.Forms.Implementation.ServerElementContent, OpcLabs.EasyOpcForms, Version=5.72.465.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", OpcLabs.BaseLib.Media.IContent, "{A1DB0591-3E22-43A2-A072-2B76C04BE0C0}")] [Guid("A1CE98D7-BA96-4572-9E44-BC2655161D14")] [TypeConverter(System.ComponentModel.ExpandableObjectConverter)] [ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.72.465.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", DefaultReadWrite=false, Export=true, PageId=10001)] [Serializable()] public ref class ServerElement sealed : public OpcLabs.BaseLib.Info, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.Text.IStringListSerializable, OpcLabs.EasyOpc.ComTypes._ServerElement, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
If you want to retrieve a list of OPC Data Access servers registered on a local or remote computer, call the BrowseServers method, passing it the name or address of the remote machine (use empty string for local computer).
In QuickOPC.NET, you will receive back a ServerElementCollection object. If you want to connect to this OPC server later in your code by calling other methods, use the built-in conversion of ServerElement to a String or ServerDescriptor, and pass the resulting string as a serverClass or a serverUrl argument either directly to the method call, or to a constructor of ServerDescriptor object.
In QuickOPC-COM, if you want to connect to some OPC server later in your code by calling other methods, obtain the value of ServerElement.ServerClass property, and pass the resulting string as a serverClass argument to the method call that accepts it.
Each ServerElement contains information gathered about one OPC server found on the specified machine, including things like the server’s CLSID, ProgID, vendor name, and readable description. For an OPC XML server, it contains its URL.
// 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='')
Rem This example shows all information available about OPC servers. Option Explicit Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient") On Error Resume Next Dim ServerElements: Set ServerElements = Client.BrowseServers("") If Err.Number <> 0 Then WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description WScript.Quit End If On Error Goto 0 Dim ServerElement: For Each ServerElement In ServerElements WScript.Echo "Information about server """ & ServerElement & """:" With ServerElement WScript.Echo Space(4) & ".ServerClass: " & .ServerClass WScript.Echo Space(4) & ".ClsidString: " & .ClsidString WScript.Echo Space(4) & ".ProgId: " & .ProgId WScript.Echo Space(4) & ".Description: " & .Description WScript.Echo Space(4) & ".Vendor: " & .Vendor WScript.Echo Space(4) & ".ServerCategories.ToString(): " & .ServerCategories.ToString() WScript.Echo Space(4) & ".VersionIndependentProgId: " & .VersionIndependentProgId End With Next
System.Object
OpcLabs.BaseLib.Object2
OpcLabs.BaseLib.Info
OpcLabs.EasyOpc.ServerElement