From 32227336f1d3d6603c315b4216c305c512e838c1 Mon Sep 17 00:00:00 2001 From: Thomas Wiedebusch Date: Tue, 10 Oct 2023 00:04:56 +0200 Subject: [PATCH] CUST: FwUpdateSw: - Date time setup at login --- .../Properties/Resources.Designer.cs | 18 +++++++++ .../Properties/Resources.de.resx | 6 +++ .../Properties/Resources.resx | 6 +++ .../ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs | 39 +++++++++++++++++++ .../Properties/Resources.Designer.cs | 18 +++++++++ .../Properties/Resources.de.resx | 6 +++ .../Properties/Resources.resx | 6 +++ 7 files changed, 99 insertions(+) diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/Resources.Designer.cs b/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/Resources.Designer.cs index d30f56cb..c7e71788 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/Resources.Designer.cs +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/Resources.Designer.cs @@ -197,6 +197,24 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder.Properties { } } + /// + /// Looks up a localized string similar to Failed to setup date time!. + /// + internal static string StrDateTimeSetupFailed { + get { + return ResourceManager.GetString("StrDateTimeSetupFailed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Date time successfully set. + /// + internal static string StrDateTimeSetupSucceeded { + get { + return ResourceManager.GetString("StrDateTimeSetupSucceeded", resourceCulture); + } + } + /// /// Looks up a localized string similar to Done!. /// diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/Resources.de.resx b/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/Resources.de.resx index e770b999..3d6930e4 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/Resources.de.resx +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/Resources.de.resx @@ -411,4 +411,10 @@ Einstellungen Wiederherstellen + + Datum und Zeit setzen fehlgeschlagen! + + + Datum und Zeit erfolgreich eingestellt + \ No newline at end of file diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/Resources.resx b/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/Resources.resx index 229d9d07..0fa76ffc 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/Resources.resx +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/Resources.resx @@ -418,4 +418,10 @@ Restore Registers + + Failed to setup date time! + + + Date time successfully set + \ No newline at end of file diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs index c449aa99..d72359c0 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs @@ -23,6 +23,7 @@ using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisPwd; using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; +using Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes; using Xylem.Common.Hardware.WaterMeter.WaterMeterCore; using Xylem.Common.Utils.Logging; using Xylem.Common.Utils.ProcessExec; @@ -1532,6 +1533,38 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw #endregion --------------------------------------- User Interaction ------------------------------------------- #region ------------------------------------------ Tools ------------------------------------------------------ + /// + /// Set data and time. + /// + /// + /// - Initial. + /// + private Boolean SetDateTime() + { + if (_currentGenesis == null) + return false; + _currentGenesis.ReLogin(); + Boolean retVal; + try + { + // get the time in UTC to program the time for the Cordonel in seconds since 01. Jan 2000 + var teaTime = new TimeT(); + // build byte array + var rawSeconds = RegisterConverter.ConvertFrom(teaTime.SecondsSince2000); + retVal = _currentGenesis.WriteRegister("SYSTEM_CalendarSeconds", rawSeconds); + _currentGenesis.WriteRegister("IRDA_MfgDate", rawSeconds); + LogSuccessText(Resources.StrDateTimeSetupSucceeded + " " + teaTime); + } + catch (Exception) + { + LogErrorText(Resources.StrDateTimeSetupFailed); + retVal = false; + } + _currentGenesis.Logout(); + return retVal; + } + + /// /// Activate the radio in customer mode with logging of success or failed. /// @@ -2776,6 +2809,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw /// /// - Initial /// + /// + /// - Date time setup. + /// private Boolean LoginAndSpecialSetupProcedure(String password, Boolean initialLogin) { // login without reading all registers and FW keeping the communication to a minimum to switch @@ -2797,10 +2833,13 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw // display to normal operation ReleaseDisplay(); + SetDateTime(); // safe all settings from RAM to FLASH to keep those for reboot if (initialLogin) + { StoreConfigurations(); + } return retVal; } diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.Designer.cs b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.Designer.cs index 9042744f..6cbd720c 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.Designer.cs +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.Designer.cs @@ -277,6 +277,24 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties { } } + /// + /// Looks up a localized string similar to Failed to setup date time!. + /// + internal static string StrDateTimeSetupFailed { + get { + return ResourceManager.GetString("StrDateTimeSetupFailed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Date time successfully set. + /// + internal static string StrDateTimeSetupSucceeded { + get { + return ResourceManager.GetString("StrDateTimeSetupSucceeded", resourceCulture); + } + } + /// /// Looks up a localized string similar to Display released to accumulator- and flow-display.. /// diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.de.resx b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.de.resx index 10c37a72..8fd58f5b 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.de.resx +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.de.resx @@ -544,4 +544,10 @@ Baugröße: + + Datum und Zeit setzen fehlgeschlagen! + + + Datum und Zeit erfolgreich eingestellt + \ No newline at end of file diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.resx b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.resx index bfe9c6fc..ade75e3f 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.resx +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/Resources.resx @@ -544,4 +544,10 @@ MeterSize: + + Failed to setup date time! + + + Date time successfully set + \ No newline at end of file