From 51b8dada6c0331a1e5d05ea98ad23ba1e9b792bf Mon Sep 17 00:00:00 2001 From: atef Date: Fri, 10 Apr 2026 15:24:33 +0200 Subject: [PATCH] Correct Sinexcel grid power sign and fix the numbering of few wrong register --- csharp/Sinexcel 12K TL/SinexcelRecord.Api.cs | 8 +++--- .../Sinexcel 12K TL/SinexcelRecord.Modbus.cs | 26 +++++++++---------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/csharp/Sinexcel 12K TL/SinexcelRecord.Api.cs b/csharp/Sinexcel 12K TL/SinexcelRecord.Api.cs index 0826b112e..b71d30a21 100644 --- a/csharp/Sinexcel 12K TL/SinexcelRecord.Api.cs +++ b/csharp/Sinexcel 12K TL/SinexcelRecord.Api.cs @@ -195,6 +195,8 @@ public partial class SinexcelRecord private readonly Int16 _factorFromKwtoW = 1000; + private readonly Int16 _correctingSign = -1; + // ─────────────────────────────────────────────── // Public API — Decoded Float Values // ─────────────────────────────────────────────── @@ -375,7 +377,7 @@ public partial class SinexcelRecord 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 TotalGridPower => ConvertBitPatternToFloat(_totalGridPower) * _factorFromKwtoW * _correctingSign ; // we correct sign public ActivePower ImportantLoadTotalPower => ConvertBitPatternToFloat(_importantLoadTotalPower)* _factorFromKwtoW; public ActivePower GeneralLoadTotalPower => ConvertBitPatternToFloat(_generalLoadTotalPower)* _factorFromKwtoW; public Voltage PvVoltage3 => ConvertBitPatternToFloat(_pv3Voltage); @@ -663,7 +665,7 @@ public partial class SinexcelRecord // ─────────────────────────────────────────────── // Parallel / System Settings // ─────────────────────────────────────────────── - public SinexcelMachineMode MachineMode + /* public SinexcelMachineMode MachineMode { get => (SinexcelMachineMode)ConvertBitPatternToFloat(_singleOrParallelMachine); set => _singleOrParallelMachine = (UInt32)value; @@ -686,7 +688,7 @@ public partial class SinexcelRecord get => (AccreditedCountry)(Int32)BitConverter.Int32BitsToSingle(unchecked((Int32)_accreditedCountries)); set => _accreditedCountries = BitConverter.ToUInt32(BitConverter.GetBytes((Single)value), 0); } - + */ // ─────────────────────────────────────────────── // Control Commands // ─────────────────────────────────────────────── diff --git a/csharp/Sinexcel 12K TL/SinexcelRecord.Modbus.cs b/csharp/Sinexcel 12K TL/SinexcelRecord.Modbus.cs index f94990f32..0318fb7c7 100644 --- a/csharp/Sinexcel 12K TL/SinexcelRecord.Modbus.cs +++ b/csharp/Sinexcel 12K TL/SinexcelRecord.Modbus.cs @@ -440,24 +440,24 @@ public partial class SinexcelRecord [HoldingRegister(12384, writable: true)] private UInt32 _outputVoltageAdjustmentFactor; // 0x3060 [HoldingRegister(12386, writable: true)] private UInt32 _setValueBatteryUndervoltage1; // 0x3062 [HoldingRegister(12388, writable: true)] private UInt32 _inverterPowerLimit; // 0x3064 - [HoldingRegister(12400, writable: true)] private UInt32 _battery2Capacity; // 0x30B0 - [HoldingRegister(12402, writable: true)] private UInt32 _maxChargingCurrentBattery2; // 0x30B2 - [HoldingRegister(12404, writable: true)] private UInt32 _maxDischargingCurrentBattery2; // 0x30B4 - [HoldingRegister(12406, writable: true)] private UInt32 _battery2RatedVoltage; // 0x30B6 - [HoldingRegister(12408, writable: true)] private UInt32 _battery2MinSoc; // 0x30B8 - [HoldingRegister(12410, writable: true)] private UInt32 _battery2OverVoltageSetting; // 0x30BA - [HoldingRegister(12412, writable: true)] private UInt32 _battery2UnderVoltageSetpoint; // 0x30BC + [HoldingRegister(12464, writable: true)] private UInt32 _battery2Capacity; // 0x30B0 + [HoldingRegister(12466, writable: true)] private UInt32 _maxChargingCurrentBattery2; // 0x30B2 + [HoldingRegister(12468, writable: true)] private UInt32 _maxDischargingCurrentBattery2; // 0x30B4 + [HoldingRegister(12470, writable: true)] private UInt32 _battery2RatedVoltage; // 0x30B6 + [HoldingRegister(12472, writable: true)] private UInt32 _battery2MinSoc; // 0x30B8 + [HoldingRegister(12474, writable: true)] private UInt32 _battery2OverVoltageSetting; // 0x30BA + [HoldingRegister(12476, writable: true)] private UInt32 _battery2UnderVoltageSetpoint; // 0x30BC // - [HoldingRegister(12414, writable: true)] private UInt32 _singleOrParallelMachine; // 0x30BE - [HoldingRegister(12416, writable: true)] private UInt32 _numberOfSystemModules; // 0x30C0 - [HoldingRegister(12418, writable: true)] private UInt32 _parallelModuleMachineNumber; // 0x30C2 - [HoldingRegister(12420, writable: true)] private UInt32 _accreditedCountries; // 0x30C4 + /* [HoldingRegister(12478, writable: true)] private UInt32 _singleOrParallelMachine; // 0x30BE // to be verified, writing not allowed + [HoldingRegister(12480, writable: true)] private UInt32 _numberOfSystemModules; // 0x30C0 // to be verified, writing not allowed + [HoldingRegister(12482, writable: true)] private UInt32 _parallelModuleMachineNumber; // 0x30C2 // to be verified, writing not allowed + [HoldingRegister(12484, writable: true)] private UInt32 _accreditedCountries; */ // 0x30C4 // to be verified, writing not allowed [HoldingRegister(12618, writable: true)] private UInt32 _battery1BackupSOC; // 0x314A [HoldingRegister(12620, writable: true)] private UInt32 _battery2BackupSOC; // 0x314C - [HoldingRegister(12746, writable: true)] private UInt32 _enableGridExport; // 0x314A - [HoldingRegister(12748, writable: true)] private UInt32 _powerGridExportLimit; // 0x314C + [HoldingRegister(12746, writable: true)] private UInt32 _enableGridExport; // 0x31CA + [HoldingRegister(12748, writable: true)] private UInt32 _powerGridExportLimit; // 0x31CC // ───────────────────────────────────────────────