public void ParsesBasicTelegram3() { var t = new DSMRTelegram(MsgToString(message_3)); t.Should().NotBeNull(); t.TariffIndicator.Should().Be(1); t.TextMessage.Should().BeEmpty(); t.ActualPowerUse.Should().Be(0.335); t.ActualPowerReturn.Should().Be(0); t.Timestamp.Should().Be(new DateTime(2017, 11, 05, 20, 13, 24)); t.PowerUsedL1.Should().Be(0.335); t.PowerUsedL2.Should().BeNull(); t.PowerUsedL3.Should().BeNull(); t.PowerReturnedL1.Should().Be(0); t.PowerReturnedL2.Should().BeNull(); t.PowerReturnedL3.Should().BeNull(); t.VoltageL1.Should().Be(229.0); t.VoltageL2.Should().BeNull(); t.VoltageL3.Should().BeNull(); t.CurrentL1.Should().Be(1); t.CurrentL2.Should().BeNull(); t.CurrentL3.Should().BeNull(); t.Electricity1FromGrid.Should().Be(51.775); t.Electricity1ToGrid.Should().Be(24.413); t.Electricity2FromGrid.Should().Be(0); t.Electricity2ToGrid.Should().Be(0); t.Crc16.Should().Be("8F46"); }
public void ParsesBasicTelegram1() { var t = new DSMRTelegram(MsgToString(message_1)); t.Should().NotBeNull(); t.TariffIndicator.Should().Be(1); t.TextMessage.Should().BeEmpty(); t.ActualPowerUse.Should().Be(0); t.ActualPowerReturn.Should().Be(0.662); t.Timestamp.Should().Be(new DateTime(2021, 03, 07, 12, 37, 21)); t.PowerUsedL1.Should().Be(0); t.PowerUsedL2.Should().Be(0.213); t.PowerUsedL3.Should().Be(0.076); t.PowerReturnedL1.Should().Be(0.9); t.PowerReturnedL2.Should().Be(0); t.PowerReturnedL3.Should().Be(0); t.VoltageL1.Should().Be(233.7); t.VoltageL2.Should().Be(233.6); t.VoltageL3.Should().Be(230.9); t.CurrentL1.Should().Be(3); t.CurrentL2.Should().Be(1); t.CurrentL3.Should().Be(0); t.Electricity1FromGrid.Should().Be(2236.186); t.Electricity1ToGrid.Should().Be(781.784); t.Electricity2FromGrid.Should().Be(1755.06); t.Electricity2ToGrid.Should().Be(1871.581); t.Crc16.Should().Be("E1FA"); }
public Measurement(DSMRTelegram t) { Timestamp = t.Timestamp; TariffIndicator = t.TariffIndicator; var powerL1 = ConvertPower(t.PowerUsedL1, t.PowerReturnedL1); var powerL2 = ConvertPower(t.PowerUsedL2, t.PowerReturnedL2); var powerL3 = ConvertPower(t.PowerUsedL3, t.PowerReturnedL3); // calculate the current based on power and voltage to get a better accuracy CurrentL1 = CalculateCurrent(powerL1, t.VoltageL1); CurrentL2 = CalculateCurrent(powerL2, t.VoltageL2); CurrentL3 = CalculateCurrent(powerL3, t.VoltageL3); VoltageL1 = t.VoltageL1; VoltageL2 = t.VoltageL2; VoltageL3 = t.VoltageL3; Electricity1FromGrid = t.Electricity1FromGrid; Electricity1ToGrid = t.Electricity1ToGrid; Electricity2FromGrid = t.Electricity2FromGrid; Electricity2ToGrid = t.Electricity2ToGrid; }