using Edge.Core.Parser.BinaryParser.Attributes; using Edge.Core.Parser.BinaryParser.MessageEntity; using Edge.Core.Parser.BinaryParser.Util; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; namespace ZhongSheng_NonIC_Pump { public abstract class MessageTemplateBase : Edge.Core.Parser.BinaryParser.MessageEntity.MessageTemplateBase { /// /// 数据包头,同步头 /// [Format(1, EncodingType.BIN, -100)] public virtual byte Prefix { get { return 0xFA; } set { ; } } /// /// 数据接收端的地址编号 ,中控地址就放0xff /// [Format(1, EncodingType.BIN, -99)] public virtual byte TargetAddress { get; set; } /// /// 数据发送端的地址编号,中控地址就放0xff /// [Format(1, EncodingType.BIN, -98)] public virtual byte SourceAddress { get; set; } /// /// 帧号/控制 /// 发送端与接收端的同步帧号,发送方发出某帧号,应答方回送此帧号, /// 该数从0x01递增到0x3F,然后再回到0x00,继续递增循环。 /// /// 注意注意,实际加油机会发送0x40进来,可能是油机的BUG,所以这里放开到0x40 /// [Format(1, EncodingType.BIN, -97)] [Range(1, 0x40, "帧号/控制 must between 0x01 to 0x3F, but now is: {0}")] public virtual byte FrameSeqNo { get; set; } /// /// 有效数据长度, 压缩 BCD,转 义字符 不计入 其中 /// [Format(1, "%OnSerializingBytesCount", EncodingType.BIN, -90)] //[Range(1, 240, "有效数据长度must between 1 and 240, but now is {0}")] public virtual int DataLength { get; set; } [Format(1, EncodingType.BIN, -80)] public virtual byte CommandCode { get; set; } //[Format(1, EncodingType.BIN, 9999)] public virtual byte CheckSum { get; set; } public override string ToLogString() { return this.GetType().Name + " " + base.ToLogString(); } } }