gOPCClassicConnector.gMonitorItems Method

Top  Previous  Next

Description

Monitoring methods create subscriptions.

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

 

VB syntax

gOPCClassicConnector.gMonitorItems(groupName As StringByRef monitorObjects() As gOPCClassicMonitorObject, ByRef updateRate As Integer)

 

C# syntax

gOPCClassicConnector.gMonitorItems(string groupName, ref gOPCClassicMonitorObject[] monitorObjects, ref int updateRate)

 

Parameters

groupName

A unique name for group.

 

monitorObjects

An array of monitor objects which specifies itemIDs of OPC Items that you want to monitor.

 

updateRate

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

Minimum: 100 ms.

 

 

 

Return Type

gOPCClassicFunctionResult

 

C# code example

  try

            {

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

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

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

                monitor_objects[0].ItemID = txtItemID1.Text;

 

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

                monitor_objects[1].ItemID = txtItemID2.Text;

 

                int updateRate = Convert.ToInt32(numUpdateRate.Value);

 

                //Step 2: Apply gMonitorItems method

                GelecekCommon.gOPCClassicFunctionResult function_result = gOPCClassicConnector1.gMonitorItems(txtGroupName.Text, ref monitor_objects, ref updateRate);

 

                txtFunctionResult.Text = function_result.ToString();

 

                //Step 3: Check Results

                //For a successful operation, function result should be "OK" and ResultID sould be "S_OK"

                if (function_result == GelecekCommon.gOPCClassicFunctionResult.OK)

                {

                    txtResultID1.Text = monitor_objects[0].ResultID.ToString();

                    txtResultID2.Text = monitor_objects[1].ResultID.ToString();

                }

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }