OPC Ua Client: Create Data Monitored Items

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
asdin
Jr. Member
Jr. Member
Posts: 3
Joined: 14 Nov 2019, 10:05

OPC Ua Client: Create Data Monitored Items

Post by asdin »

Hello i'm new here and new also in OPC ua programming.


i tried to create a monitored items operation. but it's always throw an exception error.
i tested to connect and read variables on Siemens plc.

can anyone help me?

Code: Select all

  public void StartMonitoring(short PlcIndex)
        {
            try
            {
                // Create and initialize subscription
                m_subscription = new Subscription(m_opc.GetSession());
                m_subscription.PublishingEnabled = true;
                m_subscription.PublishingInterval = 100;

                // Data change events will be received through Subscription_DataChanged
                m_subscription.DataChanged += new DataChangedEventHandler(Subscription_DataChanged);

                // Create subscription on server
                m_subscription.Create();
                foreach (XmlLineNodeClass temp in m_PlcNode.LineNode)
                {
                    string sNode = "\"Aufträge_FSD\".\"Auftrag\"[0].\"SAP_Daten\".\"Strebe\"";
                    NodeId NodeIdNew = new NodeId(sNode, m_opc.GetNamespaceIndex());
                    DataMonitoredItem monitoredItem = new DataMonitoredItem(NodeIdNew);
                    m_monitoredItems.Add(monitoredItem);
                }
                // Step 3 --------------------------------------------------
                // Create monitored items on server
                List<StatusCode> results = m_subscription.CreateMonitoredItems(m_monitoredItems);
            }
            catch(Exception e)
            {
                m_ error = e.Message, 
            }
            // Display any errors.      
        }

User avatar
Support Team
Hero Member
Hero Member
Posts: 2496
Joined: 18 Mar 2011, 15:09

Re: OPC Ua Client: Create Data Monitored Items

Post by Support Team »

Hello,

What kind of exception is caught? Please describe the content of the exception.
Best regards
Unified Automation Support Team

Post Reply