diff --git a/csharp/Sinexcel 12K TL/SinexcelRecord.Api.cs b/csharp/Sinexcel 12K TL/SinexcelRecord.Api.cs index 50905a5b7..9e97fa23c 100644 --- a/csharp/Sinexcel 12K TL/SinexcelRecord.Api.cs +++ b/csharp/Sinexcel 12K TL/SinexcelRecord.Api.cs @@ -215,268 +215,269 @@ public partial class SinexcelRecord 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 ThreePhaseWireSystem ThreePhaseWireSystem + //{ + // get => (ThreePhaseWireSystem)_threePhaseWireSystem; + // //set => _threePhaseWireSystem = (UInt32)value; + //} +// + //public InputFrequency InputFrequencyClass + //{ + // get => (InputFrequency)_inputFrequencyClass; + // //set => _inputFrequencyClass = (UInt32)value; + //} +// public WorkingMode WorkingMode { - get => (WorkingMode)ConvertBitPatternToFloat(_workingMode); - set => _workingMode = (UInt32)value; + get => (WorkingMode)(int)BitConverter.Int32BitsToSingle(unchecked((int)_workingMode)); + set => _workingMode = BitConverter.ToUInt32(BitConverter.GetBytes((float)value), 0); } - public GridSwitchMethod GridSwitchMethod - { - get => (GridSwitchMethod)_methodSwitchMode; - set => _methodSwitchMode = (UInt32)value; - } - - // ─────────────────────────────────────────────── - // 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; - } - -// Fan 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)ConvertBitPatternToFloat(_activeChargeDischarge); - set => _activeChargeDischarge = (UInt32)value; - } - - 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); - } - - // ─────────────────────────────────────────────── - // 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)ConvertBitPatternToFloat(_accreditedCountries); - set => _accreditedCountries = (UInt32)value; - } - - // ─────────────────────────────────────────────── - // Control Commands - // ─────────────────────────────────────────────── +// + //public GridSwitchMethod GridSwitchMethod + //{ + // get => (GridSwitchMethod)_methodSwitchMode; + // //set => _methodSwitchMode = (UInt32)value; + //} +// + //// ─────────────────────────────────────────────── + //// 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)ConvertBitPatternToFloat(_activeChargeDischarge); + // //set => _activeChargeDischarge = (UInt32)value; + //} + // + //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); + //} + // + //// ─────────────────────────────────────────────── + //// 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)ConvertBitPatternToFloat(_accreditedCountries); + // //set => _accreditedCountries = (UInt32)value; + //} + // + //// ─────────────────────────────────────────────── + //// Control Commands + //// ─────────────────────────────────────────────── public float PowerOn { get => BitConverter.Int32BitsToSingle(unchecked((Int32)_powerOn)); @@ -488,39 +489,39 @@ public partial class SinexcelRecord 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); - } - - public SinexcelBatteryRating BatteryVoltageRating - { - get => (SinexcelBatteryRating)ConvertBitPatternToFloat(_batteryVoltageRating); - set => _batteryVoltageRating = (UInt32)value; - } - - 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); - } +// + //public float FaultClearingf + //{ + // 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); + //} +// + //public SinexcelBatteryRating BatteryVoltageRating + //{ + // get => (SinexcelBatteryRating)ConvertBitPatternToFloat(_batteryVoltageRating); + // //set => _batteryVoltageRating = (UInt32)value; + //} +// + //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 @@ -589,7 +590,7 @@ public partial class SinexcelRecord 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 @@ -611,46 +612,66 @@ public partial class SinexcelRecord public Temperature Battery2Socsecondvalue => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab2Soc)); // 0xB206 % public Percent Battery2Soh => BitConverter.Int32BitsToSingle(unchecked((Int32)_batteryCab2Soh)); // 0xB208 % + // Repetitive-week mask (bit-mapped 0–6 = Sun–Sat) + //public float TimedChargeAndDischargeOff + //{ + // get => BitConverter.Int32BitsToSingle(unchecked((Int32)_Timed_Charge_and_Discharge_Off)) ; // only 7 bits used + // //set => _Timed_Charge_and_Discharge_Off = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0); + //} + // Repetitive-week mask (bit-mapped 0–6 = Sun–Sat) + /* public float OtherTimePeriodMode + { + get => _Other_time_period_mode ; // only 7 bits used + //set => _Other_time_period_mode = (UInt32)value; + }*/ + + + // Repetitive-week mask (bit-mapped 0–6 = Sun–Sat) public SinexcelWeekDays RepetitiveWeeks { get => (SinexcelWeekDays)(_repetitiveWeeks & 0x7F); // only 7 bits used - set => _repetitiveWeeks = (UInt32)value; + 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(); + set => _effectiveStartDate = (UInt32)new DateTimeOffset(value).ToUnixTimeSeconds(); } - +// public DateTime EffectiveEndDate { get => DateTimeOffset.FromUnixTimeSeconds(_effectiveEndDate).DateTime; - set => _effectiveEndDate = (UInt32)new DateTimeOffset(value).ToUnixTimeSeconds(); + set => _effectiveEndDate = (UInt32)new DateTimeOffset(value).ToUnixTimeSeconds(); } - - // Charging power during time period 1 (kW) +// // Charging power during time period 1 (kW) public float ChargingPowerPeriod1 { get => BitConverter.Int32BitsToSingle(unchecked((Int32)_chargingPowerPeriod1)); - set => _chargingPowerPeriod1 = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0); + 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); + set => _chargeStartTimePeriod1 = ConvertFromTimeSpan(value); } - public TimeSpan ChargeEndTimePeriod1 { get => ConvertToTimeSpan(_chargeEndTimePeriod1); - set => _chargeEndTimePeriod1 = ConvertFromTimeSpan(value); + set => _chargeEndTimePeriod1 = ConvertFromTimeSpan(value); } // ─────────────────────────────────────────────── @@ -659,34 +680,41 @@ public partial class SinexcelRecord public TimeSpan DischargeStartTimePeriod1 { get => ConvertToTimeSpan(_dischargeStartTimePeriod1); - set => _dischargeStartTimePeriod1 = ConvertFromTimeSpan(value); + set => _dischargeStartTimePeriod1 = ConvertFromTimeSpan(value); } - +// public TimeSpan DischargeEndTimePeriod1 { get => ConvertToTimeSpan(_dischargeEndTimePeriod1); - set => _dischargeEndTimePeriod1 = ConvertFromTimeSpan(value); - }*/ + set => _dischargeEndTimePeriod1 = ConvertFromTimeSpan(value); + } // ─────────────────────────────────────────────── // Conversion methodes // ─────────────────────────────────────────────── - private static TimeSpan ConvertToTimeSpan(UInt32 value) + private static TimeSpan ConvertToTimeSpan(UInt32 raw) { - int hhmm = (int)value; + // 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; - return (UInt32)hhmm; + 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); diff --git a/csharp/Sinexcel 12K TL/SinexcelRecord.Modbus.cs b/csharp/Sinexcel 12K TL/SinexcelRecord.Modbus.cs index 09f952c25..39197e941 100644 --- a/csharp/Sinexcel 12K TL/SinexcelRecord.Modbus.cs +++ b/csharp/Sinexcel 12K TL/SinexcelRecord.Modbus.cs @@ -226,70 +226,70 @@ public partial class SinexcelRecord // ─────────────────────────────────────────────── // System configuration / operation registers // ─────────────────────────────────────────────── - [HoldingRegister(12294, writable: true)] private UInt32 _threePhaseWireSystem; // 0x3006 - [HoldingRegister(12296, writable: true)] private UInt32 _remainnotused; // 0x3008 - [HoldingRegister(12298, writable: true)] private UInt32 _inputFrequencyClass; // 0x300A + //[HoldingRegister(12294, writable: true)] private UInt32 _threePhaseWireSystem; // 0x3006 + //[HoldingRegister(12296, writable: true)] private UInt32 _remainnotused; // 0x3008 + //[HoldingRegister(12298, writable: true)] private UInt32 _inputFrequencyClass; // 0x300A [HoldingRegister(12300, writable: true)] private UInt32 _workingMode; // 0x300C - [HoldingRegister(12302, writable: true)] private UInt32 _methodSwitchMode; // 0x300E + //[HoldingRegister(12302, writable: true)] private UInt32 _methodSwitchMode; // 0x300E // ─────────────────────────────────────────────── // Inverter Control and Protection Configuration // ─────────────────────────────────────────────── - [HoldingRegister(12304, writable: true)] private UInt32 _enableOnGridUnbalanceCompensation; // 0x3010 - [HoldingRegister(12306, writable: true)] private UInt32 _temperatureDrop; // 0x3012 - [HoldingRegister(12308, writable: true)] private UInt32 _hvrt; // 0x3014 - [HoldingRegister(12310, writable: true)] private UInt32 _lvrt; // 0x3016 - [HoldingRegister(12312, writable: true)] private UInt32 _fanGear; // 0x3018 + //[HoldingRegister(12304, writable: true)] private UInt32 _enableOnGridUnbalanceCompensation; // 0x3010 + //[HoldingRegister(12306, writable: true)] private UInt32 _temperatureDrop; // 0x3012 + //[HoldingRegister(12308, writable: true)] private UInt32 _hvrt; // 0x3014 + //[HoldingRegister(12310, writable: true)] private UInt32 _lvrt; // 0x3016 + //[HoldingRegister(12312, writable: true)] private UInt32 _fanGear; // 0x3018 // ─────────────────────────────────────────────── // Battery & PV Configuration // ─────────────────────────────────────────────── - [HoldingRegister(12336, writable: true)] private UInt32 _batteryAccessMethod; // 0x3030 - [HoldingRegister(12338, writable: true)] private UInt32 _meterAccessEnable; // 0x3032 - [HoldingRegister(12340, writable: true)] private UInt32 _enableBattery1; // 0x3034 - [HoldingRegister(12342, writable: true)] private UInt32 _enableBattery2; // 0x3036 - [HoldingRegister(12344, writable: true)] private UInt32 _enablePv1; // 0x3038 - [HoldingRegister(12346, writable: true)] private UInt32 _enablePv2; // 0x303A - [HoldingRegister(12348, writable: true)] private UInt32 _batteryType; // 0x303C - [HoldingRegister(12350, writable: true)] private UInt32 _batteryCapacity1; // 0x303E - [HoldingRegister(12352, writable: true)] private UInt32 _maxChargingCurrentBattery1; // 0x3040 - [HoldingRegister(12354, writable: true)] private UInt32 _maxDischargingCurrentBattery1; // 0x3042 - [HoldingRegister(12362, writable: true)] private UInt32 _ratedBatteryVoltage1; // 0x304A - [HoldingRegister(12358, writable: true)] private UInt32 _minSocBattery1; // 0x3046 - [HoldingRegister(12360, writable: true)] private UInt32 _setValueBattery1; // 0x3048 - [HoldingRegister(12364, writable: true)] private UInt32 _activeChargeDischarge; // 0x304A - [HoldingRegister(12366, writable: true)] private UInt32 _activeChargeDischargePower; // 0x304C - [HoldingRegister(12380, writable: true)] private UInt32 _enableIslandProtection; // 0x305C - [HoldingRegister(12382, writable: true)] private UInt32 _pvAccessMode; // 0x305E + //[HoldingRegister(12336, writable: true)] private UInt32 _batteryAccessMethod; // 0x3030 + //[HoldingRegister(12338, writable: true)] private UInt32 _meterAccessEnable; // 0x3032 + //[HoldingRegister(12340, writable: true)] private UInt32 _enableBattery1; // 0x3034 + //[HoldingRegister(12342, writable: true)] private UInt32 _enableBattery2; // 0x3036 + //[HoldingRegister(12344, writable: true)] private UInt32 _enablePv1; // 0x3038 + //[HoldingRegister(12346, writable: true)] private UInt32 _enablePv2; // 0x303A + //[HoldingRegister(12348, writable: true)] private UInt32 _batteryType; // 0x303C + //[HoldingRegister(12350, writable: true)] private UInt32 _batteryCapacity1; // 0x303E + //[HoldingRegister(12352, writable: true)] private UInt32 _maxChargingCurrentBattery1; // 0x3040 + //[HoldingRegister(12354, writable: true)] private UInt32 _maxDischargingCurrentBattery1; // 0x3042 + //[HoldingRegister(12362, writable: true)] private UInt32 _ratedBatteryVoltage1; // 0x304A + //[HoldingRegister(12358, writable: true)] private UInt32 _minSocBattery1; // 0x3046 + //[HoldingRegister(12360, writable: true)] private UInt32 _setValueBattery1; // 0x3048 + //[HoldingRegister(12364, writable: true)] private UInt32 _activeChargeDischarge; // 0x304A + //[HoldingRegister(12366, writable: true)] private UInt32 _activeChargeDischargePower; // 0x304C + //[HoldingRegister(12380, writable: true)] private UInt32 _enableIslandProtection; // 0x305C + //[HoldingRegister(12382, writable: true)] private UInt32 _pvAccessMode; // 0x305E // ─────────────────────────────────────────────── // System & Battery-2 Configuration // ─────────────────────────────────────────────── - [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(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(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(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 // ─────────────────────────────────────────────── // System Control & Diagnostic Registers // ─────────────────────────────────────────────── [HoldingRegister(15426, writable: true)] private UInt32 _powerOn; // 0x3C42 [HoldingRegister(15428, writable: true)] private UInt32 _powerOff; // 0x3C44 - [HoldingRegister(15430, writable: true)] private UInt32 _faultClearing; // 0x3C46 - [HoldingRegister(15518, writable: true)] private UInt32 _meterReverseManualDetection; // 0x3C9E - [HoldingRegister(15520, writable: true)] private UInt32 _batteryVoltageRating; // 0x3CA0 - [HoldingRegister(15524, writable: true)] private UInt32 _battery1Activation; // 0x3CA4 - [HoldingRegister(15526, writable: true)] private UInt32 _battery2Activation; // 0x3CA6 + //[HoldingRegister(15430, writable: true)] private UInt32 _faultClearing; // 0x3C46 + //[HoldingRegister(15518, writable: true)] private UInt32 _meterReverseManualDetection; // 0x3C9E + //[HoldingRegister(15520, writable: true)] private UInt32 _batteryVoltageRating; // 0x3CA0 + //[HoldingRegister(15524, writable: true)] private UInt32 _battery1Activation; // 0x3CA4 + //[HoldingRegister(15526, writable: true)] private UInt32 _battery2Activation; // 0x3CA6 // ─────────────────────────────────────────────── @@ -308,7 +308,7 @@ public partial class SinexcelRecord [HoldingRegister(41234)] private UInt32 _electricMeterAPhaseActivePower; // 0xA112 [HoldingRegister(41236)] private UInt32 _electricMeterBPhaseActivePower; // 0xA114 [HoldingRegister(41238)] private UInt32 _electricMeterCPhaseActivePower; // 0xA116 - /* + // ─────────────────────────────────────────────── // Battery Cabinet 1 — Energy / Pack measurements (read-only) // ─────────────────────────────────────────────── @@ -336,10 +336,15 @@ public partial class SinexcelRecord // ─────────────────────────────────────────────── // Time-based scheduling (period 1) configuration // ─────────────────────────────────────────────── + + //[HoldingRegister(49328, writable: true)] private UInt32 _Timed_Charge_and_Discharge_Off; // 0xC0B4, bit flags Sun–Sat + //[HoldingRegister(49330, writable: true)] private UInt32 _Other_time_period_mode; // 0xC0B4, bit flags Sun–Sat [HoldingRegister(49332, writable: true)] private UInt32 _repetitiveWeeks; // 0xC0B4, bit flags Sun–Sat [HoldingRegister(49334, writable: true)] private UInt32 _effectiveStartDate; // 0xC0B6, UNIX timestamp (UTC+offset) [HoldingRegister(49336, writable: true)] private UInt32 _effectiveEndDate; // 0xC0B8, UNIX timestamp (UTC+offset) [HoldingRegister(49338, writable: true)] private UInt32 _chargingPowerPeriod1; // 0xC0BA, float [0–50] kW, default 5 + [HoldingRegister(49340, writable: true)] private UInt32 _dischargingPowerPeriod1; // 0xC0BA, float [0–50] kW, default 5 + // ─────────────────────────────────────────────── // Time-based charge/discharge schedule period 1 @@ -348,5 +353,5 @@ public partial class SinexcelRecord [HoldingRegister(49174, writable: true)] private UInt32 _chargeEndTimePeriod1; // 0xC016 [0-2359] (end) [HoldingRegister(49176, writable: true)] private UInt32 _dischargeStartTimePeriod1; // 0xC018 [0-2359] (start) [HoldingRegister(49178, writable: true)] private UInt32 _dischargeEndTimePeriod1; // 0xC01A [0-2359] (end) -*/ + } \ No newline at end of file