diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterPowerCorrectionFile.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterPowerCorrectionFile.cs
index ed07e2f1..2584dad1 100644
--- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterPowerCorrectionFile.cs
+++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterPowerCorrectionFile.cs
@@ -1,4 +1,6 @@
using System;
+using System.Collections.Generic;
+using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
{
@@ -10,14 +12,19 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
///
/// Drive and name for power correction file stored on meter
///
- public const String StrMeterPowerCorrectionFilePathName = "1\\powcorr";
+ public const String StrMeterPowCorrFileName = "1\\powcorr";
+
+ private readonly GenesisMeter _currentGenesis;
+ private readonly MeterFile _meterFile;
private const Int32 MeterPwrCorrFileLengthIndex = 0;
private const Int32 MeterPwrCorrFileLengthSize = 2;
private const Int32 MeterPwrCorrFileCrcIndex = MeterPwrCorrFileLengthIndex + MeterPwrCorrFileLengthSize;
private const Int32 MeterPwrCorrFileCrcSize= 2;
private const Int32 MeterPwrCorrFileDataIndex = MeterPwrCorrFileCrcIndex + MeterPwrCorrFileCrcSize;
+ private List_meterBinData = new List();
+
///
/// Detected FW version before maintenance
///
@@ -97,5 +104,39 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// CRC of power correction file
///
public UInt32 MeterPowerCorrectionCRC { get; set; }
+
+ ///
+ /// Ctor
+ ///
+ ///
+ ///
+ /// - Initial.
+ ///
+ public MeterPowerCorrectionFile(GenesisMeter currentGenesis)
+ {
+ _currentGenesis = currentGenesis;
+ _meterFile = new MeterFile(_currentGenesis);
+ }
+
+ ///
+ /// Read power correction meter file.
+ ///
+ /// true: file found
+ ///
+ /// - Initial
+ ///
+ public Boolean ReadPowCorrMeterFile()
+ {
+ if (_currentGenesis == null || _meterFile == null)
+ return false;
+
+ var retVal = _currentGenesis.ReLogin();
+ if (retVal)
+ {
+ retVal = _meterFile.ReadMeterFile(StrMeterPowCorrFileName, out _meterBinData);
+ }
+
+ return retVal;
+ }
}
}
diff --git a/ServiceFwUpdate/UI/ServiceFwUpdateSw/Properties/Resources.Designer.cs b/ServiceFwUpdate/UI/ServiceFwUpdateSw/Properties/Resources.Designer.cs
index 2d8bbe4b..f147c5a1 100644
--- a/ServiceFwUpdate/UI/ServiceFwUpdateSw/Properties/Resources.Designer.cs
+++ b/ServiceFwUpdate/UI/ServiceFwUpdateSw/Properties/Resources.Designer.cs
@@ -1096,6 +1096,42 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Power correction:.
+ ///
+ internal static string StrPowerCorrection {
+ get {
+ return ResourceManager.GetString("StrPowerCorrection", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to ERROR: Power correction failed!.
+ ///
+ internal static string StrPowerCorrectionFailed {
+ get {
+ return ResourceManager.GetString("StrPowerCorrectionFailed", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Power correction not needed..
+ ///
+ internal static string StrPowerCorrectionNotNeeded {
+ get {
+ return ResourceManager.GetString("StrPowerCorrectionNotNeeded", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Power correction succeeded..
+ ///
+ internal static string StrPowerCorrectionSucceeded {
+ get {
+ return ResourceManager.GetString("StrPowerCorrectionSucceeded", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Process state connect.
///
diff --git a/ServiceFwUpdate/UI/ServiceFwUpdateSw/Properties/Resources.resx b/ServiceFwUpdate/UI/ServiceFwUpdateSw/Properties/Resources.resx
index 605ba6ae..c29fcf8d 100644
--- a/ServiceFwUpdate/UI/ServiceFwUpdateSw/Properties/Resources.resx
+++ b/ServiceFwUpdate/UI/ServiceFwUpdateSw/Properties/Resources.resx
@@ -694,4 +694,16 @@
ERROR: Firmware update failed!
+
+ Power correction:
+
+
+ ERROR: Power correction failed!
+
+
+ Power correction not needed.
+
+
+ Power correction succeeded.
+
\ No newline at end of file
diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs
index c6c142cd..a77eec5e 100644
--- a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs
+++ b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs
@@ -1395,10 +1395,13 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// Correct power overestimation at FW change from
/// ,
/// .
+ /// Precondition:
+ /// Meter registers have to be read in advance,
+ /// Meter files have to be read in advance.
///
///
///
- ///
+ ///
/// - Initial.
///
private void CorrectPowerOverestimation(ProcessState successExitState,
@@ -1407,29 +1410,92 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// remind the invoker being able to generate error messages based on the last state
_invokerProcessState = _processState;
- if ( _fwUpdatePowerCorrection == null
- || _currentGenesis?.InstalledFwVersion == null
- || _cordonelFirmwarePackage?.FwPackageInfo?.Version == null)
+ if (_currentGenesis?.InstalledFwVersion == null ||
+ _cordonelFirmwarePackage?.FwPackageInfo?.Version == null)
{
- InfoProcessFailed(null, Resources.StrLifeTimeCalculationFailed);
+ InfoProcessFailed(null, Resources.StrPowerCorrectionFailed);
_processState = errorExitState;
return;
}
- _fwUpdatePowerCorrection.ActualFwVersion = _currentGenesis.InstalledFwVersion;
- _fwUpdatePowerCorrection.RequiredFwVersion =
- (UInt32?)_cordonelFirmwarePackage?.FwPackageInfo?.Version;
+ var powCorrFile = new MeterPowerCorrectionFile(_currentGenesis);
+ // CASE 1: Power correction has been executed in previous run:
+ // Check if file "1\\powcorr" is in meter
+ if (_readMeterFiles.Any(f => f.Contains(MeterPowerCorrectionFile.StrMeterPowCorrFileName)))
+ {
+ // read the powCorrFile
+ powCorrFile.ReadPowCorrMeterFile();
+ LogPowCorrContent(powCorrFile);
+ _processState = successExitState;
+ return;
+ }
+ // CASE 2: Power correction needed due to update of FW to corrected version regarding the
+ // power calculation:
+ // Check required versus installed FW versions and threshold version for power correction
+ if ((_currentGenesis.Region == "EMEA" &&
+ _cordonelFirmwarePackage.FwPackageInfo.Version >= PowerCorrection.EmeaFwThresholdForPowCorr &&
+ _currentGenesis.InstalledFwVersion < PowerCorrection.EmeaFwThresholdForPowCorr) ||
+ (_currentGenesis.Region == "NA" &&
+ _cordonelFirmwarePackage.FwPackageInfo.Version >= PowerCorrection.NaFNaFwThresholdForPowCorr &&
+ _currentGenesis.InstalledFwVersion < PowerCorrection.NaFNaFwThresholdForPowCorr))
+ {
+ var applyAlgorithm1 = true;
+ // CASE 2.1: Missing power correction settings from FW update package
+ if (_fwUpdatePowerCorrection == null)
+ {
+ applyAlgorithm1 = false;
+ //do something
+ _fwUpdatePowerCorrection = new PowerCorrection();
+ }
+ // calculate the power correction
+ if (applyAlgorithm1)
+ {
+
+ }
+ else
+ {
+
+ }
+ // correct the total used seconds
+
+ // fill all infos to meter power correction file
+ _fwUpdatePowerCorrection.ActualFwVersion = _currentGenesis.InstalledFwVersion;
+ _fwUpdatePowerCorrection.RequiredFwVersion = (UInt32?)_cordonelFirmwarePackage.FwPackageInfo.Version;
+
+
+ // store results to "1\\powcorr" in the meter
+ }
+ else
+ {
+ InfoProcessSuccess(null, Resources.StrPowerCorrectionNotNeeded);
+ _processState = successExitState;
+ return;
+ }
+
+ LogPowCorrContent(powCorrFile);
+ _processState = successExitState;
+ }
+
+ ///
+ /// Log the power correction file content.
+ ///
+ ///
+ ///
+ /// - Initial.
+ ///
+ private void LogPowCorrContent(MeterPowerCorrectionFile powCorrFile)
+ {
//TODO THW
- var lifeTimeInfo = new List
+ var powerCorrectionInfo = new List
{
$"{Resources.StrLifeTimeDrainedBattery} {0} ",
$"{Resources.StrLifeTimeRemainingYears} {0} " +
$"{Resources.StrLifeTimeYears}"
};
- LogStringList(Resources.StrLifeTimeCalculation, lifeTimeInfo, Resources.StrLifeTimeCalculationSucceeded);
- _processState = successExitState;
+ LogStringList(Resources.StrPowerCorrection, powerCorrectionInfo, Resources.StrPowerCorrectionSucceeded);
+
}
///
diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.de.resx b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.de.resx
index 67c6f067..48b306e1 100644
--- a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.de.resx
+++ b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.de.resx
@@ -694,4 +694,16 @@
FEHLER: Firmware Update fehlgeschlagen!
+
+ Verbrauchskorrektur:
+
+
+ FEHLER: Verbrauchskorrektur fehlgeschlagen!
+
+
+ Verbrauchskorrektur nich nötig.
+
+
+ Verbrauchskorrektur erfolgreich durchgeführt.
+
\ No newline at end of file