Ejemplo n.º 1
0
 public void DecodeInternal()
 {
     while (RunDecodeThread)
     {
         if (Decode)
         {
             List <Original> list = RxQueue.PopAll();
             if (list != null && list.Count > 0)
             {
                 foreach (var o in list)
                 {
                     OriginalBytes obytes = o as OriginalBytes;
                     if (o != null && obytes.Data.Count() == 6)
                     {
                         LaserBaseResponse responseList = Decoder.Decode(obytes);
                         if (responseList != null)
                         {
                             RxMsgQueue.Push(responseList);
                         }
                         //LogHelper.GetLogger<LaserProtocolFactory>().Error(string.Format("接受到的原始数据为: {0}",
                         //        ByteHelper.Byte2ReadalbeXstring(obytes.Data)));
                     }
                 }
             }
         }
         Thread.Sleep(10);
     }
 }
Ejemplo n.º 2
0
 public virtual MotorBaseResponse Decode(OriginalBytes obytes)
 {
     if (obytes.Data.Length < 10)
     {
         LogHelper.GetLogger <LaserBaseResponse>().Error(string.Format("消息类型为 : {0} 长度不足!", obytes.Data[1]));
         return(null);
     }
     return(null);
 }
Ejemplo n.º 3
0
 public void DecodeInternal()
 {
     while (RunDecodeThread)
     {
         if (Decode)
         {
             List <Original> list = RxQueue.PopAll();
             {
                 if (list != null && list.Count > 0)
                 {
                     foreach (var o in list)
                     {
                         OriginalBytes obytes = o as OriginalBytes;
                         if (o != null)
                         {
                             if (obytes.Data[0] == 0x5D && obytes.Data[1] == 0x5B)
                             {
                                 MotorProtocol mp           = motorProtocol.DePackage(obytes.Data);
                                 byte[]        data         = mp.CodeRegion;
                                 byte          commandCode  = data[0];
                                 byte          additionCode = data[1];
                                 if (!Decoders.ContainsKey(commandCode))
                                 {
                                     return;
                                 }
                                 MotorBaseResponse mr = Decoders[commandCode].Decode(obytes);
                                 if (mr != null)
                                 {
                                     RxMsgQueue.Push(mr);
                                     //LogHelper.GetLogger<LaserProtocolFactory>().Error(string.Format("接受到的原始数据为: {0}",
                                     //    ByteHelper.Byte2ReadalbeXstring(obytes.Data)));
                                 }
                             }
                             else
                             {
                                 //LogHelper.GetLogger<LaserProtocolFactory>().Error(string.Format("接受到的原始数据非法: {0}",
                                 //    ByteHelper.Byte2ReadalbeXstring(obytes.Data)));
                             }
                         }
                     }
                 }
             }
         }
         Thread.Sleep(10);
     }
 }
Ejemplo n.º 4
0
 public void EncodeInternal()
 {
     while (RunEncodeThread)
     {
         if (Encode)
         {
             List <MotorBaseRequest> list = txMsgQueue.PopAll();
             if (list != null && list.Count > 0)
             {
                 foreach (var mr in list)
                 {
                     CIIBasePackage bp = mr.Encode();
                     OriginalBytes  ob = new OriginalBytes();
                     ob.Data = motorProtocol.EnPackage(bp);
                     txQueue.Push(ob);
                 }
             }
         }
         Thread.Sleep(10);
     }
 }
Ejemplo n.º 5
0
 public void EncodeInternal()
 {
     while (RunEncodeThread)
     {
         if (Encode)
         {
             List <LaserBaseRequest> list = txMsgQueue.PopAll();
             if (list != null && list.Count > 0)
             {
                 foreach (var br in list)
                 {
                     List <LaserBasePackage> bps = br.Encode();
                     foreach (LaserBasePackage bp in bps)
                     {
                         OriginalBytes ob = new OriginalBytes();
                         ob.Data = laserProtocol.EnPackage(bp);
                         txQueue.Push(ob);
                     }
                 }
             }
         }
         Thread.Sleep(10);
     }
 }
Ejemplo n.º 6
0
 public virtual LaserBaseResponse Decode(OriginalBytes obytes)
 {
     this.OriginalBytes = obytes;
     this.DtTime        = DateTime.Now;
     return(null);
 }