Innovenergy_trunk/csharp/Sinexcel 12K TL/SinexcelRecord.Api.cs

934 lines
60 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using InnovEnergy.Lib.Devices.Sinexcel_12K_TL.DataType;
using InnovEnergy.Lib.Units;
using InnovEnergy.Lib.Units.Power;
namespace InnovEnergy.Lib.Devices.Sinexcel_12K_TL;
public partial class SinexcelRecord
{
/*
// --------------------------------------------------------
// Helpers
// --------------------------------------------------------
private static ushort Bit(ushort v) => (ushort)(v & 0x01);
private static ushort Compose3(ushort b0, ushort b1, ushort b2)
=> (ushort)(Bit(b0) | (Bit(b1) << 1) | (Bit(b2) << 2));
private static ushort Compose4(ushort b0, ushort b1, ushort b2, ushort b3)
=> (ushort)(Bit(b0) | (Bit(b1) << 1) | (Bit(b2) << 2) | (Bit(b3) << 3));
// ---- Operating states
public SinexcelInverterOperatingState InverterOperatingState
=> (SinexcelInverterOperatingState)(_inverterOperatingState & 0x07);
public SinexcelPvOperatingState Pv1OperatingState
=> (SinexcelPvOperatingState)Bit(_pv1OperatingState);
public SinexcelPvOperatingState Pv2OperatingState
=> (SinexcelPvOperatingState)Bit(_pv2OperatingState);
public SinexcelPvOperatingState Pv3OperatingState
=> (SinexcelPvOperatingState)Bit(_pv3OperatingState);
public SinexcelPvOperatingState Pv4OperatingState
=> (SinexcelPvOperatingState)Bit(_pv4OperatingState);
public SinexcelBatteryOperatingState Battery1OperatingState
=> (SinexcelBatteryOperatingState)(_battery1OperatingState & 0x07);
public SinexcelBatteryOperatingState Battery2OperatingState
=> (SinexcelBatteryOperatingState)Compose3(_bat2StateBit0, _bat2StateBit1, _bat2StateBit2);
public SinexcelOredState OredState
=> (SinexcelOredState)Compose4(_oredStateBit0, _oredStateBit1, _oredStateBit2, _oredStateBit3);
public SinexcelDcdcState DcdcStateDc
=> (SinexcelDcdcState)Bit(_dcdcStateDc);
public SinexcelDcdcState DcdcStateAc
=> (SinexcelDcdcState)Bit(_dcdcStateAc);
public SinexcelPowerGridStatus PowerGridStatus
=> (SinexcelPowerGridStatus)Bit(_powerGridStatus);
// ---- Alarm / fault flags
public SinexcelAbnormalFlag AbnormalGridVoltage => (SinexcelAbnormalFlag)Bit(_abnormalGridVoltage);
public SinexcelAbnormalFlag AbnormalGridFrequency => (SinexcelAbnormalFlag)Bit(_abnormalGridFrequency);
public SinexcelAbnormalFlag InvertedSequenceOfGridVoltage => (SinexcelAbnormalFlag)Bit(_invertedSequenceOfGridVoltage);
public SinexcelAbnormalFlag GridVoltagePhaseLoss => (SinexcelAbnormalFlag)Bit(_gridVoltagePhaseLoss);
public SinexcelAbnormalFlag AbnormalOutputVoltage => (SinexcelAbnormalFlag)Bit(_abnormalOutputVoltage);
public SinexcelAbnormalFlag AbnormalOutputFrequency => (SinexcelAbnormalFlag)Bit(_abnormalOutputFrequency);
public SinexcelAbnormalFlag AbnormalNullLine => (SinexcelAbnormalFlag)Bit(_abnormalNullLine);
public SinexcelAbnormalFlag ExcessivelyHighAmbientTemperature => (SinexcelAbnormalFlag)Bit(_excessivelyHighAmbientTemperature);
public SinexcelAbnormalFlag ExcessiveRadiatorTemperature => (SinexcelAbnormalFlag)Bit(_excessiveRadiatorTemperature);
public SinexcelAbnormalFlag InsulationFault => (SinexcelAbnormalFlag)Bit(_insulationFault);
public SinexcelAbnormalFlag LeakageProtectionFault => (SinexcelAbnormalFlag)Bit(_leakageProtectionFault);
public SinexcelAbnormalFlag AuxiliaryPowerFault => (SinexcelAbnormalFlag)Bit(_auxiliaryPowerFault);
public SinexcelAbnormalFlag FanFault => (SinexcelAbnormalFlag)Bit(_fanFault);
public SinexcelAbnormalFlag ModelCapacityFault => (SinexcelAbnormalFlag)Bit(_modelCapacityFault);
public SinexcelAbnormalFlag AbnormalLightningArrester => (SinexcelAbnormalFlag)Bit(_abnormalLightningArrester);
public SinexcelAbnormalFlag IslandProtection => (SinexcelAbnormalFlag)Bit(_islandProtection);
public SinexcelAbnormalFlag Battery1NotConnected => (SinexcelAbnormalFlag)Bit(_battery1NotConnected);
public SinexcelAbnormalFlag Battery1Overvoltage => (SinexcelAbnormalFlag)Bit(_battery1Overvoltage);
public SinexcelAbnormalFlag Battery1Undervoltage => (SinexcelAbnormalFlag)Bit(_battery1Undervoltage);
public SinexcelAbnormalFlag Battery1DischargeEnd => (SinexcelAbnormalFlag)Bit(_battery1DischargeEnd);
public SinexcelAbnormalFlag Battery1Inverted => (SinexcelAbnormalFlag)Bit(_battery1Inverted);
public SinexcelAbnormalFlag Battery2NotConnected => (SinexcelAbnormalFlag)Bit(_battery2NotConnected);
public SinexcelAbnormalFlag Battery2Overvoltage => (SinexcelAbnormalFlag)Bit(_battery2Overvoltage);
public SinexcelAbnormalFlag Battery2Undervoltage => (SinexcelAbnormalFlag)Bit(_battery2Undervoltage);
public SinexcelAbnormalFlag Battery2DischargeEnd => (SinexcelAbnormalFlag)Bit(_battery2DischargeEnd);
public SinexcelAbnormalFlag Battery2Inverted => (SinexcelAbnormalFlag)Bit(_battery2Inverted);
public SinexcelAbnormalFlag Pv1NotAccessed => (SinexcelAbnormalFlag)Bit(_pv1NotAccessed);
public SinexcelAbnormalFlag Pv1Overvoltage => (SinexcelAbnormalFlag)Bit(_pv1Overvoltage);
public SinexcelAbnormalFlag AbnormalPv1CurrentSharing => (SinexcelAbnormalFlag)Bit(_abnormalPv1CurrentSharing);
public SinexcelAbnormalFlag Pv2NotAccessed => (SinexcelAbnormalFlag)Bit(_pv2NotAccessed);
public SinexcelAbnormalFlag Pv2Overvoltage => (SinexcelAbnormalFlag)Bit(_pv2Overvoltage);
public SinexcelAbnormalFlag AbnormalPv2CurrentSharing => (SinexcelAbnormalFlag)Bit(_abnormalPv2CurrentSharing);
public SinexcelAbnormalFlag DcBusOvervoltage => (SinexcelAbnormalFlag)Bit(_dcBusOvervoltage);
public SinexcelAbnormalFlag DcBusUndervoltage => (SinexcelAbnormalFlag)Bit(_dcBusUndervoltage);
public SinexcelAbnormalFlag DcBusVoltageUnbalance => (SinexcelAbnormalFlag)Bit(_dcBusVoltageUnbalance);
public SinexcelAbnormalFlag Pv1PowerTubeFault => (SinexcelAbnormalFlag)Bit(_pv1PowerTubeFault);
public SinexcelAbnormalFlag Pv2PowerTubeFault => (SinexcelAbnormalFlag)Bit(_pv2PowerTubeFault);
public SinexcelAbnormalFlag Battery1PowerTubeFault => (SinexcelAbnormalFlag)Bit(_battery1PowerTubeFault);
public SinexcelAbnormalFlag Battery2PowerTubeFault => (SinexcelAbnormalFlag)Bit(_battery2PowerTubeFault);
public SinexcelAbnormalFlag InverterPowerTubeFault => (SinexcelAbnormalFlag)Bit(_inverterPowerTubeFault);
public SinexcelAbnormalFlag SystemOutputOverload => (SinexcelAbnormalFlag)Bit(_systemOutputOverload);
public SinexcelAbnormalFlag InverterOverload => (SinexcelAbnormalFlag)Bit(_inverterOverload);
public SinexcelAbnormalFlag InverterOverloadTimeout => (SinexcelAbnormalFlag)Bit(_inverterOverloadTimeout);
public SinexcelAbnormalFlag Battery1OverloadTimeout => (SinexcelAbnormalFlag)Bit(_battery1OverloadTimeout);
public SinexcelAbnormalFlag Battery2OverloadTimeout => (SinexcelAbnormalFlag)Bit(_battery2OverloadTimeout);
public SinexcelAbnormalFlag InverterSoftStartFailure => (SinexcelAbnormalFlag)Bit(_inverterSoftStartFailure);
public SinexcelAbnormalFlag Battery1SoftStartFailure => (SinexcelAbnormalFlag)Bit(_battery1SoftStartFailure);
public SinexcelAbnormalFlag Battery2SoftStartFailure => (SinexcelAbnormalFlag)Bit(_battery2SoftStartFailure);
public SinexcelAbnormalFlag Dsp1ParameterSettingFault => (SinexcelAbnormalFlag)Bit(_dsp1ParameterSettingFault);
public SinexcelAbnormalFlag Dsp2ParameterSettingFault => (SinexcelAbnormalFlag)Bit(_dsp2ParameterSettingFault);
public SinexcelAbnormalFlag DspVersionCompatibilityFault => (SinexcelAbnormalFlag)Bit(_dspVersionCompatibilityFault);
public SinexcelAbnormalFlag CpldVersionCompatibilityFault => (SinexcelAbnormalFlag)Bit(_cpldVersionCompatibilityFault);
public SinexcelAbnormalFlag CpldCommunicationFault => (SinexcelAbnormalFlag)Bit(_cpldCommunicationFault);
public SinexcelAbnormalFlag DspCommunicationFault => (SinexcelAbnormalFlag)Bit(_dspCommunicationFault);
public SinexcelAbnormalFlag OutputVoltageDcOverlimit => (SinexcelAbnormalFlag)Bit(_outputVoltageDcOverlimit);
public SinexcelAbnormalFlag OutputCurrentDcOverlimit => (SinexcelAbnormalFlag)Bit(_outputCurrentDcOverlimit);
public SinexcelAbnormalFlag RelaySelfCheckFails => (SinexcelAbnormalFlag)Bit(_relaySelfCheckFails);
public SinexcelAbnormalFlag AbnormalInverter => (SinexcelAbnormalFlag)Bit(_abnormalInverter);
public SinexcelAbnormalFlag PoorGrounding => (SinexcelAbnormalFlag)Bit(_poorGrounding);
public SinexcelAbnormalFlag Pv1SoftStartFailure => (SinexcelAbnormalFlag)Bit(_pv1SoftStartFailure);
public SinexcelAbnormalFlag Pv2SoftStartFailure => (SinexcelAbnormalFlag)Bit(_pv2SoftStartFailure2);
public SinexcelAbnormalFlag BalancedCircuitOverloadTimeout => (SinexcelAbnormalFlag)Bit(_balancedCircuitOverloadTimeout);
public SinexcelAbnormalFlag Pv1OverloadTimeout => (SinexcelAbnormalFlag)Bit(_pv1OverloadTimeout);
public SinexcelAbnormalFlag Pv2OverloadTimeout => (SinexcelAbnormalFlag)Bit(_pv2OverloadTimeout);
public SinexcelAbnormalFlag PcbOvertemperature => (SinexcelAbnormalFlag)Bit(_pcbOvertemperature);
public SinexcelAbnormalFlag DcConverterOvertemperature => (SinexcelAbnormalFlag)Bit(_dcConverterOvertemperature);
public SinexcelAbnormalFlag BusSlowOvervoltage => (SinexcelAbnormalFlag)Bit(_busSlowOvervoltage);
public SinexcelAbnormalFlag AbnormalOffGridOutputVoltage => (SinexcelAbnormalFlag)Bit(_abnormalOffGridOutputVoltage);
public SinexcelAbnormalFlag HardwareBusOvervoltage => (SinexcelAbnormalFlag)Bit(_hardwareBusOvervoltage);
public SinexcelAbnormalFlag HardwareOvercurrent => (SinexcelAbnormalFlag)Bit(_hardwareOvercurrent);
public SinexcelAbnormalFlag DcConverterOvervoltage => (SinexcelAbnormalFlag)Bit(_dcConverterOvervoltage);
public SinexcelAbnormalFlag DcConverterHardwareOvervoltage => (SinexcelAbnormalFlag)Bit(_dcConverterHardwareOvervoltage);
public SinexcelAbnormalFlag DcConverterOvercurrent => (SinexcelAbnormalFlag)Bit(_dcConverterOvercurrent);
public SinexcelAbnormalFlag DcConverterHardwareOvercurrent => (SinexcelAbnormalFlag)Bit(_dcConverterHardwareOvercurrent);
public SinexcelAbnormalFlag DcConverterResonatorOvercurrent => (SinexcelAbnormalFlag)Bit(_dcConverterResonatorOvercurrent);
public SinexcelAbnormalFlag Pv1InsufficientPower => (SinexcelAbnormalFlag)Bit(_pv1InsufficientPower);
public SinexcelAbnormalFlag Pv2InsufficientPower => (SinexcelAbnormalFlag)Bit(_pv2InsufficientPower);
public SinexcelAbnormalFlag Battery1InsufficientPower => (SinexcelAbnormalFlag)Bit(_battery1InsufficientPower);
public SinexcelAbnormalFlag Battery2InsufficientPower => (SinexcelAbnormalFlag)Bit(_battery2InsufficientPower);
public SinexcelAbnormalFlag LithiumBattery1ChargeForbidden => (SinexcelAbnormalFlag)Bit(_lithiumBattery1ChargeForbidden);
public SinexcelAbnormalFlag LithiumBattery1DischargeForbidden => (SinexcelAbnormalFlag)Bit(_lithiumBattery1DischargeForbidden);
public SinexcelAbnormalFlag LithiumBattery2ChargeForbidden => (SinexcelAbnormalFlag)Bit(_lithiumBattery2ChargeForbidden);
public SinexcelAbnormalFlag LithiumBattery2DischargeForbidden => (SinexcelAbnormalFlag)Bit(_lithiumBattery2DischargeForbidden);
public SinexcelAbnormalFlag LithiumBattery1Full => (SinexcelAbnormalFlag)Bit(_lithiumBattery1Full);
public SinexcelAbnormalFlag LithiumBattery1DischargeEnd => (SinexcelAbnormalFlag)Bit(_lithiumBattery1DischargeEnd);
public SinexcelAbnormalFlag LithiumBattery2Full => (SinexcelAbnormalFlag)Bit(_lithiumBattery2Full);
public SinexcelAbnormalFlag LithiumBattery2DischargeEnd => (SinexcelAbnormalFlag)Bit(_lithiumBattery2DischargeEnd);
public SinexcelAbnormalFlag LoadPowerOverload => (SinexcelAbnormalFlag)Bit(_loadPowerOverload);
public SinexcelAbnormalFlag AbnormalLeakageSelfCheck => (SinexcelAbnormalFlag)Bit(_abnormalLeakageSelfCheck);
public SinexcelAbnormalFlag InverterOvertemperatureAlarm => (SinexcelAbnormalFlag)Bit(_inverterOvertemperatureAlarm);
public SinexcelAbnormalFlag InverterOvertemperature => (SinexcelAbnormalFlag)Bit(_inverterOvertemperature);
public SinexcelAbnormalFlag DcConverterOvertemperatureAlarm => (SinexcelAbnormalFlag)Bit(_dcConverterOvertemperatureAlarm);
public SinexcelAbnormalFlag ParallelCommunicationAlarm => (SinexcelAbnormalFlag)Bit(_parallelCommunicationAlarm);
public SinexcelAbnormalFlag SystemDerating => (SinexcelAbnormalFlag)Bit(_systemDerating);
public SinexcelAbnormalFlag InverterRelayOpen => (SinexcelAbnormalFlag)Bit(_inverterRelayOpen);
public SinexcelAbnormalFlag InverterRelayShortCircuit => (SinexcelAbnormalFlag)Bit(_inverterRelayShortCircuit);
public SinexcelAbnormalFlag PvAccessMethodErrorAlarm => (SinexcelAbnormalFlag)Bit(_pvAccessMethodErrorAlarm);
public SinexcelAbnormalFlag ParallelModuleMissing => (SinexcelAbnormalFlag)Bit(_parallelModuleMissing);
public SinexcelAbnormalFlag DuplicateMachineNumbersForParallelModules=> (SinexcelAbnormalFlag)Bit(_duplicateMachineNumbersForParallelModules);
public SinexcelAbnormalFlag ParameterConflictInParallelModule => (SinexcelAbnormalFlag)Bit(_parameterConflictInParallelModule);
public SinexcelAbnormalFlag ReservedAlarms4 => (SinexcelAbnormalFlag)Bit(_reservedAlarms4);
public SinexcelAbnormalFlag ReverseMeterConnection => (SinexcelAbnormalFlag)Bit(_reverseMeterConnection);
public SinexcelAbnormalFlag InverterSealPulse => (SinexcelAbnormalFlag)Bit(_inverterSealPulse);
public SinexcelAbnormalFlag Pv3NotConnected => (SinexcelAbnormalFlag)Bit(_pv3NotConnected);
public SinexcelAbnormalFlag Pv3Overvoltage => (SinexcelAbnormalFlag)Bit(_pv3Overvoltage);
public SinexcelAbnormalFlag Pv3AverageCurrentAnomaly => (SinexcelAbnormalFlag)Bit(_pv3AverageCurrentAnomaly);
public SinexcelAbnormalFlag Pv4NotConnected => (SinexcelAbnormalFlag)Bit(_pv4NotConnected);
public SinexcelAbnormalFlag Pv4Overvoltage => (SinexcelAbnormalFlag)Bit(_pv4Overvoltage);
public SinexcelAbnormalFlag Pv4AverageCurrentAnomaly => (SinexcelAbnormalFlag)Bit(_pv4AverageCurrentAnomaly);
public SinexcelAbnormalFlag Pv3PowerTubeFailure => (SinexcelAbnormalFlag)Bit(_pv3PowerTubeFailure);
public SinexcelAbnormalFlag Pv4PowerTubeFailure => (SinexcelAbnormalFlag)Bit(_pv4PowerTubeFailure);
public SinexcelAbnormalFlag Pv3SoftStartFailure => (SinexcelAbnormalFlag)Bit(_pv3SoftStartFailure);
public SinexcelAbnormalFlag Pv4SoftStartFailure => (SinexcelAbnormalFlag)Bit(_pv4SoftStartFailure);
public SinexcelAbnormalFlag Pv3OverloadTimeout => (SinexcelAbnormalFlag)Bit(_pv3OverloadTimeout);
public SinexcelAbnormalFlag Pv4OverloadTimeout => (SinexcelAbnormalFlag)Bit(_pv4OverloadTimeout);
public SinexcelAbnormalFlag Pv3ReverseConnection => (SinexcelAbnormalFlag)Bit(_pv3ReverseConnection);
public SinexcelAbnormalFlag Pv4ReverseConnection => (SinexcelAbnormalFlag)Bit(_pv4ReverseConnection);
public SinexcelAbnormalFlag AbnormalDieselGeneratorVoltage => (SinexcelAbnormalFlag)Bit(_abnormalDieselGeneratorVoltage);
public SinexcelAbnormalFlag AbnormalDieselGeneratorFrequency => (SinexcelAbnormalFlag)Bit(_abnormalDieselGeneratorFrequency);
public SinexcelAbnormalFlag DieselGeneratorVoltageReverseSequence => (SinexcelAbnormalFlag)Bit(_dieselGeneratorVoltageReverseSequence);
public SinexcelAbnormalFlag DieselGeneratorVoltageOutOfPhase => (SinexcelAbnormalFlag)Bit(_dieselGeneratorVoltageOutOfPhase);
public SinexcelAbnormalFlag LeadBatteryTemperatureAbnormality => (SinexcelAbnormalFlag)Bit(_leadBatteryTemperatureAbnormality);
public SinexcelAbnormalFlag BatteryAccessMethodError => (SinexcelAbnormalFlag)Bit(_batteryAccessMethodError);
public SinexcelAbnormalFlag ReservedAlarms5 => (SinexcelAbnormalFlag)Bit(_reservedAlarms5);
public SinexcelAbnormalFlag Battery1BackupProhibited => (SinexcelAbnormalFlag)Bit(_battery1BackupProhibited);
public SinexcelAbnormalFlag Battery2BackupProhibited => (SinexcelAbnormalFlag)Bit(_battery2BackupProhibited);
public SinexcelAbnormalFlag AbnormalGridCurrent => (SinexcelAbnormalFlag)Bit(_abnormalGridCurrent);
public SinexcelAbnormalFlag GeneratorOverload => (SinexcelAbnormalFlag)Bit(_generatorOverload);
public SinexcelAbnormalFlag BusSoftStartFailure => (SinexcelAbnormalFlag)Bit(_busSoftStartFailure);
public SinexcelAbnormalFlag OpenCircuitOfPowerGridRelay => (SinexcelAbnormalFlag)Bit(_openCircuitOfPowerGridRelay);
public SinexcelAbnormalFlag ShortCircuitOfPowerGridRelay => (SinexcelAbnormalFlag)Bit(_shortCircuitOfPowerGridRelay);
public SinexcelAbnormalFlag GeneratorRelayOpenCircuit => (SinexcelAbnormalFlag)Bit(_generatorRelayOpenCircuit);
public SinexcelAbnormalFlag GeneratorRelayShortCircuit => (SinexcelAbnormalFlag)Bit(_generatorRelayShortCircuit);
public SinexcelAbnormalFlag InsufficientPhotovoltaicPower => (SinexcelAbnormalFlag)Bit(_insufficientPhotovoltaicPower);
public SinexcelAbnormalFlag Photovoltaic1Overcurrent => (SinexcelAbnormalFlag)Bit(_photovoltaic1Overcurrent);
*/
private Int16 _factorFromKwtoW = 1000;
// ───────────────────────────────────────────────
// Public API — Decoded Float Values
// ───────────────────────────────────────────────
// ───────────────────────────────────────────────
// Grid Measurements
// ───────────────────────────────────────────────
public Voltage GridAPhaseVoltage => ConvertBitPatternToFloat(_gridAPhaseVoltage);
public Voltage GridBPhaseVoltage => UIntToFloat(_grid_B_Phase_Voltage);
public Voltage GridCPhaseVoltage => UIntToFloat(_grid_C_Phase_Voltage);
public Voltage GridAbWireVoltage => UIntToFloat(_grid_AB_Wire_Voltage);
public Voltage GridBcWireVoltage => UIntToFloat(_grid_BC_Wire_Voltage);
public Voltage GridCaWireVoltage => UIntToFloat(_grid_CA_Wire_Voltage);
public Frequency GridVoltageFrequency => UIntToFloat(_grid_Voltage_Frequency);
public Current GridAPhaseCurrent => UIntToFloat(_grid_A_Phase_Current);
public Current GridBPhaseCurrent => UIntToFloat(_grid_B_Phase_Current);
public Current GridCPhaseCurrent => UIntToFloat(_grid_C_Phase_Current);
public Current GridNWireCurrent => UIntToFloat(_grid_N_Wire_Current);
public ApparentPower GridAPhaseApparentPower => UIntToFloat(_gridAPhaseApparentPower) * _factorFromKwtoW;
public ApparentPower GridBPhaseApparentPower => UIntToFloat(_gridBPhaseApparentPower) * _factorFromKwtoW;
public ApparentPower GridCPhaseApparentPower => UIntToFloat(_gridCPhaseApparentPower) * _factorFromKwtoW;
public ActivePower GridAPhaseActivePower => UIntToFloat(_gridAPhaseActivePower) * _factorFromKwtoW;
public ActivePower GridBPhaseActivePower => UIntToFloat(_gridBPhaseActivePower) * _factorFromKwtoW;
public ActivePower GridCPhaseActivePower => UIntToFloat(_gridCPhaseActivePower) * _factorFromKwtoW;
public ReactivePower GridAPhaseReactivePower => UIntToFloat(_gridAPhaseReactivePower) * _factorFromKwtoW;
public ReactivePower GridBPhaseReactivePower => UIntToFloat(_gridBPhaseReactivePower) * _factorFromKwtoW;
public ReactivePower GridCPhaseReactivePower => UIntToFloat(_gridCPhaseReactivePower) * _factorFromKwtoW;
// ───────────────────────────────────────────────
// Load Measurements
// ───────────────────────────────────────────────
public Voltage LoadAPhaseVoltage => UIntToFloat(_loadAPhaseVoltage);
public Voltage LoadBPhaseVoltage => UIntToFloat(_loadBPhaseVoltage);
public Voltage LoadCPhaseVoltage => UIntToFloat(_loadCPhaseVoltage);
public Voltage LoadAbWireVoltage => UIntToFloat(_loadABWireVoltage);
public Voltage LoadBcWireVoltage => UIntToFloat(_loadBCWireVoltage);
public Voltage LoadCaWireVoltage => UIntToFloat(_loadCAWireVoltage);
public Frequency LoadVoltageFrequency => UIntToFloat(_loadVoltageFrequency);
public Current LoadAPhaseCurrent => UIntToFloat(_loadAPhaseCurrent);
public Current LoadBPhaseCurrent => UIntToFloat(_loadBPhaseCurrent);
public Current LoadCPhaseCurrent => UIntToFloat(_loadCPhaseCurrent);
public Current LoadNWireCurrent => UIntToFloat(_loadNWireCurrent);
public ApparentPower LoadAPhaseApparentPower => UIntToFloat(_loadAPhaseApparentPower) * _factorFromKwtoW;
public ApparentPower LoadBPhaseApparentPower => UIntToFloat(_loadBPhaseApparentPower) * _factorFromKwtoW;
public ApparentPower LoadCPhaseApparentPower => UIntToFloat(_loadCPhaseApparentPower) * _factorFromKwtoW;
public ActivePower LoadAPhaseActivePower => UIntToFloat(_loadAPhaseActivePower) * _factorFromKwtoW;
public ActivePower LoadBPhaseActivePower => UIntToFloat(_loadBPhaseActivePower) * _factorFromKwtoW;
public ActivePower LoadCPhaseActivePower => UIntToFloat(_loadCPhaseActivePower) * _factorFromKwtoW;
public ActivePower ConsumptionPower => TotalLoadPower;
public ReactivePower LoadAPhaseReactivePower => UIntToFloat(_loadAPhaseReactivePower) * _factorFromKwtoW;
public ReactivePower LoadBPhaseReactivePower => UIntToFloat(_loadBPhaseReactivePower) * _factorFromKwtoW;
public ReactivePower LoadCPhaseReactivePower => UIntToFloat(_loadCPhaseReactivePower) * _factorFromKwtoW;
// ───────────────────────────────────────────────
// Inverter Measurements
// ───────────────────────────────────────────────
public Voltage InverterAPhaseVoltage => UIntToFloat(_inverterAPhaseVoltage);
public Voltage InverterBPhaseVoltage => UIntToFloat(_inverterBPhaseVoltage);
public Voltage InverterCPhaseVoltage => UIntToFloat(_inverterCPhaseVoltage);
public Voltage InverterAbWireVoltage => UIntToFloat(_inverterABWireVoltage);
public Voltage InverterBcWireVoltage => UIntToFloat(_inverterBCWireVoltage);
public Voltage InverterCaWireVoltage => UIntToFloat(_inverterCAWireVoltage);
public ActivePower InverterAPhaseActivePower => UIntToFloat(_inverterAPhaseActivePower) * _factorFromKwtoW;
public ActivePower InverterBPhaseActivePower => UIntToFloat(_inverterBPhaseActivePower) * _factorFromKwtoW;
public ActivePower InverterCPhaseActivePower => UIntToFloat(_inverterCPhaseActivePower) * _factorFromKwtoW;
public ActivePower InverterActivePower => InverterAPhaseActivePower + InverterBPhaseActivePower + InverterCPhaseActivePower;
// ───────────────────────────────────────────────
// DC/AC Temperature Sensors (°C)
// ───────────────────────────────────────────────
public Temperature DcacTemperature1 => UIntToFloat(_dcacTemperature1);
public Temperature DcacTemperature2 => UIntToFloat(_dcacTemperature2);
public Temperature DcacTemperature3 => UIntToFloat(_dcacTemperature3);
public Temperature DcacTemperature4 => UIntToFloat(_dcacTemperature4);
public Temperature DcacTemperature5 => UIntToFloat(_dcacTemperature5);
// ───────────────────────────────────────────────
// Date / Time Information
// ───────────────────────────────────────────────
public UInt16 Year => (UInt16) ConvertBitPatternToFloat(_year);
public UInt16 Month => (UInt16) ConvertBitPatternToFloat(_month);
public UInt16 Day => (UInt16) ConvertBitPatternToFloat(_day);
public UInt16 Hour => (UInt16) ConvertBitPatternToFloat(_hour);
public UInt16 Minute => (UInt16) ConvertBitPatternToFloat(_minute);
public UInt16 Second => (UInt16) ConvertBitPatternToFloat(_second);
public DateTime SystemDateTime => new(Year, Month, Day, Hour, Minute, Second);
// ───────────────────────────────────────────────
// Diesel Generator Measurements
// ───────────────────────────────────────────────
public Voltage DieselGenAPhaseVoltage => ConvertBitPatternToFloat(_dieselGenAPhaseVoltage);
public Voltage DieselGenBPhaseVoltage => ConvertBitPatternToFloat(_dieselGenBPhaseVoltage);
public Voltage DieselGenCPhaseVoltage => ConvertBitPatternToFloat(_dieselGenCPhaseVoltage);
public Voltage DieselGenAbWireVoltage => ConvertBitPatternToFloat(_dieselGenABWireVoltage);
public Voltage DieselGenBcWireVoltage => ConvertBitPatternToFloat(_dieselGenBCWireVoltage);
public Voltage DieselGenCaWireVoltage => ConvertBitPatternToFloat(_dieselGenCAWireVoltage);
public Frequency DieselGenVoltageFrequency => ConvertBitPatternToFloat(_dieselGenVoltageFrequency);
public Current DieselGenAPhaseCurrent => ConvertBitPatternToFloat(_dieselGenAPhaseCurrent);
public Current DieselGenBPhaseCurrent => ConvertBitPatternToFloat(_dieselGenBPhaseCurrent);
public Current DieselGenCPhaseCurrent => ConvertBitPatternToFloat(_dieselGenCPhaseCurrent);
public Current DieselGenNWireCurrent => ConvertBitPatternToFloat(_dieselGenNWireCurrent);
public ApparentPower DieselGenAPhaseApparentPower => ConvertBitPatternToFloat(_dieselGenAPhaseApparentPower) * _factorFromKwtoW;
public ApparentPower DieselGenBPhaseApparentPower => ConvertBitPatternToFloat(_dieselGenBPhaseApparentPower) * _factorFromKwtoW;
public ApparentPower DieselGenCPhaseApparentPower => ConvertBitPatternToFloat(_dieselGenCPhaseApparentPower) * _factorFromKwtoW;
public ActivePower DieselGenAPhaseActivePower => ConvertBitPatternToFloat(_dieselGenAPhaseActivePower) * _factorFromKwtoW;
public ActivePower DieselGenBPhaseActivePower => ConvertBitPatternToFloat(_dieselGenBPhaseActivePower) * _factorFromKwtoW;
public ActivePower DieselGenCPhaseActivePower => ConvertBitPatternToFloat(_dieselGenCPhaseActivePower) * _factorFromKwtoW;
public ReactivePower DieselGenAPhaseReactivePower => ConvertBitPatternToFloat(_dieselGenAPhaseReactivePower) * _factorFromKwtoW;
public ReactivePower DieselGenBPhaseReactivePower => ConvertBitPatternToFloat(_dieselGenBPhaseReactivePower) * _factorFromKwtoW;
public ReactivePower DieselGenCPhaseReactivePower => ConvertBitPatternToFloat(_dieselGenCPhaseReactivePower) * _factorFromKwtoW;
// ───────────────────────────────────────────────
// Photovoltaic and Battery Measurements
// ───────────────────────────────────────────────
public Voltage PvVoltage1 => ConvertBitPatternToFloat(_pvVoltage1);
public Current PvCurrent1 => ConvertBitPatternToFloat(_pvCurrent1);
public ActivePower PvPower1 => ConvertBitPatternToFloat(_pvPower1) *_factorFromKwtoW;
public Voltage PvVoltage2 => ConvertBitPatternToFloat(_pvVoltage2);
public Current PvCurrent2 => ConvertBitPatternToFloat(_pvCurrent2);
public ActivePower PvPower2 => ConvertBitPatternToFloat(_pvPower2) * _factorFromKwtoW;
public Voltage Battery1Voltage => ConvertBitPatternToFloat(_batteryVoltage1);
public Current Battery1Current => ConvertBitPatternToFloat(_batteryCurrent1);
public ActivePower Battery1Power => ConvertBitPatternToFloat(_batteryPower1) * _factorFromKwtoW;
public Percent Battery1Soc => ConvertBitPatternToFloat(_batterySoc1);
public float BatteryFullLoadDuration1 => ConvertBitPatternToFloat(_batteryFullLoadDuration1); // this is in hour
public Voltage Battery2Voltage => ConvertBitPatternToFloat(_batteryVoltage2);
public Current Battery2Current => ConvertBitPatternToFloat(_batteryCurrent2);
public ActivePower Battery2Power => ConvertBitPatternToFloat(_batteryPower2) * _factorFromKwtoW;
public Percent Battery2Soc => ConvertBitPatternToFloat(_batterySoc2);
public float BatteryFullLoadDuration2 => ConvertBitPatternToFloat(_batteryFullLoadDuration2);
public Temperature DcdcTemperature1 => ConvertBitPatternToFloat(_dcdcTemperature1);
public Temperature DcdcTemperature2 => ConvertBitPatternToFloat(_dcdcTemperature2);
public Temperature DcdcTemperature3 => ConvertBitPatternToFloat(_dcdcTemperature3);
public Temperature DcdcTemperature4 => ConvertBitPatternToFloat(_dcdcTemperature4);
public Temperature DcdcTemperature5 => ConvertBitPatternToFloat(_dcdcTemperature5);
// ───────────────────────────────────────────────
// Energy and Power Summary
// ───────────────────────────────────────────────
public Energy TotalEnergyToUser => ConvertBitPatternToFloat(_electricityPurchased);
public Energy TotalEnergyToGrid => ConvertBitPatternToFloat(_electricityFed);
public Energy SelfGeneratedElectricity => ConvertBitPatternToFloat(_selfGeneratedElectricity);
public Energy BatteryCharge => ConvertBitPatternToFloat(_batteryCharge);
public Energy BatteryDischarge => ConvertBitPatternToFloat(_batteryDischarge);
public Energy LoadPowerConsumption => ConvertBitPatternToFloat(_loadPowerConsumption);
public Energy DailySelfGeneratedElectricity => ConvertBitPatternToFloat(_dailySelfGeneratedElectricity);
public Energy DailyElectricityPurchased => ConvertBitPatternToFloat(_dailyElectricityPurchased);
public Energy DailyElectricityFed => ConvertBitPatternToFloat(_dailyElectricityFed);
public Energy BatteryDailyChargeEnergy => ConvertBitPatternToFloat(_dailyBatteryCharge);
public Energy BatteryDailyDischargeEnergy => ConvertBitPatternToFloat(_dailyBatteryDischarge);
public Energy DailyLoadPowerConsumption => ConvertBitPatternToFloat(_dailyLoadPowerConsumption);
public ActivePower TotalPhotovoltaicPower => ConvertBitPatternToFloat(_totalPhotovoltaicPower) * _factorFromKwtoW;
public ActivePower TotalBatteryPower => ConvertBitPatternToFloat(_totalBatteryPower) * _factorFromKwtoW;
public ActivePower TotalLoadPower => ConvertBitPatternToFloat(_totalLoadPower) * _factorFromKwtoW ;
public ActivePower TotalGridPower => ConvertBitPatternToFloat(_totalGridPower) * _factorFromKwtoW ;
public ActivePower ImportantLoadTotalPower => ConvertBitPatternToFloat(_importantLoadTotalPower)* _factorFromKwtoW;
public ActivePower GeneralLoadTotalPower => ConvertBitPatternToFloat(_generalLoadTotalPower)* _factorFromKwtoW;
public Voltage PvVoltage3 => ConvertBitPatternToFloat(_pv3Voltage);
public Current PvCurrent3 => ConvertBitPatternToFloat(_pv3Current);
public ActivePower PvPower3 => ConvertBitPatternToFloat(_pv3Power) * _factorFromKwtoW;
public Voltage PvVoltage4 => ConvertBitPatternToFloat(_pv4Voltage);
public Current PvCurrent4 => ConvertBitPatternToFloat(_pv4Current);
public ActivePower PvPower4 => ConvertBitPatternToFloat(_pv4Power) * _factorFromKwtoW;
public ActivePower GeneratorTotalPower => ConvertBitPatternToFloat(_generatorTotalPower);
public ActivePower PvTotalPower => PvPower1 + PvPower2 + PvPower3 + PvPower4;
// ───────────────────────────────────────────────
// Manufacturer Information & Software Versions
// ───────────────────────────────────────────────
public UInt16 ProtocolVersionNo => _protocolVersionNo; // 0x2000
public UInt16 DcacSoftwareVersionNo => _dcacSoftwareVersionNo; // 0x2001
public UInt16 DcdcSoftwareVersionNo => _dcdcSoftwareVersionNo; // 0x2002
public UInt16 ArmSoftwareVersionNo => _armSoftwareVersionNo; // 0x2003
public UInt16 CpldVersion => _cpldVersion; // 0x2004
public UInt16 AfciSoftwareVersionNo => _afciSoftwareVersionNo; // 0x2005
public SinexcelMachineType MachineType => (SinexcelMachineType)_machineType; // 0x2006
// ───────────────────────────────────────────────
// Device Info & Model
// ───────────────────────────────────────────────
public ApparentPower RatedPowerKva => _ratedPower / 100f; // 0x2008 (value / 100)
public SinexcelModel Model => (SinexcelModel)_model; // 0x200D
public ThreePhaseWireSystem ThreePhaseWireSystem
{
get => (ThreePhaseWireSystem)_threePhaseWireSystem;
set => _threePhaseWireSystem = (UInt32)value;
}
//
public InputFrequency InputFrequencyClass
{
get => (InputFrequency)_inputFrequencyClass;
set => _inputFrequencyClass = (UInt32)value;
}
//
public WorkingMode WorkingMode
{
get => (WorkingMode)(Int32)BitConverter.Int32BitsToSingle(unchecked((Int32)_workingMode));
set => _workingMode = BitConverter.ToUInt32(BitConverter.GetBytes((Single)value), 0);
}
public GridSwitchMethod GridSwitchMethod
{
get => (GridSwitchMethod)(Int32)BitConverter.Int32BitsToSingle(unchecked((Int32)_methodSwitchMode));
set => _methodSwitchMode = BitConverter.ToUInt32(BitConverter.GetBytes((Single)value), 0);
}
// ───────────────────────────────────────────────
// Inverter Control Configuration
// ───────────────────────────────────────────────
public SinexcelUnbalanceCompensation EnableOnGridUnbalanceCompensation
{
get => (SinexcelUnbalanceCompensation)_enableOnGridUnbalanceCompensation;
set => _enableOnGridUnbalanceCompensation = (UInt32)value;
}
/*
public SinexcelTemperatureDrop TemperatureDrop
{
get => (SinexcelTemperatureDrop)ConvertBitPatternToFloat(_temperatureDrop);
//set => _temperatureDrop = (UInt32)value;
}
//
public SinexcelHvrt Hvrt
{
get => (SinexcelHvrt)_hvrt;
// set => _hvrt = (UInt32)value;
}
//
public SinexcelLvrt Lvrt
{
get => (SinexcelLvrt)_lvrt;
// set => _lvrt = (UInt32)value;
}
//
// F//an Gear — numeric [0.5 ~ 1.0], default 1.0
public float FanGear
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_fanGear));
// set => _fanGear = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
*/
//// ───────────────────────────────────────────────
//// Battery Configuration
//// ───────────────────────────────────────────────
public SinexcelBatteryAccessMethod BatteryAccessMethod
{
get => (SinexcelBatteryAccessMethod)_batteryAccessMethod;
set => _batteryAccessMethod = (UInt32)value;
}
public SinexcelMeterAccessEnable MeterAccessEnable
{
get => (SinexcelMeterAccessEnable)ConvertBitPatternToFloat(_meterAccessEnable);
set => _meterAccessEnable = (UInt32)value;
}
public SinexcelBatteryEnable EnableBattery1
{
get => (SinexcelBatteryEnable)ConvertBitPatternToFloat(_enableBattery1);
set => _enableBattery1 = (UInt32)value;
}
public SinexcelBatteryEnable EnableBattery2
{
get => (SinexcelBatteryEnable)ConvertBitPatternToFloat(_enableBattery2);
set => _enableBattery2 = (UInt32)value;
}
public SinexcelPvEnable EnablePv1
{
get => (SinexcelPvEnable)ConvertBitPatternToFloat(_enablePv1);
set => _enablePv1 = (UInt32)value;
}
public SinexcelPvEnable EnablePv2
{
get => (SinexcelPvEnable)ConvertBitPatternToFloat(_enablePv2);
set => _enablePv2 = (UInt32)value;
}
public SinexcelBatteryType BatteryType
{
get => (SinexcelBatteryType)_batteryType;
set => _batteryType = (UInt32)value;
}
public float BatteryCapacity1
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCapacity1));
set => _batteryCapacity1 = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float Battery1MaxChargingCurrent
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_maxChargingCurrentBattery1));
set => _maxChargingCurrentBattery1 = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float Battery1MaxDischargingCurrent
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_maxDischargingCurrentBattery1));
set => _maxDischargingCurrentBattery1 = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float RatedBatteryVoltage1
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_ratedBatteryVoltage1));
set => _ratedBatteryVoltage1 = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float Battery1MinSoc
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_minSocBattery1));
set => _minSocBattery1 = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float SetValueBattery1
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_setValueBattery1));
set => _setValueBattery1 = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
/* public SinexcelActiveChargeDischarge ActiveChargeDischarge
{
get => (SinexcelActiveChargeDischarge)(Int32)BitConverter.Int32BitsToSingle(unchecked((Int32)_activeChargeDischarge));
set => _activeChargeDischarge = BitConverter.ToUInt32(BitConverter.GetBytes((Single)value), 0);
}*/
public float ActiveChargeDischargePower
{
get => ConvertBitPatternToFloat(_activeChargeDischargePower) * _factorFromKwtoW;
set => _activeChargeDischargePower = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0); // we should check this may need to convert from W to KW
}
// ───────────────────────────────────────────────
// Protection & PV Mode
// ───────────────────────────────────────────────
public SinexcelIslandProtection EnableIslandProtection
{
get => (SinexcelIslandProtection)_enableIslandProtection;
set => _enableIslandProtection = (UInt32)value;
}
public SinexcelPvAccessMode PvAccessMode
{
get => (SinexcelPvAccessMode)_pvAccessMode;
set => _pvAccessMode = (UInt32)value;
}
// ───────────────────────────────────────────────
// System-Level Parameters
// ───────────────────────────────────────────────
public float OutputVoltageAdjustmentFactor
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_outputVoltageAdjustmentFactor));
set => _outputVoltageAdjustmentFactor = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float SetValueBatteryUndervoltage1
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_setValueBatteryUndervoltage1));
set => _setValueBatteryUndervoltage1 = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float InverterPowerLimit
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_inverterPowerLimit));
set => _inverterPowerLimit = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
// ───────────────────────────────────────────────
// Battery 2 Parameters
// ───────────────────────────────────────────────
public float Battery2Capacity
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_battery2Capacity));
set => _battery2Capacity = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float Battery2MaxChargingCurrent
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_maxChargingCurrentBattery2));
set => _maxChargingCurrentBattery2 = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float Battery2MaxDischargingCurrent
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_maxDischargingCurrentBattery2));
set => _maxDischargingCurrentBattery2 = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float Battery2RatedVoltage
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_battery2RatedVoltage));
set => _battery2RatedVoltage = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float Battery2MinSoc
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_battery2MinSoc));
set => _battery2MinSoc = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float Battery2OverVoltageSetting
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_battery2OverVoltageSetting));
set => _battery2OverVoltageSetting = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float Battery2UnderVoltageSetpoint
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_battery2UnderVoltageSetpoint));
set => _battery2UnderVoltageSetpoint = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float Battery1BackupSoc
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_battery1BackupSOC));
set => _battery1BackupSOC = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float Battery2BackupSoc
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_battery2BackupSOC));
set => _battery2BackupSOC = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
// to be tested
public float EnableGridExport
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_enableGridExport));
set => _enableGridExport = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float PowerGridExportLimit
{
get => BitConverter.Int32BitsToSingle(unchecked((int)_powerGridExportLimit));
set => _powerGridExportLimit = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
// ───────────────────────────────────────────────
// Parallel / System Settings
// ───────────────────────────────────────────────
public SinexcelMachineMode MachineMode
{
get => (SinexcelMachineMode)ConvertBitPatternToFloat(_singleOrParallelMachine);
set => _singleOrParallelMachine = (UInt32)value;
}
public UInt32 NumberOfSystemModules
{
get => (UInt32)ConvertBitPatternToFloat(_numberOfSystemModules);
set => _numberOfSystemModules = value;
}
public UInt32 ParallelModuleMachineNumber
{
get => (UInt32)ConvertBitPatternToFloat(_parallelModuleMachineNumber);
set => _parallelModuleMachineNumber = value;
}
public AccreditedCountry AccreditedCountry
{
get => (AccreditedCountry)(Int32)BitConverter.Int32BitsToSingle(unchecked((Int32)_accreditedCountries));
set => _accreditedCountries = BitConverter.ToUInt32(BitConverter.GetBytes((Single)value), 0);
}
// ───────────────────────────────────────────────
// Control Commands
// ───────────────────────────────────────────────
public float PowerOn
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_powerOn));
set => _powerOn = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float PowerOff
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_powerOff));
set => _powerOff = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float FaultClearing
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_faultClearing));
set => _faultClearing = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
//
// ───────────────────────────────────────────────
// Meter & Battery Control
// ───────────────────────────────────────────────
public float MeterReverseManualDetection
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_meterReverseManualDetection));
set => _meterReverseManualDetection = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
// This causing the inverter to switch off, please consider testing it first before uncommenting
/*public SinexcelBatteryRating SinexcelBatteryRating
{
get => (SinexcelBatteryRating)(Int32)BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryVoltageRating));
set => _batteryVoltageRating = BitConverter.ToUInt32(BitConverter.GetBytes((Single)value), 0);
}*/
public float Battery1Activation
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_battery1Activation));
set => _battery1Activation = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
//
public float Battery2Activation
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_battery2Activation));
set => _battery2Activation = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
// ───────────────────────────────────────────────
// Electric Meter Operating State
// ───────────────────────────────────────────────
public MeterStatus ElectricMeterOperatingState
{
get => (MeterStatus)BitConverter.Int32BitsToSingle(unchecked((Int32)_electricMeterOperatingState)); // 0 = Offline, 1 = Online
}
// ───────────────────────────────────────────────
// Electric Meter Voltages (V)
// ───────────────────────────────────────────────
public Voltage ElectricMeterAPhaseVoltage
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_electricMeterAPhaseVoltage));
}
public Voltage ElectricMeterBPhaseVoltage
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_electricMeterBPhaseVoltage));
}
public Voltage ElectricMeterCPhaseVoltage
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_electricMeterCPhaseVoltage));
}
// ───────────────────────────────────────────────
// Electric Meter Currents (A)
// ───────────────────────────────────────────────
public Current ElectricMeterAPhaseCurrent
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_electricMeterAPhaseCurrent));
}
public Current ElectricMeterBPhaseCurrent
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_electricMeterBPhaseCurrent));
}
public Current ElectricMeterCPhaseCurrent
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_electricMeterCPhaseCurrent));
}
// ───────────────────────────────────────────────
// Electric Meter Active Power (kW)
// ───────────────────────────────────────────────
public ActivePower ElectricMeterAPhaseActivePower
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_electricMeterAPhaseActivePower)) * _factorFromKwtoW;
}
public ActivePower ElectricMeterBPhaseActivePower
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_electricMeterBPhaseActivePower)) * _factorFromKwtoW;
}
public ActivePower ElectricMeterCPhaseActivePower
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_electricMeterCPhaseActivePower)) * _factorFromKwtoW;
}
public ActivePower GridPower
{
get => ElectricMeterAPhaseActivePower + ElectricMeterBPhaseActivePower + ElectricMeterCPhaseActivePower;
}
// Energy (kW·h)
public Energy Battery1TotalChargingEnergy => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab1TotalChargingEnergy)); // 0xB0FC
public Energy Battery1TotalDischargedEnergy => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab1TotalDischargedEnergy)); // 0xB0FE
// Pack totals and status
public Voltage Battery1PackTotalVoltage => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab1PackTotalVoltage)); // 0xB100 (0.01 V resolution per spec)
public Current Battery1PackTotalCurrent => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab1PackTotalCurrent)); // 0xB102 (0.01 A resolution per spec)
public Temperature Battery1Temperature => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab1Temperature)); // 0xB104 (0.01 °C resolution per spec)
public Percent Battery1SocSecondvalue => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab1Soc)); // 0xB106 %
public Percent Battery1Soh => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab1Soh)); // 0xB108 %
// Energy (kW·h)
public float Battery2TotalChargingEnergy => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab2TotalChargingEnergy)); // 0xB1FC
public float Battery2TotalDischargedEnergy => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab2TotalDischargedEnergy)); // 0xB1FE
// Pack Voltage / Current / Temperature
public Voltage Battery2PackTotalVoltage => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab2PackTotalVoltage)); // 0xB200 (0.01 V resolution)
public Current Battery2PackTotalCurrent => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab2PackTotalCurrent)); // 0xB202 (0.01 A resolution)
public Percent Battery2Socsecondvalue => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab2Soc)); // 0xB206 %
public Percent Battery2Soh => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab2Soh)); // 0xB208 %
// Repetitive-week mask (bit-mapped 06 = SunSat)
public SinexcelWeekDays RepetitiveWeeks
{
get => (SinexcelWeekDays)(_repetitiveWeeks & 0x7F); // only 7 bits used
set => _repetitiveWeeks = (UInt32)value;
}
// Effective start / end as UNIX timestamps
public DateTime EffectiveStartDate
{
get => DateTimeOffset.FromUnixTimeSeconds(_effectiveStartDate).DateTime;
set => _effectiveStartDate = (UInt32)new DateTimeOffset(value).ToUnixTimeSeconds();
}
public DateTime EffectiveEndDate
{
get => DateTimeOffset.FromUnixTimeSeconds(_effectiveEndDate).DateTime;
set => _effectiveEndDate = (UInt32)new DateTimeOffset(value).ToUnixTimeSeconds();
}
// Charging power during time period 1 (kW)
public float ChargingPowerPeriod1
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_chargingPowerPeriod1));
set => _chargingPowerPeriod1 = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
public float DishargingPowerPeriod1
{
get => BitConverter.Int32BitsToSingle(unchecked((Int32)_dischargingPowerPeriod1));
set => _dischargingPowerPeriod1 = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
}
// ───────────────────────────────────────────────
// Charging period 1
// ───────────────────────────────────────────────
public TimeSpan ChargeStartTimePeriod1
{
get => ConvertToTimeSpan(_chargeStartTimePeriod1);
set => _chargeStartTimePeriod1 = ConvertFromTimeSpan(value);
}
public TimeSpan ChargeEndTimePeriod1
{
get => ConvertToTimeSpan(_chargeEndTimePeriod1);
set => _chargeEndTimePeriod1 = ConvertFromTimeSpan(value);
}
// ───────────────────────────────────────────────
// Discharging period 1
// ───────────────────────────────────────────────
public TimeSpan DischargeStartTimePeriod1
{
get => ConvertToTimeSpan(_dischargeStartTimePeriod1);
set => _dischargeStartTimePeriod1 = ConvertFromTimeSpan(value);
}
//
public TimeSpan DischargeEndTimePeriod1
{
get => ConvertToTimeSpan(_dischargeEndTimePeriod1);
set => _dischargeEndTimePeriod1 = ConvertFromTimeSpan(value);
}
// ───────────────────────────────────────────────
// Conversion methodes
// ───────────────────────────────────────────────
private static TimeSpan ConvertToTimeSpan(UInt32 raw)
{
// raw is IEEE754 float bits, e.g. 0x44640000 for 912.0
float f = BitConverter.Int32BitsToSingle(unchecked((int)raw));
int hhmm = (int)Math.Round(f);
int hours = hhmm / 100;
int minutes = hhmm % 100;
return new TimeSpan(hours, minutes, 0);
}
private static UInt32 ConvertFromTimeSpan(TimeSpan time)
{
int hhmm = time.Hours * 100 + time.Minutes; // e.g. 9*100+12 = 912
float f = (float)hhmm; // 912.0f
// convert float to raw IEEE754 bits
return BitConverter.ToUInt32(BitConverter.GetBytes(f), 0); // e.g. 0x44640000
}
private static Single IntToFloat(Int32 intValue)
{
byte[] intBytes = BitConverter.GetBytes(intValue);
float f = BitConverter.ToSingle(intBytes, 0);
return f;
}
private static Single UIntToFloat(UInt32 uintValue)
{
byte[] uintBytes = BitConverter.GetBytes(uintValue);
float f = BitConverter.ToSingle(uintBytes, 0);
return f;
}
public static float ConvertBitPatternToFloat(uint rawValue)
{
byte[] bytes = BitConverter.GetBytes(rawValue);
return BitConverter.ToSingle(bytes, 0);
}
}