gOPCUAConnector.gAsyncReadItems Method

Top  Previous  Next

Description

Used to read values of OPC Nodes asynchronously.

This method does not freeze your application like a synchronous method.

And because this is an asynchronous method, results comes with an event: gAsyncReadItemsCompleted

 

VB syntax

gOPCUAConnector.gAsyncReadItems(itemsToRead() As gOPCUAReadWriteObject, transactionID As String)

 

C# syntax

gOPCUAConnector.gAsyncReadItems(gOPCUAReadWriteObject[] itemsToRead, string transactionID)

 

Parameters

itemsToRead

Array of ReadWriteObjects that holds OPC NodeIDs that you want to read values of them.

 

transactionID

Transaction id is ID of asynchronous operation, a unique string.

Used in gAsyncReadItemsCompleted  event or to cancel asynchronous operation.

 

 

Return Type

gOPCUAStatusCode

 

 

C# code example

  try

            {

                //Step1: Create an array of read write objects and assign ItemIDs

                GelecekCommon.gOPCUAReadWriteObject[] read_write_objects = new GelecekCommon.gOPCUAReadWriteObject[2];

                read_write_objects[0] = new GelecekCommon.gOPCUAReadWriteObject();

                read_write_objects[0].NodeID = txtNodeID1.Text; 

 

                read_write_objects[1] = new GelecekCommon.gOPCUAReadWriteObject();

                read_write_objects[1].NodeID = txtNodeID2.Text;

 

                //Step2: Run gAsyncReadItems method  

                GelecekCommon.gOPCUAStatusCode function_result = gOPCUAConnector1.gAsyncReadItems(read_write_objects, txtTransactionID.Text);

 

                //Step3: Check function result. For a successfull read, function result should be "Good"

                txtFunctionResult.Text = function_result.ToString();

 

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }