protected internal override void HandleEvent(Command command) { base.HandleEvent(command); if (command.CommandID == Convert.ToByte(Meter.command.Report)) { var report = new MeterReport(Node, command.Payload); OnChanged(new ReportEventArgs <MeterReport>(report)); } }
internal MeterSupportedReport(Node node, byte[] payload) : base(node) { if (payload.Length < 2) { throw new ReponseFormatException($"The response was not in the expected format. {GetType().Name}: Payload: {BitConverter.ToString(payload)}"); } CanReset = (payload[0] & 0x80) != 0; Type = (MeterType)Enum.ToObject(typeof(MeterType), payload[0] & 0x1F); var units = new List <string>(); var scales = new List <Enum>(); for (byte i = 0; i < 8; ++i) { if ((payload[1] & (1 << i)) == (1 << i)) { units.Add(MeterReport.GetUnit(Type, i)); scales.Add(MeterReport.GetScale(Type, i)); } } Units = units.ToArray(); Scales = scales.ToArray(); }