diff --git a/Common/.shared/SharedAssemblyInfo.cs b/Common/.shared/SharedAssemblyInfo.cs index 29e428e1..97ff286e 100644 --- a/Common/.shared/SharedAssemblyInfo.cs +++ b/Common/.shared/SharedAssemblyInfo.cs @@ -14,5 +14,5 @@ using System.Reflection; //[assembly: AssemblyVersion("1.2.*.0")] -[assembly: AssemblyVersion("2.2.1.*")] -[assembly: AssemblyFileVersion("2.2.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.2.2.*")] +[assembly: AssemblyFileVersion("2.2.2.0")] \ No newline at end of file diff --git a/Common/Common.sln.DotSettings.user b/Common/Common.sln.DotSettings.user index eb584f9a..f95d55cf 100644 --- a/Common/Common.sln.DotSettings.user +++ b/Common/Common.sln.DotSettings.user @@ -21,6 +21,7 @@ <AssemblyExplorer> <Assembly Path="D:\Projekte\SENSUS_tfs_workspaces\WorkBenchV2\Main\Common\Ui\IrdaFunctionalTestApp\bin\Debug\Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.dll" /> </AssemblyExplorer> + NewVersion True <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> <Solution /> diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs index 93bb419f..efbce87f 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs @@ -2061,6 +2061,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore /// - Corrected logic to enter write and read loop, /// - Removed SENSUSRADIO from read check as it returns NULL on read of StoreConfiguration. /// + /// + /// - After write store configuration extended sleep. + /// public Boolean StoreAllConfigurations() { var overallResult = true; @@ -2074,6 +2077,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore while (retryLeft > 0 && !done) { + Thread.Sleep(100); var result = WriteRegister(a.Key.GetIdent(), 1); if (!result) { @@ -2085,7 +2089,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore continue; } - Thread.Sleep(100); + // Wait for storing + Thread.Sleep(500); if (a.Key.AppName == "SENSUSRADIO") { done = true; @@ -2105,8 +2110,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore } done = true; - Thread.Sleep(100); - } } diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisCore/configuration.json b/Common/Hardware/WaterMeter/Genesis/GenesisCore/configuration.json index 009aa7d2..164f2315 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisCore/configuration.json +++ b/Common/Hardware/WaterMeter/Genesis/GenesisCore/configuration.json @@ -16884,16 +16884,16 @@ "details": [ { "type": "uint32_t", - "privilege": { - "lvl1": "RW", - "lvl2": "RW", - "lvl3": "RW", - "lvl4": "RW", - "lvl5": "RW", - "lvl6": "RW", - "lvl7": "RW", - "lvl8": "RW" - }, + "privilege": { + "lvl1": "RW", + "lvl2": "RW", + "lvl3": "RW", + "lvl4": "RW", + "lvl5": "RW", + "lvl6": "RW", + "lvl7": "RW", + "lvl8": "RW" + }, "description": "Lorem Ipsum", "version": { "first": 2, diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/FwUpdateState.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/FwUpdateState.cs index 7740a25a..63a0b41b 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/FwUpdateState.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/FwUpdateState.cs @@ -8,58 +8,66 @@ /// /// FW Update State Idle /// - Idle = 0, + Idle, /// /// FW update single step failed /// - StepFailed = 1, + StepFailed, /// /// FW update entire process failed /// - UpdateFailed = 2, + UpdateFailed, /// /// Start initial FW update /// - StartInitial = 3, + StartInitial, /// /// Repeat FW update /// - RepeatFwUpdate = 4, + RepeatFwUpdate, /// /// Upload (partial-) update files /// - UploadFileApps = 5, + UploadFileApps, /// /// Download (partial-) update files /// - DownloadFileApps = 6, + DownloadFileApps, /// /// Compare (partial-) update files /// - CompareFileApps = 7, + CompareFileApps, /// /// Download upgrade control file /// - DownloadUpgradeControlFile = 8, + DownloadUpgradeControlFile, /// /// Build upgrade control file /// - BuildUpgradeControlFile = 9, + BuildUpgradeControlFile, /// /// Build Update Files /// - BuildFileApps = 10, + BuildFileApps, /// /// Trigger Upgrade /// - TriggerUpgrade = 11, + TriggerUpgrade, /// /// Erase update file /// - EraseUpdateFile = 12, + EraseUpdateFile, + /// + /// Prepare update, read registers for restorer and store configuration + /// + PrepareUpdate, + /// + /// Read configuration file from meter + /// + UploadConfigFile, /// /// Delimiter for list /// - FwUpdateStateListDelimiter = 13 + FwUpdateStateListDelimiter } } \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/FwUpdateStateInfo.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/FwUpdateStateInfo.cs index c2036d2c..73ad00c8 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/FwUpdateStateInfo.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/FwUpdateStateInfo.cs @@ -20,44 +20,50 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Consts static FwUpdateStateInfo() { StateInfos = new FwUpdateStateText[(Int32)FwUpdateState.FwUpdateStateListDelimiter]; - StateInfos[0].State = FwUpdateState.Idle; - StateInfos[0].Message = Resources.StrFwUpdateStateIdle; + StateInfos[(Int32)FwUpdateState.Idle].State = FwUpdateState.Idle; + StateInfos[(Int32)FwUpdateState.Idle].Message = Resources.StrFwUpdateStateIdle; - StateInfos[1].State = FwUpdateState.StepFailed; - StateInfos[1].Message = Resources.StrFwUpdateStateStepFailed; + StateInfos[(Int32)FwUpdateState.StepFailed].State = FwUpdateState.StepFailed; + StateInfos[(Int32)FwUpdateState.StepFailed].Message = Resources.StrFwUpdateStateStepFailed; - StateInfos[2].State = FwUpdateState.UpdateFailed; - StateInfos[2].Message = Resources.StrFwUpdateStateUpdateFailed; + StateInfos[(Int32)FwUpdateState.UpdateFailed].State = FwUpdateState.UpdateFailed; + StateInfos[(Int32)FwUpdateState.UpdateFailed].Message = Resources.StrFwUpdateStateUpdateFailed; - StateInfos[3].State = FwUpdateState.StartInitial; - StateInfos[3].Message = Resources.StrFwUpdateStateStartInitial; + StateInfos[(Int32)FwUpdateState.StartInitial].State = FwUpdateState.StartInitial; + StateInfos[(Int32)FwUpdateState.StartInitial].Message = Resources.StrFwUpdateStateStartInitial; - StateInfos[4].State = FwUpdateState.RepeatFwUpdate; - StateInfos[4].Message = Resources.StrFwUpdateStateRepeatFwUpdate; + StateInfos[(Int32)FwUpdateState.RepeatFwUpdate].State = FwUpdateState.RepeatFwUpdate; + StateInfos[(Int32)FwUpdateState.RepeatFwUpdate].Message = Resources.StrFwUpdateStateRepeatFwUpdate; - StateInfos[5].State = FwUpdateState.UploadFileApps; - StateInfos[5].Message = Resources.StrFwUpdateStateUploadFileApps; + StateInfos[(Int32)FwUpdateState.UploadFileApps].State = FwUpdateState.UploadFileApps; + StateInfos[(Int32)FwUpdateState.UploadFileApps].Message = Resources.StrFwUpdateStateUploadFileApps; - StateInfos[6].State = FwUpdateState.DownloadFileApps; - StateInfos[6].Message = Resources.StrFwUpdateStateDownloadFileApps; + StateInfos[(Int32)FwUpdateState.DownloadFileApps].State = FwUpdateState.DownloadFileApps; + StateInfos[(Int32)FwUpdateState.DownloadFileApps].Message = Resources.StrFwUpdateStateDownloadFileApps; - StateInfos[7].State = FwUpdateState.CompareFileApps; - StateInfos[7].Message = Resources.StrFwUpdateStateCompareFileApps; + StateInfos[(Int32)FwUpdateState.CompareFileApps].State = FwUpdateState.CompareFileApps; + StateInfos[(Int32)FwUpdateState.CompareFileApps].Message = Resources.StrFwUpdateStateCompareFileApps; - StateInfos[8].State = FwUpdateState.DownloadUpgradeControlFile; - StateInfos[8].Message = Resources.StrFwUpdateStateDownloadUpgradeControlFile; + StateInfos[(Int32)FwUpdateState.DownloadUpgradeControlFile].State = FwUpdateState.DownloadUpgradeControlFile; + StateInfos[(Int32)FwUpdateState.DownloadUpgradeControlFile].Message = Resources.StrFwUpdateStateDownloadUpgradeControlFile; - StateInfos[9].State = FwUpdateState.BuildUpgradeControlFile; - StateInfos[9].Message = Resources.StrFwUpdateStateBuildUpgradeControlFile; + StateInfos[(Int32)FwUpdateState.BuildUpgradeControlFile].State = FwUpdateState.BuildUpgradeControlFile; + StateInfos[(Int32)FwUpdateState.BuildUpgradeControlFile].Message = Resources.StrFwUpdateStateBuildUpgradeControlFile; - StateInfos[10].State = FwUpdateState.BuildFileApps; - StateInfos[10].Message = Resources.StrFwUpdateStateBuildFileApps; + StateInfos[(Int32)FwUpdateState.BuildFileApps].State = FwUpdateState.BuildFileApps; + StateInfos[(Int32)FwUpdateState.BuildFileApps].Message = Resources.StrFwUpdateStateBuildFileApps; - StateInfos[11].State = FwUpdateState.TriggerUpgrade; - StateInfos[11].Message = Resources.StrFwUpdateStateTriggerUpgrade; + StateInfos[(Int32)FwUpdateState.TriggerUpgrade].State = FwUpdateState.TriggerUpgrade; + StateInfos[(Int32)FwUpdateState.TriggerUpgrade].Message = Resources.StrFwUpdateStateTriggerUpgrade; - StateInfos[12].State = FwUpdateState.EraseUpdateFile; - StateInfos[12].Message = Resources.StrFwUpdateStateEraseUpdateFile; + StateInfos[(Int32)FwUpdateState.EraseUpdateFile].State = FwUpdateState.EraseUpdateFile; + StateInfos[(Int32)FwUpdateState.EraseUpdateFile].Message = Resources.StrFwUpdateStateEraseUpdateFile; + + StateInfos[(Int32)FwUpdateState.PrepareUpdate].State = FwUpdateState.PrepareUpdate; + StateInfos[(Int32)FwUpdateState.PrepareUpdate].Message = Resources.StrFwUpdateStatePrepareUpdate; + + StateInfos[(Int32)FwUpdateState.UploadConfigFile].State = FwUpdateState.UploadConfigFile; + StateInfos[(Int32)FwUpdateState.UploadConfigFile].Message = Resources.StrUploadConfigFile; } /// @@ -67,7 +73,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Consts public static String GetTextFromState(FwUpdateState state) { return (from stateInfo in StateInfos - where stateInfo.State == state select stateInfo.Message).FirstOrDefault(); + where stateInfo.State == state + select stateInfo.Message).FirstOrDefault(); } /// /// Get the state of the text @@ -76,7 +83,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Consts public static FwUpdateState GetStateFromText(String text) { return (from stateInfo in StateInfos - where stateInfo.Message == text select stateInfo.State).FirstOrDefault(); + where stateInfo.Message == text + select stateInfo.State).FirstOrDefault(); } } } diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/GenesisFile.csproj b/Common/Hardware/WaterMeter/Genesis/GenesisFile/GenesisFile.csproj index 4c821315..09d6ebf2 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/GenesisFile.csproj +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/GenesisFile.csproj @@ -102,6 +102,7 @@ + diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterConfigFile.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterConfigFile.cs new file mode 100644 index 00000000..3f25017d --- /dev/null +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterConfigFile.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using Logic.ProductionToProductMapper.Cordonel; + +namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile +{ + /// + /// File for meter configuration + /// + public class MeterConfigFile + { + /// + /// Data length + /// + public UInt32 DataLength; + + /// + /// Binary file content + /// + public List BinData = new List(); + + } +} diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterFwUpdate.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterFwUpdate.cs index df3eb19b..026d291a 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterFwUpdate.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterFwUpdate.cs @@ -25,11 +25,17 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile { #region Variables + // Look up table file + public MeterConfigFile ConfigFile; + /// /// Port scan result event for message dispatcher to caller /// public event EventHandler OnProcessUpdate; + //disk and name of config file + private const String StrConfigMeterFileName = "0\\config"; + //name for upgrade control file private const String StrUpgradeCtrlFileName = "1\\upgrade"; @@ -94,11 +100,17 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// /// Core revision minimum as double for comparison /// - public Double? CoreRevisionMinimum { get; private set; } + public Double? CoreRevisionMinimum + { + get; private set; + } /// /// Core revision maximum as double for comparison /// - public Double? CoreRevisionMaximum { get; private set; } + public Double? CoreRevisionMaximum + { + get; private set; + } //reminder for the core minimum requirement as string private String _strCoreRevisionMinimum; @@ -161,6 +173,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// public Boolean SingleFilePartsRetryEnable = true; + /// + /// Store configuration in advance to the update + /// + public Boolean StoreConfigEnable = true; + /// /// Enable partial file writes from first failed part to the end /// @@ -701,6 +718,59 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile } } + /// + /// Upload the config file from meter + /// + /// + /// + /// - Initial + /// + public Boolean UploadConfigFile() + { + //counters for actual process information + var retryCtr = 0; + ConfigFile = new MeterConfigFile(); + + _processedBytesCtr = 0; + _overallBytesCtr = 6; + + _meterFile = new MeterFile(_genesisMeter); + if (_meterFile != null) + { + _meterFile.OnProcessUpdate += ProcessUpdate_Event; + } + + _genesisMeter?.ReLogin(); + _genesisMeter?.SetProcessState(DisplayCodes.FwUpdateActive, false); + + if (_genesisMeter == null || !_genesisMeter.IsLoggedOn || _meterFile == null) + return false; + + var returnValue = true; + + //write LUT files and retry if not successful + do + { + _actualOperation = Resources.StrUploadConfigFile; + + // logout and re-login to clear all ongoing processes and clear the Genesis buffers + ReestablishMeterFileSystem(); + + if (!_meterFile.ReadMeterFile(StrConfigMeterFileName, out ConfigFile.BinData, 5000)) + { + returnValue = false; + } + + if (!returnValue) + { + ReestablishMeterFileSystem(); + } + } while (!returnValue && retryCtr++ < FileWriteRetries && !StopUpdateProcess); + + _meterFile.OnProcessUpdate -= ProcessUpdate_Event; + return !StopUpdateProcess && returnValue; + } + /// /// Update meter firmware /// @@ -960,10 +1030,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// /// - Store all configurations before the update. /// + /// + /// - Message for actual operation, + /// - PrepareUpdate state introduced. + /// public Boolean UpdatePreparation() { - _actualOperation = ""; - _fwUpdateState = FwUpdateState.Idle; + _actualOperation = Resources.StrFwUpdateStatePrepareUpdate; + _fwUpdateState = FwUpdateState.PrepareUpdate; + _processedBytesCtr = 0; + _overallBytesCtr = 6; _meterFile = new MeterFile(_genesisMeter); if (_meterFile != null) @@ -990,10 +1066,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile var writeBackValue = _genesisMeter.ReadRegister(item.Key); _registersAfterUpdate.Add(item.Key, writeBackValue); _genesisMeter.WriteRegister(item.Key, item.Value); + _processedBytesCtr++; } - //store all configuration parameters - if (!_genesisMeter.StoreAllConfigurations()) return false; + if (StoreConfigEnable) + { + //store all configuration parameters + _actualOperation = Resources.StrStoreConfigurations; + if (!_genesisMeter.StoreAllConfigurations()) + return false; + } //remove the update stop action StopUpdateProcess = false; @@ -1075,6 +1157,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// /// - Introduced lock for repeated execution of state machine /// + /// + /// - Prepare update added, + /// - Upload config file added. + /// private void FwUpdateStateMachine() { if (_fwBackupUpdateState == _fwUpdateState) @@ -1090,6 +1176,12 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile case FwUpdateState.Idle: break; + case FwUpdateState.UploadConfigFile: + _fwUpdateState = UploadConfigFile() + ? FwUpdateState.Idle + : FwUpdateState.StepFailed; + break; + case FwUpdateState.StartInitial: _updateProcedureRetryCtr = 0; _fwUpdateState = FwUpdateState.BuildFileApps; @@ -1164,6 +1256,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile case FwUpdateState.UploadFileApps: break; + case FwUpdateState.PrepareUpdate: + break; + case FwUpdateState.CompareFileApps: break; @@ -1290,7 +1385,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// /// - Corrected return value (was constantly true). /// - private Boolean ValidateLoadedFiles() + private Boolean ValidateLoadedFiles() { var returnValue = true; diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterLutUpdate.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterLutUpdate.cs index fc86803e..66dfe0a7 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterLutUpdate.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterLutUpdate.cs @@ -901,7 +901,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile _genesisMeter.TransmitProtocol.SetResponseTimeout(1000); var returnValue = true; - //write LUT files and retry if not successful + //verify LUT files and retry if not successful do { var filesToUpload = new[] { StrLutMeterFileName, StrLutBackupMeterFileName }; diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.Designer.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.Designer.cs index 02bc7ce2..3cdc9d25 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.Designer.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.Designer.cs @@ -123,6 +123,15 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Properties { } } + /// + /// Looks up a localized string similar to Prepare update. + /// + public static string StrFwUpdateStatePrepareUpdate { + get { + return ResourceManager.GetString("StrFwUpdateStatePrepareUpdate", resourceCulture); + } + } + /// /// Looks up a localized string similar to Repeat FW Update. /// @@ -222,6 +231,24 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Properties { } } + /// + /// Looks up a localized string similar to Store configurations. + /// + public static string StrStoreConfigurations { + get { + return ResourceManager.GetString("StrStoreConfigurations", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Upload configuration file. + /// + public static string StrUploadConfigFile { + get { + return ResourceManager.GetString("StrUploadConfigFile", resourceCulture); + } + } + /// /// Looks up a localized string similar to Waiting..... /// diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.de.resx b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.de.resx index 45249489..cee71271 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.de.resx +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.de.resx @@ -174,4 +174,13 @@ Einspielen + + Update Vorbereitung + + + Sichere Einstellungen + + + Lade Einstellungen + \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.resx b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.resx index dfb742b4..8480a5d1 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.resx +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.resx @@ -174,4 +174,13 @@ Download + + Prepare update + + + Store configurations + + + Upload configuration file + \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/App.config b/Common/Ui/GenesisToolBox/App.config index 9dafed42..a61cb868 100644 --- a/Common/Ui/GenesisToolBox/App.config +++ b/Common/Ui/GenesisToolBox/App.config @@ -21,29 +21,6 @@ - - - - - - - - - - - - - diff --git a/Common/Ui/GenesisToolBox/FrmFwUpdate.Designer.cs b/Common/Ui/GenesisToolBox/FrmFwUpdate.Designer.cs index 07efe0f6..b20c1dad 100644 --- a/Common/Ui/GenesisToolBox/FrmFwUpdate.Designer.cs +++ b/Common/Ui/GenesisToolBox/FrmFwUpdate.Designer.cs @@ -37,8 +37,10 @@ this.label2 = new System.Windows.Forms.Label(); this.cbComSlot = new System.Windows.Forms.ComboBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.btnUploadConfig = new System.Windows.Forms.Button(); this.groupBox4 = new System.Windows.Forms.GroupBox(); - this.button1 = new System.Windows.Forms.Button(); + this.btnClearDisplay = new System.Windows.Forms.Button(); this.lblUpdateTime = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.lblWaitingForMeterResponse = new System.Windows.Forms.Label(); @@ -63,6 +65,7 @@ this.lblActualProcess = new System.Windows.Forms.Label(); this.barOverallProgressUpdate = new System.Windows.Forms.ProgressBar(); this.gridViewApplic = new System.Windows.Forms.DataGridView(); + this.cbxStoreConfigEnable = new System.Windows.Forms.CheckBox(); this.gbxSetup = new System.Windows.Forms.GroupBox(); this.cbxConsecutiveFilePartsRetryEnable = new System.Windows.Forms.CheckBox(); this.label6 = new System.Windows.Forms.Label(); @@ -76,7 +79,6 @@ this.lblFwUpdateInfo = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.tabFwSources = new System.Windows.Forms.TabControl(); this.tabLocalFile = new System.Windows.Forms.TabPage(); this.groupBox1 = new System.Windows.Forms.GroupBox(); @@ -106,8 +108,10 @@ this.label11 = new System.Windows.Forms.Label(); this.cbxFilterFWType = new System.Windows.Forms.ComboBox(); this.chbFilterIsDeveloper = new System.Windows.Forms.CheckBox(); + this.saveConfigFile = new System.Windows.Forms.SaveFileDialog(); this.grpSetup.SuspendLayout(); this.groupBox2.SuspendLayout(); + this.groupBox5.SuspendLayout(); this.groupBox4.SuspendLayout(); this.gbxManualTimingControl.SuspendLayout(); this.gbxManualTriggerControl.SuspendLayout(); @@ -220,6 +224,7 @@ // // groupBox2 // + this.groupBox2.Controls.Add(this.groupBox5); this.groupBox2.Controls.Add(this.groupBox4); this.groupBox2.Controls.Add(this.lblUpdateTime); this.groupBox2.Controls.Add(this.label9); @@ -243,25 +248,45 @@ this.groupBox2.TabStop = false; this.groupBox2.Text = "Applications "; // + // groupBox5 + // + this.groupBox5.Controls.Add(this.btnUploadConfig); + this.groupBox5.Location = new System.Drawing.Point(944, 308); + this.groupBox5.Name = "groupBox5"; + this.groupBox5.Size = new System.Drawing.Size(128, 50); + this.groupBox5.TabIndex = 22; + this.groupBox5.TabStop = false; + this.groupBox5.Text = "Configuration File"; + // + // btnUploadConfig + // + this.btnUploadConfig.Location = new System.Drawing.Point(6, 19); + this.btnUploadConfig.Name = "btnUploadConfig"; + this.btnUploadConfig.Size = new System.Drawing.Size(116, 25); + this.btnUploadConfig.TabIndex = 11; + this.btnUploadConfig.Text = "Upload Config"; + this.btnUploadConfig.UseVisualStyleBackColor = true; + this.btnUploadConfig.Click += new System.EventHandler(this.btnUploadConfig_Click); + // // groupBox4 // - this.groupBox4.Controls.Add(this.button1); - this.groupBox4.Location = new System.Drawing.Point(950, 414); + this.groupBox4.Controls.Add(this.btnClearDisplay); + this.groupBox4.Location = new System.Drawing.Point(946, 413); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(126, 49); this.groupBox4.TabIndex = 21; this.groupBox4.TabStop = false; this.groupBox4.Text = "Display"; // - // button1 + // btnClearDisplay // - this.button1.Location = new System.Drawing.Point(5, 19); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(116, 25); - this.button1.TabIndex = 0; - this.button1.Text = "Clear Display"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.btnClearDisplay.Location = new System.Drawing.Point(5, 19); + this.btnClearDisplay.Name = "btnClearDisplay"; + this.btnClearDisplay.Size = new System.Drawing.Size(116, 25); + this.btnClearDisplay.TabIndex = 0; + this.btnClearDisplay.Text = "Clear Display"; + this.btnClearDisplay.UseVisualStyleBackColor = true; + this.btnClearDisplay.Click += new System.EventHandler(this.btnClearDisplay_Click); // // lblUpdateTime // @@ -296,7 +321,7 @@ this.gbxManualTimingControl.Controls.Add(this.label8); this.gbxManualTimingControl.Controls.Add(this.cbAddRetryTimeout); this.gbxManualTimingControl.Controls.Add(this.label7); - this.gbxManualTimingControl.Location = new System.Drawing.Point(944, 238); + this.gbxManualTimingControl.Location = new System.Drawing.Point(944, 235); this.gbxManualTimingControl.Name = "gbxManualTimingControl"; this.gbxManualTimingControl.Size = new System.Drawing.Size(128, 69); this.gbxManualTimingControl.TabIndex = 17; @@ -365,7 +390,7 @@ // this.gbxManualTriggerControl.Controls.Add(this.btnTriggerUpdate); this.gbxManualTriggerControl.Controls.Add(this.btnPrepareTrigger); - this.gbxManualTriggerControl.Location = new System.Drawing.Point(944, 150); + this.gbxManualTriggerControl.Location = new System.Drawing.Point(944, 147); this.gbxManualTriggerControl.Name = "gbxManualTriggerControl"; this.gbxManualTriggerControl.Size = new System.Drawing.Size(128, 88); this.gbxManualTriggerControl.TabIndex = 16; @@ -395,7 +420,7 @@ // gbxManualUploadAndVerification // this.gbxManualUploadAndVerification.Controls.Add(this.btnVerifyFiles); - this.gbxManualUploadAndVerification.Location = new System.Drawing.Point(944, 100); + this.gbxManualUploadAndVerification.Location = new System.Drawing.Point(944, 95); this.gbxManualUploadAndVerification.Name = "gbxManualUploadAndVerification"; this.gbxManualUploadAndVerification.Size = new System.Drawing.Size(128, 50); this.gbxManualUploadAndVerification.TabIndex = 15; @@ -416,7 +441,7 @@ // this.gbxManualDownload.Controls.Add(this.btnRetryFileParts); this.gbxManualDownload.Controls.Add(this.btnDownloadFiles); - this.gbxManualDownload.Location = new System.Drawing.Point(944, 19); + this.gbxManualDownload.Location = new System.Drawing.Point(944, 13); this.gbxManualDownload.Name = "gbxManualDownload"; this.gbxManualDownload.Size = new System.Drawing.Size(128, 81); this.gbxManualDownload.TabIndex = 13; @@ -446,7 +471,7 @@ // groupBox3 // this.groupBox3.Controls.Add(this.btnUpdateFw); - this.groupBox3.Location = new System.Drawing.Point(949, 358); + this.groupBox3.Location = new System.Drawing.Point(945, 358); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(126, 49); this.groupBox3.TabIndex = 12; @@ -513,17 +538,31 @@ this.gridViewApplic.TabIndex = 2; this.gridViewApplic.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridViewApplic_CellClick); // + // cbxStoreConfigEnable + // + this.cbxStoreConfigEnable.AutoSize = true; + this.cbxStoreConfigEnable.Checked = true; + this.cbxStoreConfigEnable.CheckState = System.Windows.Forms.CheckState.Checked; + this.cbxStoreConfigEnable.Location = new System.Drawing.Point(6, 22); + this.cbxStoreConfigEnable.Name = "cbxStoreConfigEnable"; + this.cbxStoreConfigEnable.Size = new System.Drawing.Size(121, 17); + this.cbxStoreConfigEnable.TabIndex = 22; + this.cbxStoreConfigEnable.Text = "Store Configurations"; + this.cbxStoreConfigEnable.UseVisualStyleBackColor = true; + this.cbxStoreConfigEnable.CheckedChanged += new System.EventHandler(this.cbxStoreConfigEnable_CheckedChanged); + // // gbxSetup // + this.gbxSetup.Controls.Add(this.cbxStoreConfigEnable); this.gbxSetup.Controls.Add(this.cbxConsecutiveFilePartsRetryEnable); this.gbxSetup.Controls.Add(this.label6); this.gbxSetup.Controls.Add(this.label5); this.gbxSetup.Controls.Add(this.cbFilePartSize); this.gbxSetup.Controls.Add(this.cbxSingleFilePartsRetryEnable); this.gbxSetup.Controls.Add(this.cbxManualControl); - this.gbxSetup.Location = new System.Drawing.Point(915, 90); + this.gbxSetup.Location = new System.Drawing.Point(924, 59); this.gbxSetup.Name = "gbxSetup"; - this.gbxSetup.Size = new System.Drawing.Size(165, 119); + this.gbxSetup.Size = new System.Drawing.Size(165, 150); this.gbxSetup.TabIndex = 20; this.gbxSetup.TabStop = false; this.gbxSetup.Text = "Setup"; @@ -531,7 +570,7 @@ // cbxConsecutiveFilePartsRetryEnable // this.cbxConsecutiveFilePartsRetryEnable.AutoSize = true; - this.cbxConsecutiveFilePartsRetryEnable.Location = new System.Drawing.Point(6, 69); + this.cbxConsecutiveFilePartsRetryEnable.Location = new System.Drawing.Point(6, 97); this.cbxConsecutiveFilePartsRetryEnable.Name = "cbxConsecutiveFilePartsRetryEnable"; this.cbxConsecutiveFilePartsRetryEnable.Size = new System.Drawing.Size(159, 17); this.cbxConsecutiveFilePartsRetryEnable.TabIndex = 23; @@ -542,7 +581,7 @@ // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(127, 93); + this.label6.Location = new System.Drawing.Point(127, 121); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(26, 13); this.label6.TabIndex = 22; @@ -551,7 +590,7 @@ // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(3, 95); + this.label5.Location = new System.Drawing.Point(3, 123); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(73, 13); this.label5.TabIndex = 21; @@ -568,7 +607,7 @@ "16", "32", "64"}); - this.cbFilePartSize.Location = new System.Drawing.Point(82, 91); + this.cbFilePartSize.Location = new System.Drawing.Point(82, 119); this.cbFilePartSize.Name = "cbFilePartSize"; this.cbFilePartSize.Size = new System.Drawing.Size(44, 21); this.cbFilePartSize.TabIndex = 20; @@ -579,7 +618,7 @@ this.cbxSingleFilePartsRetryEnable.AutoSize = true; this.cbxSingleFilePartsRetryEnable.Checked = true; this.cbxSingleFilePartsRetryEnable.CheckState = System.Windows.Forms.CheckState.Checked; - this.cbxSingleFilePartsRetryEnable.Location = new System.Drawing.Point(6, 44); + this.cbxSingleFilePartsRetryEnable.Location = new System.Drawing.Point(6, 72); this.cbxSingleFilePartsRetryEnable.Name = "cbxSingleFilePartsRetryEnable"; this.cbxSingleFilePartsRetryEnable.Size = new System.Drawing.Size(129, 17); this.cbxSingleFilePartsRetryEnable.TabIndex = 19; @@ -590,7 +629,7 @@ // cbxManualControl // this.cbxManualControl.AutoSize = true; - this.cbxManualControl.Location = new System.Drawing.Point(6, 19); + this.cbxManualControl.Location = new System.Drawing.Point(6, 47); this.cbxManualControl.Name = "cbxManualControl"; this.cbxManualControl.Size = new System.Drawing.Size(135, 17); this.cbxManualControl.TabIndex = 18; @@ -630,16 +669,12 @@ // pictureBox1 // this.pictureBox1.Image = global::Xylem.Common.Ui.GenesisToolBox.Properties.Resources.SensusLogoXylem; - this.pictureBox1.Location = new System.Drawing.Point(978, 30); + this.pictureBox1.Location = new System.Drawing.Point(986, 4); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(102, 54); this.pictureBox1.TabIndex = 29; this.pictureBox1.TabStop = false; // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // // tabFwSources // this.tabFwSources.Controls.Add(this.tabLocalFile); @@ -940,6 +975,10 @@ this.chbFilterIsDeveloper.Text = "For Developer"; this.chbFilterIsDeveloper.UseVisualStyleBackColor = true; // + // saveConfigFile + // + this.saveConfigFile.Filter = "configuration file (*.hex)|*.hex"; + // // FrmFwUpdate // this.AccessibleRole = System.Windows.Forms.AccessibleRole.Sound; @@ -961,6 +1000,7 @@ this.grpSetup.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); + this.groupBox5.ResumeLayout(false); this.groupBox4.ResumeLayout(false); this.gbxManualTimingControl.ResumeLayout(false); this.gbxManualTimingControl.PerformLayout(); @@ -1028,7 +1068,6 @@ private System.Windows.Forms.Label label8; private System.Windows.Forms.ComboBox cbAddRetryTimeout; private System.Windows.Forms.Label label7; - private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.Label lblWaitingForMeterResponse; private System.Windows.Forms.Label lblCoreRevision; private System.Windows.Forms.Label lblUpdateTime; @@ -1062,8 +1101,12 @@ private System.Windows.Forms.Label label12; private System.Windows.Forms.DataGridView dgvFiles; private System.Windows.Forms.GroupBox groupBox4; - private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button btnClearDisplay; private System.Windows.Forms.Label label13; private System.Windows.Forms.Button btnFixBat; + private System.Windows.Forms.CheckBox cbxStoreConfigEnable; + private System.Windows.Forms.GroupBox groupBox5; + private System.Windows.Forms.Button btnUploadConfig; + private System.Windows.Forms.SaveFileDialog saveConfigFile; } } \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/FrmFwUpdate.cs b/Common/Ui/GenesisToolBox/FrmFwUpdate.cs index 93f650b2..59fb37d8 100644 --- a/Common/Ui/GenesisToolBox/FrmFwUpdate.cs +++ b/Common/Ui/GenesisToolBox/FrmFwUpdate.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Data; using System.Drawing; using System.Globalization; +using System.IO; using System.Linq; using System.Reflection; using System.Threading; @@ -76,9 +77,6 @@ namespace Xylem.Common.Ui.GenesisToolBox private DateTimeOffset _startTime; private Boolean _resetTimeMeasurement; - - - private static String DefaultBinaryPath { get => Settings.Default.InitialBinaryPath; @@ -119,13 +117,16 @@ namespace Xylem.Common.Ui.GenesisToolBox "This is a stepwise update, proceed until update is completed!\n"; private const String StrUpdateErrorMessage = "FW UPDATE FAILED!\n\n"; - private FwSource _fwSource = FwSource.File; + private enum FwSource { File, -// Production, + // Production, Db } + + + private FwSource _fwSource = FwSource.File; #endregion #region FormControls /// @@ -154,14 +155,18 @@ namespace Xylem.Common.Ui.GenesisToolBox btnStopFwUpdate.ForeColor = Color.Red; SetControlDownloadsLocked(); btnStopFwUpdate.Enabled = false; - btnOpenUpdateDirectory.Enabled = true; - btnOpenPackageControlFile.Enabled = true; + btnOpenUpdateDirectory.Enabled = false; + btnOpenPackageControlFile.Enabled = false; + btnFixBat.Enabled = false; + btnUploadConfig.Enabled = false; + btnClearDisplay.Enabled = false; cbFilePartSize.Enabled = true; CheckManualControl(); if (_meterFwUpdate != null) { _meterFwUpdate.SingleFilePartsRetryEnable = cbxSingleFilePartsRetryEnable.Checked; _meterFwUpdate.ConsecutiveFilePartsRetryEnable = cbxConsecutiveFilePartsRetryEnable.Checked; + _meterFwUpdate.StoreConfigEnable = cbxStoreConfigEnable.Checked; } _dataTable.Rows.Clear(); @@ -342,7 +347,8 @@ namespace Xylem.Common.Ui.GenesisToolBox /// private void UpdateInformationStyleSet() { - if (_meterFwUpdate == null) return; + if (_meterFwUpdate == null) + return; foreach (DataGridViewRow dataGridRow in gridViewApplic.Rows) { var testString = dataGridRow.Cells[StrStatus].Value.ToString(); @@ -560,6 +566,9 @@ namespace Xylem.Common.Ui.GenesisToolBox btnPrepareTrigger.Enabled = true; btnTriggerUpdate.Enabled = true; + btnFixBat.Enabled = true; + btnClearDisplay.Enabled = true; + btnUploadConfig.Enabled = true; } private void SetControlDownloadsLocked() @@ -594,6 +603,9 @@ namespace Xylem.Common.Ui.GenesisToolBox btnPrepareTrigger.Enabled = false; btnTriggerUpdate.Enabled = false; + btnFixBat.Enabled = false; + btnClearDisplay.Enabled = false; + btnUploadConfig.Enabled = false; } private void SetControlsDownloadIsFinished() @@ -618,6 +630,9 @@ namespace Xylem.Common.Ui.GenesisToolBox btnPrepareTrigger.Enabled = true; btnTriggerUpdate.Enabled = true; + btnFixBat.Enabled = true; + btnClearDisplay.Enabled = true; + btnUploadConfig.Enabled = true; } #endregion #region BoardControls @@ -660,10 +675,9 @@ namespace Xylem.Common.Ui.GenesisToolBox try { Init(); - Int32 slotNr; if (string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) || - !int.TryParse(cbComSlot.SelectedItem.ToString(), out slotNr)) + !int.TryParse(cbComSlot.SelectedItem.ToString(), out var slotNr)) { return; } @@ -715,7 +729,10 @@ namespace Xylem.Common.Ui.GenesisToolBox CheckUpdateEnabled(); _currentGenesis.Logout(); })); - }).ContinueWith(delegate { ViewProgressPcb(false); }); + }).ContinueWith(delegate + { + ViewProgressPcb(false); + }); } catch (Exception ex) { @@ -836,6 +853,26 @@ namespace Xylem.Common.Ui.GenesisToolBox })); } } + private void UploadFileControl(Boolean isActive) + { + if (isActive) + { + Invoke(new Action(() => + { + _lastFwUpdateState = ""; + ProcessViewControl(true); + tmrProgressUpdate.Enabled = true; + })); + } + else + { + Invoke(new Action(() => + { + ProcessViewControl(false); + SetControlsDownloadIsFinished(); + })); + } + } private void DownloadFilesControl(Boolean isActive) { @@ -935,6 +972,7 @@ namespace Xylem.Common.Ui.GenesisToolBox } } + private void VerifyFilesControl(Boolean isActive) { if (isActive) @@ -1000,9 +1038,25 @@ namespace Xylem.Common.Ui.GenesisToolBox } private Boolean CheckUpdateEnabled() { + // enable file load and fix battery only if device is connected + if (_currentGenesis != null) + { + btnOpenUpdateDirectory.Enabled = true; + btnOpenPackageControlFile.Enabled = true; + btnFixBat.Enabled = true; + btnClearDisplay.Enabled = true; + btnUploadConfig.Enabled = true; - SetControlDownloadsUnlocked(); - return true; + } + else + { + btnOpenUpdateDirectory.Enabled = false; + btnOpenPackageControlFile.Enabled = false; + btnFixBat.Enabled = false; + btnClearDisplay.Enabled = false; + btnUploadConfig.Enabled = false; + + } //this check has been placed here to force display update if (_meterFwUpdate != null && _currentGenesis != null && @@ -1013,11 +1067,9 @@ namespace Xylem.Common.Ui.GenesisToolBox SetControlDownloadsUnlocked(); return true; } - else - { - SetControlDownloadsLocked(); - return false; - } + + SetControlDownloadsLocked(); + return false; } private Boolean CheckRetryPossible() @@ -1272,7 +1324,10 @@ namespace Xylem.Common.Ui.GenesisToolBox { _fileAppsSuccessfulWritten = _meterFwUpdate.ManualVerifyFiles(); Thread.Sleep(1000); - }).ContinueWith(delegate { VerifyFilesControl(false); }); + }).ContinueWith(delegate + { + VerifyFilesControl(false); + }); } @@ -1313,7 +1368,10 @@ namespace Xylem.Common.Ui.GenesisToolBox { _fileAppsSuccessfulWritten = _meterFwUpdate.ManualDownloadAllFileApps(); Thread.Sleep(1000); - }).ContinueWith(delegate { DownloadFilesControl(false); }); + }).ContinueWith(delegate + { + DownloadFilesControl(false); + }); } @@ -1336,7 +1394,10 @@ namespace Xylem.Common.Ui.GenesisToolBox { _fileAppsSuccessfulWritten = _meterFwUpdate.ManualDownloadRemainingFileAppsParts(); Thread.Sleep(1000); - }).ContinueWith(delegate { DownloadFilesControl(false); }); + }).ContinueWith(delegate + { + DownloadFilesControl(false); + }); } /// @@ -1374,7 +1435,10 @@ namespace Xylem.Common.Ui.GenesisToolBox { _fileAppsSuccessfulWritten = _meterFwUpdate.ManualTriggerUpgrade(); Thread.Sleep(1000); - }).ContinueWith(delegate { TriggerUpdateControl(false); }); + }).ContinueWith(delegate + { + TriggerUpdateControl(false); + }); } @@ -1416,7 +1480,10 @@ namespace Xylem.Common.Ui.GenesisToolBox { _fileAppsSuccessfulWritten = _meterFwUpdate.UpdateMeterFw(); Thread.Sleep(1000); - }).ContinueWith(delegate { AutomaticUpdateControl(false); }); + }).ContinueWith(delegate + { + AutomaticUpdateControl(false); + }); } private void btnStopFwUpdate_Click(Object sender, EventArgs e) @@ -1571,17 +1638,11 @@ namespace Xylem.Common.Ui.GenesisToolBox return true; } - else - { - return false; - } + + return false; - } - public void StartUpdate() - { - } public MsgEventargs LastMsgEvent; public class MsgEventargs : EventArgs @@ -1608,7 +1669,7 @@ namespace Xylem.Common.Ui.GenesisToolBox #endregion - + #region User Controls private void tabDb_Click(Object sender, EventArgs e) { @@ -1618,15 +1679,15 @@ namespace Xylem.Common.Ui.GenesisToolBox { if (tabFwSources.SelectedTab == tabLocalFile) { - checkSelectionChanged(FwSource.File); + CheckSelectionChanged(FwSource.File); } else if (tabFwSources.SelectedTab == tabProduction) { - checkSelectionChanged(FwSource.File); + CheckSelectionChanged(FwSource.File); } else if (tabFwSources.SelectedTab == tabDb) { - checkSelectionChanged(FwSource.Db); + CheckSelectionChanged(FwSource.Db); cbxFilterFwDn.Items.Add("ALL"); @@ -1650,20 +1711,21 @@ namespace Xylem.Common.Ui.GenesisToolBox } else { - MessageBox.Show("No Tab selected!"); + MessageBox.Show(@"No Tab selected!"); } //tabFwSources.SelectedTab = tabLocalFile; } - private void checkSelectionChanged(FwSource newMode) + private void CheckSelectionChanged(FwSource newSource) { - if (newMode == _fwSource) + // ReSharper disable once RedundantCheckBeforeAssignment + if (newSource == _fwSource) { return; } - _fwSource = newMode; + _fwSource = newSource; } private void PushFwFile(MeterFwUpdate meterFwUpdate) @@ -1688,19 +1750,19 @@ namespace Xylem.Common.Ui.GenesisToolBox private void btnGetFWFiles_Click(Object sender, EventArgs e) { - var IsDevloper = chbFilterIsDeveloper.Checked; + var isDeveloper = chbFilterIsDeveloper.Checked; - var url = $"http://sla12iis01/MeterProcessState/api/FileUpToDate/GetFwFiles?FileIsForDeveloperOnly={IsDevloper}"; + var url = $"http://sla12iis01/MeterProcessState/api/FileUpToDate/GetFwFiles?FileIsForDeveloperOnly={isDeveloper}"; if (cbxFilterFwDn.SelectedItem.ToString() != "ALL") { - var MyMeterSize = ((MeterSize)cbxFilterFwDn.SelectedItem).GetHashCode(); - url = url + $"&CordonelFwFile_Dn={MyMeterSize}"; + var myMeterSize = ((MeterSize)cbxFilterFwDn.SelectedItem).GetHashCode(); + url = url + $"&CordonelFwFile_Dn={myMeterSize}"; } if (cbxFilterFWType.SelectedItem.ToString() != "ALL") { - var FWTypeEnum = ((CordonelFWTypeEnum)cbxFilterFWType.SelectedItem).GetHashCode(); - url = url + $"&CordonelFwFile_Type={FWTypeEnum}"; + var fwTypeEnum = ((CordonelFWTypeEnum)cbxFilterFWType.SelectedItem).GetHashCode(); + url = url + $"&CordonelFwFile_Type={fwTypeEnum}"; } url = url + $"&FileCategoryID=1"; @@ -1751,14 +1813,14 @@ namespace Xylem.Common.Ui.GenesisToolBox else if (item.FileName.ToLower().EndsWith(".txt")) { //encode content - String ControlFileContent = ""; + String controlFileContent; System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); - ControlFileContent = enc.GetString(item.FileContent.ToArray()); + controlFileContent = enc.GetString(item.FileContent.ToArray()); - _meterFwUpdate.LoadPackageFileFromText(ControlFileContent); + _meterFwUpdate.LoadPackageFileFromText(controlFileContent); } } @@ -1772,15 +1834,13 @@ namespace Xylem.Common.Ui.GenesisToolBox CheckUpdateEnabled(); _resetTimeMeasurement = true; - - - } - private void button1_Click(Object sender, EventArgs e) + private void btnClearDisplay_Click(Object sender, EventArgs e) { - if (_currentGenesis == null ) return; + if (_currentGenesis == null) + return; if (!_currentGenesis.IsLoggedOn) { _currentGenesis.Login(); @@ -1792,39 +1852,61 @@ namespace Xylem.Common.Ui.GenesisToolBox private void btnFixBat_Click(Object sender, EventArgs e) { - try - { - _currentGenesis.Login(); - _currentGenesis.WriteRegister("GENESISFLOW_SealDisplay", (UInt32)0, true, false); - _currentGenesis.ResetAlarm(GenesisMeter.Alarm.ALL); + _currentGenesis.Login(); + _currentGenesis.WriteRegister("GENESISFLOW_SealDisplay", (UInt32)0); + _currentGenesis.ResetAlarm(GenesisMeter.Alarm.ALL); - _currentGenesis.WriteRegister("POWERMON_WarnFromClamp", (UInt32)630720000, true, false); - _currentGenesis.WriteRegister("POWERMON_BatteryQuantity", (UInt32)2, true, false); - _currentGenesis.WriteRegister("POWERMON_StoreConfiguration", (UInt32)1, true, false); - _currentGenesis.WriteRegister("GENESISFLOW_TriggerIdle", (UInt32)0, true, false); - - - _currentGenesis.StoreAllConfigurations(); - _currentGenesis.Logout(); + _currentGenesis.WriteRegister("POWERMON_WarnFromClamp", (UInt32)630720000); + _currentGenesis.WriteRegister("POWERMON_BatteryQuantity", (UInt32)2); + _currentGenesis.WriteRegister("POWERMON_StoreConfiguration", (UInt32)1); + _currentGenesis.WriteRegister("GENESISFLOW_TriggerIdle", (UInt32)0); - Thread.Sleep(15000); - _currentGenesis.Login(); - - } - catch (Exception) - { - - throw; - } - + _currentGenesis.StoreAllConfigurations(); + _currentGenesis.Logout(); + Thread.Sleep(5000); + _currentGenesis.Login(); } - private void label2_Click(Object sender, EventArgs e) + private void cbxStoreConfigEnable_CheckedChanged(Object sender, EventArgs e) + { + if (_meterFwUpdate != null) + _meterFwUpdate.StoreConfigEnable = cbxStoreConfigEnable.Checked; + } + + /// + /// Read config file from meter and store it to disk. + /// + /// + /// - Initial + /// + private void btnUploadConfig_Click(Object sender, EventArgs e) { + if (_currentGenesis == null ) return; + if (_meterFwUpdate == null) _meterFwUpdate = new MeterFwUpdate(_currentGenesis); + + UploadFileControl(true); + if (!_currentGenesis.IsLoggedOn) _currentGenesis.ReLogin(); + + if (_meterFwUpdate.UploadConfigFile()) + { + if (saveConfigFile.ShowDialog() == DialogResult.OK) + { + var fs = new FileStream(saveConfigFile.FileName, FileMode.OpenOrCreate); + var bw = new BinaryWriter(fs); + foreach (var t in _meterFwUpdate.ConfigFile.BinData) + bw.Write(t); + fs.Close(); + } + } + + _currentGenesis.Logout(); + UploadFileControl(false); + } + #endregion } } diff --git a/Common/Ui/GenesisToolBox/FrmFwUpdate.resx b/Common/Ui/GenesisToolBox/FrmFwUpdate.resx index baf207bc..14eefb68 100644 --- a/Common/Ui/GenesisToolBox/FrmFwUpdate.resx +++ b/Common/Ui/GenesisToolBox/FrmFwUpdate.resx @@ -126,13 +126,13 @@ 17, 17 - - 465, 17 - True True + + 465, 17 + \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/FrmLutUpdate.cs b/Common/Ui/GenesisToolBox/FrmLutUpdate.cs index 221779e2..125fbd61 100644 --- a/Common/Ui/GenesisToolBox/FrmLutUpdate.cs +++ b/Common/Ui/GenesisToolBox/FrmLutUpdate.cs @@ -165,10 +165,9 @@ namespace Xylem.Common.Ui.GenesisToolBox try { Init(); - Int32 slotNr; if (string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) || - !int.TryParse(cbComSlot.SelectedItem.ToString(), out slotNr)) + !int.TryParse(cbComSlot.SelectedItem.ToString(), out var slotNr)) { return; }