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

69 lines
2.2 KiB
C#

using InnovEnergy.Lib.Protocols.Modbus.Reflection.Attributes;
using InnovEnergy.Lib.StatusApi.DeviceTypes;
using InnovEnergy.Lib.Units.Composite;
using static System.Math;
#pragma warning disable CS0649
namespace InnovEnergy.Lib.Devices.IEM3kGridMeter;
using Float32 = Single;
[AddressOffset(-2)] // why?
public class Iem3KGridMeterRegisters : IAc3Meter
{
private const Float32 ZeroBecauseReactivePowerNotSupported = 0;
// TODO
[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
[HoldingRegister<Float32>(3000)] public Float32 CurrentL1;
[HoldingRegister<Float32>(3002)] public Float32 CurrentL2;
[HoldingRegister<Float32>(3004)] public Float32 CurrentL3;
//
[HoldingRegister<Float32>(3028)] public Float32 VoltageL1N;
[HoldingRegister<Float32>(3030)] public Float32 VoltageL2N;
[HoldingRegister<Float32>(3032)] public Float32 VoltageL3N;
[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;
public Ac3Bus Ac => new Ac3Bus
{
L1 = new ()
{
Current = Abs(CurrentL1),
Voltage = Abs(VoltageL1N),
Phi = Atan2(ZeroBecauseReactivePowerNotSupported, ActivePowerL1)
},
L2 = new ()
{
Current = Abs(CurrentL2),
Voltage = Abs(VoltageL2N),
Phi = Atan2(ZeroBecauseReactivePowerNotSupported, ActivePowerL2)
},
L3 = new ()
{
Current = Abs(CurrentL3),
Voltage = Abs(VoltageL3N),
Phi = Atan2(ZeroBecauseReactivePowerNotSupported, ActivePowerL3)
},
Frequency = _frequency
};
}