79 lines
3.2 KiB
C#
79 lines
3.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.EmuMeter;
|
|
|
|
using Float32 = Single;
|
|
|
|
|
|
[AddressOffset(-2)] // why?
|
|
public class EmuMeterRegisters : IAc3Meter
|
|
{
|
|
|
|
[HoldingRegister<UInt64>(6004, writable: true)] private UInt64 _ActivePowerImportT1;
|
|
[HoldingRegister<UInt64>(6024, writable: true)] private UInt64 _ActivePowerExportT1;
|
|
[HoldingRegister<UInt64>(6008, writable: true)] private UInt64 _ActivePowerImportT2;
|
|
[HoldingRegister<UInt64>(6028, writable: true)] private UInt64 _ActivePowerExportT2;
|
|
[HoldingRegister<UInt32>(8002, writable: true)] private UInt32 _ActivePowerImportT3;
|
|
[HoldingRegister<UInt32>(8012, writable: true)] private UInt32 _ActivePowerExportT3;
|
|
[HoldingRegister<UInt32>(8000, writable: true)] private UInt32 _ActivePowerImportT4;
|
|
[HoldingRegister<UInt32>(8010, writable: true)] private UInt32 _ActivePowerExportT4;
|
|
[HoldingRegister<Float32>(9002, writable: true)] private Float32 _ActivePowerL1;
|
|
[HoldingRegister<Float32>(9004, writable: true)] private Float32 _ActivePowerL2;
|
|
[HoldingRegister<Float32>(9006, writable: true)] private Float32 _ActivePowerL3;
|
|
[HoldingRegister<Float32>(9012, writable: true)] private Float32 _ReactivePowerL1;
|
|
[HoldingRegister<Float32>(9014, writable: true)] private Float32 _ReactivePowerL2;
|
|
[HoldingRegister<Float32>(9016, writable: true)] private Float32 _ReactivePowerL3;
|
|
[HoldingRegister<Float32>(9102, writable: true)] private Float32 _CurrentL1;
|
|
[HoldingRegister<Float32>(9104, writable: true)] private Float32 _CurrentL2;
|
|
[HoldingRegister<Float32>(9106, writable: true)] private Float32 _CurrentL3;
|
|
[HoldingRegister<Float32>(9200, writable: true)] private Float32 _VoltageL1N;
|
|
[HoldingRegister<Float32>(9202, writable: true)] private Float32 _VoltageL2N;
|
|
[HoldingRegister<Float32>(9204, writable: true)] private Float32 _VoltageL3N;
|
|
|
|
[HoldingRegister<Float32>(9310, writable: true)] 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;
|
|
|
|
}
|
|
|
|
|
|
|