Innovenergy_trunk/csharp/Lib/Devices/EmuMeter/EmuMeterRegisters.cs

83 lines
2.9 KiB
C#
Raw Permalink Normal View History

2023-05-06 13:41:39 +00:00
using InnovEnergy.Lib.Protocols.Modbus.Reflection.Attributes;
using InnovEnergy.Lib.StatusApi.DeviceTypes;
using InnovEnergy.Lib.Units.Composite;
2023-09-01 06:54:46 +00:00
using static System.Math;
2023-05-06 13:41:39 +00:00
#pragma warning disable CS0649
namespace InnovEnergy.Lib.Devices.EmuMeter;
using Float32 = Single;
[AddressOffset(-2)] // why?
2023-06-13 10:54:06 +00:00
public class EmuMeterRegisters : IAc3Meter
2023-05-06 13:41:39 +00:00
{
2024-01-19 15:57:02 +00:00
[HoldingRegister<UInt64>(6004)] private UInt64 _ActivePowerImportT1;
[HoldingRegister<UInt64>(6024)] private UInt64 _ActivePowerExportT1;
2024-01-19 15:57:02 +00:00
[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;
2024-01-19 15:57:02 +00:00
2023-05-06 13:41:39 +00:00
[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;
2023-09-01 06:54:46 +00:00
public Ac3Bus Ac => new Ac3Bus
{
L1 = new ()
{
2023-09-01 12:15:06 +00:00
Current = Abs(_CurrentL1),
Voltage = Abs(_VoltageL1N),
2023-09-01 06:54:46 +00:00
Phi = Atan2(_ReactivePowerL1, _ActivePowerL1)
},
L2 = new ()
{
2023-09-01 12:15:06 +00:00
Current = Abs(_CurrentL2),
Voltage = Abs(_VoltageL2N),
2023-09-01 06:54:46 +00:00
Phi = Atan2(_ReactivePowerL2, _ActivePowerL2)
},
L3 = new ()
{
2023-09-01 12:15:06 +00:00
Current = Abs(_CurrentL3),
Voltage = Abs(_VoltageL3N),
2023-09-01 06:54:46 +00:00
Phi = Atan2(_ReactivePowerL3, _ActivePowerL3)
},
Frequency = _Frequency
};
2024-01-19 15:57:02 +00:00
public UInt64 ActivePowerImportT1 => _ActivePowerImportT1;
public UInt64 ActivePowerExportT1 => _ActivePowerExportT1;
public UInt64 ActivePowerImportT2 => _ActivePowerImportT2;
public UInt64 ActivePowerExportT2 => _ActivePowerExportT2;
2024-01-25 09:17:55 +00:00
public UInt32 ActivePowerImportT3 => _ActivePowerImportT3;
public UInt32 ActivePowerExportT3 => _ActivePowerExportT3;
2024-01-19 15:57:02 +00:00
public UInt64 ActivePowerImportT4 => _ActivePowerImportT4;
public UInt64 ActivePowerExportT4 => _ActivePowerExportT4;
2023-05-06 13:41:39 +00:00
}