예제 #1
0
        public new static MSG_ENABLE_ROSPEC FromString(string str)
        {
            string val;

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

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


            val = XmlUtil.GetNodeValue(node, "ROSpecID");

            msg.ROSpecID = Convert.ToUInt32(val);

            return msg;
        }
예제 #2
0
        public MSG_ENABLE_ROSPEC_RESPONSE ENABLE_ROSPEC(MSG_ENABLE_ROSPEC msg, out MSG_ERROR_MESSAGE msg_err, int time_out)
        {
            msg_err = null;
            //Add your code here
            _event_ENABLE_ROSPEC_RESPONSE = new ClientManualResetEvent(false);
            _event_ENABLE_ROSPEC_RESPONSE.msg_id = msg.MSG_ID;
            _event_ERROR_MESSAGE = new ClientManualResetEvent(false);

            WaitHandle[] waitHandles = new WaitHandle[] { _event_ENABLE_ROSPEC_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_ENABLE_ROSPEC_RESPONSE.data);
                        length = bArr.Count;
                        MSG_ENABLE_ROSPEC_RESPONSE msg_rsp = MSG_ENABLE_ROSPEC_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;
            }
        }
예제 #3
0
        public new static MSG_ENABLE_ROSPEC 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_ENABLE_ROSPEC obj = new MSG_ENABLE_ROSPEC();

            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);


            if (cursor > length) throw new Exception("Input data is not complete message");

            field_len = 32;

            Util.ConvertBitArrayToObj(ref bit_array, ref cursor, out obj_val, typeof(UInt32), field_len);
            obj.ROSpecID = (UInt32)obj_val;

            return obj;
        }
예제 #4
0
        /// <summary>
        /// This message is issued by the Client to the Reader. Upon receiving the message, 
        /// the Reader moves the ROSpec corresponding to the ROSpecID passed in this message 
        /// from the disabled to the inactive state.
        /// </summary>
        public void Enable_RoSpec()
        {
            MSG_ENABLE_ROSPEC msg = new MSG_ENABLE_ROSPEC();
            msg.ROSpecID = 123;

            MSG_ENABLE_ROSPEC_RESPONSE rsp = client.ENABLE_ROSPEC(msg, out msg_err, 3000);

            if (rsp != null)
            {
                //textBox2.Text = rsp.ToString();
                WriteMessage(rsp.ToString(), "Enable_RoSpec");
            }
            else if (msg_err != null)
            {
                WriteMessage("Enable_RoSpec " + msg_err.ToString());
            }
            else
                WriteMessage("Enable_RoSpec Command time out!");

        }