Esempio n. 1
0
 public CsmDataFrame(CAN.DataFrame CanDataFram)
 {
     Address = (ushort)(CanDataFram.ID >> 3 & 0x1F);
     if ((CanDataFram.ID & 0x07) != 1)
     {
         this._type = (FrameType)(CanDataFram.ID & 0x07);
     }
     else
     {
         throw new Exception(string.Format("帧类型错误!\nID:{0}\nData:{1}",
             CanDataFram.ID.ToString(),BitConverter.ToString(CanDataFram.Date)));
     }
     Data = CanDataFram.Date;
     _prority = (FramePrority)(CanDataFram.ID>>8 & 0x1);
     _feature = (FrameFeature)(CanDataFram.ID>>9 &0x1);
     _direction = (FrameDirection)(CanDataFram.ID>>10 &0x1);
 }
Esempio n. 2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public CsmDataFrame(ushort address, byte[] data, FrameDirection direction = FrameDirection.Send,
     FrameFeature feature = FrameFeature.independ, FrameType type = FrameType.OneIndependFrame,
     FramePrority prority = FramePrority.Low)
 {
     try
     {
         Address = address;
         Data = data;
         _direction = direction;
         _feature = feature;
         _type = type;
         _prority = prority;
     }
     catch (Exception e)
     {
         System.Windows.Forms.MessageBox.Show(e.ToString(), "错误:",
             System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
 }