QuickOPC User's Guide and Reference
DAItemVtqArguments Class
Members 



OpcLabs.EasyOpcClassicCore Assembly > OpcLabs.EasyOpc.DataAccess.OperationModel Namespace : DAItemVtqArguments Class
Holds an OPC server and item descriptor, and a value/timestamp/quality (OpcLabs.EasyOpc.DataAccess.DAVtq), as arguments to some operation.
Object Model
DAItemVtqArguments ClassDAVtq ClassDAItemDescriptor ClassServerDescriptor ClassDAVtq Class
Syntax
'Declaration
 
<CLSCompliantAttribute(True)>
<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAItemVtqArguments)>
<ComVisibleAttribute(True)>
<GuidAttribute("D31DCB89-EF2E-4E3C-85A3-0B813A5DCB10")>
<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 Class DAItemVtqArguments 
   Inherits DAItemArguments
   Implements LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.OperationModel.ComTypes._OperationArguments, OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAItemArguments, OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAItemVtqArguments, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable 
'Usage
 
Dim instance As DAItemVtqArguments
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAItemVtqArguments)]
[ComVisible(true)]
[Guid("D31DCB89-EF2E-4E3C-85A3-0B813A5DCB10")]
[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 class DAItemVtqArguments : DAItemArguments, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.OperationModel.ComTypes._OperationArguments, OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAItemArguments, OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAItemVtqArguments, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAItemVtqArguments)]
[ComVisible(true)]
[Guid("D31DCB89-EF2E-4E3C-85A3-0B813A5DCB10")]
[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 DAItemVtqArguments : public DAItemArguments, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.OperationModel.ComTypes._OperationArguments, OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAItemArguments, OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAItemVtqArguments, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
Remarks

 

Some newer OPC servers allow a combination of value, timestamp, and quality (VTQ) be written into their items.

If you need to do this, call WriteItem or WriteMultipleItems method.

A single item

.NET

// This example shows how to write a value, timestamp and quality into a single item.

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

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

            try
            {
                client.WriteItem("", "OPCLabs.KitServer.2", "Simulation.Register_I4", 
                    12345, DateTime.SpecifyKind(new DateTime(1980, 1, 1), DateTimeKind.Utc), 192);
            }
            catch (OpcException opcException)
            {
                Console.WriteLine($"*** Failure: {opcException.GetBaseException().Message}");
                return;
            }
            Console.WriteLine("Success");
        }
    }
}
# This example shows how to write a value, timestamp and quality into a single item.

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

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


# Instantiate the client object.
client = EasyDAClient()

# Perform the operation
try:
    IEasyDAClientExtension.WriteItem(client, '', 'OPCLabs.KitServer.2', 'Simulation.Register_I4',
                                     12345, DateTime.SpecifyKind(DateTime(1980, 1, 1), DateTimeKind.Utc),
                                     DAQuality(192))
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message)
    exit()

print('Finished.')
# This example shows how to write a value, timestamp and quality into a single item.

#requires -Version 5.1
using namespace System
using namespace OpcLabs.EasyOpc.DataAccess
using namespace OpcLabs.EasyOpc.OperationModel

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicCore.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassic.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicComponents.dll"

# Instantiate the client object.
$client = New-Object EasyDAClient

try {
    [IEasyDAClientExtension]::WriteItem($client, "", "OPCLabs.KitServer.2", "Simulation.Register_I4",
        12345, [DateTime]::SpecifyKind((New-Object DateTime(1980, 1, 1)), [DateTimeKind]::Utc), 192)
}
catch [OpcException] {
    Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)"
    return
}

Write-Host "Success"

COM

// This example shows how to write a value, timestamp and quality into a single item.

class procedure WriteItem.Main;
var
  Client: OpcLabs_EasyOpcClassic_TLB._EasyDAClient;
begin
  // Instantiate the client object
  Client := CoEasyDAClient.Create;

  try
    Client.WriteItem('', 'OPCLabs.KitServer.2', 'Simulation.Register_I4', 12345, EncodeDate(1980, 1, 1), DAQualities_GoodNonSpecific);
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
      Exit;
    end;
  end;

end;
Rem This example shows how to write a value, timestamp and quality into a single item.

Private Sub WriteItem_Main_Command_Click()
    OutputText = ""
    
    ' Instantiate the client object
    Dim client As New EasyDAClient

    On Error Resume Next
    Call client.WriteItem("", "OPCLabs.KitServer.2", "Simulation.Register_I4", 12345, DateSerial(1980, 1, 1), DAQualities_GoodNonspecific)
    If Err.Number <> 0 Then
        OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf
        Exit Sub
    End If
    On Error GoTo 0
End Sub
Rem This example shows how to write a value, timestamp and quality into a single item.

Option Explicit

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
On Error Resume Next
Client.WriteItem "", "OPCLabs.KitServer.2", "Simulation.Register_I4", 12345, DateSerial(1980, 1, 1), 192
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

 

Multiple items

.NET

// This example shows how to write values, timestamps and qualities into 3 items at once.

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

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

            Console.WriteLine("Writing multiple items...");
            OperationResult[] resultArray = client.WriteMultipleItems(
                new[] { 
                    new DAItemVtqArguments("OPCLabs.KitServer.2", "Simulation.Register_I4", 
                        new DAVtq(23456, DateTime.UtcNow, DAQualities.GoodNonspecific)),
                    new DAItemVtqArguments("OPCLabs.KitServer.2", "Simulation.Register_R8", 
                        new DAVtq(2.34567890, DateTime.UtcNow, DAQualities.GoodNonspecific)),
                    new DAItemVtqArguments("OPCLabs.KitServer.2", "Simulation.Register_BSTR", 
                        new DAVtq("ABC", DateTime.UtcNow, DAQualities.GoodNonspecific))
                });
            
            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);
                }
            }
        }
    }
}
# This example shows how to write values, timestamps and qualities into 3 items at once.

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

# Import .NET namespaces.
from System 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 items...')
operationResultArray = client.WriteMultipleItems([
    DAItemVtqArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Register_I4'),
                       DAVtq(23456, DateTime.UtcNow, DAQuality(DAQualities.GoodNonspecific))),
    DAItemVtqArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Register_R8'),
                       DAVtq(2.34567890, DateTime.UtcNow, DAQuality(DAQualities.GoodNonspecific))),
    DAItemVtqArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Register_BSTR'),
                       DAVtq('ABC', DateTime.UtcNow, DAQuality(DAQualities.GoodNonspecific))),
    ])

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('Finished.')
# This example shows how to write values, timestamps and qualities into 3 items at once.

#requires -Version 5.1
using namespace System
using namespace OpcLabs.EasyOpc.DataAccess
using namespace OpcLabs.EasyOpc.DataAccess.OperationModel

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicCore.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassic.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicComponents.dll"

# Instantiate the client object.
$client = New-Object EasyDAClient

Write-Host "Writing multiple items..."
$resultArray = $client.WriteMultipleItems(@(
    (New-Object DAItemVtqArguments("OPCLabs.KitServer.2", "Simulation.Register_I4", 
        (New-Object DAVtq(23456, [DateTime]::UtcNow, [DAQualities]::GoodNonspecific)))),
    (New-Object DAItemVtqArguments("OPCLabs.KitServer.2", "Simulation.Register_R8", 
        (New-Object DAVtq(2.345667890, [DateTime]::UtcNow, [DAQualities]::GoodNonspecific)))),
    (New-Object DAItemVtqArguments("OPCLabs.KitServer.2", "Simulation.Register_BSTR",
        (New-Object DAVtq("ABC", [DateTime]::UtcNow, [DAQualities]::GoodNonspecific))))
    ))

for ($i = 0; $i -lt $resultArray.Length; $i++) {
    $result = $resultArray[$i]
    if ($result.Succeeded) {
        Write-Host "Result $($i): success"
    }
    else {
        Write-Host "Result $($i) *** Failure: $($result.ErrorMessageBrief)"
    }
}

COM

// This example shows how to write values, timestamps and qualities into 3 items at once.

class procedure WriteMultipleItems.Main;
var
  Arguments: OleVariant;
  Client: OpcLabs_EasyOpcClassic_TLB._EasyDAClient;
  I: Cardinal;
  ItemVtqArguments1: _DAItemVtqArguments;
  ItemVtqArguments2: _DAItemVtqArguments;
  ItemVtqArguments3: _DAItemVtqArguments;
  Results: OleVariant;
  OperationResult: _OperationResult;

begin
  ItemVtqArguments1 := CoDAItemVtqArguments.Create;
  ItemVtqArguments1.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';
  ItemVtqArguments1.ItemDescriptor.ItemID := 'Simulation.Register_I4';
  ItemVtqArguments1.Vtq.Value := 23456;
  ItemVtqArguments1.Vtq.TimestampLocal := Now();
  ItemVtqArguments1.Vtq.Quality.NumericalValue := DAQualities_GoodNonSpecific;

  ItemVtqArguments2 := CoDAItemVtqArguments.Create;
  ItemVtqArguments2.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';
  ItemVtqArguments2.ItemDescriptor.ItemID := 'Simulation.Register_R8';
  ItemVtqArguments2.Vtq.Value := 2.34567890;
  ItemVtqArguments2.Vtq.TimestampLocal := Now();
  ItemVtqArguments2.Vtq.Quality.NumericalValue := DAQualities_GoodNonSpecific;

  ItemVtqArguments3 := CoDAItemVtqArguments.Create;
  ItemVtqArguments3.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';
  ItemVtqArguments3.ItemDescriptor.ItemID := 'Simulation.Register_BSTR';
  ItemVtqArguments3.Vtq.Value := 'ABC';
  ItemVtqArguments3.Vtq.TimestampLocal := Now();
  ItemVtqArguments3.Vtq.Quality.NumericalValue := DAQualities_GoodNonSpecific;

  Arguments := VarArrayCreate([0, 2], varVariant);
  Arguments[0] := ItemVtqArguments1;
  Arguments[1] := ItemVtqArguments2;
  Arguments[2] := ItemVtqArguments3;

  // Instantiate the client object
  Client := CoEasyDAClient.Create;

  // Modify values of nodes
  TVarData(Results).VType := varArray or varVariant;
  TVarData(Results).VArray := PVarArray(
    Client.WriteMultipleItems(Arguments));

  // Display results
  for I := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do
  begin
    OperationResult := IInterface(Results[I]) as _OperationResult;
    if OperationResult.Succeeded then
      WriteLn('Result ', I, ' success')
    else
      WriteLn('Result ', I, ' *** Failure: ', OperationResult.Exception.GetBaseException.Message);
  end;

  VarClear(Results);
  VarClear(Arguments);
end;
Rem This example shows how to write values, timestamps and qualities into 3 items at once.

Private Sub WriteMultipleItems_Main_Command_Click()
    OutputText = ""
    
    Dim itemVtqArguments1 As New DAItemVtqArguments
    itemVtqArguments1.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    itemVtqArguments1.ItemDescriptor.itemId = "Simulation.Register_I4"
    itemVtqArguments1.vtq.SetValue 23456
    itemVtqArguments1.vtq.TimestampLocal = Now()
    itemVtqArguments1.vtq.Quality.NumericalValue = DAQualities_GoodNonspecific
    
    Dim itemVtqArguments2 As New DAItemVtqArguments
    itemVtqArguments2.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    itemVtqArguments2.ItemDescriptor.itemId = "Simulation.Register_R8"
    itemVtqArguments2.vtq.SetValue 2.3456789
    itemVtqArguments2.vtq.TimestampLocal = Now()
    itemVtqArguments2.vtq.Quality.NumericalValue = DAQualities_GoodNonspecific
    
    Dim itemVtqArguments3 As New DAItemVtqArguments
    itemVtqArguments3.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    itemVtqArguments3.ItemDescriptor.itemId = "Simulation.Register_BSTR"
    itemVtqArguments3.vtq.SetValue "ABC"
    itemVtqArguments3.vtq.TimestampLocal = Now()
    itemVtqArguments3.vtq.Quality.NumericalValue = DAQualities_GoodNonspecific
    
    Dim arguments(2) As Variant
    Set arguments(0) = itemVtqArguments1
    Set arguments(1) = itemVtqArguments2
    Set arguments(2) = itemVtqArguments3

    ' Instantiate the client object
    Dim client As New EasyDAClient

    ' Modify values of nodes
    Dim results() As Variant
    results = client.WriteMultipleItems(arguments)

    ' Display results
    Dim i: For i = LBound(results) To UBound(results)
        Dim operationResult As operationResult: Set operationResult = results(i)
        If operationResult.Succeeded Then
            OutputText = OutputText & "result " & i & " success" & vbCrLf
        Else
            OutputText = OutputText & "result " & i & " *** Failure: " & operationResult.ErrorMessageBrief & vbCrLf
        End If
    Next
End Sub
Rem This example shows how to write values, timestamps and qualities into 3 items at once.

Option Explicit

Dim ItemVtqArguments1: Set ItemVtqArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAItemVtqArguments")
ItemVtqArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ItemVtqArguments1.ItemDescriptor.ItemID = "Simulation.Register_I4"
ItemVtqArguments1.Vtq.Value = 23456
ItemVtqArguments1.Vtq.TimestampLocal = Now()
ItemVtqArguments1.Vtq.Quality.NumericalValue = 192

Dim ItemVtqArguments2: Set ItemVtqArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAItemVtqArguments")
ItemVtqArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ItemVtqArguments2.ItemDescriptor.ItemID = "Simulation.Register_R8"
ItemVtqArguments2.Vtq.Value = 2.34567890
ItemVtqArguments2.Vtq.TimestampLocal = Now()
ItemVtqArguments2.Vtq.Quality.NumericalValue = 192

Dim ItemVtqArguments3: Set ItemVtqArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAItemVtqArguments")
ItemVtqArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ItemVtqArguments3.ItemDescriptor.ItemID = "Simulation.Register_BSTR"
ItemVtqArguments3.Vtq.Value = "ABC"
ItemVtqArguments3.Vtq.TimestampLocal = Now()
ItemVtqArguments3.Vtq.Quality.NumericalValue = 192

Dim arguments(2)
Set arguments(0) = ItemVtqArguments1
Set arguments(1) = ItemVtqArguments2
Set arguments(2) = ItemVtqArguments3

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
Dim results: results = Client.WriteMultipleItems(arguments)

Dim i: For i = LBound(results) To UBound(results)
    Dim OperationResult: Set OperationResult = results(i)
    If OperationResult.Succeeded Then
        WScript.Echo "Result " & i & ": success"
    Else
        WScript.Echo "Result " & i & ": " & OperationResult.Exception.GetBaseException.Message
    End If
Next

 

More...

You can also specify the requested data type when writing the value, timestamp and quality. See Data Type in OPC Classic Write.

 

 

Inheritance Hierarchy

System.Object
   OpcLabs.BaseLib.Object2
      OpcLabs.BaseLib.Info
         OpcLabs.BaseLib.OperationModel.OperationArguments
            OpcLabs.EasyOpc.DataAccess.OperationModel.DAItemArguments
               OpcLabs.EasyOpc.DataAccess.OperationModel.DAItemVtqArguments
                  OpcLabs.EasyOpc.DataAccess.Generic.DAItemVtqArguments<T>

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