Beispiel #1
0
        public new static MSG_CLOSE_CONNECTION FromString(string str)
        {
            string val;

            XmlDocument xdoc = new XmlDocument();
            xdoc.LoadXml(str);
            XmlNode node = (XmlNode)xdoc.DocumentElement;

            MSG_CLOSE_CONNECTION msg = new MSG_CLOSE_CONNECTION();
            try { msg.MSG_ID = Convert.ToUInt32(XmlUtil.GetNodeAttrValue(node, "MessageID")); }
            catch { }


            return msg;
        }
Beispiel #2
0
        public bool Close()
        {
            try
            {
                MSG_CLOSE_CONNECTION msg = new MSG_CLOSE_CONNECTION();
                MSG_ERROR_MESSAGE msg_err;
                MSG_CLOSE_CONNECTION_RESPONSE rsp = this.CLOSE_CONNECTION(msg, out msg_err, MSG_TIME_OUT);

                if (rsp == null || rsp.LLRPStatus.StatusCode != ENUM_StatusCode.M_Success) return false;

                cI.Close();
                cI.OnMessageReceived -= new delegateMessageReceived(ProcesssMessage);

                return true;
            }
            catch
            {
                return false;
            }
        }
Beispiel #3
0
        public new static MSG_CLOSE_CONNECTION FromBitArray(ref BitArray bit_array, ref int cursor, int length)
        {
            if (cursor > length) return null;

            int field_len = 0;
            object obj_val;
            ArrayList param_list = new ArrayList();

            MSG_CLOSE_CONNECTION obj = new MSG_CLOSE_CONNECTION();

            int msg_type = 0;
            cursor += 6;
            msg_type = (int)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 10);

            if (msg_type != obj.msgType)
            {
                cursor -= 16;
                return null;
            }

            obj.msgLen = (UInt32)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 32);
            obj.msgID = (UInt32)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 32);


            return obj;
        }
Beispiel #4
0
        public MSG_CLOSE_CONNECTION_RESPONSE CLOSE_CONNECTION(MSG_CLOSE_CONNECTION msg, out MSG_ERROR_MESSAGE msg_err, int time_out)
        {
            msg_err = null;
            //Add your code here
            _event_CLOSE_CONNECTION_RESPONSE = new ClientManualResetEvent(false);
            _event_CLOSE_CONNECTION_RESPONSE.msg_id = msg.MSG_ID;
            _event_ERROR_MESSAGE = new ClientManualResetEvent(false);

            WaitHandle[] waitHandles = new WaitHandle[] { _event_CLOSE_CONNECTION_RESPONSE.evt, _event_ERROR_MESSAGE.evt };

            bool[] bit_array = msg.ToBitArray();
            byte[] data = Util.ConvertBitArrayToByteArray(bit_array);

            cI.Send(data);

            int wait_result = WaitHandle.WaitAny(waitHandles, time_out, false);

            int cursor = 0;
            int length;
            BitArray bArr;

            try
            {
                switch (wait_result)
                {
                    case 0:
                        bArr = Util.ConvertByteArrayToBitArray(_event_CLOSE_CONNECTION_RESPONSE.data);
                        length = bArr.Count;
                        MSG_CLOSE_CONNECTION_RESPONSE msg_rsp = MSG_CLOSE_CONNECTION_RESPONSE.FromBitArray(ref bArr, ref cursor, length);
                        if (msg_rsp.MSG_ID != msg.MSG_ID) return null;
                        else
                            return msg_rsp;
                    case 1:
                        bArr = Util.ConvertByteArrayToBitArray(_event_ERROR_MESSAGE.data);
                        length = bArr.Count;
                        msg_err = MSG_ERROR_MESSAGE.FromBitArray(ref bArr, ref cursor, length);
                        return null;
                    default:
                        return null;
                }
            }
            catch
            {
                return null;
            }
        }