public void start()
 {
     lock (this.rfidLock)
     {
         if (String.IsNullOrEmpty(HardwareInterface) || HardwareInterfaceConnectionSpeed == "0")
         {//如果发现RFID的串口参数没有配置,则抛出事件
             eventAggregator.GetEvent<RFIDHardwareEvent>().Publish("串口未设置");
             return;
         }
         //初始化并打开RFID设备
         if (this.backgroundTaskStatus == false)
         {
             rfidDevice = new RFIDDevice();
             try
             {
                 rfidDevice.openSerialPort(HardwareInterface, int.Parse(HardwareInterfaceConnectionSpeed));
                 //打开串口时可能由于设备设置错误或者未加电导致打开失败
             }
             catch (OpenRFIDDeviceException)
             {
                 eventAggregator.GetEvent<RFIDHardwareEvent>().Publish("串口打开失败");
                 return;
             }
             this.backgroundTaskStatus = true;
         }   
     }        
     
 }
Example #2
0
 public void start()
 {
     lock (this.rfidLock)
     {
         if (String.IsNullOrEmpty(HardwareInterface) || HardwareInterfaceConnectionSpeed == "0")
         {//如果发现RFID的串口参数没有配置,则抛出事件
             eventAggregator.GetEvent <RFIDHardwareEvent>().Publish("串口未设置");
             return;
         }
         //初始化并打开RFID设备
         if (this.backgroundTaskStatus == false)
         {
             rfidDevice = new RFIDDevice();
             try
             {
                 rfidDevice.openSerialPort(HardwareInterface, int.Parse(HardwareInterfaceConnectionSpeed));
                 //打开串口时可能由于设备设置错误或者未加电导致打开失败
             }
             catch (OpenRFIDDeviceException)
             {
                 eventAggregator.GetEvent <RFIDHardwareEvent>().Publish("串口打开失败");
                 return;
             }
             this.backgroundTaskStatus = true;
         }
     }
 }