MeterResetPsu: - removed delay of 20s, instead polled for PcbId to wait for reboot,

FrmLutUpdate: - [ClearDisplay] butoon added
This commit is contained in:
Thomas Wiedebusch
2022-12-12 13:15:45 +01:00
parent 2654f70bf2
commit bc0971525b
12 changed files with 157 additions and 49 deletions
+1 -1
View File
@@ -155,7 +155,7 @@
</site>
<site name="MeterProcessState" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\drabesch_ro\Repo\lab\la_operations\laa_production\Common\Service\MeterProcessState" />
<virtualDirectory path="/" physicalPath="C:\Users\wiedebu_th.WORLD\Source\Repos\laa_production\Common\Service\MeterProcessState" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:56011:localhost" />
+1 -1
View File
@@ -27,7 +27,7 @@
<s:Boolean x:Key="/Default/Environment/ExcludedFiles/FilesAndFoldersToSkip/=1057AD21_002DBA22_002D4CAB_002DB3FE_002D88C5C9980E6A_002Fd_003AScripts_002Ff_003Ajquery_002D1_002E10_002E2_002Eintellisense_002Ejs/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/Environment/Hierarchy/Build/SolBuilderDuo/UseMsbuildSolutionBuilder/@EntryValue">NewVersion</s:String>
<s:Boolean x:Key="/Default/Environment/Hierarchy/EntityFrameworkOptions/IsAlreadyNotifiedAboutEntityFramework/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/Environment/Highlighting/HighlightingSourceSnapshotLocation/@EntryValue">C:\Users\Thomas\AppData\Local\Temp\JetBrains\ReSharperPlatformVs15\vAny_33007af5\CoverageData\_Common.-1885154465\Snapshot\snapshot.utdcvr</s:String>
@@ -45,11 +45,15 @@
/// Download upgrade file upg18
/// </summary>
DownloadUpgradeCtrlFile,
/// <summary>
/// <summary>
/// Trigger Upgrade
/// </summary>
TriggerUpgrade,
/// <summary>
/// Wait until meter reboot with communication polling
/// </summary>
WaitReboot,
/// <summary>
/// Delimiter for list
/// </summary>
ResetStateListDelimiter
@@ -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
/// <remarks date="2022-Aug-16" author="Thomas Wiedebusch">
/// - Store configurations added
/// </remarks>
/// <remarks date="2022-Dec-12" author="Thomas Wiedebusch">
/// - Wait re-boot introduced.
/// </remarks>
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;
}
/// <summary>
/// Wait for reboot of meter
/// </summary>
/// <returns></returns>
/// <remarks date="2022-Aug-10" author="Thomas Wiedebusch">
/// - Initial
/// </remarks>
private Boolean WaitReboot()
{
_actualOperation = Resources.StrWaitingForReboot;
var rebootCtr = 0;
String pcbId;
do
{
pcbId = RegisterConverter.ConvertTo<String>(
_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
@@ -257,5 +257,14 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Properties {
return ResourceManager.GetString("StrWaiting", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Waiting for reboot.
/// </summary>
public static string StrWaitingForReboot {
get {
return ResourceManager.GetString("StrWaitingForReboot", resourceCulture);
}
}
}
}
@@ -159,6 +159,9 @@
<data name="StrWaiting" xml:space="preserve">
<value>Warte....</value>
</data>
<data name="StrWaitingForReboot" xml:space="preserve">
<value>Warte auf Neustart</value>
</data>
<data name="StrMeterAppTriggerFailed" xml:space="preserve">
<value>Abschlußvorgang mißlungen</value>
</data>
@@ -156,9 +156,12 @@
<data name="StrFwUpdateStateUploadFileApps" xml:space="preserve">
<value>Upload Update Files</value>
</data>
<data name="StrWaiting" xml:space="preserve">
<data name="StrWaiting" xml:space="preserve">
<value>Waiting....</value>
</data>
<data name="StrWaitingForReboot" xml:space="preserve">
<value>Waiting for reboot</value>
</data>
<data name="StrMeterAppTriggerFailed" xml:space="preserve">
<value>Trigger upgrade failed</value>
</data>
@@ -1 +1 @@
1a3d4919c9c702245832d925951f2b7cb72fc333
d6acafee485301268608cd081e3b8b166497c098
@@ -1 +1 @@
0d85a5b3a7561b41163c20e5dc7713bcd0d65555
8b50223304bf33a04e89f81c8416e46bbd1ea8d8
-1
View File
@@ -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;
+40 -27
View File
@@ -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;
}
}
+52 -13
View File
@@ -669,14 +669,34 @@ namespace Xylem.Common.Ui.GenesisToolBox
#endregion
#region ExternalCalls
/// <summary>
///
/// </summary>
public MsgEventArgs LastMsgEvent;
/// <inheritdoc />
public class MsgEventArgs : EventArgs
{
/// <summary>
/// Text to display
/// </summary>
public String Text;
/// <summary>
/// Headline
/// </summary>
public String Caption;
/// <summary>
/// Buttons
/// </summary>
public MessageBoxButtons Buttons;
/// <summary>
/// Icon
/// </summary>
public MessageBoxIcon Icon;
}
/// <summary>
/// Message pop up event handler
/// </summary>
public event EventHandler<MsgEventArgs> 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;
}
}
}
}