diff --git a/Common/.vs/config/applicationhost.config b/Common/.vs/config/applicationhost.config index 40cde372..305a2bb6 100644 --- a/Common/.vs/config/applicationhost.config +++ b/Common/.vs/config/applicationhost.config @@ -155,7 +155,7 @@ - + diff --git a/Common/Common.sln.DotSettings.user b/Common/Common.sln.DotSettings.user index 83a49bf8..a978e48d 100644 --- a/Common/Common.sln.DotSettings.user +++ b/Common/Common.sln.DotSettings.user @@ -27,7 +27,7 @@ True NewVersion True - C:\Users\Thomas\AppData\Local\Temp\JetBrains\ReSharperPlatformVs15\vAny_33007af5\CoverageData\_Common.-1885154465\Snapshot\snapshot.utdcvr + diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/MeterResetPsuState.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/MeterResetPsuState.cs index b2e5f043..5fdf5836 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/MeterResetPsuState.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/MeterResetPsuState.cs @@ -45,11 +45,15 @@ /// Download upgrade file upg18 /// DownloadUpgradeCtrlFile, - /// + /// /// Trigger Upgrade /// TriggerUpgrade, /// + /// Wait until meter reboot with communication polling + /// + WaitReboot, + /// /// Delimiter for list /// ResetStateListDelimiter diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterResetPsu.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterResetPsu.cs index 8b25fa1e..b5a8e962 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterResetPsu.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterResetPsu.cs @@ -62,6 +62,12 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile //trigger update retries private const Int32 TriggerWriteRetries = 2; + //time to wait until next trial of communication during reboot + private const Int32 RebootWaitTimeMs = 500; + + //reboot wait cycles to be multiplied with reboot wait time for maximum overall time if unsuccessful + private const Int32 RebootWaitCycles = 60; + //retry of entire update procedure private const Int32 UpdateProcedureRetries = 1; @@ -276,7 +282,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile { MeterResetPsuStateMachine(); } - Thread.Sleep(20000); return ExitPreparation(true); } @@ -370,6 +375,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// /// - Store configurations added /// + /// + /// - Wait re-boot introduced. + /// private void MeterResetPsuStateMachine() { if (_backupMeterResetPsuState == _meterResetPsuState) @@ -413,10 +421,14 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile break; case MeterResetPsuState.TriggerUpgrade: - _meterResetPsuState = TriggerUpgrade() ? MeterResetPsuState.ResetSucceeded : + _meterResetPsuState = TriggerUpgrade() ? MeterResetPsuState.WaitReboot : MeterResetPsuState.StepFailed; break; + case MeterResetPsuState.WaitReboot: + _meterResetPsuState = WaitReboot() ? MeterResetPsuState.ResetSucceeded : + MeterResetPsuState.StepFailed; + break; case MeterResetPsuState.StepFailed: _meterResetPsuState = _processRetryCtr++ < UpdateProcedureRetries @@ -663,6 +675,32 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile return returnValue && !StopUpdateProcess; } + /// + /// Wait for reboot of meter + /// + /// + /// + /// - Initial + /// + private Boolean WaitReboot() + { + _actualOperation = Resources.StrWaitingForReboot; + var rebootCtr = 0; + String pcbId; + do + { + pcbId = RegisterConverter.ConvertTo( + _genesisMeter.ReadRegister(Register.Configexchange.PcbSerialNumber, 12)); + + if (string.IsNullOrEmpty(pcbId)) + { + Thread.Sleep(RebootWaitTimeMs); + } + + } while (string.IsNullOrEmpty(pcbId) && rebootCtr++ < RebootWaitCycles && !StopUpdateProcess); + + return !string.IsNullOrEmpty(pcbId) && !StopUpdateProcess; + } #endregion diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.Designer.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.Designer.cs index 3cdc9d25..3bb58940 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.Designer.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.Designer.cs @@ -257,5 +257,14 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Properties { return ResourceManager.GetString("StrWaiting", resourceCulture); } } + + /// + /// Looks up a localized string similar to Waiting for reboot. + /// + public static string StrWaitingForReboot { + get { + return ResourceManager.GetString("StrWaitingForReboot", resourceCulture); + } + } } } diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.de.resx b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.de.resx index cee71271..29e6c483 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.de.resx +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.de.resx @@ -159,6 +159,9 @@ Warte.... + + Warte auf Neustart + Abschlußvorgang mißlungen diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.resx b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.resx index 8480a5d1..ddfa14c6 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.resx +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/Properties/Resources.resx @@ -156,9 +156,12 @@ Upload Update Files - + Waiting.... + + Waiting for reboot + Trigger upgrade failed diff --git a/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache b/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache index d8b5c8f6..7286a520 100644 --- a/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache +++ b/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -1a3d4919c9c702245832d925951f2b7cb72fc333 +d6acafee485301268608cd081e3b8b166497c098 diff --git a/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache b/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache index 133b97f0..8345ac8d 100644 --- a/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache +++ b/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -0d85a5b3a7561b41163c20e5dc7713bcd0d65555 +8b50223304bf33a04e89f81c8416e46bbd1ea8d8 diff --git a/Common/Ui/GenesisToolBox/FrmFwUpdate.cs b/Common/Ui/GenesisToolBox/FrmFwUpdate.cs index 5cc5395a..d5bf23c3 100644 --- a/Common/Ui/GenesisToolBox/FrmFwUpdate.cs +++ b/Common/Ui/GenesisToolBox/FrmFwUpdate.cs @@ -11,7 +11,6 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -using Logic.ProductionToProductMapper.Cordonel; using Xylem.Common.CommonCore.Configuration; using Xylem.Common.Hardware.WaterMeter.Genesis.Applications; using Xylem.Common.Hardware.WaterMeter.Genesis.Applications.Const; diff --git a/Common/Ui/GenesisToolBox/FrmLutUpdate.Designer.cs b/Common/Ui/GenesisToolBox/FrmLutUpdate.Designer.cs index f1092754..e85c58c2 100644 --- a/Common/Ui/GenesisToolBox/FrmLutUpdate.Designer.cs +++ b/Common/Ui/GenesisToolBox/FrmLutUpdate.Designer.cs @@ -30,6 +30,8 @@ { this.components = new System.ComponentModel.Container(); this.grpSetup = new System.Windows.Forms.GroupBox(); + this.label10 = new System.Windows.Forms.Label(); + this.tbxRadio = new System.Windows.Forms.TextBox(); this.tbxRegion = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); this.tbxPcbId = new System.Windows.Forms.TextBox(); @@ -74,8 +76,7 @@ this.label9 = new System.Windows.Forms.Label(); this.lblUpdateTime = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); - this.tbxRadio = new System.Windows.Forms.TextBox(); - this.label10 = new System.Windows.Forms.Label(); + this.btnClearDisplay = new System.Windows.Forms.Button(); this.grpSetup.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.groupBox1.SuspendLayout(); @@ -83,6 +84,7 @@ // // grpSetup // + this.grpSetup.Controls.Add(this.btnClearDisplay); this.grpSetup.Controls.Add(this.label10); this.grpSetup.Controls.Add(this.tbxRadio); this.grpSetup.Controls.Add(this.tbxRegion); @@ -100,11 +102,28 @@ this.grpSetup.Controls.Add(this.cbComSlot); this.grpSetup.Location = new System.Drawing.Point(12, 69); this.grpSetup.Name = "grpSetup"; - this.grpSetup.Size = new System.Drawing.Size(257, 250); + this.grpSetup.Size = new System.Drawing.Size(257, 273); this.grpSetup.TabIndex = 24; this.grpSetup.TabStop = false; this.grpSetup.Text = "Cordonel"; // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(10, 212); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(116, 13); + this.label10.TabIndex = 36; + this.label10.Text = "Radio frequency[MHz]:"; + // + // tbxRadio + // + this.tbxRadio.Location = new System.Drawing.Point(128, 208); + this.tbxRadio.Name = "tbxRadio"; + this.tbxRadio.ReadOnly = true; + this.tbxRadio.Size = new System.Drawing.Size(68, 20); + this.tbxRadio.TabIndex = 35; + // // tbxRegion // this.tbxRegion.Location = new System.Drawing.Point(128, 178); @@ -244,7 +263,7 @@ // this.lblWaitingForMeterResponse.AutoSize = true; this.lblWaitingForMeterResponse.ForeColor = System.Drawing.Color.Red; - this.lblWaitingForMeterResponse.Location = new System.Drawing.Point(529, 331); + this.lblWaitingForMeterResponse.Location = new System.Drawing.Point(529, 351); this.lblWaitingForMeterResponse.Name = "lblWaitingForMeterResponse"; this.lblWaitingForMeterResponse.Size = new System.Drawing.Size(182, 13); this.lblWaitingForMeterResponse.TabIndex = 18; @@ -273,7 +292,7 @@ // lblOverall // this.lblOverall.AutoSize = true; - this.lblOverall.Location = new System.Drawing.Point(18, 368); + this.lblOverall.Location = new System.Drawing.Point(18, 388); this.lblOverall.Name = "lblOverall"; this.lblOverall.Size = new System.Drawing.Size(80, 13); this.lblOverall.TabIndex = 7; @@ -281,7 +300,7 @@ // // barSingleProgressUpdate // - this.barSingleProgressUpdate.Location = new System.Drawing.Point(9, 347); + this.barSingleProgressUpdate.Location = new System.Drawing.Point(9, 367); this.barSingleProgressUpdate.Name = "barSingleProgressUpdate"; this.barSingleProgressUpdate.Size = new System.Drawing.Size(702, 18); this.barSingleProgressUpdate.TabIndex = 6; @@ -290,7 +309,7 @@ // lblActualProcess // this.lblActualProcess.AutoSize = true; - this.lblActualProcess.Location = new System.Drawing.Point(18, 331); + this.lblActualProcess.Location = new System.Drawing.Point(18, 351); this.lblActualProcess.Name = "lblActualProcess"; this.lblActualProcess.Size = new System.Drawing.Size(76, 13); this.lblActualProcess.TabIndex = 4; @@ -298,7 +317,7 @@ // // barOverallProgressUpdate // - this.barOverallProgressUpdate.Location = new System.Drawing.Point(9, 384); + this.barOverallProgressUpdate.Location = new System.Drawing.Point(9, 404); this.barOverallProgressUpdate.Name = "barOverallProgressUpdate"; this.barOverallProgressUpdate.Size = new System.Drawing.Size(702, 18); this.barOverallProgressUpdate.TabIndex = 3; @@ -357,7 +376,7 @@ this.groupBox1.Controls.Add(this.btnOpenLutFile); this.groupBox1.Location = new System.Drawing.Point(275, 69); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(436, 250); + this.groupBox1.Size = new System.Drawing.Size(436, 273); this.groupBox1.TabIndex = 28; this.groupBox1.TabStop = false; this.groupBox1.Text = "Lookup Table File"; @@ -513,7 +532,7 @@ // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(247, 331); + this.label9.Location = new System.Drawing.Point(247, 351); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(101, 13); this.label9.TabIndex = 30; @@ -522,7 +541,7 @@ // lblUpdateTime // this.lblUpdateTime.AutoSize = true; - this.lblUpdateTime.Location = new System.Drawing.Point(354, 331); + this.lblUpdateTime.Location = new System.Drawing.Point(354, 351); this.lblUpdateTime.Name = "lblUpdateTime"; this.lblUpdateTime.Size = new System.Drawing.Size(28, 13); this.lblUpdateTime.TabIndex = 31; @@ -538,29 +557,22 @@ this.label7.TabIndex = 32; this.label7.Text = "Cordonel LUT Update"; // - // tbxRadio + // btnClearDisplay // - this.tbxRadio.Location = new System.Drawing.Point(128, 208); - this.tbxRadio.Name = "tbxRadio"; - this.tbxRadio.ReadOnly = true; - this.tbxRadio.Size = new System.Drawing.Size(68, 20); - this.tbxRadio.TabIndex = 35; - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(10, 212); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(116, 13); - this.label10.TabIndex = 36; - this.label10.Text = "Radio frequency[MHz]:"; + this.btnClearDisplay.Location = new System.Drawing.Point(128, 239); + this.btnClearDisplay.Name = "btnClearDisplay"; + this.btnClearDisplay.Size = new System.Drawing.Size(116, 25); + this.btnClearDisplay.TabIndex = 33; + this.btnClearDisplay.Text = "Clear Display"; + this.btnClearDisplay.UseVisualStyleBackColor = true; + this.btnClearDisplay.Click += new System.EventHandler(this.btnClearDisplay_Click); // // FrmLutUpdate // this.AccessibleRole = System.Windows.Forms.AccessibleRole.Sound; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(723, 418); + this.ClientSize = new System.Drawing.Size(723, 432); this.Controls.Add(this.label7); this.Controls.Add(this.lblUpdateTime); this.Controls.Add(this.label9); @@ -640,5 +652,6 @@ private System.Windows.Forms.Button btnLoadfromDb; private System.Windows.Forms.Label label10; private System.Windows.Forms.TextBox tbxRadio; + private System.Windows.Forms.Button btnClearDisplay; } } \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/FrmLutUpdate.cs b/Common/Ui/GenesisToolBox/FrmLutUpdate.cs index 5cc77f3f..a2d43131 100644 --- a/Common/Ui/GenesisToolBox/FrmLutUpdate.cs +++ b/Common/Ui/GenesisToolBox/FrmLutUpdate.cs @@ -669,14 +669,34 @@ namespace Xylem.Common.Ui.GenesisToolBox #endregion #region ExternalCalls + /// + /// + /// public MsgEventArgs LastMsgEvent; + + /// public class MsgEventArgs : EventArgs { + /// + /// Text to display + /// public String Text; + /// + /// Headline + /// public String Caption; + /// + /// Buttons + /// public MessageBoxButtons Buttons; + /// + /// Icon + /// public MessageBoxIcon Icon; } + /// + /// Message pop up event handler + /// public event EventHandler OnMsgPopUp; private void MessageBoxShow(String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon) { @@ -698,25 +718,25 @@ namespace Xylem.Common.Ui.GenesisToolBox private void SwitchView(Object sender, EventArgs e) { btnLoadfromDb.Enabled = false; - Boolean File = rbtFile.Checked; - cbxDbLuts.Visible = !File; - lblSelectDb.Visible = !File; - btnLoadfromDb.Visible = !File; + var file = rbtFile.Checked; + cbxDbLuts.Visible = !file; + lblSelectDb.Visible = !file; + btnLoadfromDb.Visible = !file; - lvlSelechtFile.Visible = File; - tbxLutFilePathName.Visible = File; - btnOpenLutFile.Visible = File; - if (!File) + lvlSelechtFile.Visible = file; + tbxLutFilePathName.Visible = file; + btnOpenLutFile.Visible = file; + if (!file) { LoadDbLuts(rbtProd.Checked); } } - private void LoadDbLuts(Boolean Prod) + private void LoadDbLuts(Boolean prod) { - StringBuilder sbUrl = new StringBuilder(); + var sbUrl = new StringBuilder(); sbUrl.Append("http://10.49.40.25/MeterProcessState/api/FileUpToDate/GetLutFiles"); //sbUrl.Append("http://localhost:56011/api/FileUpToDate/GetLutFiles"); //sbUrl.Append($"?DataLength={_DataLength}"); @@ -736,7 +756,7 @@ namespace Xylem.Common.Ui.GenesisToolBox foreach (var item in a) { - if (!Prod || item.CurrentVersionForProd) + if (!prod || item.CurrentVersionForProd) { cbxDbLuts.Items.Add(item); } @@ -753,7 +773,7 @@ namespace Xylem.Common.Ui.GenesisToolBox private void cbxDbLuts_SelectedIndexChanged(Object sender, EventArgs e) { - if (cbxDbLuts.SelectedItem is CordonelMetrologyLut lut) + if (cbxDbLuts.SelectedItem is CordonelMetrologyLut) { btnLoadfromDb.Enabled = true; } @@ -822,6 +842,25 @@ namespace Xylem.Common.Ui.GenesisToolBox { } + + private void btnClearDisplay_Click(Object sender, EventArgs e) + { + if (_currentGenesis == null) + return; + + lblOverall.Text = @"Set display to normal operation"; + lblOverall.Visible = true; + Update(); + + if (!_currentGenesis.IsLoggedOn) + { + _currentGenesis.ReLogin(); + } + + _currentGenesis.SetLcdText(true, new Byte[] { 0x00, 0x00, 0x00, 0x00 }); + _currentGenesis.Logout(); + lblOverall.Visible = false; + } } - } +}