MeterFwUpdate: - Corrected to set metrology upgrade permission,
LowLevelTool: - Erase of single manual input files
This commit is contained in:
@@ -260,9 +260,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// <remarks date="2020-Dec-19" author="Thomas Wiedebusch">
|
||||
/// - Check installed application before require access to registers.
|
||||
/// </remarks>
|
||||
/// <remarks date="2023-Jan-18" author="Thomas Wiedebusch">
|
||||
/// - Enable update of Genesis Flow on request.
|
||||
/// </remarks>
|
||||
public MeterFwUpdate(GenesisMeter genesisMeter, Boolean updateGenesisFlowEnable = false)
|
||||
{
|
||||
if (genesisMeter == null)
|
||||
@@ -287,11 +284,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
{
|
||||
_registersBeforeUpdate.Add(Register.Sensusradio.WakeupInterval, new Byte[] { 6 });
|
||||
}
|
||||
|
||||
if (UpdateGenesisFlowEnable)
|
||||
{
|
||||
_registersBeforeUpdate.Add(Register.System.MetrologyUpgradePermission, new Byte[] { 0xFF });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -996,8 +988,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// <remarks date="2022-Jun-23" author="Thomas Wiedebusch">
|
||||
/// - Try catch block to avoid e.g. METROLOGYASST_PulseMode.
|
||||
/// </remarks>
|
||||
/// <remarks date="2023-Jan-19" author="Thomas Wiedebusch">
|
||||
/// - Read back upgrade permission for metrology.
|
||||
/// <remarks date="2023-Jan-20" author="Thomas Wiedebusch">
|
||||
/// - Set upgrade permission for metrology to 0xFF if required (will be done by GTB).
|
||||
/// </remarks>
|
||||
public Boolean UpdatePreparation()
|
||||
{
|
||||
@@ -1037,6 +1029,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
_registersAfterUpdate = new Dictionary<String, Byte[]>();
|
||||
try
|
||||
{
|
||||
if (UpdateGenesisFlowEnable)
|
||||
{
|
||||
_genesisMeter.WriteRegister(Register.System.MetrologyUpgradePermission, new Byte[] { 0xFF });
|
||||
}
|
||||
foreach (var item in _registersBeforeUpdate)
|
||||
{
|
||||
var writeBackValue = _genesisMeter.ReadRegister(item.Key);
|
||||
|
||||
+85
-10
@@ -57,6 +57,7 @@
|
||||
this.lblFwUpdateInfo = new System.Windows.Forms.Label();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.btnTidyFile = new System.Windows.Forms.Button();
|
||||
this.btnGetDateTime = new System.Windows.Forms.Button();
|
||||
this.btnSetDateTime = new System.Windows.Forms.Button();
|
||||
this.btnRebootMeter = new System.Windows.Forms.Button();
|
||||
@@ -70,11 +71,17 @@
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.btnListFileDetails = new System.Windows.Forms.Button();
|
||||
this.btnReadLogFiles = new System.Windows.Forms.Button();
|
||||
this.btnTidyFile = new System.Windows.Forms.Button();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.tbxFileToEraseName = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.tbxFileToEraseDrive = new System.Windows.Forms.TextBox();
|
||||
this.btnEraseFile = new System.Windows.Forms.Button();
|
||||
this.grpSetup.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// grpSetup
|
||||
@@ -363,6 +370,16 @@
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Tools";
|
||||
//
|
||||
// btnTidyFile
|
||||
//
|
||||
this.btnTidyFile.Location = new System.Drawing.Point(10, 174);
|
||||
this.btnTidyFile.Name = "btnTidyFile";
|
||||
this.btnTidyFile.Size = new System.Drawing.Size(116, 25);
|
||||
this.btnTidyFile.TabIndex = 39;
|
||||
this.btnTidyFile.Text = "Tidy File System";
|
||||
this.btnTidyFile.UseVisualStyleBackColor = true;
|
||||
this.btnTidyFile.Click += new System.EventHandler(this.btnTidyFile_Click);
|
||||
//
|
||||
// btnGetDateTime
|
||||
//
|
||||
this.btnGetDateTime.Location = new System.Drawing.Point(10, 144);
|
||||
@@ -462,7 +479,7 @@
|
||||
this.groupBox2.Controls.Add(this.btnUploadConfig);
|
||||
this.groupBox2.Location = new System.Drawing.Point(417, 69);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(136, 273);
|
||||
this.groupBox2.Size = new System.Drawing.Size(136, 123);
|
||||
this.groupBox2.TabIndex = 37;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Log";
|
||||
@@ -487,15 +504,64 @@
|
||||
this.btnReadLogFiles.UseVisualStyleBackColor = true;
|
||||
this.btnReadLogFiles.Click += new System.EventHandler(this.btnReadLogFiles_Click);
|
||||
//
|
||||
// btnTidyFile
|
||||
// groupBox3
|
||||
//
|
||||
this.btnTidyFile.Location = new System.Drawing.Point(10, 174);
|
||||
this.btnTidyFile.Name = "btnTidyFile";
|
||||
this.btnTidyFile.Size = new System.Drawing.Size(116, 25);
|
||||
this.btnTidyFile.TabIndex = 39;
|
||||
this.btnTidyFile.Text = "Tidy File System";
|
||||
this.btnTidyFile.UseVisualStyleBackColor = true;
|
||||
this.btnTidyFile.Click += new System.EventHandler(this.btnTidyFile_Click);
|
||||
this.groupBox3.Controls.Add(this.label4);
|
||||
this.groupBox3.Controls.Add(this.tbxFileToEraseName);
|
||||
this.groupBox3.Controls.Add(this.label3);
|
||||
this.groupBox3.Controls.Add(this.tbxFileToEraseDrive);
|
||||
this.groupBox3.Controls.Add(this.btnEraseFile);
|
||||
this.groupBox3.Location = new System.Drawing.Point(559, 69);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(136, 123);
|
||||
this.groupBox3.TabIndex = 40;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "Erase Files";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(10, 60);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(38, 13);
|
||||
this.label4.TabIndex = 40;
|
||||
this.label4.Text = "Name:";
|
||||
//
|
||||
// tbxFileToEraseName
|
||||
//
|
||||
this.tbxFileToEraseName.Location = new System.Drawing.Point(50, 57);
|
||||
this.tbxFileToEraseName.Name = "tbxFileToEraseName";
|
||||
this.tbxFileToEraseName.Size = new System.Drawing.Size(76, 20);
|
||||
this.tbxFileToEraseName.TabIndex = 41;
|
||||
this.tbxFileToEraseName.Text = "tstfile";
|
||||
this.tbxFileToEraseName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxFileToEraseName_KeyDown);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(10, 30);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(35, 13);
|
||||
this.label3.TabIndex = 39;
|
||||
this.label3.Text = "Drive:";
|
||||
//
|
||||
// tbxFileToEraseDrive
|
||||
//
|
||||
this.tbxFileToEraseDrive.Location = new System.Drawing.Point(50, 27);
|
||||
this.tbxFileToEraseDrive.Name = "tbxFileToEraseDrive";
|
||||
this.tbxFileToEraseDrive.Size = new System.Drawing.Size(76, 20);
|
||||
this.tbxFileToEraseDrive.TabIndex = 39;
|
||||
this.tbxFileToEraseDrive.Text = "1";
|
||||
//
|
||||
// btnEraseFile
|
||||
//
|
||||
this.btnEraseFile.Location = new System.Drawing.Point(10, 84);
|
||||
this.btnEraseFile.Name = "btnEraseFile";
|
||||
this.btnEraseFile.Size = new System.Drawing.Size(116, 25);
|
||||
this.btnEraseFile.TabIndex = 39;
|
||||
this.btnEraseFile.Text = "Erase File";
|
||||
this.btnEraseFile.UseVisualStyleBackColor = true;
|
||||
this.btnEraseFile.Click += new System.EventHandler(this.btnEraseFile_Click);
|
||||
//
|
||||
// FrmLowLevelTools
|
||||
//
|
||||
@@ -503,6 +569,7 @@
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(723, 432);
|
||||
this.Controls.Add(this.groupBox3);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.label7);
|
||||
this.Controls.Add(this.lblUpdateTime);
|
||||
@@ -532,6 +599,8 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.groupBox3.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -581,5 +650,11 @@
|
||||
private System.Windows.Forms.Button btnReadLogFiles;
|
||||
private System.Windows.Forms.Button btnListFileDetails;
|
||||
private System.Windows.Forms.Button btnTidyFile;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox tbxFileToEraseDrive;
|
||||
private System.Windows.Forms.Button btnEraseFile;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.TextBox tbxFileToEraseName;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using Logic.ProductionToProductMapper.Cordonel;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -157,6 +158,9 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
btnReadLogFiles.Enabled = false;
|
||||
btnListFileDetails.Enabled = false;
|
||||
btnTidyFile.Enabled = false;
|
||||
btnEraseFile.Enabled = false;
|
||||
tbxFileToEraseName.Enabled = false;
|
||||
tbxFileToEraseDrive.Enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -174,6 +178,9 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
btnReadLogFiles.Enabled = true;
|
||||
btnListFileDetails.Enabled = true;
|
||||
btnTidyFile.Enabled = true;
|
||||
btnEraseFile.Enabled = true;
|
||||
tbxFileToEraseName.Enabled = true;
|
||||
tbxFileToEraseDrive.Enabled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1372,7 +1379,8 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
? $@"File {fileToErase} successfully erased"
|
||||
: $@"File {fileToErase} erasure failed");
|
||||
|
||||
if (success) continue;
|
||||
if (success)
|
||||
continue;
|
||||
_currentGenesis.Logout();
|
||||
_currentGenesis.ReLogin();
|
||||
}
|
||||
@@ -1391,6 +1399,65 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
});
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Erase a specified file
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <remarks date="2022-Dec-20" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
private void btnEraseFile_Click(Object sender, EventArgs e)
|
||||
{
|
||||
if (_currentGenesis == null)
|
||||
return;
|
||||
if (_meterFile == null)
|
||||
_meterFile = new MeterFile(_currentGenesis);
|
||||
|
||||
//reset timer
|
||||
_startTime = DateTimeOffset.UtcNow;
|
||||
|
||||
LowLevelActionControl(true);
|
||||
|
||||
var file = $@"{tbxFileToEraseDrive.Text}\{tbxFileToEraseName.Text}";
|
||||
var msg = $@"Erase file {file}";
|
||||
LogText(msg);
|
||||
lblOverall.Text = msg;
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
_currentGenesis.ReLogin();
|
||||
|
||||
// erase files
|
||||
_meterFile.UnlockEraseWriteMeterFile(file);
|
||||
var success = _meterFile.EraseMeterFile(file);
|
||||
|
||||
LogText(success
|
||||
? $@"File {file} successfully erased"
|
||||
: $@"File {file} erasure failed");
|
||||
|
||||
// catalogue after cleaning
|
||||
SetActualProcessAndLog(@"List meter files");
|
||||
ListMeterFiles();
|
||||
|
||||
}).ContinueWith(delegate
|
||||
{
|
||||
//add a blank line to separate next operation
|
||||
LogText("");
|
||||
_currentGenesis.Logout();
|
||||
LowLevelActionControl(false);
|
||||
Invoke(new Action(() => { tbxFileToEraseName.Focus(); }));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void tbxFileToEraseName_KeyDown(Object sender, System.Windows.Forms.KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
btnEraseFile_Click(this, null);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user