Beispiel #1
0
        void reader_OnMessageNotificationReceived(Invengo.NetAPI.Core.BaseReader reader, Invengo.NetAPI.Core.IMessageNotification msg)
        {
            // String nowString = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
//            MessageBox.Show(nowString); //brett
            // String utcString = nowString;

            if (msg.StatusCode != 0)
            {
                showMsg(msg.ErrInfo);
                return;
            }
            String msgType = msg.GetMessageType();

            msgType = msgType.Substring(msgType.LastIndexOf('.') + 1);
            switch (msgType)
            {
                #region RXD_TagData
            case "RXD_TagData":
            {
                IRP1.RXD_TagData m    = (IRP1.RXD_TagData)msg;
                string           rssi = m.ReceivedMessage.RSSI[0].ToString(); //RSSI
                SendMQTT(m);                                                  // Sends to MQTT
                display(m);                                                   // Local Display
            }
            break;

                #endregion
                #region RXD_IOTriggerSignal_800
            case "RXD_IOTriggerSignal_800":
            {
                IRP1.RXD_IOTriggerSignal_800 m = (IRP1.RXD_IOTriggerSignal_800)msg;
                if (m.ReceivedMessage.IsStart)
                {
                    changeCtrlEnable("scan");
                    // lbl_msg.Text = " Reading";
                    // btn_Stop.Enabled = true;
                    // btn_ReadEPC.Enabled = false;
                }
                else
                {
                    changeCtrlEnable("conn");
                    //lbl_msg.Text = " stop";
                    //btn_Stop.Enabled = false;
                    //btn_ReadEPC.Enabled = true;
                }
            }
            break;
                #endregion
            }
        }
Beispiel #2
0
        /// <summary>
        /// 接收到读写器消息触发事件
        /// </summary>
        /// <param name="reader">读写器类</param>
        /// <param name="msg">消息内容</param>
        void reader_OnMessageNotificationReceived(Invengo.NetAPI.Core.BaseReader reader, Invengo.NetAPI.Core.IMessageNotification msg)
        {
            if (msg.StatusCode != 0)
            {
                //显示错误信息
                showMsg(msg.ErrInfo);
                return;
            }
            String msgType = msg.GetMessageType();

            msgType = msgType.Substring(msgType.LastIndexOf('.') + 1);
            switch (msgType)
            {
                #region RXD_TagData
            case "RXD_TagData":
            {
                IRP1.RXD_TagData m       = (IRP1.RXD_TagData)msg;
                string           tagType = m.ReceivedMessage.TagType;
                display(m);
            }
            break;

                #endregion
                #region RXD_IOTriggerSignal_800
            case "RXD_IOTriggerSignal_800":
            {
                IRP1.RXD_IOTriggerSignal_800 m = (IRP1.RXD_IOTriggerSignal_800)msg;
                if (m.ReceivedMessage.IsStart)
                {
                    changeCtrlEnable("scan");
                    showMsg(" I/O 触发,正在读卡...");
                }
                else
                {
                    changeCtrlEnable("conn");
                    showMsg(" I/O 触发,停止读卡");
                }
            }
            break;
                #endregion
            }
        }
Beispiel #3
0
        static void reader_OnMessageNotificationReceived(Invengo.NetAPI.Core.BaseReader reader, Invengo.NetAPI.Core.IMessageNotification msg)
        {
            if (msg.StatusCode != 0)
            {
                //显示错误信息
                throw (new Exception(msg.ErrInfo));
            }
            String msgType = msg.GetMessageType();

            msgType = msgType.Substring(msgType.LastIndexOf('.') + 1);
            switch (msgType)
            {
                #region RXD_TagData
            case "RXD_TagData":
            {
                IRP1.RXD_TagData m = (IRP1.RXD_TagData)msg;
                if (OnRFIDDisplay != null)
                {
                    OnRFIDDisplay(m);
                }
            }
            break;

                #endregion
                #region RXD_IOTriggerSignal_800
            case "RXD_IOTriggerSignal_800":
            {
                IRP1.RXD_IOTriggerSignal_800 m = (IRP1.RXD_IOTriggerSignal_800)msg;
                if (m.ReceivedMessage.IsStart)
                {
                }
                else
                {
                }
            }
            break;
                #endregion
            }
        }
Beispiel #4
0
        void r_OnMessageNotificationReceived(BaseReader reader, IMessageNotification msg)
        {
            String nowString         = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
            String utcString         = nowString;
            String reserve           = string.Empty;
            NotificationMessage nmsg = null;

            switch (reader.ProtocolVersion)
            {
            case "IRP1":
            {
                if (msg.StatusCode != 0)
                {
                    if (OnReaderErrorMsg != null)
                    {
                        OnReaderErrorMsg((IRP1.Reader)reader, msg.ErrInfo);
                    }
                    Log.Debug(reader.ReaderName + ":" + msg.ErrInfo);
                    return;
                }
                String msgType = msg.GetMessageType();
                msgType = msgType.Substring(msgType.LastIndexOf('.') + 1);
                switch (msgType)
                {
                    #region RXD_TagData
                case "RXD_TagData":
                {
                    IRP1.RXD_TagData m     = (IRP1.RXD_TagData)msg;
                    Byte[]           bRssi = m.ReceivedMessage.RSSI;
                    string           rssi  = "";
                    if (bRssi != null)
                    {
                        if (reader.ModelNumber.IndexOf("502E") != -1 || reader.ModelNumber.IndexOf("811") != -1)
                        {
                            rssi = bRssi[0].ToString("X2") + bRssi[1].ToString("X2");
                        }
                        else
                        {
                            rssi = bRssi[0].ToString("X2");
                        }
                    }
                    string rxdTime = Common.ReadTimeToString(m.ReceivedMessage.RXDTime);
                    if (rxdTime != "")
                    {
                        nowString = rxdTime;
                    }
                    nmsg = new NotificationMessage(
                        m.ReceivedMessage.ReaderName,
                        m.ReceivedMessage.TagType,
                        Util.ConvertByteArrayToHexWordString(m.ReceivedMessage.EPC),
                        Util.ConvertByteArrayToHexWordString(m.ReceivedMessage.TID),
                        Util.ConvertByteArrayToHexWordString(m.ReceivedMessage.UserData),
                        Util.ConvertByteArrayToHexWordString(m.ReceivedMessage.Reserved),
                        rssi,
                        m.ReceivedMessage.Antenna,
                        nowString
                        );
                }
                break;

                    #endregion
                    #region EasAlarm_6C
                case "EasAlarm_6C":
                {
                    IRP1.EasAlarm_6C m = (IRP1.EasAlarm_6C)msg;
                    if (m.ReceivedMessage.AnswerType == 0xa0)
                    {
                        if (OnTagAlarm != null)
                        {
                            OnTagAlarm(null, EventArgs.Empty);
                        }
                    }
                }
                break;

                    #endregion
                    #region PcSendTime_500(805)
                case "PcSendTime_500":
                {
                    IRP1.PcSendTime_500 m   = (IRP1.PcSendTime_500)msg;
                    DateTime            now = DateTime.Now;
                    TimeSpan            ts  = now - new DateTime(1970, 1, 1);
                    int    d     = (int)ts.TotalSeconds;
                    Byte[] bytes = BitConverter.GetBytes(d);
                    Byte[] time  = new Byte[4];


                    time[0] = bytes[3];
                    time[1] = bytes[2];
                    time[2] = bytes[1];
                    time[3] = bytes[0];

                    IRP1.PcSendTime_500 order = new IRP1.PcSendTime_500(m.ReceivedMessage.ReaderID, time);
                    reader.Send(order);
                }
                break;

                    #endregion
                    #region RXD_IOTriggerSignal_800
                case "RXD_IOTriggerSignal_800":
                {
                    IRP1.RXD_IOTriggerSignal_800 m = (IRP1.RXD_IOTriggerSignal_800)msg;
                    if (m.ReceivedMessage.IsStart)
                    {
                        //TODO:
                    }
                    else
                    {
                        //TODO:
                    }
                }
                break;

                    #endregion
                    #region Keepalive
                case "Keepalive":
                {
                    reader.Send(new IRP1.Keepalive());
                }
                break;
                    #endregion
                }
            }
            break;

            case "IRP2":
                // TODO:
                break;
            }
            if (OnReaderNotificationMsg != null)
            {
                OnReaderNotificationMsg((IRP1.Reader)reader, nmsg);
            }
        }