Innovenergy_trunk/csharp/Lib/Devices/IEM3kGridMeter/IEM3kGridMeterRegisters.cs

69 lines
2.2 KiB
C#
Raw Normal View History

2023-07-11 12:06:53 +00:00
using InnovEnergy.Lib.Protocols.Modbus.Reflection.Attributes;
using InnovEnergy.Lib.StatusApi.DeviceTypes;
using InnovEnergy.Lib.Units.Composite;
2024-02-20 16:43:23 +00:00
using static System.Math;
2023-07-11 12:06:53 +00:00
#pragma warning disable CS0649
namespace InnovEnergy.Lib.Devices.IEM3kGridMeter;
using Float32 = Single;
[AddressOffset(-2)] // why?
public class Iem3KGridMeterRegisters : IAc3Meter
2023-07-11 12:06:53 +00:00
{
2024-02-20 16:43:23 +00:00
private const Float32 ZeroBecauseReactivePowerNotSupported = 0;
2023-07-11 12:06:53 +00:00
// TODO
2024-02-20 16:43:23 +00:00
[HoldingRegister<Float32>(3054)] public Float32 ActivePowerL1; // in Kw
[HoldingRegister<Float32>(3056)] public Float32 ActivePowerL2; // in Kw
[HoldingRegister<Float32>(3058)] public Float32 ActivePowerL3; // in Kw
[HoldingRegister<Float32>(3060)] public Float32 TotalActivePower; // in Kw
2023-07-11 12:06:53 +00:00
[HoldingRegister<Float32>(3000)] public Float32 CurrentL1;
[HoldingRegister<Float32>(3002)] public Float32 CurrentL2;
[HoldingRegister<Float32>(3004)] public Float32 CurrentL3;
2024-06-04 10:23:19 +00:00
//
[HoldingRegister<Float32>(3028)] public Float32 VoltageL1N;
[HoldingRegister<Float32>(3030)] public Float32 VoltageL2N;
[HoldingRegister<Float32>(3032)] public Float32 VoltageL3N;
2024-06-12 12:05:29 +00:00
[HoldingRegister<Float32>(3518)] public Float32 ActiveEnergyImportL1;
[HoldingRegister<Float32>(3522)] public Float32 ActiveEnergyImportL2;
[HoldingRegister<Float32>(3526)] public Float32 ActiveEnergyImportL3;
[HoldingRegister<Float32>(45100)] public Float32 TotalActiveImport;
[HoldingRegister<Float32>(45102)] public Float32 TotalActiveExport;
[HoldingRegister<Float32>(3110)] private Float32 _frequency;
2024-06-12 12:05:29 +00:00
public Ac3Bus Ac => new Ac3Bus
2024-02-20 16:43:23 +00:00
{
L1 = new ()
{
Current = Abs(CurrentL1),
Voltage = Abs(VoltageL1N),
Phi = Atan2(ZeroBecauseReactivePowerNotSupported, ActivePowerL1)
2024-02-20 16:43:23 +00:00
},
L2 = new ()
{
Current = Abs(CurrentL2),
Voltage = Abs(VoltageL2N),
Phi = Atan2(ZeroBecauseReactivePowerNotSupported, ActivePowerL2)
2024-02-20 16:43:23 +00:00
},
L3 = new ()
{
Current = Abs(CurrentL3),
Voltage = Abs(VoltageL3N),
Phi = Atan2(ZeroBecauseReactivePowerNotSupported, ActivePowerL3)
2024-02-20 16:43:23 +00:00
},
Frequency = _frequency
};
2024-06-04 10:23:19 +00:00
2023-07-11 12:06:53 +00:00
}