LowLevelTools extended - unfinished
This commit is contained in:
@@ -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="D:\Projekte\SENSUS_GitLab\laa_production\Common\Service\MeterProcessState" />
|
||||
</application>
|
||||
<bindings>
|
||||
<binding protocol="http" bindingInformation="*:56011:localhost" />
|
||||
|
||||
@@ -52,6 +52,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
private String _fileName;
|
||||
private Int32 _overallBytesCtr;
|
||||
|
||||
/// <summary>
|
||||
/// Configuration file of meter.
|
||||
/// </summary>
|
||||
public const String StrMeterConfigFile = "0\\config";
|
||||
|
||||
/// <summary>
|
||||
/// Engineering log index file of meter.
|
||||
/// </summary>
|
||||
public const String StrMeterEngLogIndexFile = "1\\logindex";
|
||||
|
||||
/// <summary>
|
||||
/// Drive zero of meter.
|
||||
/// </summary>
|
||||
@@ -71,7 +81,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// Wildcard for search all.
|
||||
/// </summary>
|
||||
public const Char WildcardAll = '*';
|
||||
// public const String StrWildcardAll = "*";
|
||||
|
||||
/// <summary>
|
||||
/// Processed bytes counter
|
||||
@@ -429,11 +438,13 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// <remarks date="2021-Feb-16" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public Boolean ReadMeterFileCatalog(out List<String> files, String drive, String wildcard)
|
||||
/// <remarks date="2023-Jan-04" author="Thomas Wiedebusch">
|
||||
/// - Default wildcard.
|
||||
/// </remarks>
|
||||
public Boolean ReadMeterFileCatalog(out List<String> files, String drive, Char wildcard = WildcardAll)
|
||||
{
|
||||
files = new List<String>();
|
||||
|
||||
|
||||
//write the initial key
|
||||
var key = 0;
|
||||
_stopProcess = false;
|
||||
@@ -568,6 +579,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
public Boolean GetFileSize(String fileName, out Int32 fileSize)
|
||||
{
|
||||
fileSize = 0;
|
||||
|
||||
//add file name delimiter
|
||||
fileName += StringDelimiter;
|
||||
|
||||
var returnValue = OpenMeterFile(fileName, StrOpenFileReadOnlyMode, true);
|
||||
|
||||
if (returnValue)
|
||||
@@ -602,6 +617,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
{
|
||||
var returnValue = true;
|
||||
|
||||
//add file name delimiter
|
||||
fileName += StringDelimiter;
|
||||
|
||||
if (!ReadMeterFile(fileName, out var binData) || binData == null || binData.Count == 0)
|
||||
return false;
|
||||
|
||||
@@ -889,6 +907,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// <remarks date="2022-Apr-01" author="Thomas Wiedebusch">
|
||||
/// - Ignore file close write return!
|
||||
/// </remarks>
|
||||
/// <remarks date="2023-Jan-04" author="Thomas Wiedebusch">
|
||||
/// - Removed extended timeout.
|
||||
/// </remarks>
|
||||
private Boolean CloseMeterFile()
|
||||
{
|
||||
//avoid file close if file pointer assignment failed
|
||||
@@ -896,7 +917,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
return false;
|
||||
|
||||
//set extended timeout for file operations
|
||||
_currentGenesis.TransmitProtocol.SetResponseTimeout(ExtendedFileIoTimeoutMs);
|
||||
//_currentGenesis.TransmitProtocol.SetResponseTimeout(ExtendedFileIoTimeoutMs);
|
||||
CommunicationConfig.RequestRetries = 0;
|
||||
_currentGenesis.WriteRegister(Register.Configexchange.FileClose, _filePointer);
|
||||
|
||||
@@ -904,7 +925,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
var returnValue = 0 == RegisterConverter.ConvertTo<Int32>(
|
||||
_currentGenesis.ReadRegister(Register.Configexchange.FileClose));
|
||||
//set timeout back to default value
|
||||
_currentGenesis.TransmitProtocol.SetDefaultResponseTimeout();
|
||||
//_currentGenesis.TransmitProtocol.SetDefaultResponseTimeout();
|
||||
CommunicationConfig.RequestRetries = CommunicationConfig.DefaultRequestRetries;
|
||||
|
||||
return returnValue;
|
||||
|
||||
@@ -681,8 +681,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
_meterFilesDrive1.Clear();
|
||||
|
||||
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs("List meter files drive 1"));
|
||||
if (!_meterFile.ReadMeterFileCatalog(out var meterFilesDrive1, MeterFile.StrMeterDrive1,
|
||||
MeterFile.WildcardAll.ToString()))
|
||||
if (!_meterFile.ReadMeterFileCatalog(out var meterFilesDrive1, MeterFile.StrMeterDrive1))
|
||||
return false;
|
||||
|
||||
_meterFilesDrive1.AddRange(meterFilesDrive1);
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3
|
||||
1a3d4919c9c702245832d925951f2b7cb72fc333
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
this.saveConfigFile = new System.Windows.Forms.SaveFileDialog();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.btnReadLogFiles = new System.Windows.Forms.Button();
|
||||
this.btnListFileDetails = new System.Windows.Forms.Button();
|
||||
this.grpSetup.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.groupBox1.SuspendLayout();
|
||||
@@ -454,6 +455,7 @@
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.btnListFileDetails);
|
||||
this.groupBox2.Controls.Add(this.btnReadLogFiles);
|
||||
this.groupBox2.Controls.Add(this.btnUploadConfig);
|
||||
this.groupBox2.Location = new System.Drawing.Point(417, 69);
|
||||
@@ -473,6 +475,16 @@
|
||||
this.btnReadLogFiles.UseVisualStyleBackColor = true;
|
||||
this.btnReadLogFiles.Click += new System.EventHandler(this.btnReadLogFiles_Click);
|
||||
//
|
||||
// btnListFileDetails
|
||||
//
|
||||
this.btnListFileDetails.Location = new System.Drawing.Point(10, 84);
|
||||
this.btnListFileDetails.Name = "btnListFileDetails";
|
||||
this.btnListFileDetails.Size = new System.Drawing.Size(116, 25);
|
||||
this.btnListFileDetails.TabIndex = 39;
|
||||
this.btnListFileDetails.Text = "List File Details";
|
||||
this.btnListFileDetails.UseVisualStyleBackColor = true;
|
||||
this.btnListFileDetails.Click += new System.EventHandler(this.btnListFileDetails_Click);
|
||||
//
|
||||
// FrmLowLevelTools
|
||||
//
|
||||
this.AccessibleRole = System.Windows.Forms.AccessibleRole.Sound;
|
||||
@@ -555,5 +567,6 @@
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button btnGetDateTime;
|
||||
private System.Windows.Forms.Button btnReadLogFiles;
|
||||
private System.Windows.Forms.Button btnListFileDetails;
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,9 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
public partial class FrmLowLevelTools : Form
|
||||
{
|
||||
#region Variables
|
||||
|
||||
private readonly MeterBatch _meterBatch = new MeterBatch();
|
||||
private GenesisMeter _currentGenesis;
|
||||
private const String StrConnecting = "Connecting to PCB";
|
||||
private const String StrNotConnected = "NOT CONNECTED";
|
||||
private const String StrPartPcbConnected = "PCB ID: ";
|
||||
private const String StrBurnUpgrade = "Waiting for meter response";
|
||||
@@ -57,6 +57,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
// status information
|
||||
private static readonly Color ColorDefault = Color.Black;
|
||||
private static readonly Color ColorSuccess = Color.Green;
|
||||
|
||||
private static readonly Color ColorProcessFailed = Color.Red;
|
||||
//private static readonly Color ColorOngoingProcess = Color.Blue;
|
||||
//private static readonly Color ColorUnknownStatus = Color.Gray;
|
||||
@@ -65,9 +66,11 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
private const String StrSeparator = "-----------------------------------------------------" +
|
||||
"-----------------------------------------------------";
|
||||
|
||||
#endregion
|
||||
|
||||
#region FormControls
|
||||
|
||||
/// <summary>
|
||||
/// Ctor FW update
|
||||
/// </summary>
|
||||
@@ -133,9 +136,11 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
_resetTimeMeasurement = true;
|
||||
Init();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ActivationControls
|
||||
|
||||
/// <summary>
|
||||
/// Disable all buttons except the connect button
|
||||
/// </summary>
|
||||
@@ -149,6 +154,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
btnStoreConfiguration.Enabled = false;
|
||||
btnUploadConfig.Enabled = false;
|
||||
btnReadLogFiles.Enabled = false;
|
||||
btnListFileDetails.Enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -164,6 +170,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
btnStoreConfiguration.Enabled = true;
|
||||
btnUploadConfig.Enabled = true;
|
||||
btnReadLogFiles.Enabled = true;
|
||||
btnListFileDetails.Enabled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -202,9 +209,11 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
_currentGenesis.RequestProtocol.AdditionalRetryTimeoutMs = 0;
|
||||
SetCordonelAccessEnabled();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BoardControls
|
||||
|
||||
/// <summary>
|
||||
/// Connect the Cordonel
|
||||
/// </summary>
|
||||
@@ -220,7 +229,8 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
return;
|
||||
}
|
||||
|
||||
lblOverall.Text = @"Establish data base connection..";
|
||||
lblOverall.Text = @"Login to Cordonel...";
|
||||
lblActualProcess.Text = @"Establish data base connection...";
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
@@ -230,12 +240,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
//dispose old meter
|
||||
_meterBatch.RemoveAllMeters();
|
||||
_currentGenesis = null;
|
||||
Thread.Sleep(200);
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
lblOverall.Text = @"Login to Cordonel";
|
||||
}));
|
||||
//assign new meter and assign meter to FW update file if this exists
|
||||
_currentGenesis = new GenesisMeter();
|
||||
|
||||
@@ -244,10 +249,13 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
_currentGenesis.Configuration.UseRegisterWatchService = false;
|
||||
_currentGenesis.Configuration.UseMinMaxCheck = false;
|
||||
|
||||
Invoke(new Action(() => { lblActualProcess.Text = @"Connecting to PCB..."; }));
|
||||
_meterBatch.MetersLogin();
|
||||
|
||||
if (!_currentGenesis.IsLoggedOn)
|
||||
{
|
||||
//this is needed from meter as an unsuccessfully login requires a delay for the next trial
|
||||
Thread.Sleep(2000);
|
||||
_meterBatch.MetersLogin();
|
||||
}
|
||||
@@ -306,8 +314,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
return;
|
||||
}
|
||||
|
||||
lblActualProcess.Text = StrBurnUpgrade;
|
||||
lblOverall.Text = @"Update Applications and Restart Meter";
|
||||
SetActualProcessAndLog(@"Update Applications and Restart Meter");
|
||||
ViewProcessControl(true);
|
||||
|
||||
//wait until meter update is completed and meter is re-booted
|
||||
@@ -321,22 +328,28 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
text = RegisterConverter.ConvertTo<String>(
|
||||
_currentGenesis.ReadRegister(Register.Configexchange.PcbSerialNumber, 12));
|
||||
barOverallProgressUpdate.Value = barOverallProgressUpdate.Value + 4 > 100 ? 0 :
|
||||
barOverallProgressUpdate.Value + 4;
|
||||
barOverallProgressUpdate.Value =
|
||||
barOverallProgressUpdate.Value + 4 > 100 ? 0 : barOverallProgressUpdate.Value + 4;
|
||||
var bootProcess = (Int32)(bootDelayMs * 100.0 / maxBootDelayMs);
|
||||
barSingleProgressUpdate.Value = barSingleProgressUpdate.Value + bootProcess > 100 ? 0 :
|
||||
barSingleProgressUpdate.Value + bootProcess;
|
||||
barSingleProgressUpdate.Value = barSingleProgressUpdate.Value + bootProcess > 100
|
||||
? 0
|
||||
: barSingleProgressUpdate.Value + bootProcess;
|
||||
Update();
|
||||
bootDelayMs += loopDelayMs;
|
||||
Thread.Sleep((Int32)loopDelayMs);
|
||||
}
|
||||
|
||||
//add a blank line to separate next operation
|
||||
LogText("");
|
||||
|
||||
ViewProcessControl(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessControls
|
||||
private void owLevelActionControl(Boolean isActive)
|
||||
|
||||
private void LowLevelActionControl(Boolean isActive)
|
||||
{
|
||||
if (isActive)
|
||||
{
|
||||
@@ -388,6 +401,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void ViewProgressPcb(Boolean isActive)
|
||||
{
|
||||
if (_updateGui)
|
||||
@@ -398,7 +412,6 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
{
|
||||
_tryConnectPcb = true;
|
||||
ViewProcessControl(true);
|
||||
lblActualProcess.Text = StrConnecting;
|
||||
}));
|
||||
}
|
||||
else
|
||||
@@ -464,10 +477,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ViewProcessControl(false);
|
||||
}));
|
||||
Invoke(new Action(() => { ViewProcessControl(false); }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,8 +499,8 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
foreach (var app in _currentGenesis.MeterAppListVersion)
|
||||
{
|
||||
var versionString = app.IsInstalled ? $"V: {app.StrVersion} - CRC: 0x{app.Crc:X4}" :
|
||||
"App NOT Installed";
|
||||
var versionString =
|
||||
app.IsInstalled ? $"V: {app.StrVersion} - CRC: 0x{app.Crc:X4}" : "App NOT Installed";
|
||||
LogText($"AppId: 0x{app.AppId:X2} - {versionString} - " + $"AppName: {app.AppName}");
|
||||
|
||||
if (app.IsInstalled)
|
||||
@@ -505,8 +515,10 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LogText(StrSeparator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate and log the PC and Cordonel time.
|
||||
/// </summary>
|
||||
@@ -523,13 +535,16 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
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 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}");
|
||||
|
||||
//add a blank line to separate next operation
|
||||
LogText("");
|
||||
_currentGenesis.Logout();
|
||||
}
|
||||
|
||||
@@ -561,6 +576,18 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
InfoWindowColoredText(txtHistory, ColorDefault);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the actual process and log the text.
|
||||
/// </summary>
|
||||
/// <remarks date="2023-Jan-04" author="Thomas Wiedebusch">
|
||||
/// - Color added.
|
||||
/// </remarks>
|
||||
private void SetActualProcessAndLog(String message)
|
||||
{
|
||||
Invoke(new Action(() => { lblActualProcess.Text = message; }));
|
||||
LogText(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Output exclusively to user update remarks text window.
|
||||
/// </summary>
|
||||
@@ -596,9 +623,11 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
_frmHistory.rtbHistory.ResumeLayout();
|
||||
}));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Checks
|
||||
|
||||
private void CheckUpdateEnabled()
|
||||
{
|
||||
//this check has been placed here to force display update
|
||||
@@ -607,8 +636,10 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
SetCordonelAccessEnabled();
|
||||
return;
|
||||
}
|
||||
|
||||
SetCordonelAccessLocked();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
@@ -629,22 +660,23 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
#endregion
|
||||
|
||||
#region TimerControls
|
||||
|
||||
private void tmrProgressUpdate_Tick(Object sender, EventArgs e)
|
||||
{
|
||||
//cbxManualControl.Visible = true;
|
||||
if (_tryConnectPcb || _progressBarOn)
|
||||
{
|
||||
barOverallProgressUpdate.Value = barOverallProgressUpdate.Value + 1 > 100 ? 0 :
|
||||
barOverallProgressUpdate.Value + 1;
|
||||
barSingleProgressUpdate.Value = barSingleProgressUpdate.Value + 4 > 100 ? 0 :
|
||||
barSingleProgressUpdate.Value + 4;
|
||||
barOverallProgressUpdate.Value =
|
||||
barOverallProgressUpdate.Value + 1 > 100 ? 0 : barOverallProgressUpdate.Value + 1;
|
||||
barSingleProgressUpdate.Value =
|
||||
barSingleProgressUpdate.Value + 4 > 100 ? 0 : barSingleProgressUpdate.Value + 4;
|
||||
}
|
||||
else if (_meterResetProcessActive)
|
||||
{
|
||||
lblActualProcess.Text = _meterResetPsu?.GetActualOperation();
|
||||
|
||||
barOverallProgressUpdate.Value = barOverallProgressUpdate.Value + 1 > 100 ? 0 :
|
||||
barOverallProgressUpdate.Value + 1;
|
||||
barOverallProgressUpdate.Value =
|
||||
barOverallProgressUpdate.Value + 1 > 100 ? 0 : barOverallProgressUpdate.Value + 1;
|
||||
barOverallProgressUpdate.Update();
|
||||
|
||||
var singleProgress = (Int32)(_meterResetPsu?.SingleFileProcessCtrPercent ?? 0);
|
||||
@@ -652,6 +684,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
_lastSingleProgress = singleProgress;
|
||||
barSingleProgressUpdate.Update();
|
||||
}
|
||||
|
||||
SetTimeDisplay();
|
||||
Update();
|
||||
}
|
||||
@@ -662,7 +695,9 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
var timeSpan = time - _startTime;
|
||||
lblUpdateTime.Text = $@"{(UInt32)timeSpan.TotalMinutes}:{timeSpan.Seconds:00}";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ExternalCalls
|
||||
|
||||
/// <summary>
|
||||
@@ -677,23 +712,28 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
/// 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)
|
||||
{
|
||||
if (_updateGui)
|
||||
@@ -710,6 +750,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
#endregion
|
||||
|
||||
#region Buttons
|
||||
|
||||
private void btnConnect_Click(Object sender, EventArgs e)
|
||||
{
|
||||
if (_resetTimeMeasurement)
|
||||
@@ -717,8 +758,10 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
_startTime = DateTimeOffset.UtcNow;
|
||||
_resetTimeMeasurement = false;
|
||||
}
|
||||
|
||||
Connect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases the display to normal operation
|
||||
/// </summary>
|
||||
@@ -732,11 +775,9 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
if (_currentGenesis == null)
|
||||
return;
|
||||
|
||||
var msg = @"Set display of meter to normal operation";
|
||||
LogText(msg);
|
||||
lblActualProcess.Text = msg;
|
||||
SetActualProcessAndLog(@"Set display of meter to normal operation");
|
||||
|
||||
owLevelActionControl(true);
|
||||
LowLevelActionControl(true);
|
||||
_currentGenesis.ReLogin();
|
||||
|
||||
_currentGenesis.SetLcdText(true, new Byte[] { 0x00, 0x00, 0x00, 0x00 });
|
||||
@@ -762,36 +803,28 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
LogText(msg);
|
||||
lblOverall.Text = msg;
|
||||
|
||||
owLevelActionControl(true);
|
||||
LowLevelActionControl(true);
|
||||
_currentGenesis.ReLogin();
|
||||
|
||||
msg = @"Seal display for time of setup";
|
||||
LogText(msg);
|
||||
lblActualProcess.Text = msg;
|
||||
SetActualProcessAndLog(@"Seal display for time of setup");
|
||||
_currentGenesis.WriteRegister("GENESISFLOW_SealDisplay", (UInt32)0);
|
||||
|
||||
msg = @"Reset alarms in meter";
|
||||
LogText(msg);
|
||||
lblActualProcess.Text = msg;
|
||||
SetActualProcessAndLog(@"Reset alarms in meter");
|
||||
_currentGenesis.ResetAlarm(GenesisMeter.Alarm.ALL);
|
||||
|
||||
msg = @"Set project end time to meter";
|
||||
LogText(msg);
|
||||
lblActualProcess.Text = msg;
|
||||
SetActualProcessAndLog(@"Set project end time to meter");
|
||||
_currentGenesis.WriteRegister("POWERMON_WarnFromClamp", (UInt32)630720000); // 20 years in seconds
|
||||
|
||||
msg = @"Set meter battery quantity to 2";
|
||||
LogText(msg);
|
||||
lblActualProcess.Text = msg;
|
||||
SetActualProcessAndLog(@"Set meter battery quantity to 2");
|
||||
_currentGenesis.WriteRegister("POWERMON_BatteryQuantity", (UInt32)2);
|
||||
|
||||
msg = @"Trigger idle to release function to normal operation";
|
||||
LogText(msg);
|
||||
lblActualProcess.Text = msg;
|
||||
SetActualProcessAndLog(@"Trigger idle to release function to normal operation");
|
||||
_currentGenesis.WriteRegister("GENESISFLOW_TriggerIdle", (UInt32)0);
|
||||
|
||||
//add a blank line to separate next operation
|
||||
LogText("");
|
||||
_currentGenesis.Logout();
|
||||
owLevelActionControl(false);
|
||||
LowLevelActionControl(false);
|
||||
|
||||
// reboot the meter to take the new settings
|
||||
btnRebootMeter_Click(this, null);
|
||||
@@ -814,16 +847,17 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
LogText(msg);
|
||||
lblActualProcess.Text = msg;
|
||||
|
||||
owLevelActionControl(true);
|
||||
LowLevelActionControl(true);
|
||||
_currentGenesis.ReLogin();
|
||||
|
||||
_currentGenesis.StoreAllConfigurations();
|
||||
|
||||
//add a blank line to separate next operation
|
||||
LogText("");
|
||||
_currentGenesis.Logout();
|
||||
owLevelActionControl(false);
|
||||
LowLevelActionControl(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Reboot the meter
|
||||
@@ -887,7 +921,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
if (_meterFile == null)
|
||||
_meterFile = new MeterFile(_currentGenesis);
|
||||
|
||||
owLevelActionControl(true);
|
||||
LowLevelActionControl(true);
|
||||
|
||||
var msg = @"Upload configuration file from meter";
|
||||
LogText(msg);
|
||||
@@ -899,9 +933,8 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
_currentGenesis.ReLogin();
|
||||
_meterFile.ReadMeterFile("0\\config", out var data);
|
||||
_meterFile.ReadMeterFile(MeterFile.StrMeterConfigFile, out var data);
|
||||
rawData.AddRange(data);
|
||||
Thread.Sleep(1000);
|
||||
}).ContinueWith(delegate
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
@@ -916,8 +949,10 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
}
|
||||
}));
|
||||
|
||||
//add a blank line to separate next operation
|
||||
LogText("");
|
||||
_currentGenesis.Logout();
|
||||
owLevelActionControl(false);
|
||||
LowLevelActionControl(false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -938,11 +973,9 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
LogText(msg);
|
||||
lblOverall.Text = msg;
|
||||
|
||||
msg = @"Set seconds since 2000-01-01 00:00:00 to meter";
|
||||
LogText(msg);
|
||||
lblActualProcess.Text = msg;
|
||||
SetActualProcessAndLog(@"Set seconds since 2000-01-01 00:00:00 to meter");
|
||||
|
||||
owLevelActionControl(true);
|
||||
LowLevelActionControl(true);
|
||||
_currentGenesis.ReLogin();
|
||||
|
||||
var ts = DateTimeOffset.UtcNow - new DateTimeOffset(2000, 1, 1, 0, 0, 0, new TimeSpan(0));
|
||||
@@ -970,7 +1003,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
/// <summary>
|
||||
/// Read engineering log file from meter.
|
||||
/// </summary>
|
||||
/// <remarks date="2023-Jan-02" author="Roland Drabesch/Thomas Wiedebusch">
|
||||
/// <remarks date="2023-Jan-04" author="Roland Drabesch/Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
private void btnReadLogFiles_Click(Object sender, EventArgs e)
|
||||
@@ -981,19 +1014,16 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
_meterFile = new MeterFile(_currentGenesis);
|
||||
|
||||
var statusMap = new Dictionary<Int32, String>();
|
||||
if (System.IO.File.Exists("Status.json"))
|
||||
if (File.Exists("Status.json"))
|
||||
{
|
||||
var dict = JsonConvert.DeserializeObject<Dictionary<String, JObject>>(System.IO.File.ReadAllText("Status.json"));
|
||||
var dict = JsonConvert.DeserializeObject<Dictionary<String, JObject>>(File.ReadAllText("Status.json"));
|
||||
foreach (var item in dict)
|
||||
{
|
||||
statusMap.Add(int.Parse(item.Value.First.Values().First().ToString()), item.Key);
|
||||
}
|
||||
//var jo = JObject.Parse();
|
||||
//((JObject)jo).ChildrenTokens
|
||||
//var retListRealCsd = JsonConvert.DeserializeObject(<List<CsdParameterResult>>(retStr);
|
||||
}
|
||||
|
||||
owLevelActionControl(true);
|
||||
LowLevelActionControl(true);
|
||||
|
||||
var msg = @"Upload engineering log file from meter";
|
||||
LogText(msg);
|
||||
@@ -1003,25 +1033,12 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
{
|
||||
_currentGenesis.ReLogin();
|
||||
|
||||
msg = @"Flushing the logger";
|
||||
LogText(msg);
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
lblActualProcess.Text = msg;
|
||||
}));
|
||||
|
||||
SetActualProcessAndLog(@"Flushing the logger");
|
||||
_currentGenesis.WriteRegister("LOGGER_TriggerLogFlush", 1);
|
||||
|
||||
msg = @"Reading log index file";
|
||||
LogText(msg);
|
||||
SetActualProcessAndLog(@"Reading log index file");
|
||||
_meterFile.ReadMeterFile(MeterFile.StrMeterEngLogIndexFile, out var data);
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
lblActualProcess.Text = msg;
|
||||
}));
|
||||
|
||||
_meterFile.ReadMeterFile("1\\logindex", out var data);
|
||||
var fileNames = new List<String>();
|
||||
var rawData = data.ToArray();
|
||||
var sample = new Byte[4];
|
||||
@@ -1040,87 +1057,123 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
foreach (var fileName in fileNames)
|
||||
{
|
||||
msg = $"1\\{fileName}";
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
lblActualProcess.Text = "Reading " + msg;
|
||||
}));
|
||||
|
||||
SetActualProcessAndLog($@"Reading {msg}");
|
||||
_meterFile.ReadMeterFile(msg, out data);
|
||||
LogText(msg);
|
||||
LogText($"Data: {ByteArrayStyle.ByteStyler.ToString(data.ToArray())}");
|
||||
|
||||
if (data.Count >= 4)
|
||||
LogText("Data:");
|
||||
LogText($"{ByteArrayStyle.ByteStyler.ToString(data.ToArray())}");
|
||||
|
||||
if (data.Count >= 5)
|
||||
{
|
||||
var logType = data[0];
|
||||
var status = BitConverter.ToUInt16(data.GetRange(1, 2).ToArray(), 0);
|
||||
var count = (Int32)BitConverter.ToUInt16(data.GetRange(2, 2).ToArray(), 0);
|
||||
|
||||
count += 1;
|
||||
var extraDataSize = data.GetRange(3, 1).ToString();
|
||||
|
||||
switch (logType)
|
||||
for (var ctr = 0; ctr < data.Count;)
|
||||
{
|
||||
case 0:
|
||||
msg = $"({logType}) Informational";
|
||||
break;
|
||||
case 1:
|
||||
msg = $"({logType}) Warning";
|
||||
break;
|
||||
case 2:
|
||||
msg = $"({logType}) Critical";
|
||||
break;
|
||||
}
|
||||
LogText($"Log type:{msg}");
|
||||
if (statusMap.ContainsKey(status))
|
||||
{
|
||||
LogText($"Status: ({status}) {statusMap[status]}");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogText($"Status:{status}");
|
||||
}
|
||||
LogText($"Count:{count}");
|
||||
var logType = data[ctr];
|
||||
var status = (data[ctr + 2] << 8) + data[ctr + 1];
|
||||
var count = data[ctr + 3] + 1;
|
||||
var extraDataSize = data[ctr + 4];
|
||||
|
||||
LogText($"Extra data size:{extraDataSize}");
|
||||
|
||||
if (int.TryParse(extraDataSize, out var extraDataLength))
|
||||
{
|
||||
LogText("Extra data: ");
|
||||
for (var i = 0; i <= extraDataLength; i++)
|
||||
switch (logType)
|
||||
{
|
||||
LogText(data.GetRange(i, 2).First().ToString("X2"));
|
||||
LogText(" ");
|
||||
case 0:
|
||||
msg = $"({logType}) Informational";
|
||||
break;
|
||||
case 1:
|
||||
msg = $"({logType}) Warning";
|
||||
break;
|
||||
case 2:
|
||||
msg = $"({logType}) Critical";
|
||||
break;
|
||||
}
|
||||
LogText(" ");
|
||||
}
|
||||
|
||||
LogText($"Log type:{msg}");
|
||||
LogText(statusMap.ContainsKey(status)
|
||||
? $"Status: ({status}) {statusMap[status]}"
|
||||
: $"Status:{status}");
|
||||
LogText($"Count:{count}");
|
||||
LogText($"Extra data size:{extraDataSize}");
|
||||
|
||||
var extraData = data.GetRange(ctr + 5, extraDataSize);
|
||||
LogText("Extra data:");
|
||||
LogText($"{ByteArrayStyle.ByteStyler.ToString(extraData.ToArray())}");
|
||||
LogText(" ");
|
||||
ctr += (5 + extraDataSize);
|
||||
//exit if index for next run is out of range
|
||||
if (ctr + 5 >= data.Count) break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogText("File is empty");
|
||||
}
|
||||
}
|
||||
|
||||
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 rawData)
|
||||
// bw.Write(t);
|
||||
// fs.Close();
|
||||
// }
|
||||
//}));
|
||||
|
||||
_currentGenesis.Logout();
|
||||
owLevelActionControl(false);
|
||||
});
|
||||
{
|
||||
//add a blank line to separate next operation
|
||||
LogText("");
|
||||
_currentGenesis.Logout();
|
||||
LowLevelActionControl(false);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List file details from meter.
|
||||
/// </summary>
|
||||
/// <remarks date="2023-Jan-04" author="Roland Drabesch/Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
private void btnListFileDetails_Click(Object sender, EventArgs e)
|
||||
{
|
||||
if (_currentGenesis == null)
|
||||
return;
|
||||
if (_meterFile == null)
|
||||
_meterFile = new MeterFile(_currentGenesis);
|
||||
|
||||
LowLevelActionControl(true);
|
||||
|
||||
var msg = @"List file details from meter";
|
||||
LogText(msg);
|
||||
lblOverall.Text = msg;
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
_currentGenesis.ReLogin();
|
||||
var fileNames = new List<String>();
|
||||
Invoke(new Action(() => { lblActualProcess.Text = @"List meter files drive 0"; }));
|
||||
_meterFile.ReadMeterFileCatalog(out var fileNamesDrive0, MeterFile.StrMeterDrive0);
|
||||
if (fileNamesDrive0.Count == 0)
|
||||
{
|
||||
LogText(@"Could not read drive 0");
|
||||
}
|
||||
|
||||
Invoke(new Action(() => { lblActualProcess.Text = @"List meter files drive 1"; }));
|
||||
_meterFile.ReadMeterFileCatalog(out var fileNamesDrive1, MeterFile.StrMeterDrive1);
|
||||
|
||||
if (fileNamesDrive1.Count == 0)
|
||||
{
|
||||
LogText(@"Could not read drive 1");
|
||||
}
|
||||
|
||||
fileNames.AddRange(fileNamesDrive0);
|
||||
fileNames.AddRange(fileNamesDrive1);
|
||||
foreach (var fileName in fileNames)
|
||||
{
|
||||
Invoke(new Action(() => { lblActualProcess.Text = $@"Analyze file {fileName}"; }));
|
||||
var success = _meterFile.GetFileSize(fileName, out var fileSize);
|
||||
|
||||
LogText(success ? $@"File name: {fileName}, File size: {fileSize} byte"
|
||||
: $@"File name: {fileName} Unable to access file");
|
||||
}
|
||||
}).ContinueWith(delegate
|
||||
{
|
||||
//add a blank line to separate next operation
|
||||
LogText("");
|
||||
_currentGenesis.Logout();
|
||||
LowLevelActionControl(false);
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -217,6 +217,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
if (!_currentGenesis.IsLoggedOn)
|
||||
{
|
||||
//this is needed from meter as an unsuccessfully login requires a delay for the next trial
|
||||
Thread.Sleep(2000);
|
||||
_meterBatch.MetersLogin();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user