

'Declaration<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.UA.ComTypes._UAIndexRangeList)> <ComVisibleAttribute(True)> <DebuggerDisplayAttribute("{ToString()}")> <GuidAttribute("92147D88-FA19-4C0A-B63E-9DCD30CE6DC4")> <TypeConverterAttribute(OpcLabs.EasyOpc.UA.Internal.UAIndexRangeListConverter)> <DefaultMemberAttribute("Item")> <DebuggerTypeProxyAttribute(System.Collections.Generic.Mscorlib_CollectionDebugView`1)> <SerializableAttribute()> Public NotInheritable Class UAIndexRangeList Inherits System.Collections.Generic.List(Of UAIndexRange) Implements OpcLabs.EasyOpc.UA.ComTypes._UAIndexRangeList, System.Collections.Generic.ICollection(Of UAIndexRange), System.Collections.Generic.IEnumerable(Of UAIndexRange), System.Collections.Generic.IList(Of UAIndexRange), System.Collections.Generic.IReadOnlyCollection(Of UAIndexRange), System.Collections.Generic.IReadOnlyList(Of UAIndexRange), System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ICloneable
'UsageDim instance As UAIndexRangeList
[ComDefaultInterface(OpcLabs.EasyOpc.UA.ComTypes._UAIndexRangeList)] [ComVisible(true)] [DebuggerDisplay("{ToString()}")] [Guid("92147D88-FA19-4C0A-B63E-9DCD30CE6DC4")] [TypeConverter(OpcLabs.EasyOpc.UA.Internal.UAIndexRangeListConverter)] [DefaultMember("Item")] [DebuggerTypeProxy(System.Collections.Generic.Mscorlib_CollectionDebugView`1)] [Serializable()] public sealed class UAIndexRangeList : System.Collections.Generic.List<UAIndexRange>, OpcLabs.EasyOpc.UA.ComTypes._UAIndexRangeList, System.Collections.Generic.ICollection<UAIndexRange>, System.Collections.Generic.IEnumerable<UAIndexRange>, System.Collections.Generic.IList<UAIndexRange>, System.Collections.Generic.IReadOnlyCollection<UAIndexRange>, System.Collections.Generic.IReadOnlyList<UAIndexRange>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ICloneable
[ComDefaultInterface(OpcLabs.EasyOpc.UA.ComTypes._UAIndexRangeList)] [ComVisible(true)] [DebuggerDisplay("{ToString()}")] [Guid("92147D88-FA19-4C0A-B63E-9DCD30CE6DC4")] [TypeConverter(OpcLabs.EasyOpc.UA.Internal.UAIndexRangeListConverter)] [DefaultMember("Item")] [DebuggerTypeProxy(System.Collections.Generic.Mscorlib_CollectionDebugView`1)] [Serializable()] public ref class UAIndexRangeList sealed : public System.Collections.Generic.List<UAIndexRange>, OpcLabs.EasyOpc.UA.ComTypes._UAIndexRangeList, System.Collections.Generic.ICollection<UAIndexRange>, System.Collections.Generic.IEnumerable<UAIndexRange>, System.Collections.Generic.IList<UAIndexRange>, System.Collections.Generic.IReadOnlyCollection<UAIndexRange>, System.Collections.Generic.IReadOnlyList<UAIndexRange>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ICloneable
// This example shows how to read a range of values from an array. // // Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-CSharp . // Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.OperationModel; namespace UACommonDocExamples._UAIndexRangeList { partial class Usage { public static void ReadValue() { UAEndpointDescriptor endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) // or "https://opcua.demo-this.com:51212/UA/SampleServer/" // Instantiate the client object var client = new EasyUAClient(); // Obtain the value, indicating that just the elements 2 to 4 should be returned object value; try { value = client.ReadValue( new UAReadArguments( endpointDescriptor, "nsu=http://test.org/UA/Data/ ;ns=2;i=10305", // /Data.Static.Array.Int32Value UAIndexRangeList.OneDimension(2, 4))); } catch (UAException uaException) { Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message); return; } // Cast to typed array var arrayValue = (Int32[]) value; // Display results for (int i = 0; i < 3; i++) Console.WriteLine("arrayValue[{0}]: {1}", i, arrayValue[i]); // Example output: //arrayValue[0]: 180410224 //arrayValue[1]: 1919239969 //arrayValue[2]: 1700185172 } } }
# This example shows how to read a range of values from an array. # # Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . # OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell . # Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. #requires -Version 5.1 using namespace OpcLabs.EasyOpc.UA using namespace OpcLabs.EasyOpc.UA.OperationModel # The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows . Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUAPrimitives.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUACore.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUA.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUAComponents.dll" [UAEndpointDescriptor]$endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" # or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) # or "https://opcua.demo-this.com:51212/UA/SampleServer/" # Instantiate the client object. $client = New-Object EasyUAClient # Obtain the value, indicating that just the elements 2 to 4 should be returned try { $value = [OpcLabs.EasyOpc.UA.IEasyUAClientExtension]::ReadValue($client, (New-Object UAReadArguments( $endpointDescriptor, "nsu=http://test.org/UA/Data/ ;ns=2;i=10305", # /Data.Static.Array.Int32Value [OpcLabs.EasyOpc.UA.UAIndexRangeList]::OneDimension(2, 4) ))) } catch [UAException] { Write-Host ("Failure: {0}" -f $_.Exception.GetBaseException().Message) return } # Cast to typed array [int[]] $arrayValue = $value # Display results for ($i = 0; $i -lt 3; $i++) { Write-Host ("arrayValue[{0}]: {1}" -f $i, $arrayValue[$i]) } # Write-Host "arrayValue[$($i)]: $($arrayValue[$i])" # Example output: #arrayValue[0]: 180410224 #arrayValue[1]: 1919239969 #arrayValue[2]: 1700185172
' This example shows how to read a range of values from an array. ' ' Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports OpcLabs.EasyOpc.UA Imports OpcLabs.EasyOpc.UA.OperationModel Namespace Global.UACommonDocExamples._UAIndexRangeList Friend Class Usage Public Shared Sub ReadValue() Dim endpointDescriptor As UAEndpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) ' or "https://opcua.demo-this.com:51212/UA/SampleServer/" ' Instantiate the client object Dim client = New EasyUAClient() ' Obtain the value, indicating that just the elements 2 to 4 should be returned Dim value As Object Try value = client.ReadValue( New UAReadArguments( endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10305", UAIndexRangeList.OneDimension(2, 4))) ' or "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" Catch uaException As UAException Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message) Exit Sub End Try ' Cast to typed array Dim arrayValue = DirectCast(value, Int32()) ' Display results For i = 0 To 2 Console.WriteLine("arrayValue[{0}]: {1}", i, arrayValue(i)) Next End Sub End Class End Namespace
// This example shows how to read a range of values from an array. // // Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . // OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-OP . // Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. class procedure Usage.ReadValue; var Client: _EasyUAClient; EndpointDescriptor: string; ReadArguments1: _UAReadArguments; Arguments, Results: OleVariant; I: Cardinal; IndexRange: _UAIndexRange; IndexRangeList: OpcLabs_EasyOpcUAPrimitives_TLB._UAIndexRangeList; ArrayValue: OleVariant; Value: Integer; ValueResult: _ValueResult; begin EndpointDescriptor := //'http://opcua.demo-this.com:51211/UA/SampleServer'; //'https://opcua.demo-this.com:51212/UA/SampleServer/'; 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'; // Instantiate the client object Client := CoEasyUAClient.Create; // Prepare the arguments, indicating that just the elements 2 to 4 should be returned. IndexRangeList := CoUAIndexRangeList.Create; IndexRange := CoUAIndexRange.Create; IndexRange.Minimum := 2; IndexRange.Maximum := 4; IndexRangeList.Add(IndexRange); ReadArguments1 := CoUAReadArguments.Create; ReadArguments1.EndpointDescriptor.UrlString := EndpointDescriptor; ReadArguments1.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;ns=2;i=10305'; ReadArguments1.IndexRangeList := IndexRangeList; Arguments := VarArrayCreate([0, 0], varVariant); Arguments[0] := ReadArguments1; // Obtain value. TVarData(Results).VType := varArray or varVariant; TVarData(Results).VArray := PVarArray(Client.ReadMultipleValues(Arguments)); ValueResult := IInterface(Results[0]) as _ValueResult; if not ValueResult.Succeeded then begin WriteLn(' *** Failure: ', ValueResult.Exception.GetBaseException.Message); Exit; end; // Display results ArrayValue := ValueResult.Value; for I := VarArrayLowBound(ArrayValue, 1) to VarArrayHighBound(ArrayValue, 1) do begin Value := ArrayValue[I]; WriteLn('arrayValue[', I, ']: ', Value); end; VarClear(Results); VarClear(Arguments); // Example output: //arrayValue[0]: 180410224 //arrayValue[1]: 1919239969 //arrayValue[2]: 1700185172 end;
// This example shows how to read a range of values from an array. // // Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . // OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-PHP . // Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. $EndpointDescriptor = //"http://opcua.demo-this.com:51211/UA/SampleServer"; //"https://opcua.demo-this.com:51212/UA/SampleServer/"; "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; // Instantiate the client object $Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient"); // Prepare the arguments, indicating that just the elements 2 to 4 should be returned. $IndexRangeList = new COM("OpcLabs.EasyOpc.UA.UAIndexRangeList"); $IndexRange = new COM("OpcLabs.EasyOpc.UA.UAIndexRange"); $IndexRange->Minimum = 2; $IndexRange->Maximum = 4; $IndexRangeList->Add($IndexRange); $ReadArguments1 = new COM("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments"); $ReadArguments1->EndpointDescriptor->UrlString = $EndpointDescriptor; $ReadArguments1->NodeDescriptor->NodeId->ExpandedText = "nsu=http://test.org/UA/Data/ ;ns=2;i=10305"; $ReadArguments1->IndexRangeList = $IndexRangeList; $arguments[0] = $ReadArguments1; // Obtain value. $results = $Client->ReadMultipleValues($arguments); $ValueResult = $results[0]; if (!$ValueResult->Succeeded) { printf("*** Failure: %s\n", $ValueResult->ErrorMessageBrief); Exit(); } // Display results $ArrayValue = $ValueResult->Value; for ($i = 0; $i <= 2; $i++) { printf("arrayValue[d]s\n", $i, $ArrayValue[$i]); } // Example output: //arrayValue[0]: 180410224 //arrayValue[1]: 1919239969 //arrayValue[2]: 1700185172
REM This example shows how to read a range of values from an array. REM REM Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-VB . REM Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own REM a commercial license in order to use Online Forums, and we reply to every post. Private Sub Usage_ReadValue_Command_Click() OutputText = "" Dim endpointDescriptor As String 'endpointDescriptor = "http://opcua.demo-this.com:51211/UA/SampleServer" 'endpointDescriptor = "https://opcua.demo-this.com:51212/UA/SampleServer/" endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ' Instantiate the client object Dim Client As New EasyUAClient ' Prepare the arguments, indicating that just the elements 2 to 4 should be returned. Dim indexRangeList As New UAIndexRangeList Dim indexRange As New UAIndexRange indexRange.Minimum = 2 indexRange.Maximum = 4 indexRangeList.Add indexRange Dim readArguments1 As New UAReadArguments readArguments1.endpointDescriptor.UrlString = endpointDescriptor readArguments1.NodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;ns=2;i=10305" Set readArguments1.indexRangeList = indexRangeList Dim arguments(0) As Variant Set arguments(0) = readArguments1 ' Obtain value. Dim results() As Variant results = Client.ReadMultipleValues(arguments) Dim valueResult As valueResult Set valueResult = results(0) If Not valueResult.Succeeded Then OutputText = OutputText & "*** Failure: " & valueResult.Exception.GetBaseException.Message & vbCrLf Exit Sub End If ' Display results Dim arrayValue() As Long arrayValue = valueResult.value Dim i: For i = LBound(arrayValue) To UBound(arrayValue) OutputText = OutputText & "arrayValue(" & i & "):" & arrayValue(i) & vbCrLf Next ' Example output: 'arrayValue(0): 180410224 'arrayValue(1): 1919239969 'arrayValue(2): 1700185172 End Sub
Rem This example shows how to read a range of values from an array. Rem Rem Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-VBScript . Rem Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own Rem a commercial license in order to use Online Forums, and we reply to every post. Option Explicit Dim endpointDescriptor: endpointDescriptor = _ "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" '"http://opcua.demo-this.com:51211/UA/SampleServer" '"https://opcua.demo-this.com:51212/UA/SampleServer/" ' Instantiate the client object Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient") ' Prepare the arguments, indicating that just the elements 2 to 4 should be returned. Dim IndexRangeList: Set IndexRangeList = CreateObject("OpcLabs.EasyOpc.UA.UAIndexRangeList") Dim IndexRange: Set IndexRange = CreateObject("OpcLabs.EasyOpc.UA.UAIndexRange") IndexRange.Minimum = 2 IndexRange.Maximum = 4 IndexRangeList.Add IndexRange ' Dim ReadArguments1: Set ReadArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments") ReadArguments1.EndpointDescriptor.UrlString = endpointDescriptor ReadArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;ns=2;i=10305" ReadArguments1.IndexRangeList = IndexRangeList Dim arguments(0) Set arguments(0) = ReadArguments1 ' Obtain the value. Dim results: results = Client.ReadMultipleValues(arguments) Dim ValueResult: Set ValueResult = results(0) If Not ValueResult.Succeeded Then WScript.Echo "*** Failure: " & ValueResult.Exception.GetBaseException().Message WScript.Quit End If ' VBScript can only handle well arrays of VARIANTs; most other COM tool will be able to use simply the .Value property. Dim arrayValue: arrayValue = ValueResult.RegularizedValue ' Display results Dim i: For i = 0 To 2 WScript.Echo "arrayValue[" & i & "]: " & arrayValue(i) Next ' Example output: 'arrayValue[0]: 180410224 'arrayValue[1]: 1919239969 'arrayValue[2]: 1700185172
# This example shows how to read a range of values from an array. # # Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-Python . # Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc # Import .NET namespaces. from OpcLabs.EasyOpc.UA import * from OpcLabs.EasyOpc.UA.OperationModel import * endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer') # or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported) # or 'https://opcua.demo-this.com:51212/UA/SampleServer/' # Instantiate the client object. client = EasyUAClient() # Obtain the value, indicating that just the elements 2 to 4 should be returned try: arrayValue = IEasyUAClientExtension.ReadValue(client, endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;ns=2;i=10305'), # /Data.Static.Array.Int32Value UAIndexRangeList.OneDimension(2, 4)) except UAException as uaException: print('*** Failure: ' + uaException.GetBaseException().Message) exit() # Display results. for i, elementValue in enumerate(arrayValue): print('arrayValue[', i, ']: ', elementValue, sep='') print() print('Finished.')
// This example shows how to subscribe to range of values from an array. // // Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-CSharp . // Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.OperationModel; namespace UACommonDocExamples._UAIndexRangeList { partial class Usage { public static void Subscribe() { UAEndpointDescriptor endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) // or "https://opcua.demo-this.com:51212/UA/SampleServer/" // Instantiate the client object var client = new EasyUAClient(); Console.WriteLine("Subscribing to range..."); var attributeArguments = new UAAttributeArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10933") { IndexRangeList = UAIndexRangeList.OneDimension(2, 4) }; var monitoredItemArguments = new UAMonitoredItemArguments(attributeArguments, monitoringParameters:1000); // The callback is a lambda expression the displays the value client.SubscribeMonitoredItem(monitoredItemArguments, (sender, eventArgs) => { if (eventArgs.Succeeded) { var arrayValue = eventArgs.AttributeData.Value as Int32[]; if (!(arrayValue is null)) Console.WriteLine($"Value: {{{String.Join(",", arrayValue)}}}"); } else Console.WriteLine($"*** Failure: {eventArgs.ErrorMessageBrief}"); }); Console.WriteLine("Processing data change events for 10 seconds..."); System.Threading.Thread.Sleep(10 * 1000); Console.WriteLine("Unsubscribing..."); client.UnsubscribeAllMonitoredItems(); Console.WriteLine("Waiting for 2 seconds..."); System.Threading.Thread.Sleep(2 * 1000); } } }
# This example shows how to subscribe to range of values from an array. # # Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . # OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell . # Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. #requires -Version 5.1 using namespace OpcLabs.EasyOpc.UA using namespace OpcLabs.EasyOpc.UA.OperationModel using namespace OpcLabs.PowerShellManagement # The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows . Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUAPrimitives.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUACore.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUA.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUAComponents.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.PowerShellManagement.dll" [UAEndpointDescriptor]$endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" # or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) # or "https://opcua.demo-this.com:51212/UA/SampleServer/" # Instantiate the client object. $client = New-Object EasyUAClient Write-Host "Subscribing to range..." $attributeArguments = New-Object UAAttributeArguments($endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10933") -Property @{ IndexRangeList = [UAIndexRangeList]::OneDimension(2, 4) } $monitoredItemArguments = New-Object UAMonitoredItemArguments($attributeArguments, 1000) # The callback is a lambda expression the displays the value [void][IEasyUAClientExtension]::SubscribeMonitoredItem($client, $monitoredItemArguments, [RunspacedDelegateFactory]::NewRunspacedDelegate([EasyUADataChangeNotificationEventHandler] { param($sender, $eventArgs) if ($eventArgs.Succeeded) { $arrayValue = $eventArgs.AttributeData.Value -as [int[]] if ($arrayValue -ne $null) { Write-Host "Value: {$($arrayValue -join ",")}" } } else { Write-Host "*** Failure: $($EventArgs.ErrorMessageBrief)" } })) Write-Host "Processing data change events for 10 seconds..." $stopwatch = [System.Diagnostics.Stopwatch]::StartNew() while ($stopwatch.Elapsed.TotalSeconds -lt 10) { Start-Sleep -Seconds 1 } Write-Host "Unsubscribing..." $client.UnsubscribeAllMonitoredItems() Write-Host "Waiting for 2 seconds..." $stopwatch = [System.Diagnostics.Stopwatch]::StartNew() while ($stopwatch.Elapsed.TotalSeconds -lt 2) { Start-Sleep -Seconds 1 }
' This example shows how to subscribe to range of values from an array. ' ' Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports OpcLabs.EasyOpc.UA Imports OpcLabs.EasyOpc.UA.OperationModel Namespace Global.UACommonDocExamples._UAIndexRangeList Partial Friend Class Usage Public Shared Sub Subscribe() ' Define which server we will work with. Dim endpointDescriptor As UAEndpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) ' or "https://opcua.demo-this.com:51212/UA/SampleServer/" ' Instantiate the client object Dim client = New EasyUAClient() Console.WriteLine("Subscribing to range...") Dim attributeArguments = New UAAttributeArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10933") With { .IndexRangeList = UAIndexRangeList.OneDimension(2, 4) } Dim monitoredItemArguments = New UAMonitoredItemArguments(attributeArguments, monitoringParameters:=1000) ' The callback is a lambda expression the displays the value client.SubscribeMonitoredItem(monitoredItemArguments, Sub(sender, eventArgs) If eventArgs.Succeeded Then Dim arrayValue = CType(eventArgs.AttributeData.Value, Int32()) If (arrayValue IsNot Nothing) Then Console.WriteLine($"Value: {{{String.Join(",", arrayValue)}}}") End If Else Console.WriteLine("*** Failure: {0}", eventArgs.ErrorMessageBrief) End If End Sub) Console.WriteLine("Processing data change events for 10 seconds...") Threading.Thread.Sleep(10 * 1000) Console.WriteLine("Unsubscribing...") client.UnsubscribeAllMonitoredItems() Console.WriteLine("Waiting for 2 seconds...") Threading.Thread.Sleep(2 * 1000) End Sub End Class End Namespace
# This example shows how to subscribe to range of values from an array. # # Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-Python . # Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc import time # Import .NET namespaces. from OpcLabs.EasyOpc.UA import * from OpcLabs.EasyOpc.UA.OperationModel import * def dataChangeNotification(sender, eventArgs): # Display value. if eventArgs.Succeeded: arrayValue = eventArgs.AttributeData.Value print('Value: {', ", ".join(["{}"]*len(arrayValue)).format(*arrayValue), '}', sep='') else: print('*** Failure: ', eventArgs.ErrorMessageBrief, sep='') endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer') # or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported) # or 'https://opcua.demo-this.com:51212/UA/SampleServer/' # Instantiate the client object. client = EasyUAClient() print('Subscribing to range...') attributeArguments = UAAttributeArguments(endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10933')) attributeArguments.IndexRangeList = UAIndexRangeList.OneDimension(2, 4) monitoredItemArguments = UAMonitoredItemArguments(attributeArguments, UAMonitoringParameters(1000)) IEasyUAClientExtension.SubscribeMonitoredItem(client, monitoredItemArguments, EasyUADataChangeNotificationEventHandler(dataChangeNotification)) print('Processing data change events for 10 seconds...') time.sleep(10) print('Unsubscribing...') client.UnsubscribeAllMonitoredItems() print('Waiting for 2 seconds...') time.sleep(2) print('Finished.')
// Shows how to create an observable for a range of OPC UA array elements, and subscribe to it. // // Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-CSharp . // Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using OpcLabs.EasyOpc.UA.Reactive; using System; using System.Threading; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.OperationModel; namespace ReactiveDocExamples { namespace _UADataChangeNotificationObservable { partial class Subscribe { public static void IndexRangeList() { // Define which server we will work with. UAEndpointDescriptor endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) // or "https://opcua.demo-this.com:51212/UA/SampleServer/" Console.WriteLine("Creating observable..."); var attributeArguments = new UAAttributeArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10933") { IndexRangeList = UAIndexRangeList.OneDimension(2, 4) }; var monitoredItemArguments = new UAMonitoredItemArguments(attributeArguments, monitoringParameters: 1000); UADataChangeNotificationObservable<Int32[]> observable = UADataChangeNotificationObservable.Create<Int32[]>(monitoredItemArguments); Console.WriteLine("Subscribing..."); using (observable.Subscribe(e => Console.WriteLine( (e.Exception is null) ? e.AttributeData.ToString() : e.Exception.GetBaseException().ToString()))) { Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10*1000); Console.WriteLine("Unsubscribing..."); } Console.WriteLine("Waiting for 2 seconds..."); Thread.Sleep(2 * 1000); } } } }
System.Object
System.Collections.Generic.List<T>
OpcLabs.EasyOpc.UA.UAIndexRangeList