// This example shows how to read 4 items at once, and display their values, timestamps and qualities.
using System;
using System.Diagnostics;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;
namespace DocExamples.DataAccess._EasyDAClient
{
partial class ReadMultipleItems
{
public static void Main1()
{
// Instantiate the client object.
var client = new EasyDAClient();
DAVtqResult[] vtqResults = client.ReadMultipleItems("OPCLabs.KitServer.2",
new DAItemDescriptor[]
{
"Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4"
});
for (int i = 0; i < vtqResults.Length; i++)
{
Debug.Assert(vtqResults[i] != null);
if (vtqResults[i].Succeeded)
Console.WriteLine("vtqResults[{0}].Vtq: {1}", i, vtqResults[i].Vtq);
else
Console.WriteLine("vtqResults[{0}] *** Failure: {1}", i, vtqResults[i].ErrorMessageBrief);
}
}
}
}
# This example shows how to read 4 items at once, and display their values, timestamps and qualities.
#requires -Version 5.1
using namespace OpcLabs.EasyOpc.DataAccess
# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Assemblies/net47/OpcLabs.EasyOpcClassic.dll"
# Instantiate the client object.
$client = New-Object EasyDAClient
$vtqResults = [IEasyDAClientExtension]::ReadMultipleItems($client, "OPCLabs.KitServer.2", @(
(New-Object DAItemDescriptor("Simulation.Random")),
(New-Object DAItemDescriptor("Trends.Ramp (1 min)")),
(New-Object DAItemDescriptor("Trends.Sine (1 min)")),
(New-Object DAItemDescriptor("Simulation.Register_I4"))
))
for ($i = 0; $i -lt $vtqResults.Length; $i++) {
$vtqResult = $vtqResults[$i]
if ($vtqResult.Succeeded) {
Write-Host "vtqResults[$($i)].Vtq: $($vtqResult.Vtq)"
}
else {
Write-Host "vtqResults[$($i)] *** Failure: $($vtqResult.ErrorMessageBrief)"
}
}
// This example shows how to read 4 items at once, and display their values, timestamps and qualities.
$ReadItemArguments1 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments");
$ReadItemArguments1->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";
$ReadItemArguments1->ItemDescriptor->ItemID = "Simulation.Random";
$ReadItemArguments2 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments");
$ReadItemArguments2->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";
$ReadItemArguments2->ItemDescriptor->ItemID = "Trends.Ramp (1 min)";
$ReadItemArguments3 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments");
$ReadItemArguments3->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";
$ReadItemArguments3->ItemDescriptor->ItemID = "Trends.Sine (1 min)";
$ReadItemArguments4 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments");
$ReadItemArguments4->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";
$ReadItemArguments4->ItemDescriptor->ItemID = "Simulation.Register_I4";
$arguments[0] = $ReadItemArguments1;
$arguments[1] = $ReadItemArguments2;
$arguments[2] = $ReadItemArguments3;
$arguments[3] = $ReadItemArguments4;
$Client = new COM("OpcLabs.EasyOpc.DataAccess.EasyDAClient");
$results = $Client->ReadMultipleItems($arguments);
for ($i = 0; $i < count($results); $i++)
{
$VtqResult = $results[$i];
if ($VtqResult->Succeeded)
printf("results[d].Vtq.ToString()s\n", $i, $VtqResult->Vtq->ToString);
else
printf("results[d]: *** Failures\n", $i, $VtqResult->ErrorMessageBrief);
}
' This example shows how to read 4 items at once, and display their values, timestamps and qualities.
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.OperationModel
Namespace DocExamples.DataAccess._EasyDAClient
Partial Friend Class ReadMultipleItems
Public Shared Sub Main1()
Dim client = New EasyDAClient()
Dim vtqResults() As DAVtqResult = client.ReadMultipleItems(
"OPCLabs.KitServer.2",
New DAItemDescriptor() {"Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4"})
For i = 0 To vtqResults.Length - 1
Debug.Assert(vtqResults(i) IsNot Nothing)
If vtqResults(i).Succeeded Then
Console.WriteLine("vtqResult[{0}].Vtq: {1}", i, vtqResults(i).Vtq)
Else
Console.WriteLine("vtqResult[{0}] *** Failure: {1}", i, vtqResults(i).ErrorMessageBrief)
End If
Next i
End Sub
End Class
End Namespace