System.IO.BACnet.BacnetMstpProtocolTransport.WaitForReply C# (CSharp) Méthode

WaitForReply() private méthode

private WaitForReply ( ) : StateChanges
Résultat StateChanges
        private StateChanges WaitForReply()
        {
            BacnetMstpFrameTypes frame_type;
            byte destination_address;
            byte source_address;
            int msg_length;

            //fetch message
            GetMessageStatus status = GetNextMessage(T_REPLY_TIMEOUT, out frame_type, out destination_address, out source_address, out msg_length);

            if (status == GetMessageStatus.Good)
            {
                try
                {
                    if (destination_address == (byte)m_TS && (frame_type == BacnetMstpFrameTypes.FRAME_TYPE_TEST_RESPONSE || frame_type == BacnetMstpFrameTypes.FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY))
                    {
                        //signal upper layer
                        if (MessageRecieved != null && frame_type != BacnetMstpFrameTypes.FRAME_TYPE_TEST_RESPONSE)
                        {
                            BacnetAddress remote_address = new BacnetAddress(BacnetAddressTypes.MSTP, 0, new byte[] { source_address });
                            try
                            {
                                MessageRecieved(this, m_local_buffer, MSTP.MSTP_HEADER_LENGTH, msg_length, remote_address);
                            }
                            catch (Exception ex)
                            {
                                Trace.TraceError("Exception in MessageRecieved event: " + ex.Message);
                            }
                        }

                        /* ReceivedReply */
                        return StateChanges.ReceivedReply;
                    }
                    else if (frame_type == BacnetMstpFrameTypes.FRAME_TYPE_REPLY_POSTPONED)
                    {
                        /* ReceivedPostpone */
                        return StateChanges.ReceivedPostpone;
                    }
                    else
                    {
                        /* ReceivedUnexpectedFrame */
                        return StateChanges.ReceivedUnexpectedFrame;
                    }
                }
                finally
                {
                    RemoveCurrentMessage(msg_length);
                }
            }
            else if (status == GetMessageStatus.Timeout)
            {
                /* ReplyTimeout */
                m_frame_count = m_max_info_frames;
                return StateChanges.ReplyTimeOut;
            }
            else
            {
                /* InvalidFrame */
                return StateChanges.InvalidFrame;
            }
        }