gOPCUAConnector.gAsyncReadOneItemCompleted Event

Top  Previous  Next

Description

Occurs when gAsyncReadOneItem method is completed.

 

VB syntax

Private Sub gOPCUAConnector_gAsyncReadOneItemCompleted(sender As Object, transactionID As String, operationResult As gOPCUAStatusCode, resultObject As gOPCUAReadWriteObjectHandles gOPCUAConnector.gAsyncReadItemsCompleted

 

C# syntax

private void gOPCUAConnector_gAsyncReadOneItemCompleted(object sender, string transactionID, gOPCUAStatusCode operationResult, gOPCUAReadWriteObject resultObject)

 

Arguments

sender

OPC UA Connector that raising this event.

 

transactionID

ID of asynchronous operation that caused this event.

 

operationResult

Gives information about result of gAsyncReadOneItem method.

 

resultObject

Object that holds information of OPC Node that you wanted to read.

 

C# code example

 

    //This event is response to gAsyncReadOneItem method.

        private void gOPCUAConnector1_gAsyncReadOneItemCompleted(object sender, string transactionID, GelecekCommon.gOPCUAStatusCode operationResult, GelecekCommon.gOPCUAReadWriteObject resultObject)

        {

            try

            {

                //Check transaction ID and get value..

                if (transactionID == txtTransactionID.Text)

                {

                    txtStatusCode1.Text = resultObject.StatusCode.ToString();

                    txtOperationResult.Text = operationResult.ToString();

 

                    //Check status code and operation result

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

                    if (resultObject.StatusCode == GelecekCommon.gOPCUAStatusCode.Good && operationResult == GelecekCommon.gOPCUAStatusCode.Good)

                    {

                        txtValue1.Text = resultObject.Value.ToString();  //Be careful, Value should be able to convert to string..

                    }

                }

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }

        }