gOPCUAConnector.gAsyncReadItemsCompleted Event

Top  Previous  Next

Description

Occurs when gAsyncReadItems method is completed.

 

VB syntax

Private Sub gOPCUAConnector_gAsyncReadItemsCompleted(sender As Object, transactionID As String, operationResult As gOPCUAStatusCode, resultObjects() As gOPCUAReadWriteObjectHandles gOPCUAConnector.gAsyncReadItemsCompleted

 

C# syntax

private void gOPCUAConnector_gAsyncReadItemsCompleted(object sender, string transactionID, gOPCUAStatusCode operationResult, gOPCUAReadWriteObject[] resultObjects)

 

Arguments

sender

OPC UA Connector that raising this event.

 

transactionID

ID of asynchronous operation that caused this event.

 

operationResult

Gives information about result of gAsyncReadItems method.

 

resultObjects

Objects that hold information of OPC Nodes that you wanted to read.

 

C# code example

 

     private void gOPCUAConnector1_gAsyncReadItemsCompleted(object sender, string transactionID, GelecekCommon.gOPCUAStatusCode operationResult, GelecekCommon.gOPCUAReadWriteObject[] resultObjects)

        {

            //Check transaction ID and get value..

            try

            {

                if (transactionID == txtTransactionID.Text)

                {

                    txtOperationResult.Text = operationResult.ToString();

 

                    //Loop all results, get values if operation result is "Good" and status code is "Good"

                    for (int i = 0; i < resultObjects.Length; i++)

                    {

 

                        if (i == 0)

                        {

                            txtStatusCode1.Text = resultObjects[i].StatusCode.ToString();

 

                            //For a successfull read, status code sould be "Good" and operation result should be "Good"

                            if (resultObjects[i].StatusCode == GelecekCommon.gOPCUAStatusCode.Good && operationResult == GelecekCommon.gOPCUAStatusCode.Good)

                            {

                                txtValue1.Text = resultObjects[i].Value.ToString(); //Be careful, Value should be able to convert to string..

                            }

                        }

                        else if (i == 1)

                        {

                            txtStatusCode2.Text = resultObjects[i].StatusCode.ToString();

 

 

                            //For a successfull read, status code sould be "Good" and operation result should be "Good"

                            if (resultObjects[i].StatusCode == GelecekCommon.gOPCUAStatusCode.Good && operationResult == GelecekCommon.gOPCUAStatusCode.Good)

                            {

                                txtValue2.Text = resultObjects[i].Value.ToString(); //Be careful, Value should be able to convert to string..

                            }

                        }

                    } //for

                }

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }

        }