gOPCClassicConnector.gMonitorOneItem Method

Top  Previous  Next

Description

Monitoring methods defines subscriptions, when value of monitored item changes gMonitoredItemsValueChanged event occurs to give new value.

 

VB syntax

gOPCClassicConnector.gMonitorOneItem(groupName As StringByRef monitorObject As gOPCClassicMonitorObject, ByRef updateRate As Integer)

 

C# syntax

gOPCClassicConnector.gMonitorOneItem(string groupName, ref gOPCClassicMonitorObject monitorObject, ref int updateRate)

 

Parameters

groupName

A unique name of group.

 

monitorObject

A monitor object which specifies itemID of OPC Item that you want to monitor

 

updateRate

Miliseconds. Refreshing period of new value comes from OPC Item.

Minimum: 100 ms.

 

 

Return Type

gOPCClassicFunctionResult

 

C# code example

  try

            {

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

                GelecekCommon.gOPCClassicMonitorObject monitor_object = new GelecekCommon.gOPCClassicMonitorObject;

                monitor_object.ItemID = txtItemID1.Text;

 

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

 

                //Step 2: Apply gMonitorItems method

                GelecekCommon.gOPCClassicFunctionResult function_result = gOPCClassicConnector1.gMonitorOneItem(txtGroupName.Text, ref monitor_object, 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_object.ResultID.ToString();

                }

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }