using System; using System.Collections.Generic; namespace BatCharging.Model { public class SetPeakValleyTime : ASDU { /// /// 时段个数 /// public byte Count { get; set; } /// /// 时段 开始时间 /// public List PeakVallyTimes { get; set; } public SetPeakValleyTime(byte count, List peakVallyTimes) { this.Count = count; this.PeakVallyTimes = peakVallyTimes; //TODO BCD处理 } } public class PeakVallyTime { public byte StartHour { get; set; } public byte StartMinute { get; set; } public byte Type { get; set; } public PeakVallyTime(byte startHour, byte startMinute, byte type) { this.StartHour = startHour; this.StartMinute = startMinute; this.Type = type; } public byte[] GetBcd() { byte[] bytes = new byte[2]; int startHourTen = StartHour / 10; int startHour = StartHour % 10; bytes[0] = Convert.ToByte(startHourTen << 4 + startHour); int startMinuteTen = StartMinute / 10; int startMinute = StartMinute % 10; bytes[1] = Convert.ToByte(startMinuteTen << 4 + startMinute); return bytes; } } }