Exemple #1
0
 void RaiseEvent(RFIDEventType eventType)
 {
     if (null != evtCardState)
     {
         evtCardState(eventType, null);
     }
 }
 void HandleEventInNewThread(RFIDEventType type, object arg)
 {
     RFIDEventArg rfidArg = new RFIDEventArg(type, arg);
     BackgroundWorker backgroundWorker1 = new BackgroundWorker();
     backgroundWorker1.DoWork += new DoWorkEventHandler(BackgroundThreadWork);
     backgroundWorker1.RunWorkerAsync(rfidArg);
 }
Exemple #3
0
        void RaiseEvent(RFIDEventType eventType, object o)
        {
            if (eventType == RFIDEventType.WriteToSerialPort)
            {
                if (null != evtWriteToSerialPort)
                {
                    evtWriteToSerialPort((byte[])o);
                }
                return;
            }
            if (bStopCallback)
            {
                return;
            }

            if (null != evtCardState)
            {
                if (this.bRaiseEvent)
                {
                    evtCardState(eventType, o);
                }
                else
                if (eventType == RFIDEventType.RMU_Exception)
                {
                    bRaiseEvent = true;
                    evtCardState(eventType, o);
                }
            }
        }
Exemple #4
0
 void EditEventStatusValue(RFIDEventType type, bool bValue)
 {
     MRE_DicEdit.WaitOne();
     MRE_DicEdit.Reset();
     dicCommandSuccess[(int)type] = bValue;
     MRE_DicEdit.Set();
 }
Exemple #5
0
        /// <summary>
        /// 当读写器处于识别标签状态时,只能发送停止识别的命令才能被接收
        /// 因此如果接收到RMU_Exception事件,也可能是因为命令没有被接收
        /// 这里尝试发送 停止识别命令以确认这种情况
        /// </summary>
        /// <param name="eventType"></param>
        /// <param name="o"></param>
        public virtual void clearException(RFIDEventType eventType, object o)
        {
            if (eventType == RFIDEventType.RMU_Unknown)
            {
                return;
            }
            switch ((int)eventType)
            {
            case (int)RFIDEventType.RMU_Exception:
                if (!bInventoryStoped)
                {
                    bInventoryStoped = true;
                    _RFIDHelper.SendCommand(RFIDHelper.RFIDCommand_RMU_StopGet, RFIDEventType.RMU_StopGet);
                    break;
                }
                if (null != this.callback)
                {
                    this.callback(new operateMessage("fail", "设备异常"));
                }
                break;

            case (int)RFIDEventType.RMU_Inventory:
            case (int)RFIDEventType.RMU_InventoryAnti:
                _RFIDHelper.SendCommand(RFIDHelper.RFIDCommand_RMU_StopGet, RFIDEventType.RMU_StopGet);
                this.OperateStart();
                break;

            case (int)RFIDEventType.RMU_StopGet:
                this.OperateStart();
                break;
            }
        }
Exemple #6
0
        void RaiseEvent(RFIDEventType eventType, object o)
        {
            if (eventType == RFIDEventType.WriteToSerialPort)
            {
                //if (null != evtWriteToSerialPort)
                //{
                //    evtWriteToSerialPort((byte[])o);
                //}
                return;
            }
            if (bStopCallback)
            {
                return;
            }

            //if (null != evtCardState)
            //{
            //    if (this.bRaiseEvent)
            //    {
            //        evtCardState(eventType, o);
            //    }
            //    else
            //        if (eventType == RFIDEventType.RMU_Exception)
            //        {
            //            bRaiseEvent = true;
            //            evtCardState(eventType, o);
            //        }
            //}
        }
Exemple #7
0
 void StopSeeing(RFIDEventType type)
 {
     if (_CurrentEventType == type || _CurrentEventType == RFIDEventType.RMU_CardIsReady)
     {
         RMUStatus.Set();
     }
 }
Exemple #8
0
        public void SendCommand(string command, RFIDEventType type)
        {
            Debug.WriteLine(string.Format("SendCommand -> {0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.Millisecond.ToString()));
            dicCommandSuccess[(int)type] = false;

            this.WriteData(command);

            WaitToSee(type);
            Debug.WriteLine(string.Format("SendCommand -> {0} {1} type = {2} value = {3}",
                                          DateTime.Now.ToLongTimeString(),
                                          DateTime.Now.Millisecond.ToString(),
                                          type.ToString(),
                                          GetEventStatusValue(type).ToString()));
            if (!GetEventStatusValue(type))
            {
                //在响应时间内无返回,肯定出现设备异常,且仅在该种情况下使用该功能
                RaiseEvent(RFIDEventType.RMU_Exception, type.ToString());
            }
        }
Exemple #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="commands"></param>
 /// <param name="type"></param>
 /// <param name="bReturnInstance">true,需要对每一个命令进行处理</param>
 public void SendCommand(List <string> commands, RFIDEventType type, bool bReturnInstance)
 {
     if (commands == null || commands.Count <= 0)
     {
         return;
     }
     //如果要连续发送多条命令,并且在这多条命令发送完之前不需要进行返回值的处理
     if (!bReturnInstance && commands.Count > 1)
     {
         bRaiseEvent = false;
     }
     for (int i = 0; i < commands.Count; i++)
     {
         if (commands.Count - 1 == i)
         {
             bRaiseEvent = true;
         }
         SendCommand(commands[i], type);
         Thread.Sleep(200);
     }
 }
        void RaiseEvent(RFIDEventType eventType, object o)
        {
            /*
            if (eventType == RFIDEventType.WriteToSerialPort)
            {
                if (null != evtWriteToSerialPort)
                {
                    evtWriteToSerialPort((byte[])o);
                }
                return;
            }
             */
            if (bStopCallback)
            {
                return;
            }

            if (null != evtCardState)
            {
                if (this.bRaiseEvent)
                {
                    if (o == null)
                    {
                        Debug.WriteLine(string.Format("RaiseEvent  eventType->{0} value->null", eventType.ToString()));
                    }
                    else
                    {
                        Debug.WriteLine(string.Format("RaiseEvent  eventType->{0} value->{1}", eventType.ToString(), o.ToString()));
                    }
                    evtCardState(eventType, o);

                }
                else
                    if (eventType == RFIDEventType.RMU_Exception)
                    {
                        bRaiseEvent = true;
                        evtCardState(eventType, o);
                    }
            }
        }
        /// <summary>
        /// 当读写器处于识别标签状态时,只能发送停止识别的命令才能被接收
        /// 因此如果接收到RMU_Exception事件,也可能是因为命令没有被接收
        /// 这里尝试发送 停止识别命令以确认这种情况
        /// </summary>
        /// <param name="eventType"></param>
        /// <param name="o"></param>
        public virtual void clearException(RFIDEventType eventType, object o)
        {
            if (eventType == RFIDEventType.RMU_Unknown)
            {
                return;
            }
            List<string> list = null;
            switch ((int)eventType)
            {
                case (int)RFIDEventType.RMU_Exception:
                    if (!bInventoryStoped)
                    {
                        bInventoryStoped = true;
                        list = new List<string>();
                        //list.Add(Rmu900RFIDHelper.RFIDCommand_RMU_StopGet);
                        _RFIDHelper.SendCommand(
                           list, RFIDEventType.RMU_StopGet, true);

                        //_RFIDHelper.SendCommand(Rmu900RFIDHelper.RFIDCommand_RMU_StopGet, RFIDEventType.RMU_StopGet,true);
                        break;
                    }
                    if (null != this.callback)
                    {
                        this.callback(new operateMessage("fail", "设备异常"));
                    }
                    break;
                case (int)RFIDEventType.RMU_Inventory:
                case (int)RFIDEventType.RMU_InventoryAnti:
                    list = new List<string>();
                    //list.Add(Rmu900RFIDHelper.RFIDCommand_RMU_StopGet);
                    _RFIDHelper.SendCommand(
                       list, RFIDEventType.RMU_StopGet, true);
                    this.OperateStart();
                    break;
                case (int)RFIDEventType.RMU_StopGet:
                    this.OperateStart();
                    break;
            }
        }
        public void SendCommand(string command, RFIDEventType type)
        {
            if (null == command || type == RFIDEventType.RMU_Unknown)
            {
                return;
            }
            //当要将某命令选入发送到接收器时,首先将该命令的标识设为false,
            //当对应该命令的返回值正确时,将该标识重置为true,
            // 以此来判定该命令的执行情况
            dicCommandSuccess[(int)type] = false;

            this.WriteData(command);

            //等待命令执行一段时间
            WaitToSee(type);
            //如果执行到期后,命令标识仍为false,说明命令执行错误
            if (!GetEventStatusValue(type))
            {
                //在响应时间内无返回,肯定出现设备异常,且仅在该种情况下使用该功能
                RaiseEvent(RFIDEventType.RMU_Exception, type.ToString());
            }
        }
Exemple #13
0
        void RaiseEvent(RFIDEventType eventType, object o)
        {
            if (eventType == RFIDEventType.WriteToSerialPort)
            {
                if (null != evtWriteToSerialPort)
                {
                    evtWriteToSerialPort((byte[])o);
                }
                //if (null != evtwriteToSerialPort)
                //{
                //    string temp = Encoding.UTF8.GetString((byte[])o);
                //    this.evtwriteToSerialPort(temp);
                //}
                //if (this.dataTransfer != null)
                //{
                //    dataTransfer.writeData((byte[])o);
                //}
                return;
            }
            if (bStopCallback)
            {
                return;
            }

            if (null != evtCardState)
            {
                if (this.bRaiseEvent)
                {
                    evtCardState(eventType, o);
                }
                else
                if (eventType == RFIDEventType.RMU_Exception)
                {
                    bRaiseEvent = true;
                    evtCardState(eventType, o);
                }
            }
        }
Exemple #14
0
        void _RFIDHelper_evtCardState(RFIDEventType eventType, object o)
        {
            if ((this.ActionIndex + 1) <= actionList.Count)
            {
                operateAction action = actionList[ActionIndex];
                if (!action.bLoop)
                {
                    ActionIndex++;
                }
                if (eventType == action.invokeEvent)
                {
                    string value = null;
                    value = action.getProcessedData(o);
                    if (value != null)
                    {
                        if (null != this.callback)
                        {
                            this.callback(new operateMessage("success", value));
                        }
                    }
                    if (action.nextCommandType != RFIDEventType.RMU_Unknown)
                    {
                        _RFIDHelper.SendCommand(action.nextCommand, action.nextCommandType, false);
                    }

                    //如果已经是最后一个action,选择是否自动关闭数据解析回调
                    if ((ActionIndex > (actionList.Count - 1)) && this.bAutoRemoveParser)
                    {
                        this.closeSerialPort();
                    }
                }
                else
                {
                    //异常出现
                    this.clearException(eventType, o);
                }
            }
        }
 void HandleEventInNewThread(RFIDEventType type)
 {
     HandleEventInNewThread(type, null);
 }
Exemple #16
0
        void _helper_evtCardState(RFIDEventType eventType, object o)
        {
            switch ((int)eventType)
            {
            case (int)RFIDEventType.RMU_Exception:
                WriterClear("写入数据失败");
                break;

            case (int)RFIDEventType.RMU_CardIsReady:
                //设备准备就绪,查找周围是否有标签存在
                _helper.SendCommand(RFIDHelper.RFIDCommand_RMU_InventoryAnti3, RFIDEventType.RMU_InventoryAnti);
                break;

            case (int)RFIDEventType.RMU_InventoryAnti:
                if (null == o)
                {
                    WriterClear("请将标签防止读卡器作用范围内!");
                }
                else
                if ((string)o != "ok")
                {
                    Debug.WriteLine(string.Format("_helper_evtCardState ->RMU_InventoryAnti {0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.Millisecond.ToString()));
                    _uii = (string)o;
                    _helper.SendCommand(RFIDHelper.RFIDCommand_RMU_StopGet, RFIDEventType.RMU_StopGet);
                }
                break;

            case (int)RFIDEventType.RMU_StopGet:
            {
                Debug.WriteLine(string.Format("_helper_evtCardState ->RMU_StopGet {0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.Millisecond.ToString()));
                //首先进行锁定
                if (OperationType == 0)
                {
                    _helper.RmuLockTagReserverdEpcTid(_initialPwd, _uii);
                }
                else
                if (OperationType == 1)
                {
                    _helper.RmuLockTagReserverdEpcTid(_strPwd, _uii);
                }
            }
            break;

            case (int)RFIDEventType.RMU_LockMem:
            {
                if (null == o)
                {
                    WriterClear("标签锁定失败 ");
                }
                else if ((string)o == "ok")
                {
                    Debug.WriteLine(string.Format("_helper_evtCardState ->RMU_LockMem {0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.Millisecond.ToString()));

                    List <string> commands = null;
                    if (OperationType == 0)        // initial tag
                    {
                        //周围有标签存在,可以写入数据
                        commands = RFIDHelper.RmuWriteDataCommandCompose(RMU_CommandType.RMU_SingleWriteData, _initialPwd, 1, 2, GetWriteCommand(), null);
                        string        strPwdT           = RFIDHelper.PwdCheck(_strPwd);
                        string        pwdTH4            = strPwdT.Substring(0, 4); //前四位
                        string        pwdTT4            = strPwdT.Substring(4, 4); //后四位
                        List <string> commandSetSecret1 = RFIDHelper.RmuWriteDataCommandCompose(RMU_CommandType.RMU_SingleWriteData, _initialPwd, 0, 2, pwdTH4, null);
                        List <string> commandSetSecret2 = RFIDHelper.RmuWriteDataCommandCompose(RMU_CommandType.RMU_SingleWriteData, pwdTH4 + _initialPwd, 0, 3, pwdTT4, null);
                        commands.AddRange(commandSetSecret1);
                        commands.AddRange(commandSetSecret2);
                    }
                    if (OperationType == 1)
                    {
                        commands = RFIDHelper.RmuWriteDataCommandCompose(RMU_CommandType.RMU_SingleWriteData, RFIDHelper.PwdCheck(_strPwd), 1, 2, GetWriteCommand(), null);
                    }
                    _helper.SendCommand(commands, RFIDEventType.RMU_SingleWriteData, false);
                }
            }
            break;

            case (int)RFIDEventType.RMU_SingleWriteData:
                if (null != o)
                {
                    WriterClear("标签成功 ");
                }
                else
                {
                    WriterClear("标签写入数据失败,请检查设备并将标签放在读卡器范围内!");
                }
                break;
            }
        }
        public void SendCommand(string command, RFIDEventType type)
        {
            if (null == command || type == RFIDEventType.RMU_Unknown)
            {
                return;
            }
            //当要将某命令选入发送到接收器时,首先将该命令的标识设为false,
            //当对应该命令的返回值正确时,将该标识重置为true,
            // 以此来判定该命令的执行情况
            dicCommandSuccess[(int)type] = false;

            this.WriteData(command);

            //等待命令执行一段时间
            WaitToSee(type);
            //如果执行到期后,命令标识仍为false,说明命令执行错误
            if (!GetEventStatusValue(type))
            {
                //在响应时间内无返回,肯定出现设备异常,且仅在该种情况下使用该功能
                RaiseEvent(RFIDEventType.RMU_Exception, type.ToString());
            }
        }
Exemple #18
0
 void WaitToSee(RFIDEventType type)
 {
     _CurrentEventType = type;
     RMUStatus.Reset();
     RMUStatus.WaitOne(1000, false);
 }
 public void SendCommand(List<string> commands, RFIDEventType type)
 {
     SendCommand(commands, type, true);
 }
Exemple #20
0
 public RFIDEventArg(RFIDEventType type, object arg)
 {
     this._type = type;
     this._arg  = arg;
 }
 void StopSeeing(RFIDEventType type)
 {
     if (_CurrentEventType == type || _CurrentEventType == RFIDEventType.RMU_CardIsReady)
     {
         RMUStatus.Set();
     }
 }
        void RaiseEvent(RFIDEventType eventType, object o)
        {
            if (eventType == RFIDEventType.WriteToSerialPort)
            {
                if (null != evtWriteToSerialPort)
                {
                    evtWriteToSerialPort((byte[])o);
                }
                return;
            }
            if (bStopCallback)
            {
                return;
            }

            if (null != evtCardState)
            {
                if (this.bRaiseEvent)
                {
                    evtCardState(eventType, o);
                }
                else
                    if (eventType == RFIDEventType.RMU_Exception)
                    {
                        bRaiseEvent = true;
                        evtCardState(eventType, o);
                    }
            }
        }
 //void BackgroundThreadWork(object sender, DoWorkEventArgs e)
 //{
 //    RFIDEventArg rfidArg = (RFIDEventArg)e.Argument;
 //    RaiseEvent(rfidArg._type, rfidArg._arg);
 //}
 void HandleEventInNewThread(RFIDEventType type, object arg)
 {
     RaiseEvent(type, arg);
     //RFIDEventArg rfidArg = new RFIDEventArg(type, arg);
     //BackgroundWorker backgroundWorker1 = new BackgroundWorker();
     //backgroundWorker1.DoWork += new DoWorkEventHandler(BackgroundThreadWork);
     //backgroundWorker1.RunWorkerAsync(rfidArg);
 }
 bool GetEventStatusValue(RFIDEventType type)
 {
     MRE_DicEdit.WaitOne();
     return dicCommandSuccess[(int)type];
 }
 void EditEventStatusValue(RFIDEventType type, bool bValue)
 {
     MRE_DicEdit.WaitOne();
     MRE_DicEdit.Reset();
     dicCommandSuccess[(int)type] = bValue;
     MRE_DicEdit.Set();
 }
 public void SendCommand(List<string> commands, RFIDEventType type, bool bReturnInstance)
 {
     if (commands == null || commands.Count <= 0)
     {
         return;
     }
     //如果要连续发送多条命令,并且在这多条命令发送完之前不需要进行返回值的处理
     if (!bReturnInstance && commands.Count > 1)
     {
         bRaiseEvent = false;
     }
     for (int i = 0; i < commands.Count; i++)
     {
         if (commands.Count - 1 == i)
         {
             bRaiseEvent = true;
         }
         SendCommand(commands[i], type);
         Thread.Sleep(200);
     }
 }
        public void SendCommand(string command, RFIDEventType type)
        {
            if (null == command || type == RFIDEventType.RMU_Unknown)
            {
                return;
            }
            Debug.WriteLine(string.Format("SendCommand -> {0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.Millisecond.ToString()));
            dicCommandSuccess[(int)type] = false;

            this.WriteData(command);

            WaitToSee(type);
            Debug.WriteLine(string.Format("SendCommand -> {0} {1} type = {2} value = {3}",
                            DateTime.Now.ToLongTimeString(),
                            DateTime.Now.Millisecond.ToString(),
                            type.ToString(),
                            GetEventStatusValue(type).ToString()));
            if (!GetEventStatusValue(type))
            {
                //在响应时间内无返回,肯定出现设备异常,且仅在该种情况下使用该功能
                RaiseEvent(RFIDEventType.RMU_Exception, type.ToString());
            }
        }
Exemple #28
0
 bool GetEventStatusValue(RFIDEventType type)
 {
     MRE_DicEdit.WaitOne();
     return(dicCommandSuccess[(int)type]);
 }
Exemple #29
0
 public ObjCommand(string command, RFIDEventType type)
 {
     this._strCommand = command;
     this.eventType   = type;
 }
Exemple #30
0
 public void SendCommand(List <string> commands, RFIDEventType type, int interval)
 {
 }
Exemple #31
0
 public void SendCommand(List <string> commands, RFIDEventType type)
 {
     SendCommand(commands, type, true);
 }
 void RaiseEvent(RFIDEventType eventType)
 {
     if (null != evtCardState)
     {
         evtCardState(eventType, null);
     }
 }
Exemple #33
0
 void HandleEventInNewThread(RFIDEventType type)
 {
     HandleEventInNewThread(type, null);
 }
        void RaiseEvent(RFIDEventType eventType, object o)
        {
            if (eventType == RFIDEventType.WriteToSerialPort)
            {
                if (null != evtWriteToSerialPort)
                {
                    evtWriteToSerialPort((byte[])o);
                }
                //if (null != evtwriteToSerialPort)
                //{
                //    string temp = Encoding.UTF8.GetString((byte[])o);
                //    this.evtwriteToSerialPort(temp);
                //}
                //if (this.dataTransfer != null)
                //{
                //    dataTransfer.writeData((byte[])o);
                //}
                return;
            }
            if (bStopCallback)
            {
                return;
            }

            if (null != evtCardState)
            {
                if (this.bRaiseEvent)
                {
                    evtCardState(eventType, o);
                }
                else
                    if (eventType == RFIDEventType.RMU_Exception)
                    {
                        bRaiseEvent = true;
                        evtCardState(eventType, o);
                    }
            }
        }
        void _RFIDHelper_evtCardState(RFIDEventType eventType, object o)
        {
            string value = "";

            switch ((int)eventType)
            {
            case (int)RFIDEventType.RMU_Exception:
                if (null != o)
                {
                }
                MessageBox.Show("设备尚未准备就绪!");
                break;

            case (int)RFIDEventType.RMU_CardIsReady:
                _RFIDHelper.SendCommand(RFIDHelper.RFIDCommand_RMU_InventoryAnti3, RFIDEventType.RMU_InventoryAnti);
                break;

            case (int)RFIDEventType.RMU_InventoryAnti:
                this.bRfidCheckClosed = false;
                if (this.btnReadRfid.InvokeRequired)
                {
                    this.btnReadRfid.Invoke(new deleUpdateContorl(this.UpdateStartRfidCheckButton), false.ToString());
                }
                else
                {
                    this.btnReadRfid.Enabled = false;
                }

                if (this.btnStopRfidCheck.InvokeRequired)
                {
                    this.btnStopRfidCheck.Invoke(new deleUpdateContorl(this.UpdateStopRfidCheckButton), true.ToString());
                }
                else
                {
                    this.btnStopRfidCheck.Enabled = true;
                }
                if (null == o)
                {
                    value = "正在检测标签...";
                    //this.btnReadRfid.Enabled = false;
                    //this.btnStopRfidCheck.Enabled = true;
                }
                else
                if ((string)o != "ok")
                {
                    value = "读取到标签:" + (string)o;
                    //string id = ((string)o).Substring(4, 6);
                    string epc = RFIDHelper.GetEPCFormUII((string)o);
                    AddNewIDToCheckRecordList_Temp(epc);
                    UpdateCheckListControl(null);
                }
                if (this.labelStatus.InvokeRequired)
                {
                    this.labelStatus.Invoke(new deleUpdateContorl(UpdateStatusLable), value);
                }
                else
                {
                    //this.statusLabel.Text = value;
                    UpdateStatusLable(value);
                }
                break;

            case (int)RFIDEventType.RMU_StopGet:
                _RFIDHelper.StopCallback();
                this.bRfidCheckClosed = true;
                value = "本地考勤服务停止";
                //this.btnReadRfid.Enabled = true;
                //this.btnStopRfidCheck.Enabled = false;
                if (this.btnReadRfid.InvokeRequired)
                {
                    this.btnReadRfid.Invoke(new deleUpdateContorl(this.UpdateStartRfidCheckButton), true.ToString());
                }
                else
                {
                    this.btnReadRfid.Enabled = true;
                }
                if (this.btnStopRfidCheck.InvokeRequired)
                {
                    this.btnStopRfidCheck.Invoke(new deleUpdateContorl(this.UpdateStopRfidCheckButton), false.ToString());
                }
                else
                {
                    this.btnStopRfidCheck.Enabled = false;
                }
                if (this.labelStatus.InvokeRequired)
                {
                    this.labelStatus.Invoke(new deleUpdateContorl(UpdateStatusLable), value);
                }
                else
                {
                    //this.statusLabel.Text = value;
                    UpdateStatusLable(value);
                }
                break;
            }
        }
        void _RFIDHelper_evtCardState(RFIDEventType eventType, object o)
        {
            string value       = "";
            string secret      = null;
            string readCommand = null;

            switch ((int)eventType)
            {
            case (int)RFIDEventType.RMU_Exception:
                if (null != o)
                {
                }
                //MessageBox.Show("设备尚未准备就绪!");
                value = "设备出现异常!";
                if (this.labelStatus.InvokeRequired)
                {
                    this.labelStatus.Invoke(new deleUpdateContorl(UpdateStatusLable), value);
                }
                else
                {
                    UpdateStatusLable(value);
                }
                break;

            case (int)RFIDEventType.RMU_CardIsReady:
                _RFIDHelper.SendCommand(RFIDHelper.RFIDCommand_RMU_InventoryAnti3, RFIDEventType.RMU_InventoryAnti);
                //value = "设备状态正常!";
                //if (this.labelStatus.InvokeRequired)
                //{
                //    this.labelStatus.Invoke(new deleUpdateContorl(UpdateStatusLable), value);
                //}
                //else
                //{
                //    //this.statusLabel.Text = value;
                //    UpdateStatusLable(value);
                //}
                //secret = ConfigManager.GetLockMemSecret();
                //if (secret == null)
                //{
                //    secret = "12345678";
                //}

                //readCommand =
                //         RFIDHelper.RmuReadDataCommandComposer(
                //             RMU_CommandType.RMU_SingleReadData
                //                , secret,
                //                0,
                //                2,
                //                2,
                //                null);
                //_RFIDHelper.SendCommand(readCommand, RFIDEventType.RMU_SingleReadData);
                break;

            case (int)RFIDEventType.RMU_InventoryAnti:
                this.bRfidCheckClosed = false;
                if (this.button1.InvokeRequired)
                {
                    this.button1.Invoke(new deleUpdateContorl(this.UpdateButton1), "关闭");
                }
                else
                {
                    this.button1.Text = "关闭";
                }
                if (null == o)
                {
                    value = "正在检测标签...";
                }
                else
                if ((string)o != "ok")
                {
                    string id = RFIDHelper.GetEPCFormUII((string)o);
                    //string id = RFIDHelper.GetIDFromEPC((string)o);
                    value = "读取到学号:" + id;
                    // value = "读取到标签:" + (string)o;
                    // secret = ConfigManager.GetLockMemSecret();
                    // if (secret == null)
                    // {
                    //     secret = "12345678";
                    // }
                    // //读取密码段
                    //readCommand =
                    //     RFIDHelper.RmuReadDataCommandComposer(
                    //                         RMU_CommandType.RMU_SingleReadData
                    //                            , secret,
                    //                            0,
                    //                            2,
                    //                            2,
                    //                            null);
                    // _RFIDHelper.SendCommand(readCommand, RFIDEventType.RMU_SingleReadData);

                    CheckToRemoteServer(id);
                }
                if (this.labelStatus.InvokeRequired)
                {
                    this.labelStatus.Invoke(new deleUpdateContorl(UpdateStatusLable), value);
                }
                else
                {
                    //this.statusLabel.Text = value;
                    UpdateStatusLable(value);
                }
                break;

            case (int)RFIDEventType.RMU_SingleReadData:
                if (null != o)
                {
                    string data = (string)o;
                    int    n    = data.IndexOf("&");//data + & + uii
                    string uii  = data.Substring(n + 1);
                    string epc  = RFIDHelper.GetEPCFormUII(uii);
                    value = "读取到标签:" + uii;
                    if (this.labelStatus.InvokeRequired)
                    {
                        this.labelStatus.Invoke(new deleUpdateContorl(UpdateStatusLable), value);
                    }
                    else
                    {
                        UpdateStatusLable(value);
                    }
                    CheckToRemoteServer(epc);
                }
                break;

            case (int)RFIDEventType.RMU_StopGet:
                string buttonText = "";
                if (bStartOrCloseStop == true)    //如果只是开始时的初始化命令
                {
                    this.bRfidCheckClosed = false;
                    value      = "本地考勤服务开始";
                    buttonText = "关闭";
                    this.StartReadRFIDTag();
                }
                else
                {
                    _RFIDHelper.StopCallback();
                    this.bRfidCheckClosed = true;
                    value      = "本地考勤服务停止";
                    buttonText = "打开";
                }

                if (this.button1.InvokeRequired)
                {
                    this.button1.Invoke(new deleUpdateContorl(this.UpdateButton1), buttonText);
                }
                else
                {
                    this.button1.Text = buttonText;
                }

                if (this.labelStatus.InvokeRequired)
                {
                    this.labelStatus.Invoke(new deleUpdateContorl(UpdateStatusLable), value);
                }
                else
                {
                    //this.statusLabel.Text = value;
                    UpdateStatusLable(value);
                }
                break;
            }
        }
 void WaitToSee(RFIDEventType type)
 {
     _CurrentEventType = type;
     RMUStatus.Reset();
     RMUStatus.WaitOne(5000, false);
 }
        void _RFIDHelper_evtCardState(RFIDEventType eventType, object o)
        {
            if ((this.ActionIndex + 1) <= actionList.Count)
            {
                operateAction action = actionList[ActionIndex];
                if (!action.bLoop)
                {
                    ActionIndex++;
                }
                if (eventType == action.invokeEvent)
                {
                    string value = null;
                    value = action.getProcessedData(o);
                    if (value != null)
                    {
                        if (null != this.callback)
                        {
                            this.callback(new operateMessage("success", value));
                        }
                    }
                    if ((ActionIndex <= (actionList.Count - 1)) && (action.nextCommandType != RFIDEventType.RMU_Unknown))
                    {
                        _RFIDHelper.SendCommand(action.nextCommand, action.nextCommandType, false);
                    }

                    //如果已经是最后一个action,选择是否自动关闭数据解析回调
                    if ((ActionIndex > (actionList.Count - 1)) && this.bAutoRemoveParser)
                    {
                        this.linkClose();
                    }
                }
                else
                {
                    //异常出现
                    this.clearException(eventType, o);
                }
            }
        }
Exemple #39
0
        void _RFIDHelper_evtCardState(RFIDEventType eventType, object o)
        {
            string value = "";

            switch ((int)eventType)
            {
            case (int)RFIDEventType.RMU_Exception:
                if (null != o)
                {
                }
                value = "设备尚未准备就绪!";
                //MessageBox.Show("设备尚未准备就绪!");
                UpdateStatus(value);
                break;

            case (int)RFIDEventType.RMU_CardIsReady:
                _RFIDHelper.SendCommand(RFIDHelper.RFIDCommand_RMU_InventoryAnti3, RFIDEventType.RMU_InventoryAnti);
                break;

            case (int)RFIDEventType.RMU_InventoryAnti:
                if (o != null && (string)o != "ok")
                {
                    value = RFIDHelper.GetEPCFormUII((string)o);

                    _RFIDHelper.StopCallback();
                    _RFIDHelper.SendCommand(RFIDHelper.RFIDCommand_RMU_StopGet, RFIDEventType.RMU_StopGet);
                }
                if (this.textBox1.InvokeRequired)
                {
                    this.textBox1.Invoke(new deleUpdateContorl(UpdateEPCtxtBox), value);
                }
                else
                {
                    UpdateEPCtxtBox(value);
                }
                break;

            case (int)RFIDEventType.RMU_SingleWriteData:
                if (nSingleWriteDataState == 0)
                {
                    if (o == null)
                    {
                        //MessageBox.Show("更改标签EPC失败");
                        value = "更改标签EPC失败";
                    }
                    else
                    {
                        value = "更改标签EPC成功";
                        //MessageBox.Show("更改标签EPC成功");
                    }
                }
                if (nSingleWriteDataState == 1)
                {
                    if (o == null)
                    {
                        value = "标签锁定失败";
                        //MessageBox.Show("标签锁定失败");
                    }
                    else
                    {
                        value = "标签( " + (string)o + " )锁定成功 ";

                        //MessageBox.Show(value);
                    }
                }
                UpdateStatus(value);
                break;

            case (int)RFIDEventType.RMU_Inventory:
                if (null == o)
                {
                    value = "正在检测周围标签...";
                }
                else
                {
                    _RFIDHelper.SendCommand(RFIDHelper.RFIDCommand_RMU_StopGet, RFIDEventType.RMU_StopGet);
                    tagUII = (string)o;
                    value  = "检测到标签:" + tagUII;
                }
                UpdateStatus(value);
                break;

            case (int)RFIDEventType.RMU_StopGet:
                _RFIDHelper.RmuLockTagReserverdEpcTid("00000000", tagUII);

                break;

            case (int)RFIDEventType.RMU_LockMem:
            {
                if (null == o)
                {
                    value = "标签锁定失败 ";
                    //MessageBox.Show("标签锁定失败 ");
                }
                else if ((string)o == "ok")        //写入密码
                {
                    value = "写入密码...";
                    Debug.WriteLine(string.Format(" 写入密码->RMU_LockMem {0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.Millisecond.ToString()));
                    string        _initialPwd       = RFIDHelper.PwdCheck(null);
                    List <string> commands          = new List <string>();
                    string        strPwdT           = RFIDHelper.PwdCheck(txtSecret.Text);
                    string        pwdTH4            = strPwdT.Substring(0, 4); //前四位
                    string        pwdTT4            = strPwdT.Substring(4, 4); //后四位
                    List <string> commandSetSecret1 = RFIDHelper.RmuWriteDataCommandCompose(RMU_CommandType.RMU_SingleWriteData, _initialPwd, 0, 2, pwdTH4, null);
                    List <string> commandSetSecret2 = RFIDHelper.RmuWriteDataCommandCompose(RMU_CommandType.RMU_SingleWriteData, pwdTH4 + _initialPwd, 0, 3, pwdTT4, null);
                    commands.AddRange(commandSetSecret1);
                    commands.AddRange(commandSetSecret2);
                    this.nSingleWriteDataState = 1;
                    _RFIDHelper.SendCommand(commands, RFIDEventType.RMU_SingleWriteData, false);
                }
            }
                UpdateStatus(value);
                break;
            }
        }
 public RFIDEventArg(RFIDEventType type, object arg)
 {
     this._type = type;
     this._arg = arg;
 }