using Edge.Core.Parser.BinaryParser.Attributes; using Edge.Core.Parser.BinaryParser.Util; using System; using System.Collections.Generic; using System.Text; using static TATSUNO_Pump.Messages.PollingOrSelectingRequest; namespace TATSUNO_Pump.Messages { public abstract class TextMessageBase : MessageBase { [Format(1, EncodingType.BIN, -9999)] public byte STX { get; set; } = 0x02; /// /// actual the device address which configed in device side, range from 40H~7FH /// [Format(1, EncodingType.BIN, -9900)] [Range(0x40, 0x7F, "StationAddress must range from 0x40 to 0x7F")] public byte StationAddress { get; set; } private byte unitAddress_Raw = 0; [Format(1, EncodingType.BIN, -9800)] public byte UnitAddress_Raw { get { return this.unitAddress_Raw; } set { this.unitAddress_Raw = value; if (this.unitAddress_Raw.GetBit(4) == 0) this.RequestType = RequestTypeEnum.Selecting; else this.RequestType = RequestTypeEnum.Polling; var kindsRaw = this.unitAddress_Raw & 0x0F; this.DeviceKind = (DeviceKindEnum)Enum.Parse(typeof(DeviceKindEnum), kindsRaw.ToString()); } } public RequestTypeEnum RequestType { get; set; } public DeviceKindEnum DeviceKind { get; set; } [Format(1, EncodingType.BIN, -9700)] public byte Code { get; set; } //public enum PosToDeviceTextMessageCodeEnum //{ // //code 11 // PermissionOfRefueling, // //code 12 // CancellationOfRefueling, // //code 13 // PumpLock, // //code 14 // CancellationOfPumpLock, // //code 15 // RequestForStatusOfGasPump, // //code 20 // RequestForTota1AmountOfRefueling //} } }