private void HandleMeterReport(MeterReport report)
        {
            _lastUpdate = DateTime.UtcNow;

            var variable = report.Type + "Meter";
            UpdateVariable(report, variable, (double)report.Value);
            UpdateVariable(report, variable + "Unit", report.Unit);
        }
Пример #2
0
        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));
            }
        }
Пример #3
0
        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));
            }
        }
Пример #4
0
        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>();

            for (byte i = 0; i < 8; ++i)
            {
                if ((payload[1] & (1 << i)) == (1 << i))
                {
                    units.Add(MeterReport.GetUnit(Type, i));
                }
            }
            Units = units.ToArray();
        }