GTB: -FwUpdate, LUT Update and MeterFile ReadMeterFile modified
This commit is contained in:
@@ -34,10 +34,21 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
//wb open file for writing in binary mode, if file exists its contents will be overwritten,
|
//wb open file for writing in binary mode, if file exists its contents will be overwritten,
|
||||||
//if file does not exist it will be created
|
//if file does not exist it will be created
|
||||||
private const String StrNewFileReadWriteMode = "wb";
|
private const String StrNewFileReadWriteMode = "wb";
|
||||||
//Open for reading in binary mode. If the file does not exist, fopen( ) returns NULL
|
//Open for reading in binary mode. If the file does not exist, FOpen returns NULL
|
||||||
private const String StrOpenFileReadOnlyMode = "rb";
|
private const String StrOpenFileReadOnlyMode = "rb";
|
||||||
//Open for both reading and writing in binary mode. If the file does not exist, fopen( ) returns NULL
|
//Open for both reading and writing in binary mode. If the file does not exist, FOpen returns NULL
|
||||||
private const String StrOpenFileReadWriteMode = "rb+";
|
private const String StrOpenFileReadWriteMode = "rb+";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// FSeek for start of file
|
||||||
|
/// </summary>
|
||||||
|
public const Int32 FSeekStartOfFile = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// FSeek for end of file
|
||||||
|
/// </summary>
|
||||||
|
public const Int32 FSeekEndOfFile = 2;
|
||||||
|
|
||||||
private String _fileName;
|
private String _fileName;
|
||||||
private Int32 _overallBytesCtr;
|
private Int32 _overallBytesCtr;
|
||||||
|
|
||||||
@@ -270,12 +281,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
_currentGenesis.ReadRegister(Register.Configexchange.FileWrite));
|
_currentGenesis.ReadRegister(Register.Configexchange.FileWrite));
|
||||||
returnedFileOffset = ReadFilePointerOffset();
|
returnedFileOffset = ReadFilePointerOffset();
|
||||||
}
|
}
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// //read DUMMY to overcome FW malfunction
|
|
||||||
// _currentGenesis.ReadRegister(Register.System.MonotonicSeconds);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//set timeout back to default value
|
//set timeout back to default value
|
||||||
_currentGenesis.TransmitProtocol.SetDefaultResponseTimeout();
|
_currentGenesis.TransmitProtocol.SetDefaultResponseTimeout();
|
||||||
CommunicationConfig.RequestRetries = CommunicationConfig.DefaultRequestRetries;
|
CommunicationConfig.RequestRetries = CommunicationConfig.DefaultRequestRetries;
|
||||||
@@ -300,7 +306,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fileName">file name as string</param>
|
/// <param name="fileName">file name as string</param>
|
||||||
/// <param name="readBackData">empty list of data</param>
|
/// <param name="readBackData">empty list of data</param>
|
||||||
/// <param name="readBackCount">size to read</param>
|
|
||||||
/// <returns>file content as byte array</returns>
|
/// <returns>file content as byte array</returns>
|
||||||
/// <remarks date="2019-Jun-20" author="Thomas Wiedebusch">
|
/// <remarks date="2019-Jun-20" author="Thomas Wiedebusch">
|
||||||
/// - Initial
|
/// - Initial
|
||||||
@@ -333,7 +338,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
/// <remarks date="2022-Apr-01" author="Thomas Wiedebusch">
|
/// <remarks date="2022-Apr-01" author="Thomas Wiedebusch">
|
||||||
/// - Add a NULL at the end of the file name.
|
/// - Add a NULL at the end of the file name.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public Boolean ReadMeterFile(String fileName, out List<Byte> readBackData, Int32 readBackCount)
|
/// <remarks date="2023-Jan-02" author="Thomas Wiedebusch">
|
||||||
|
/// - Read data according to file size searched with FSeek.
|
||||||
|
/// </remarks>
|
||||||
|
public Boolean ReadMeterFile(String fileName, out List<Byte> readBackData)
|
||||||
{
|
{
|
||||||
//set processing counter
|
//set processing counter
|
||||||
ProcessedBytesCtr = 0;
|
ProcessedBytesCtr = 0;
|
||||||
@@ -343,8 +351,12 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
fileName += StringDelimiter;
|
fileName += StringDelimiter;
|
||||||
|
|
||||||
readBackData = new List<Byte>();
|
readBackData = new List<Byte>();
|
||||||
var returnValue = OpenMeterFile(fileName, StrOpenFileReadOnlyMode);
|
|
||||||
|
|
||||||
|
// Get the current file size
|
||||||
|
var returnValue = GetFileSize(fileName, out var readBackCount);
|
||||||
|
|
||||||
|
returnValue &= OpenMeterFile(fileName, StrOpenFileReadOnlyMode);
|
||||||
|
|
||||||
if (returnValue)
|
if (returnValue)
|
||||||
{
|
{
|
||||||
//set register write retries to 0 to avoid doubling of records
|
//set register write retries to 0 to avoid doubling of records
|
||||||
@@ -524,11 +536,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
_currentGenesis.ReadRegister(Register.Configexchange.FileWrite));
|
_currentGenesis.ReadRegister(Register.Configexchange.FileWrite));
|
||||||
returnedFileOffset = ReadFilePointerOffset();
|
returnedFileOffset = ReadFilePointerOffset();
|
||||||
}
|
}
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// //read DUMMY to overcome FW malfunction
|
|
||||||
// _currentGenesis.ReadRegister(Register.System.MonotonicSeconds);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//set timeout back to default value
|
//set timeout back to default value
|
||||||
_currentGenesis.TransmitProtocol.SetDefaultResponseTimeout();
|
_currentGenesis.TransmitProtocol.SetDefaultResponseTimeout();
|
||||||
@@ -543,6 +550,34 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Uses FSeek to get the file size.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">file name as string</param>
|
||||||
|
/// <param name="fileSize">file size of the given file</param>
|
||||||
|
/// <returns>true: file found </returns>
|
||||||
|
/// <remarks date="2023-Jan-02" author="Thomas Wiedebusch">
|
||||||
|
/// - Initial
|
||||||
|
/// </remarks>
|
||||||
|
public Boolean GetFileSize(String fileName, out Int32 fileSize)
|
||||||
|
{
|
||||||
|
fileSize = 0;
|
||||||
|
var returnValue = OpenMeterFile(fileName, StrOpenFileReadOnlyMode);
|
||||||
|
|
||||||
|
if (returnValue)
|
||||||
|
{
|
||||||
|
returnValue &= SetFilePointerOffset(fSeekPara: FSeekEndOfFile);
|
||||||
|
|
||||||
|
if (returnValue)
|
||||||
|
{
|
||||||
|
fileSize = ReadFilePointerOffset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
returnValue &= CloseMeterFile();
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Meter file verification against given data
|
/// Meter file verification against given data
|
||||||
/// Takes into account, that the read file is always integer dividable by 4 due to the chunk size
|
/// Takes into account, that the read file is always integer dividable by 4 due to the chunk size
|
||||||
@@ -561,15 +596,23 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
{
|
{
|
||||||
var returnValue = true;
|
var returnValue = true;
|
||||||
|
|
||||||
if (!ReadMeterFile(fileName, out var binData, dataBytes.Length)) return false;
|
if (!ReadMeterFile(fileName, out var binData)|| binData == null || binData.Count == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
// compare the entire buffer which also includes the header of the file, remind the original
|
// compare the entire buffer which also includes the header of the file, remind the original
|
||||||
// buffer may be smaller due to the chunk size of the communication (always dividable by 4),
|
// buffer may be smaller due to the chunk size of the communication (always dividable by 4),
|
||||||
// meaning the receive buffer is always and integer of this chunk size!
|
// meaning the receive buffer is always and integer of this chunk size!
|
||||||
if (dataBytes.Where((t, ctr) => t != binData[ctr]).Any())
|
for (var ctr = 0; ctr < dataBytes.Length; ctr++)
|
||||||
{
|
{
|
||||||
returnValue = false;
|
if (binData[ctr] != dataBytes[ctr])
|
||||||
|
{
|
||||||
|
returnValue = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//if (dataBytes.Where((t, ctr) => t != binData[ctr]).Any())
|
||||||
|
//{
|
||||||
|
// returnValue = false;
|
||||||
|
//}
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
@@ -639,9 +682,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// FSeek implementation of genesis meter
|
/// FSeek implementation of genesis meter. FOpen has to be executed in advance to get
|
||||||
|
/// the file pointer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filePointerOffset"></param>
|
/// <param name="filePointerOffset"></param>
|
||||||
|
/// <param name="fSeekPara">positioning to file start or end</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <remarks date="2019-Jun-20" author="Thomas Wiedebusch">
|
/// <remarks date="2019-Jun-20" author="Thomas Wiedebusch">
|
||||||
/// - Initial
|
/// - Initial
|
||||||
@@ -656,10 +701,17 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
/// - Retries changed for and back,
|
/// - Retries changed for and back,
|
||||||
/// - Timeout changed for and back.
|
/// - Timeout changed for and back.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
private Boolean SetFilePointerOffset(Int32 filePointerOffset)
|
/// <remarks date="2023-Jan-02" author="Thomas Wiedebusch">
|
||||||
|
/// - Extended FSeek for file end positioning.
|
||||||
|
/// </remarks>
|
||||||
|
private Boolean SetFilePointerOffset(Int32 filePointerOffset = 0, Int32 fSeekPara = FSeekStartOfFile)
|
||||||
{
|
{
|
||||||
Boolean returnValue;
|
Boolean returnValue;
|
||||||
var retryCtr = 0;
|
var retryCtr = 0;
|
||||||
|
if (FSeekEndOfFile == fSeekPara)
|
||||||
|
{
|
||||||
|
filePointerOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -680,7 +732,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
returnValue &= _currentGenesis.WriteRegister(Register.Configexchange.SetFilePointerOffset,
|
returnValue &= _currentGenesis.WriteRegister(Register.Configexchange.SetFilePointerOffset,
|
||||||
filePointerOffset, false);
|
filePointerOffset, false);
|
||||||
returnValue &= _currentGenesis.WriteRegister(Register.Configexchange.SetFilePointerOffset,
|
returnValue &= _currentGenesis.WriteRegister(Register.Configexchange.SetFilePointerOffset,
|
||||||
0, false);
|
fSeekPara, false);
|
||||||
|
|
||||||
//function call returns 0 if FSeek successfully set
|
//function call returns 0 if FSeek successfully set
|
||||||
returnValue &= 0 == RegisterConverter.ConvertTo<UInt32>(_currentGenesis.ReadRegister(
|
returnValue &= 0 == RegisterConverter.ConvertTo<UInt32>(_currentGenesis.ReadRegister(
|
||||||
|
|||||||
@@ -743,7 +743,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
|
|
||||||
var returnValue = true;
|
var returnValue = true;
|
||||||
|
|
||||||
//write LUT files and retry if not successful
|
//read config file and retry if not successful
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
_actualOperation = Resources.StrUploadConfigFile;
|
_actualOperation = Resources.StrUploadConfigFile;
|
||||||
@@ -751,7 +751,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
// logout and re-login to clear all ongoing processes and clear the Genesis buffers
|
// logout and re-login to clear all ongoing processes and clear the Genesis buffers
|
||||||
ReestablishMeterFileSystem();
|
ReestablishMeterFileSystem();
|
||||||
|
|
||||||
if (!_meterFile.ReadMeterFile(StrConfigMeterFileName, out ConfigFile.BinData, 5000))
|
if (!_meterFile.ReadMeterFile(StrConfigMeterFileName, out ConfigFile.BinData))
|
||||||
{
|
{
|
||||||
returnValue = false;
|
returnValue = false;
|
||||||
}
|
}
|
||||||
|
|||||||
-40
@@ -30,7 +30,6 @@
|
|||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
this.components = new System.ComponentModel.Container();
|
||||||
this.grpSetup = new System.Windows.Forms.GroupBox();
|
this.grpSetup = new System.Windows.Forms.GroupBox();
|
||||||
this.btnFixBat = new System.Windows.Forms.Button();
|
|
||||||
this.lblCoreRevision = new System.Windows.Forms.Label();
|
this.lblCoreRevision = new System.Windows.Forms.Label();
|
||||||
this.btnConnect = new System.Windows.Forms.Button();
|
this.btnConnect = new System.Windows.Forms.Button();
|
||||||
this.lblConnectPcb = new System.Windows.Forms.Label();
|
this.lblConnectPcb = new System.Windows.Forms.Label();
|
||||||
@@ -38,8 +37,6 @@
|
|||||||
this.cbComSlot = new System.Windows.Forms.ComboBox();
|
this.cbComSlot = new System.Windows.Forms.ComboBox();
|
||||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||||
this.btnRebootMeter = new System.Windows.Forms.Button();
|
this.btnRebootMeter = new System.Windows.Forms.Button();
|
||||||
this.groupBox5 = new System.Windows.Forms.GroupBox();
|
|
||||||
this.btnUploadConfig = new System.Windows.Forms.Button();
|
|
||||||
this.groupBox4 = new System.Windows.Forms.GroupBox();
|
this.groupBox4 = new System.Windows.Forms.GroupBox();
|
||||||
this.btnClearDisplay = new System.Windows.Forms.Button();
|
this.btnClearDisplay = new System.Windows.Forms.Button();
|
||||||
this.lblUpdateTime = new System.Windows.Forms.Label();
|
this.lblUpdateTime = new System.Windows.Forms.Label();
|
||||||
@@ -112,7 +109,6 @@
|
|||||||
this.saveConfigFile = new System.Windows.Forms.SaveFileDialog();
|
this.saveConfigFile = new System.Windows.Forms.SaveFileDialog();
|
||||||
this.grpSetup.SuspendLayout();
|
this.grpSetup.SuspendLayout();
|
||||||
this.groupBox2.SuspendLayout();
|
this.groupBox2.SuspendLayout();
|
||||||
this.groupBox5.SuspendLayout();
|
|
||||||
this.groupBox4.SuspendLayout();
|
this.groupBox4.SuspendLayout();
|
||||||
this.gbxManualTimingControl.SuspendLayout();
|
this.gbxManualTimingControl.SuspendLayout();
|
||||||
this.gbxManualTriggerControl.SuspendLayout();
|
this.gbxManualTriggerControl.SuspendLayout();
|
||||||
@@ -132,7 +128,6 @@
|
|||||||
//
|
//
|
||||||
// grpSetup
|
// grpSetup
|
||||||
//
|
//
|
||||||
this.grpSetup.Controls.Add(this.btnFixBat);
|
|
||||||
this.grpSetup.Controls.Add(this.lblCoreRevision);
|
this.grpSetup.Controls.Add(this.lblCoreRevision);
|
||||||
this.grpSetup.Controls.Add(this.btnConnect);
|
this.grpSetup.Controls.Add(this.btnConnect);
|
||||||
this.grpSetup.Controls.Add(this.lblConnectPcb);
|
this.grpSetup.Controls.Add(this.lblConnectPcb);
|
||||||
@@ -145,16 +140,6 @@
|
|||||||
this.grpSetup.TabStop = false;
|
this.grpSetup.TabStop = false;
|
||||||
this.grpSetup.Text = "Connection";
|
this.grpSetup.Text = "Connection";
|
||||||
//
|
//
|
||||||
// btnFixBat
|
|
||||||
//
|
|
||||||
this.btnFixBat.Location = new System.Drawing.Point(128, 115);
|
|
||||||
this.btnFixBat.Name = "btnFixBat";
|
|
||||||
this.btnFixBat.Size = new System.Drawing.Size(116, 24);
|
|
||||||
this.btnFixBat.TabIndex = 26;
|
|
||||||
this.btnFixBat.Text = "Fix Bat";
|
|
||||||
this.btnFixBat.UseVisualStyleBackColor = true;
|
|
||||||
this.btnFixBat.Click += new System.EventHandler(this.btnFixBat_Click);
|
|
||||||
//
|
|
||||||
// lblCoreRevision
|
// lblCoreRevision
|
||||||
//
|
//
|
||||||
this.lblCoreRevision.AutoSize = true;
|
this.lblCoreRevision.AutoSize = true;
|
||||||
@@ -226,7 +211,6 @@
|
|||||||
// groupBox2
|
// groupBox2
|
||||||
//
|
//
|
||||||
this.groupBox2.Controls.Add(this.btnRebootMeter);
|
this.groupBox2.Controls.Add(this.btnRebootMeter);
|
||||||
this.groupBox2.Controls.Add(this.groupBox5);
|
|
||||||
this.groupBox2.Controls.Add(this.groupBox4);
|
this.groupBox2.Controls.Add(this.groupBox4);
|
||||||
this.groupBox2.Controls.Add(this.lblUpdateTime);
|
this.groupBox2.Controls.Add(this.lblUpdateTime);
|
||||||
this.groupBox2.Controls.Add(this.label9);
|
this.groupBox2.Controls.Add(this.label9);
|
||||||
@@ -260,26 +244,6 @@
|
|||||||
this.btnRebootMeter.UseVisualStyleBackColor = true;
|
this.btnRebootMeter.UseVisualStyleBackColor = true;
|
||||||
this.btnRebootMeter.Click += new System.EventHandler(this.btnRebootMeter_Click);
|
this.btnRebootMeter.Click += new System.EventHandler(this.btnRebootMeter_Click);
|
||||||
//
|
//
|
||||||
// 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
|
// groupBox4
|
||||||
//
|
//
|
||||||
this.groupBox4.Controls.Add(this.btnClearDisplay);
|
this.groupBox4.Controls.Add(this.btnClearDisplay);
|
||||||
@@ -1019,7 +983,6 @@
|
|||||||
this.grpSetup.PerformLayout();
|
this.grpSetup.PerformLayout();
|
||||||
this.groupBox2.ResumeLayout(false);
|
this.groupBox2.ResumeLayout(false);
|
||||||
this.groupBox2.PerformLayout();
|
this.groupBox2.PerformLayout();
|
||||||
this.groupBox5.ResumeLayout(false);
|
|
||||||
this.groupBox4.ResumeLayout(false);
|
this.groupBox4.ResumeLayout(false);
|
||||||
this.gbxManualTimingControl.ResumeLayout(false);
|
this.gbxManualTimingControl.ResumeLayout(false);
|
||||||
this.gbxManualTimingControl.PerformLayout();
|
this.gbxManualTimingControl.PerformLayout();
|
||||||
@@ -1122,10 +1085,7 @@
|
|||||||
private System.Windows.Forms.GroupBox groupBox4;
|
private System.Windows.Forms.GroupBox groupBox4;
|
||||||
private System.Windows.Forms.Button btnClearDisplay;
|
private System.Windows.Forms.Button btnClearDisplay;
|
||||||
private System.Windows.Forms.Label label13;
|
private System.Windows.Forms.Label label13;
|
||||||
private System.Windows.Forms.Button btnFixBat;
|
|
||||||
private System.Windows.Forms.CheckBox cbxStoreConfigEnable;
|
private System.Windows.Forms.CheckBox cbxStoreConfigEnable;
|
||||||
private System.Windows.Forms.GroupBox groupBox5;
|
|
||||||
private System.Windows.Forms.Button btnUploadConfig;
|
|
||||||
private System.Windows.Forms.SaveFileDialog saveConfigFile;
|
private System.Windows.Forms.SaveFileDialog saveConfigFile;
|
||||||
private System.Windows.Forms.Button btnRebootMeter;
|
private System.Windows.Forms.Button btnRebootMeter;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using System.Collections.Generic;
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -160,8 +159,6 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
btnStopFwUpdate.Enabled = false;
|
btnStopFwUpdate.Enabled = false;
|
||||||
btnOpenUpdateDirectory.Enabled = false;
|
btnOpenUpdateDirectory.Enabled = false;
|
||||||
btnOpenPackageControlFile.Enabled = false;
|
btnOpenPackageControlFile.Enabled = false;
|
||||||
btnFixBat.Enabled = false;
|
|
||||||
btnUploadConfig.Enabled = false;
|
|
||||||
btnRebootMeter.Enabled = false;
|
btnRebootMeter.Enabled = false;
|
||||||
btnClearDisplay.Enabled = false;
|
btnClearDisplay.Enabled = false;
|
||||||
cbFilePartSize.Enabled = true;
|
cbFilePartSize.Enabled = true;
|
||||||
@@ -571,9 +568,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
|
|
||||||
btnPrepareTrigger.Enabled = true;
|
btnPrepareTrigger.Enabled = true;
|
||||||
btnTriggerUpdate.Enabled = true;
|
btnTriggerUpdate.Enabled = true;
|
||||||
btnFixBat.Enabled = true;
|
|
||||||
btnClearDisplay.Enabled = true;
|
btnClearDisplay.Enabled = true;
|
||||||
btnUploadConfig.Enabled = true;
|
|
||||||
btnRebootMeter.Enabled = true;
|
btnRebootMeter.Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,9 +604,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
|
|
||||||
btnPrepareTrigger.Enabled = false;
|
btnPrepareTrigger.Enabled = false;
|
||||||
btnTriggerUpdate.Enabled = false;
|
btnTriggerUpdate.Enabled = false;
|
||||||
btnFixBat.Enabled = false;
|
|
||||||
btnClearDisplay.Enabled = false;
|
btnClearDisplay.Enabled = false;
|
||||||
btnUploadConfig.Enabled = false;
|
|
||||||
btnRebootMeter.Enabled = false;
|
btnRebootMeter.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,9 +630,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
|
|
||||||
btnPrepareTrigger.Enabled = true;
|
btnPrepareTrigger.Enabled = true;
|
||||||
btnTriggerUpdate.Enabled = true;
|
btnTriggerUpdate.Enabled = true;
|
||||||
btnFixBat.Enabled = true;
|
|
||||||
btnClearDisplay.Enabled = true;
|
btnClearDisplay.Enabled = true;
|
||||||
btnUploadConfig.Enabled = true;
|
|
||||||
btnRebootMeter.Enabled = true;
|
btnRebootMeter.Enabled = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -691,27 +682,25 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
}
|
}
|
||||||
|
|
||||||
lblOverall.Text = @"Establish data base connection..";
|
lblOverall.Text = @"Establish data base connection..";
|
||||||
lblOverall.Visible = true;
|
|
||||||
Update();
|
|
||||||
_currentGenesis?.DisposeMeter();
|
|
||||||
//dispose old meter
|
|
||||||
_meterBatch.RemoveAllMeters();
|
|
||||||
_currentGenesis = null;
|
|
||||||
Thread.Sleep(200);
|
|
||||||
|
|
||||||
//assign new meter and assign meter to FW update file if this exists
|
|
||||||
_currentGenesis = new GenesisMeter();
|
|
||||||
|
|
||||||
_currentGenesis.SetupFromConfigFile(slotNr);
|
|
||||||
_meterBatch.AddMeter(_currentGenesis);
|
|
||||||
|
|
||||||
_currentGenesis.Configuration.UseRegisterWatchService = false;
|
|
||||||
_currentGenesis.Configuration.UseMinMaxCheck = false;
|
|
||||||
|
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
ViewProgressPcb(true);
|
ViewProgressPcb(true);
|
||||||
|
|
||||||
|
_currentGenesis?.DisposeMeter();
|
||||||
|
//dispose old meter
|
||||||
|
_meterBatch.RemoveAllMeters();
|
||||||
|
_currentGenesis = null;
|
||||||
|
Thread.Sleep(200);
|
||||||
|
|
||||||
|
//assign new meter and assign meter to FW update file if this exists
|
||||||
|
_currentGenesis = new GenesisMeter();
|
||||||
|
|
||||||
|
_currentGenesis.SetupFromConfigFile(slotNr);
|
||||||
|
_meterBatch.AddMeter(_currentGenesis);
|
||||||
|
|
||||||
|
_currentGenesis.Configuration.UseRegisterWatchService = false;
|
||||||
|
_currentGenesis.Configuration.UseMinMaxCheck = false;
|
||||||
_meterBatch.MetersLogin();
|
_meterBatch.MetersLogin();
|
||||||
|
|
||||||
if (!_currentGenesis.IsLoggedOn)
|
if (!_currentGenesis.IsLoggedOn)
|
||||||
@@ -1081,18 +1070,14 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
{
|
{
|
||||||
btnOpenUpdateDirectory.Enabled = true;
|
btnOpenUpdateDirectory.Enabled = true;
|
||||||
btnOpenPackageControlFile.Enabled = true;
|
btnOpenPackageControlFile.Enabled = true;
|
||||||
btnFixBat.Enabled = true;
|
|
||||||
btnClearDisplay.Enabled = true;
|
btnClearDisplay.Enabled = true;
|
||||||
btnUploadConfig.Enabled = true;
|
|
||||||
btnRebootMeter.Enabled = true;
|
btnRebootMeter.Enabled = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
btnOpenUpdateDirectory.Enabled = false;
|
btnOpenUpdateDirectory.Enabled = false;
|
||||||
btnOpenPackageControlFile.Enabled = false;
|
btnOpenPackageControlFile.Enabled = false;
|
||||||
btnFixBat.Enabled = false;
|
|
||||||
btnClearDisplay.Enabled = false;
|
btnClearDisplay.Enabled = false;
|
||||||
btnUploadConfig.Enabled = false;
|
|
||||||
btnRebootMeter.Enabled = false;
|
btnRebootMeter.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1695,11 +1680,26 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class MsgEventargs : EventArgs
|
public class MsgEventargs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Message text
|
||||||
|
/// </summary>
|
||||||
public String Text;
|
public String Text;
|
||||||
|
/// <summary>
|
||||||
|
/// Title
|
||||||
|
/// </summary>
|
||||||
public String Caption;
|
public String Caption;
|
||||||
|
/// <summary>
|
||||||
|
/// Buttons
|
||||||
|
/// </summary>
|
||||||
public MessageBoxButtons Buttons;
|
public MessageBoxButtons Buttons;
|
||||||
|
/// <summary>
|
||||||
|
/// The Icon
|
||||||
|
/// </summary>
|
||||||
public MessageBoxIcon Icon;
|
public MessageBoxIcon Icon;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<MsgEventargs> OnMsgPopUp;
|
public event EventHandler<MsgEventargs> OnMsgPopUp;
|
||||||
private void MessageBoxShow(String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon)
|
private void MessageBoxShow(String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon)
|
||||||
{
|
{
|
||||||
@@ -1903,75 +1903,12 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
lblOverall.Visible = false;
|
lblOverall.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnFixBat_Click(Object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
lblOverall.Text = @"Fix battery settings";
|
|
||||||
lblOverall.Visible = true;
|
|
||||||
Update();
|
|
||||||
|
|
||||||
_currentGenesis.ReLogin();
|
|
||||||
_currentGenesis.WriteRegister("GENESISFLOW_SealDisplay", (UInt32)0);
|
|
||||||
_currentGenesis.ResetAlarm(GenesisMeter.Alarm.ALL);
|
|
||||||
|
|
||||||
_currentGenesis.WriteRegister("POWERMON_WarnFromClamp", (UInt32)630720000);
|
|
||||||
_currentGenesis.WriteRegister("POWERMON_BatteryQuantity", (UInt32)2);
|
|
||||||
_currentGenesis.WriteRegister("POWERMON_StoreConfiguration", (UInt32)1);
|
|
||||||
_currentGenesis.WriteRegister("GENESISFLOW_TriggerIdle", (UInt32)0);
|
|
||||||
|
|
||||||
|
|
||||||
_currentGenesis.StoreAllConfigurations();
|
|
||||||
_currentGenesis.Logout();
|
|
||||||
|
|
||||||
Thread.Sleep(5000);
|
|
||||||
_currentGenesis.ReLogin();
|
|
||||||
lblOverall.Visible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cbxStoreConfigEnable_CheckedChanged(Object sender, EventArgs e)
|
private void cbxStoreConfigEnable_CheckedChanged(Object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_meterFwUpdate != null)
|
if (_meterFwUpdate != null)
|
||||||
_meterFwUpdate.StoreConfigEnable = cbxStoreConfigEnable.Checked;
|
_meterFwUpdate.StoreConfigEnable = cbxStoreConfigEnable.Checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Read config file from meter and store it to disk.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks date="2021-Jan-05" author="Thomas Wiedebusch">
|
|
||||||
/// - Initial
|
|
||||||
/// </remarks>
|
|
||||||
private void btnUploadConfig_Click(Object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (_currentGenesis == null)
|
|
||||||
return;
|
|
||||||
if (_meterFwUpdate == null)
|
|
||||||
_meterFwUpdate = new MeterFwUpdate(_currentGenesis);
|
|
||||||
|
|
||||||
UploadFileControl(true);
|
|
||||||
|
|
||||||
Task.Factory.StartNew(() =>
|
|
||||||
{
|
|
||||||
_currentGenesis.ReLogin();
|
|
||||||
_meterFwUpdate.UploadConfigFile();
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
}).ContinueWith(delegate
|
|
||||||
{
|
|
||||||
Invoke(new Action(() =>
|
|
||||||
{
|
|
||||||
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
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+51
-38
@@ -30,6 +30,8 @@
|
|||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
this.components = new System.ComponentModel.Container();
|
||||||
this.grpSetup = new System.Windows.Forms.GroupBox();
|
this.grpSetup = new System.Windows.Forms.GroupBox();
|
||||||
|
this.tbxDateTime = new System.Windows.Forms.TextBox();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.label10 = new System.Windows.Forms.Label();
|
this.label10 = new System.Windows.Forms.Label();
|
||||||
this.tbxRadio = new System.Windows.Forms.TextBox();
|
this.tbxRadio = new System.Windows.Forms.TextBox();
|
||||||
this.tbxRegion = new System.Windows.Forms.TextBox();
|
this.tbxRegion = new System.Windows.Forms.TextBox();
|
||||||
@@ -41,8 +43,8 @@
|
|||||||
this.label5 = new System.Windows.Forms.Label();
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
this.label6 = new System.Windows.Forms.Label();
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
this.lblFwVersion = new System.Windows.Forms.Label();
|
this.lblFwVersion = new System.Windows.Forms.Label();
|
||||||
this.btnConnect = new System.Windows.Forms.Button();
|
|
||||||
this.lblConnectPcb = new System.Windows.Forms.Label();
|
this.lblConnectPcb = new System.Windows.Forms.Label();
|
||||||
|
this.btnConnect = new System.Windows.Forms.Button();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
this.cbComSlot = new System.Windows.Forms.ComboBox();
|
this.cbComSlot = new System.Windows.Forms.ComboBox();
|
||||||
this.btnClearDisplay = new System.Windows.Forms.Button();
|
this.btnClearDisplay = new System.Windows.Forms.Button();
|
||||||
@@ -55,6 +57,7 @@
|
|||||||
this.lblFwUpdateInfo = new System.Windows.Forms.Label();
|
this.lblFwUpdateInfo = new System.Windows.Forms.Label();
|
||||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.btnSetDateTime = new System.Windows.Forms.Button();
|
||||||
this.btnRebootMeter = new System.Windows.Forms.Button();
|
this.btnRebootMeter = new System.Windows.Forms.Button();
|
||||||
this.btnStoreConfiguration = new System.Windows.Forms.Button();
|
this.btnStoreConfiguration = new System.Windows.Forms.Button();
|
||||||
this.btnFixBattery = new System.Windows.Forms.Button();
|
this.btnFixBattery = new System.Windows.Forms.Button();
|
||||||
@@ -64,9 +67,7 @@
|
|||||||
this.label7 = new System.Windows.Forms.Label();
|
this.label7 = new System.Windows.Forms.Label();
|
||||||
this.saveConfigFile = new System.Windows.Forms.SaveFileDialog();
|
this.saveConfigFile = new System.Windows.Forms.SaveFileDialog();
|
||||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||||
this.btnSetDateTime = new System.Windows.Forms.Button();
|
this.btnGetDateTime = new System.Windows.Forms.Button();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.tbxDateTime = new System.Windows.Forms.TextBox();
|
|
||||||
this.grpSetup.SuspendLayout();
|
this.grpSetup.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
this.groupBox1.SuspendLayout();
|
this.groupBox1.SuspendLayout();
|
||||||
@@ -96,6 +97,23 @@
|
|||||||
this.grpSetup.TabStop = false;
|
this.grpSetup.TabStop = false;
|
||||||
this.grpSetup.Text = "Cordonel Info";
|
this.grpSetup.Text = "Cordonel Info";
|
||||||
//
|
//
|
||||||
|
// tbxDateTime
|
||||||
|
//
|
||||||
|
this.tbxDateTime.Location = new System.Drawing.Point(130, 207);
|
||||||
|
this.tbxDateTime.Name = "tbxDateTime";
|
||||||
|
this.tbxDateTime.ReadOnly = true;
|
||||||
|
this.tbxDateTime.Size = new System.Drawing.Size(116, 20);
|
||||||
|
this.tbxDateTime.TabIndex = 38;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(10, 210);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(87, 13);
|
||||||
|
this.label1.TabIndex = 37;
|
||||||
|
this.label1.Text = "Date Time [UTC]";
|
||||||
|
//
|
||||||
// label10
|
// label10
|
||||||
//
|
//
|
||||||
this.label10.AutoSize = true;
|
this.label10.AutoSize = true;
|
||||||
@@ -189,6 +207,15 @@
|
|||||||
this.lblFwVersion.TabIndex = 25;
|
this.lblFwVersion.TabIndex = 25;
|
||||||
this.lblFwVersion.Text = "Meter FW:";
|
this.lblFwVersion.Text = "Meter FW:";
|
||||||
//
|
//
|
||||||
|
// lblConnectPcb
|
||||||
|
//
|
||||||
|
this.lblConnectPcb.AutoSize = true;
|
||||||
|
this.lblConnectPcb.Location = new System.Drawing.Point(10, 29);
|
||||||
|
this.lblConnectPcb.Name = "lblConnectPcb";
|
||||||
|
this.lblConnectPcb.Size = new System.Drawing.Size(33, 13);
|
||||||
|
this.lblConnectPcb.TabIndex = 23;
|
||||||
|
this.lblConnectPcb.Text = "NOT ";
|
||||||
|
//
|
||||||
// btnConnect
|
// btnConnect
|
||||||
//
|
//
|
||||||
this.btnConnect.Location = new System.Drawing.Point(427, 26);
|
this.btnConnect.Location = new System.Drawing.Point(427, 26);
|
||||||
@@ -199,15 +226,6 @@
|
|||||||
this.btnConnect.UseVisualStyleBackColor = true;
|
this.btnConnect.UseVisualStyleBackColor = true;
|
||||||
this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
|
this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
|
||||||
//
|
//
|
||||||
// lblConnectPcb
|
|
||||||
//
|
|
||||||
this.lblConnectPcb.AutoSize = true;
|
|
||||||
this.lblConnectPcb.Location = new System.Drawing.Point(10, 29);
|
|
||||||
this.lblConnectPcb.Name = "lblConnectPcb";
|
|
||||||
this.lblConnectPcb.Size = new System.Drawing.Size(33, 13);
|
|
||||||
this.lblConnectPcb.TabIndex = 23;
|
|
||||||
this.lblConnectPcb.Text = "NOT ";
|
|
||||||
//
|
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
this.label2.AutoSize = true;
|
this.label2.AutoSize = true;
|
||||||
@@ -328,6 +346,7 @@
|
|||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
|
this.groupBox1.Controls.Add(this.btnGetDateTime);
|
||||||
this.groupBox1.Controls.Add(this.btnSetDateTime);
|
this.groupBox1.Controls.Add(this.btnSetDateTime);
|
||||||
this.groupBox1.Controls.Add(this.btnRebootMeter);
|
this.groupBox1.Controls.Add(this.btnRebootMeter);
|
||||||
this.groupBox1.Controls.Add(this.btnStoreConfiguration);
|
this.groupBox1.Controls.Add(this.btnStoreConfiguration);
|
||||||
@@ -340,6 +359,16 @@
|
|||||||
this.groupBox1.TabStop = false;
|
this.groupBox1.TabStop = false;
|
||||||
this.groupBox1.Text = "Tools";
|
this.groupBox1.Text = "Tools";
|
||||||
//
|
//
|
||||||
|
// btnSetDateTime
|
||||||
|
//
|
||||||
|
this.btnSetDateTime.Location = new System.Drawing.Point(10, 114);
|
||||||
|
this.btnSetDateTime.Name = "btnSetDateTime";
|
||||||
|
this.btnSetDateTime.Size = new System.Drawing.Size(116, 25);
|
||||||
|
this.btnSetDateTime.TabIndex = 37;
|
||||||
|
this.btnSetDateTime.Text = "Set Date Time";
|
||||||
|
this.btnSetDateTime.UseVisualStyleBackColor = true;
|
||||||
|
this.btnSetDateTime.Click += new System.EventHandler(this.btnSetDateTime_Click);
|
||||||
|
//
|
||||||
// btnRebootMeter
|
// btnRebootMeter
|
||||||
//
|
//
|
||||||
this.btnRebootMeter.Location = new System.Drawing.Point(10, 234);
|
this.btnRebootMeter.Location = new System.Drawing.Point(10, 234);
|
||||||
@@ -422,32 +451,15 @@
|
|||||||
this.groupBox2.TabStop = false;
|
this.groupBox2.TabStop = false;
|
||||||
this.groupBox2.Text = "Log";
|
this.groupBox2.Text = "Log";
|
||||||
//
|
//
|
||||||
// btnSetDateTime
|
// btnGetDateTime
|
||||||
//
|
//
|
||||||
this.btnSetDateTime.Location = new System.Drawing.Point(10, 114);
|
this.btnGetDateTime.Location = new System.Drawing.Point(10, 144);
|
||||||
this.btnSetDateTime.Name = "btnSetDateTime";
|
this.btnGetDateTime.Name = "btnGetDateTime";
|
||||||
this.btnSetDateTime.Size = new System.Drawing.Size(116, 25);
|
this.btnGetDateTime.Size = new System.Drawing.Size(116, 25);
|
||||||
this.btnSetDateTime.TabIndex = 37;
|
this.btnGetDateTime.TabIndex = 38;
|
||||||
this.btnSetDateTime.Text = "Set Date Time";
|
this.btnGetDateTime.Text = "Get Date Time";
|
||||||
this.btnSetDateTime.UseVisualStyleBackColor = true;
|
this.btnGetDateTime.UseVisualStyleBackColor = true;
|
||||||
this.btnSetDateTime.Click += new System.EventHandler(this.btnSetDateTime_Click);
|
this.btnGetDateTime.Click += new System.EventHandler(this.btnGetDateTime_Click);
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(10, 210);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(87, 13);
|
|
||||||
this.label1.TabIndex = 37;
|
|
||||||
this.label1.Text = "Date Time [UTC]";
|
|
||||||
//
|
|
||||||
// tbxDateTime
|
|
||||||
//
|
|
||||||
this.tbxDateTime.Location = new System.Drawing.Point(130, 207);
|
|
||||||
this.tbxDateTime.Name = "tbxDateTime";
|
|
||||||
this.tbxDateTime.ReadOnly = true;
|
|
||||||
this.tbxDateTime.Size = new System.Drawing.Size(116, 20);
|
|
||||||
this.tbxDateTime.TabIndex = 38;
|
|
||||||
//
|
//
|
||||||
// FrmLowLevelTools
|
// FrmLowLevelTools
|
||||||
//
|
//
|
||||||
@@ -529,5 +541,6 @@
|
|||||||
private System.Windows.Forms.Button btnSetDateTime;
|
private System.Windows.Forms.Button btnSetDateTime;
|
||||||
private System.Windows.Forms.TextBox tbxDateTime;
|
private System.Windows.Forms.TextBox tbxDateTime;
|
||||||
private System.Windows.Forms.Label label1;
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.Button btnGetDateTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,55 +132,77 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ActivationControls
|
|
||||||
|
|
||||||
|
|
||||||
|
#region ActivationControls
|
||||||
|
/// <summary>
|
||||||
|
/// Disable all buttons except the connect button
|
||||||
|
/// </summary>
|
||||||
private void DisableToolButtons()
|
private void DisableToolButtons()
|
||||||
{
|
{
|
||||||
btnClearDisplay.Enabled = false;
|
btnClearDisplay.Enabled = false;
|
||||||
btnSetDateTime.Enabled = false;
|
btnSetDateTime.Enabled = false;
|
||||||
|
btnGetDateTime.Enabled = false;
|
||||||
btnFixBattery.Enabled = false;
|
btnFixBattery.Enabled = false;
|
||||||
btnRebootMeter.Enabled = false;
|
btnRebootMeter.Enabled = false;
|
||||||
btnStoreConfiguration.Enabled = false;
|
btnStoreConfiguration.Enabled = false;
|
||||||
btnUploadConfig.Enabled = false;
|
btnUploadConfig.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enable all buttons except the connect button
|
||||||
|
/// </summary>
|
||||||
private void EnableToolButtons()
|
private void EnableToolButtons()
|
||||||
{
|
{
|
||||||
btnClearDisplay.Enabled = true;
|
btnClearDisplay.Enabled = true;
|
||||||
btnSetDateTime.Enabled = true;
|
btnSetDateTime.Enabled = true;
|
||||||
|
btnGetDateTime.Enabled = true;
|
||||||
btnFixBattery.Enabled = true;
|
btnFixBattery.Enabled = true;
|
||||||
btnRebootMeter.Enabled = true;
|
btnRebootMeter.Enabled = true;
|
||||||
btnStoreConfiguration.Enabled = true;
|
btnStoreConfiguration.Enabled = true;
|
||||||
btnUploadConfig.Enabled = true;
|
btnUploadConfig.Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Lock all buttons, enable the connect button
|
||||||
|
/// </summary>
|
||||||
private void SetCordonelAccessLocked()
|
private void SetCordonelAccessLocked()
|
||||||
{
|
{
|
||||||
btnConnect.Enabled = true;
|
btnConnect.Enabled = true;
|
||||||
DisableToolButtons();
|
DisableToolButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetControlsDownloadIsOngoing()
|
/// <summary>
|
||||||
{
|
/// Enable all buttons, Cordonel has to be connected
|
||||||
btnConnect.Enabled = false;
|
/// </summary>
|
||||||
DisableToolButtons();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetControlsDownloadIsFinished()
|
|
||||||
{
|
|
||||||
_currentGenesis.RequestProtocol.AdditionalRetryTimeoutMs = 0;
|
|
||||||
btnConnect.Enabled = true;
|
|
||||||
EnableToolButtons();
|
|
||||||
}
|
|
||||||
private void SetCordonelAccessEnabled()
|
private void SetCordonelAccessEnabled()
|
||||||
{
|
{
|
||||||
btnConnect.Enabled = true;
|
btnConnect.Enabled = true;
|
||||||
EnableToolButtons();
|
EnableToolButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disable all buttons during operation with device
|
||||||
|
/// </summary>
|
||||||
|
private void SetControlsLowLevelOpOngoing()
|
||||||
|
{
|
||||||
|
btnConnect.Enabled = false;
|
||||||
|
DisableToolButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Restore setting of buttons and timeout after operation with device
|
||||||
|
/// </summary>
|
||||||
|
private void SetControlsLowLevelOpIsFinished()
|
||||||
|
{
|
||||||
|
_currentGenesis.RequestProtocol.AdditionalRetryTimeoutMs = 0;
|
||||||
|
SetCordonelAccessEnabled();
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region BoardControls
|
#region BoardControls
|
||||||
|
/// <summary>
|
||||||
|
/// Connect the Cordonel
|
||||||
|
/// </summary>
|
||||||
private void Connect()
|
private void Connect()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -194,21 +216,6 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
}
|
}
|
||||||
|
|
||||||
lblOverall.Text = @"Establish data base connection..";
|
lblOverall.Text = @"Establish data base connection..";
|
||||||
//UploadFileControl(true);
|
|
||||||
//_currentGenesis?.DisposeMeter();
|
|
||||||
////dispose old meter
|
|
||||||
//_meterBatch.RemoveAllMeters();
|
|
||||||
//_currentGenesis = null;
|
|
||||||
//Thread.Sleep(200);
|
|
||||||
|
|
||||||
////assign new meter and assign meter to FW update file if this exists
|
|
||||||
//_currentGenesis = new GenesisMeter();
|
|
||||||
|
|
||||||
//_currentGenesis.SetupFromConfigFile(slotNr);
|
|
||||||
//_meterBatch.AddMeter(_currentGenesis);
|
|
||||||
|
|
||||||
//_currentGenesis.Configuration.UseRegisterWatchService = false;
|
|
||||||
//_currentGenesis.Configuration.UseMinMaxCheck = false;
|
|
||||||
|
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
@@ -267,18 +274,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
lblConnectPcb.ForeColor = Color.Green;
|
lblConnectPcb.ForeColor = Color.Green;
|
||||||
CheckUpdateEnabled();
|
CheckUpdateEnabled();
|
||||||
|
|
||||||
var dt = DateTime.UtcNow;
|
LogPcAndCordonelTime();
|
||||||
var msg = $@"{dt:yyyy-MM-dd hh:mm:ss}";
|
|
||||||
LogText($@"PC date time [UTC]: {msg}");
|
|
||||||
|
|
||||||
var secSince2000 = RegisterConverter.ConvertTo<Int32>(_currentGenesis.ReadRegister("SYSTEM_CalendarSeconds"));
|
|
||||||
var ts = TimeSpan.FromSeconds(secSince2000);
|
|
||||||
var meterDateTime = new DateTime(2000, 1, 1, 0, 0, 0).Add(ts);
|
|
||||||
msg = $@"{meterDateTime:yyyy-MM-dd hh:mm:ss}";
|
|
||||||
tbxDateTime.Text = msg;
|
|
||||||
LogText($@"Meter date time [UTC]: {msg}");
|
|
||||||
|
|
||||||
_currentGenesis.Logout();
|
|
||||||
LogInstalledMeterFw();
|
LogInstalledMeterFw();
|
||||||
}));
|
}));
|
||||||
}).ContinueWith(delegate
|
}).ContinueWith(delegate
|
||||||
@@ -293,6 +289,9 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wait for reboot is completed by polling of PcbId
|
||||||
|
/// </summary>
|
||||||
private void WaitForReboot()
|
private void WaitForReboot()
|
||||||
{
|
{
|
||||||
if (_currentGenesis == null)
|
if (_currentGenesis == null)
|
||||||
@@ -347,7 +346,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
Invoke(new Action(() =>
|
Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
ProcessViewControl(false);
|
ProcessViewControl(false);
|
||||||
SetControlsDownloadIsFinished();
|
SetControlsLowLevelOpIsFinished();
|
||||||
_progressBarOn = false;
|
_progressBarOn = false;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -369,7 +368,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
Invoke(new Action(() =>
|
Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
ProcessViewControl(false);
|
ProcessViewControl(false);
|
||||||
SetControlsDownloadIsFinished();
|
SetControlsLowLevelOpIsFinished();
|
||||||
|
|
||||||
if (_rebootSucceeded)
|
if (_rebootSucceeded)
|
||||||
{
|
{
|
||||||
@@ -464,7 +463,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
Invoke(new Action(() =>
|
Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
ProcessViewControl(false);
|
ProcessViewControl(false);
|
||||||
SetControlsDownloadIsFinished();
|
SetControlsLowLevelOpIsFinished();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -505,6 +504,31 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
}
|
}
|
||||||
LogText(StrSeparator);
|
LogText(StrSeparator);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Calculate and log the PC and Cordonel time.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks date="2023-Jan-02" author="Thomas Wiedebusch">
|
||||||
|
/// - Init.
|
||||||
|
/// </remarks>
|
||||||
|
private void LogPcAndCordonelTime()
|
||||||
|
{
|
||||||
|
if (_currentGenesis == null)
|
||||||
|
return;
|
||||||
|
_currentGenesis.ReLogin();
|
||||||
|
|
||||||
|
var dt = DateTime.UtcNow;
|
||||||
|
var msg = $@"{dt:yyyy-MM-dd hh:mm:ss}";
|
||||||
|
LogText($@"PC date time [UTC]: {msg}");
|
||||||
|
|
||||||
|
var secSince2000 = RegisterConverter.ConvertTo<Int32>(_currentGenesis.ReadRegister("SYSTEM_CalendarSeconds"));
|
||||||
|
var ts = TimeSpan.FromSeconds(secSince2000);
|
||||||
|
var meterDateTime = new DateTime(2000, 1, 1, 0, 0, 0).Add(ts);
|
||||||
|
msg = $@"{meterDateTime:yyyy-MM-dd hh:mm:ss}";
|
||||||
|
tbxDateTime.Text = msg;
|
||||||
|
LogText($@"Meter date time [UTC]: {msg}");
|
||||||
|
|
||||||
|
_currentGenesis.Logout();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clear history window.
|
/// Clear history window.
|
||||||
@@ -859,7 +883,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
|
|
||||||
_meterResetProcessActive = true;
|
_meterResetProcessActive = true;
|
||||||
|
|
||||||
SetControlsDownloadIsOngoing();
|
SetControlsLowLevelOpOngoing();
|
||||||
RebootControl(true);
|
RebootControl(true);
|
||||||
|
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
@@ -893,7 +917,6 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
LogText(msg);
|
LogText(msg);
|
||||||
lblOverall.Text = msg;
|
lblOverall.Text = msg;
|
||||||
lblActualProcess.Text = @"Read config file";
|
lblActualProcess.Text = @"Read config file";
|
||||||
|
|
||||||
|
|
||||||
UploadFileControl(true);
|
UploadFileControl(true);
|
||||||
|
|
||||||
@@ -922,7 +945,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set battery dependencies
|
/// Set date and time from PC to Cordonel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
@@ -945,16 +968,27 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
UploadFileControl(true);
|
UploadFileControl(true);
|
||||||
_currentGenesis.ReLogin();
|
_currentGenesis.ReLogin();
|
||||||
|
|
||||||
var dt = DateTime.UtcNow;
|
|
||||||
var ts = DateTimeOffset.UtcNow - new DateTimeOffset(2000, 1, 1, 0, 0, 0, new TimeSpan(0));
|
var ts = DateTimeOffset.UtcNow - new DateTimeOffset(2000, 1, 1, 0, 0, 0, new TimeSpan(0));
|
||||||
_currentGenesis.WriteRegister("SYSTEM_CalendarSeconds", Convert.ToInt32(ts.TotalSeconds));
|
_currentGenesis.WriteRegister("SYSTEM_CalendarSeconds", Convert.ToInt32(ts.TotalSeconds));
|
||||||
msg = $@"{dt:yyyy-MM-dd hh:mm:ss}";
|
|
||||||
tbxDateTime.Text = msg;
|
LogPcAndCordonelTime();
|
||||||
LogText($@"Set date time to meter [UTC]: {msg}");
|
|
||||||
|
|
||||||
// store configuration will logout
|
// store configuration will logout
|
||||||
btnStoreConfiguration_Click(this, null);
|
btnStoreConfiguration_Click(this, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get date and time from PC and Cordonel and record it
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
/// <remarks date="2022-Dec-23" author="Roland Drabesch">
|
||||||
|
/// - Initial
|
||||||
|
/// </remarks>
|
||||||
|
private void btnGetDateTime_Click(Object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LogPcAndCordonelTime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,17 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
lblFwUpdateInfo.Text = $@"Version: {version.Major}.{version.Minor}.{version.Build}";
|
lblFwUpdateInfo.Text = $@"Version: {version.Major}.{version.Minor}.{version.Build}";
|
||||||
_resetTimeMeasurement = true;
|
_resetTimeMeasurement = true;
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
|
var xPosition = Location.X + Size.Width;
|
||||||
|
var yPosition = Location.Y;
|
||||||
|
if (_frmHistory != null)
|
||||||
|
{
|
||||||
|
_frmHistory.SetDesktopLocation(xPosition, yPosition);
|
||||||
|
_frmHistory.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
LogText($"GenesisToolBox: {_version.Major}.{_version.Minor}.{_version.Build}");
|
||||||
|
LogText(StrSeparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FrmLutUpdate_FormClosing(Object sender, FormClosingEventArgs e)
|
private void FrmLutUpdate_FormClosing(Object sender, FormClosingEventArgs e)
|
||||||
@@ -183,40 +194,25 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
}
|
}
|
||||||
|
|
||||||
lblOverall.Text = @"Establish data base connection..";
|
lblOverall.Text = @"Establish data base connection..";
|
||||||
lblOverall.Visible = true;
|
|
||||||
Update();
|
|
||||||
_currentGenesis?.DisposeMeter();
|
|
||||||
//dispose old meter
|
|
||||||
_meterBatch.RemoveAllMeters();
|
|
||||||
_currentGenesis = null;
|
|
||||||
Thread.Sleep(200);
|
|
||||||
|
|
||||||
//assign new meter and assign meter to FW update file if this exists
|
|
||||||
_currentGenesis = new GenesisMeter();
|
|
||||||
|
|
||||||
_currentGenesis.SetupFromConfigFile(slotNr);
|
|
||||||
_meterBatch.AddMeter(_currentGenesis);
|
|
||||||
|
|
||||||
_currentGenesis.Configuration.UseRegisterWatchService = false;
|
|
||||||
_currentGenesis.Configuration.UseMinMaxCheck = false;
|
|
||||||
|
|
||||||
var xPosition = Location.X + Size.Width;
|
|
||||||
var yPosition = Location.Y;
|
|
||||||
if (_frmHistory != null)
|
|
||||||
{
|
|
||||||
_frmHistory.SetDesktopLocation(xPosition, yPosition);
|
|
||||||
_frmHistory.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
ClearHistoryWindow();
|
|
||||||
LogText(StrSeparator);
|
|
||||||
LogText($"GenesisToolBox: {_version.Major}.{_version.Minor}.{_version.Build}");
|
|
||||||
LogText($"Date: {DateTime.Now.ToShortDateString()}");
|
|
||||||
LogText(StrSeparator);
|
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
ViewProgressPcb(true);
|
ViewProgressPcb(true);
|
||||||
|
|
||||||
|
_currentGenesis?.DisposeMeter();
|
||||||
|
//dispose old meter
|
||||||
|
_meterBatch.RemoveAllMeters();
|
||||||
|
_currentGenesis = null;
|
||||||
|
Thread.Sleep(200);
|
||||||
|
|
||||||
|
//assign new meter and assign meter to FW update file if this exists
|
||||||
|
_currentGenesis = new GenesisMeter();
|
||||||
|
|
||||||
|
_currentGenesis.SetupFromConfigFile(slotNr);
|
||||||
|
_meterBatch.AddMeter(_currentGenesis);
|
||||||
|
|
||||||
|
_currentGenesis.Configuration.UseRegisterWatchService = false;
|
||||||
|
_currentGenesis.Configuration.UseMinMaxCheck = false;
|
||||||
_meterBatch.MetersLogin();
|
_meterBatch.MetersLogin();
|
||||||
|
|
||||||
if (!_currentGenesis.IsLoggedOn)
|
if (!_currentGenesis.IsLoggedOn)
|
||||||
@@ -229,7 +225,6 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_meterLutUpdate?.AssignGenesis(_currentGenesis);
|
_meterLutUpdate?.AssignGenesis(_currentGenesis);
|
||||||
|
|
||||||
Invoke(new Action(() =>
|
Invoke(new Action(() =>
|
||||||
|
|||||||
Reference in New Issue
Block a user