83 lines
2.9 KiB
C#
83 lines
2.9 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.EmuMeter;
|
|
|
|
using Float32 = Single;
|
|
|
|
|
|
[AddressOffset(-2)] // why?
|
|
public class EmuMeterRegisters : IAc3Meter
|
|
{
|
|
|
|
[HoldingRegister<UInt64>(6004)] private UInt64 _ActivePowerImportT1;
|
|
[HoldingRegister<UInt64>(6024)] private UInt64 _ActivePowerExportT1;
|
|
[HoldingRegister<UInt64>(6008)] private UInt64 _ActivePowerImportT2;
|
|
[HoldingRegister<UInt64>(6028)] private UInt64 _ActivePowerExportT2;
|
|
[HoldingRegister<UInt32>(8002)] private UInt32 _ActivePowerImportT3;
|
|
[HoldingRegister<UInt32>(8012)] private UInt32 _ActivePowerExportT3;
|
|
[HoldingRegister<UInt32>(8000)] private UInt32 _ActivePowerImportT4;
|
|
[HoldingRegister<UInt32>(8010)] private UInt32 _ActivePowerExportT4;
|
|
|
|
[HoldingRegister<Float32>(9002)] private Float32 _ActivePowerL1;
|
|
[HoldingRegister<Float32>(9004)] private Float32 _ActivePowerL2;
|
|
[HoldingRegister<Float32>(9006)] private Float32 _ActivePowerL3;
|
|
|
|
[HoldingRegister<Float32>(9012)] private Float32 _ReactivePowerL1;
|
|
[HoldingRegister<Float32>(9014)] private Float32 _ReactivePowerL2;
|
|
[HoldingRegister<Float32>(9016)] private Float32 _ReactivePowerL3;
|
|
|
|
[HoldingRegister<Float32>(9102)] private Float32 _CurrentL1;
|
|
[HoldingRegister<Float32>(9104)] private Float32 _CurrentL2;
|
|
[HoldingRegister<Float32>(9106)] private Float32 _CurrentL3;
|
|
|
|
[HoldingRegister<Float32>(9200)] private Float32 _VoltageL1N;
|
|
[HoldingRegister<Float32>(9202)] private Float32 _VoltageL2N;
|
|
[HoldingRegister<Float32>(9204)] private Float32 _VoltageL3N;
|
|
|
|
[HoldingRegister<Float32>(9310)] private Float32 _Frequency;
|
|
|
|
public Ac3Bus Ac => new Ac3Bus
|
|
{
|
|
L1 = new ()
|
|
{
|
|
Current = Abs(_CurrentL1),
|
|
Voltage = Abs(_VoltageL1N),
|
|
Phi = Atan2(_ReactivePowerL1, _ActivePowerL1)
|
|
},
|
|
L2 = new ()
|
|
{
|
|
Current = Abs(_CurrentL2),
|
|
Voltage = Abs(_VoltageL2N),
|
|
Phi = Atan2(_ReactivePowerL2, _ActivePowerL2)
|
|
},
|
|
L3 = new ()
|
|
{
|
|
Current = Abs(_CurrentL3),
|
|
Voltage = Abs(_VoltageL3N),
|
|
Phi = Atan2(_ReactivePowerL3, _ActivePowerL3)
|
|
},
|
|
Frequency = _Frequency
|
|
};
|
|
|
|
public UInt64 ActivePowerImportT1 => _ActivePowerImportT1;
|
|
public UInt64 ActivePowerExportT1 => _ActivePowerExportT1;
|
|
|
|
public UInt64 ActivePowerImportT2 => _ActivePowerImportT2;
|
|
public UInt64 ActivePowerExportT2 => _ActivePowerExportT2;
|
|
|
|
public UInt32 ActivePowerImportT3 => _ActivePowerImportT3;
|
|
public UInt32 ActivePowerExportT3 => _ActivePowerExportT3;
|
|
|
|
public UInt64 ActivePowerImportT4 => _ActivePowerImportT4;
|
|
public UInt64 ActivePowerExportT4 => _ActivePowerExportT4;
|
|
|
|
}
|
|
|
|
|
|
|