gOPCUAConnector.gMonitorItems Method

Top  Previous  Next


Monitoring methods create subscriptions.

When values of monitored items changes, gMonitoredItemValueChanged event occurs, to give new values.


VB syntax

gOPCUAConnector.gMonitorItems(subscriptionID As StringByRef monitorObjects() As gOPCUAMonitorObject, ByRef publishingInterval As Integer)


C# syntax

gOPCUAConnector.gMonitorItems(string subscriptionID, ref gOPCUAMonitorObject[] monitorObjects, ref int publishingInterval)




A unique name for subscription.



Object array that specify which itemIDs are communicated to.



Miliseconds. Refreshing period of new values come from OPC Nodes.

This value might be modified by server, check it after calling method.


Return Type



C# code example



                //Step1: Create an array of monitor objects and assign NodeIDs

                GelecekCommon.gOPCUAMonitorObject[] monitor_objects = new GelecekCommon.gOPCUAMonitorObject[2];

                monitor_objects[0] = new GelecekCommon.gOPCUAMonitorObject();

                monitor_objects[0].NodeID = txtNodeID1.Text;


                monitor_objects[1] = new GelecekCommon.gOPCUAMonitorObject();

                monitor_objects[1].NodeID = txtNodeID2.Text;


                int publishing_interval = Convert.ToInt32(numPublishingInterval.Value);


                //Step 2: Apply gMonitorItems method

                GelecekCommon.gOPCUAStatusCode function_result = gOPCUAConnector1.gMonitorItems(txtSubscriptionID.Text, ref monitor_objects, ref publishing_interval);


                txtFunctionResult.Text = function_result.ToString();


                //Step 3: Check Results

                //For a successfull operation, function result should be "Good" and StatusCode sould be "Good"

                if (function_result == GelecekCommon.gOPCUAStatusCode.Good)


                    txtStatusCode1.Text = monitor_objects[0].StatusCode.ToString();

                    txtStatusCode2.Text = monitor_objects[1].StatusCode.ToString();



                //publishing_interval may be changed by server, you can check it here..


                //Values of Monitored Items will come with "gMonitoredItemsValueChanged" event of Connector



            catch (Exception ex)