OPC Studio User's Guide and Reference
GetMonitoredItemArgumentsDictionary Method (IEasyUAClient)
Example 



View with Navigation Tools
OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA Namespace > IEasyUAClient Interface : GetMonitoredItemArgumentsDictionary Method
Obtains information about all monitored item subscriptions on this IEasyUAClient object.
Syntax
'Declaration
 
<NotNullAttribute()>
Function GetMonitoredItemArgumentsDictionary() As EasyUAMonitoredItemArgumentsDictionary
 
'Usage
 
Dim instance As IEasyUAClient
Dim value As EasyUAMonitoredItemArgumentsDictionary
 
value = instance.GetMonitoredItemArgumentsDictionary()

Return Value

Returns a dictionary of monitored item argument objects. The dictionary is keyed by the monitored item subscription handles, and its values contain information describing each subscription.

This method never returns null (Nothing in Visual Basic).

The individual elements of the returned value are never null (Nothing in Visual Basic).

Remarks

This method or property does not throw any exceptions, aside from execution exceptions such as System.Threading.ThreadAbortException or System.OutOfMemoryException.

Example
// This example shows how to obtain dictionary of parameters of all monitored item subscriptions.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.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 UADocExamples._EasyUAClient
{
    class GetMonitoredItemArgumentsDictionary
    {
        public static void Main1()
        {
            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 and hook events.
            var client = new EasyUAClient();
            client.DataChangeNotification += client_DataChangeNotification;

            Console.WriteLine("Subscribing...");
            client.SubscribeMultipleMonitoredItems(new[]
                {
                    new EasyUAMonitoredItemArguments(null, endpointDescriptor, 
                        "nsu=http://test.org/UA/Data/ ;i=10845", 1000),
                    new EasyUAMonitoredItemArguments(null, endpointDescriptor, 
                        "nsu=http://test.org/UA/Data/ ;i=10853", 1000),
                    new EasyUAMonitoredItemArguments(null, endpointDescriptor, 
                        "nsu=http://test.org/UA/Data/ ;i=10855", 1000)
                });

            Console.WriteLine("Getting monitored item arguments dictionary...");
            EasyUAMonitoredItemArgumentsDictionary monitoredItemArgumentsDictionary =
                client.GetMonitoredItemArgumentsDictionary();

            foreach (EasyUAMonitoredItemArguments monitoredItemArguments in monitoredItemArgumentsDictionary.Values)
            {
                Console.WriteLine();
                Console.WriteLine($"NodeDescriptor: {monitoredItemArguments.NodeDescriptor}");
                Console.WriteLine($"SamplingInterval: {monitoredItemArguments.MonitoringParameters.SamplingInterval}");
                Console.WriteLine($"PublishingInterval: {monitoredItemArguments.SubscriptionParameters.PublishingInterval}");
            }

            Console.WriteLine();
            Console.WriteLine("Waiting for 5 seconds...");
            System.Threading.Thread.Sleep(5 * 1000);

            Console.WriteLine("Unsubscribing...");
            client.UnsubscribeAllMonitoredItems();

            Console.WriteLine("Waiting for 5 seconds...");
            System.Threading.Thread.Sleep(5 * 1000);

            Console.WriteLine("Finished.");
        }

        static void client_DataChangeNotification(object sender, EasyUADataChangeNotificationEventArgs e)
        {
            // Your code would do the processing here.
        }


        // Example output:
        //
        //Subscribing...
        //Getting monitored item arguments dictionary...
        //
        //NodeDescriptor: NodeId="nsu=http://test.org/UA/Data/ ;i=10845"
        //SamplingInterval: 1000
        //PublishingInterval: 0
        //
        //NodeDescriptor: NodeId="nsu=http://test.org/UA/Data/ ;i=10853"
        //SamplingInterval: 1000
        //PublishingInterval: 0
        //
        //NodeDescriptor: NodeId="nsu=http://test.org/UA/Data/ ;i=10855"
        //SamplingInterval: 1000
        //PublishingInterval: 0
        //
        //Waiting for 5 seconds...
        //Unsubscribing...
        //Waiting for 5 seconds...
        //Finished.
    }
}
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