QuickOPC User's Guide and Reference
DAItemDescriptor Class
Members  Example 



OpcLabs.EasyOpcClassicCore Assembly > OpcLabs.EasyOpc.DataAccess Namespace : DAItemDescriptor Class
Contains information necessary to identify an OPC item, such as its Item Id.
Object Model
DAItemDescriptor ClassBrowsePath ClassDANodeDescriptor ClassDAItemDescriptor ClassVarType Class
Syntax
'Declaration
 
<CLSCompliantAttribute(True)>
<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.DataAccess.ComTypes._DAItemDescriptor)>
<ComVisibleAttribute(True)>
<GuidAttribute("523E5903-C1E5-4637-AE1F-9F0A3A5328AD")>
<TypeConverterAttribute(OpcLabs.EasyOpc.DataAccess.Implementation.DAItemDescriptorConverter)>
<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 DAItemDescriptor 
   Inherits DANodeDescriptor
   Implements LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.Aliasing.ComTypes._Aliasable, OpcLabs.BaseLib.Aliasing.IAliasable, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.Text.IStringListSerializable, OpcLabs.EasyOpc.ComTypes._NodeDescriptor, OpcLabs.EasyOpc.DataAccess.ComTypes._DAItemDescriptor, OpcLabs.EasyOpc.DataAccess.ComTypes._DANodeDescriptor, System.ComponentModel.INotifyPropertyChanged, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable 
'Usage
 
Dim instance As DAItemDescriptor
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.DataAccess.ComTypes._DAItemDescriptor)]
[ComVisible(true)]
[Guid("523E5903-C1E5-4637-AE1F-9F0A3A5328AD")]
[TypeConverter(OpcLabs.EasyOpc.DataAccess.Implementation.DAItemDescriptorConverter)]
[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 DAItemDescriptor : DANodeDescriptor, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.Aliasing.ComTypes._Aliasable, OpcLabs.BaseLib.Aliasing.IAliasable, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.Text.IStringListSerializable, OpcLabs.EasyOpc.ComTypes._NodeDescriptor, OpcLabs.EasyOpc.DataAccess.ComTypes._DAItemDescriptor, OpcLabs.EasyOpc.DataAccess.ComTypes._DANodeDescriptor, System.ComponentModel.INotifyPropertyChanged, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.DataAccess.ComTypes._DAItemDescriptor)]
[ComVisible(true)]
[Guid("523E5903-C1E5-4637-AE1F-9F0A3A5328AD")]
[TypeConverter(OpcLabs.EasyOpc.DataAccess.Implementation.DAItemDescriptorConverter)]
[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 DAItemDescriptor sealed : public DANodeDescriptor, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.Aliasing.ComTypes._Aliasable, OpcLabs.BaseLib.Aliasing.IAliasable, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.Text.IStringListSerializable, OpcLabs.EasyOpc.ComTypes._NodeDescriptor, OpcLabs.EasyOpc.DataAccess.ComTypes._DAItemDescriptor, OpcLabs.EasyOpc.DataAccess.ComTypes._DANodeDescriptor, System.ComponentModel.INotifyPropertyChanged, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
Remarks
It is possible to construct this object from OpcLabs.EasyOpc.DataAccess.AddressSpace.DANodeElement returned by the browsing methods.
Example

.NET

// Shows how to write into multiple OPC items using a single method call, specifying their requested data types.

using System;
using System.Diagnostics;
using OpcLabs.BaseLib.ComInterop;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class WriteMultipleItemValues
    {
        public static void RequestedDataType()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            Console.WriteLine("Writing multiple item values...");
            OperationResult[] resultArray = client.WriteMultipleItemValues(new[] { 
                    new DAItemValueArguments("", "OPCLabs.KitServer.2", "Simulation.Register_I2", 12345) 
                        { ItemDescriptor = { RequestedDataType = VarTypes.I2}}, // <-- the requested data type
                    new DAItemValueArguments("", "OPCLabs.KitServer.2", "Simulation.Register_R4", 234.56)
                        { ItemDescriptor = { RequestedDataType = VarTypes.R4}}  // <-- the requested data type 
                });


            for (int i = 0; i < resultArray.Length; i++)
            {
                Debug.Assert(resultArray[i] != null);
                if (resultArray[i].Succeeded)
                    Console.WriteLine("Result {0}: success", i);
                else
                {
                    Debug.Assert(!(resultArray[i].Exception is null));
                    Console.WriteLine("Result {0} *** Failure: {1}", i, resultArray[i].ErrorMessageBrief);
                }
            }

            Console.WriteLine("Reading multiple item values...");
            ValueResult[] valueResultArray = client.ReadMultipleItemValues("OPCLabs.KitServer.2",
                new DAItemDescriptor[] { "Simulation.Register_I2", "Simulation.Register_R4" });

            for (int i = 0; i < valueResultArray.Length; i++)
            {
                Debug.Assert(valueResultArray[i] != null);
                Console.WriteLine("valueResultArray[{0}]: {1}", i, valueResultArray[i]);
            }
        }
    }
}
# Shows how to write into multiple OPC items using a single method call, specifying their requested data types.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.BaseLib.ComInterop import *
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

print('Writing multiple item values...')
arguments1 = DAItemValueArguments(ServerDescriptor('OPCLabs.KitServer.2'),
                                  DAItemDescriptor('Simulation.Register_I2'),
                                  12345)
arguments1.ItemDescriptor.RequestedDataType = VarType(VarTypes.I2)  # <-- the requested data type
arguments2 = DAItemValueArguments(ServerDescriptor('OPCLabs.KitServer.2'),
                                  DAItemDescriptor('Simulation.Register_R4'),
                                  234.56)
arguments2.ItemDescriptor.RequestedDataType = VarType(VarTypes.R4)  # <-- the requested data type
operationResultArray = client.WriteMultipleItemValues([arguments1, arguments2])

for i, operationResult in enumerate(operationResultArray):
    assert operationResult is not None
    if operationResult.Succeeded:
        print('operationResultArray[', i, ']: success', sep='')
    else:
        assert operationResult.Exception is not None
        print('operationResultArray[', i, '] *** Failure: ', operationResult.ErrorMessageBrief, sep='')

print('Reading multiple item values...')
try:
    valueResultArray = IEasyDAClientExtension.ReadMultipleItemValues(client, ServerDescriptor('OPCLabs.KitServer.2'), [
        DAItemDescriptor('Simulation.Register_I2'),
        DAItemDescriptor('Simulation.Register_R4'),
    ])
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message)
    exit()

for i, valueResult in enumerate(valueResultArray):
    assert valueResult is not None
    if valueResult.Succeeded:
        print('valueResultArray[', i, '].Value: ', valueResult.Value, sep='')
    else:
        assert valueResult.Exception is not None
        print('valueResultArray[', i, '] *** Failure: ', valueResult.ErrorMessageBrief, sep='')

print('Finished.')
' Shows how to write into multiple OPC items using a single method call, specifying their requested data types.

Imports OpcLabs.BaseLib.ComInterop
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.OperationModel

Namespace DataAccess._EasyDAClient
    Partial Friend Class WriteMultipleItemValues
        Public Shared Sub RequestedDataType()
            Dim client = New EasyDAClient()

            Console.WriteLine("Writing multiple item values...")
            Dim resultArray = client.WriteMultipleItemValues(New DAItemValueArguments() { _
                New DAItemValueArguments("", "OPCLabs.KitServer.2", "Simulation.Register_I2", 12345) With _
                {.ItemDescriptor = New DAItemDescriptor() With {.RequestedDataType = VarTypes.I2}}, _
                New DAItemValueArguments("", "OPCLabs.KitServer.2", "Simulation.Register_R4", 234.56) With _
                {.ItemDescriptor = New DAItemDescriptor() With {.RequestedDataType = VarTypes.R4}} _
            })

            For i = 0 To resultArray.Length - 1
                Debug.Assert(resultArray(i) IsNot Nothing)
                If resultArray(i).Succeeded Then
                    Console.WriteLine("Result {0}: success", i)
                Else
                    Debug.Assert(resultArray(i).Exception IsNot Nothing)
                    Console.WriteLine("Result {0} *** Failure: {1}", i, resultArray(i).ErrorMessageBrief)
                End If
            Next i

            Console.WriteLine("Reading multiple item values...")
            Dim valueResultArray = client.ReadMultipleItemValues("OPCLabs.KitServer.2",
                    New DAItemDescriptor() {"Simulation.Register_I2", "Simulation.Register_R4"})

            For i = 0 To valueResultArray.Length - 1
                Debug.Assert(valueResultArray(i) IsNot Nothing)
                Console.WriteLine("valueResultArray[{0}]: {1}", i, valueResultArray(i))
            Next i
        End Sub
    End Class
End Namespace
Inheritance Hierarchy

System.Object
   OpcLabs.BaseLib.Object2
      OpcLabs.BaseLib.Info
         OpcLabs.EasyOpc.NodeDescriptor
            OpcLabs.EasyOpc.DataAccess.DANodeDescriptor
               OpcLabs.EasyOpc.DataAccess.DAItemDescriptor

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also