History window for additional information

This commit is contained in:
Thomas Wiedebusch
2022-03-28 13:23:03 +02:00
parent c015b16f0a
commit 50f15842aa
15 changed files with 1096 additions and 454 deletions
@@ -630,8 +630,8 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
/// <remarks date="2018-Oct-23" author="T.Wiedebusch"> /// <remarks date="2018-Oct-23" author="T.Wiedebusch">
/// - Doubling of sync byte in protocol behind sync byte itself implemented /// - Doubling of sync byte in protocol behind sync byte itself implemented
/// </remarks> /// </remarks>
/// <remarks date="2022-Feb-25" author="T.Wiedebusch"> /// <remarks date="2022-Feb-25" author="T.Wiedebusch, R.Drabesch">
/// - RTS signal trial as MOXA sometimes takes two messages and combines these two one! /// - Flush buffer as MOXA sometimes takes two messages and combines these two one!
/// As the Genesis needs a separated wake-up message with a following delay before the /// As the Genesis needs a separated wake-up message with a following delay before the
/// real payload message, this causes a lot of trouble. /// real payload message, this causes a lot of trouble.
/// </remarks> /// </remarks>
@@ -655,18 +655,19 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
} }
} }
_serialPort.RtsEnable = true;
_serialPort.Write(txByteList.ToArray(), 0, txByteList.Count); _serialPort.Write(txByteList.ToArray(), 0, txByteList.Count);
_serialPort.RtsEnable = false;
OnRawRecordSendOut?.Invoke(this, new ListBytePortDataEventArgs(txByteList, DateTimeOffset.UtcNow));
// flush the buffer for MOXA, to avoid two subsequent communications assembled to one communication!
_serialPort.BaseStream.Flush();
OnRawRecordSendOut?.Invoke(this, new ListBytePortDataEventArgs(txByteList, DateTimeOffset.UtcNow));
} }
catch (Exception ex) catch (Exception ex)
{ {
_byteDataLogger.Error($"{Ident} {ex.Message}"); _byteDataLogger.Error($"{Ident} {ex.Message}");
} }
} }
#region Prop #region Prop
#endregion #endregion
} }
@@ -22,13 +22,6 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
/// - wakeup burst pattern changed from 2 times 0xF0 to 4 times 0x01, /// - wakeup burst pattern changed from 2 times 0xF0 to 4 times 0x01,
/// - required delay from 500µs to 1ms between wakeup burst and data. /// - required delay from 500µs to 1ms between wakeup burst and data.
/// </remarks> /// </remarks>
/// <remarks date="2022-Mar-03" author="T.Wiedebusch">
/// - Generated the required delay with an 8 Byte pattern, as MOXA interface collects data
/// and sends it in one burst, meaning it sends the wake up and payload without delay.
/// So including a pattern instead will force this delay. At 115.200 kBit/s a Byte of 8 Bit
/// one start and one stop step resulting in 10 bits with a Byte length of 86.8 µs. An 8
/// Byte pattern will generate a 694 µs delay.
/// </remarks>
protected override void SpecificPortWrite(Byte[] tx) protected override void SpecificPortWrite(Byte[] tx)
{ {
//send wake up burst //send wake up burst
@@ -36,8 +29,7 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
PhysicalWrite(wakeUpBurst); PhysicalWrite(wakeUpBurst);
//delay at least 500 µs //delay at least 500 µs
var delayPattern = new Byte[] { 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F }; Thread.Sleep(1);
PhysicalWrite(delayPattern);
//send the IrDA record //send the IrDA record
PhysicalWrite(tx); PhysicalWrite(tx);
File diff suppressed because it is too large Load Diff
@@ -40,7 +40,7 @@
/// <summary> /// <summary>
/// Download the CRC, the meter size and store calibration as preparation for the lookup table /// Download the CRC, the meter size and store calibration as preparation for the lookup table
/// </summary> /// </summary>
PrepareLutDownload, FinalizeLutDownload,
/// <summary> /// <summary>
/// Erase lookup table file /// Erase lookup table file
/// </summary> /// </summary>
@@ -44,7 +44,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Consts
StateInfos[7].State = LutUpdateState.CompareLutFile; StateInfos[7].State = LutUpdateState.CompareLutFile;
StateInfos[7].Message = "Compare LUT file"; StateInfos[7].Message = "Compare LUT file";
StateInfos[8].State = LutUpdateState.PrepareLutDownload; StateInfos[8].State = LutUpdateState.FinalizeLutDownload;
StateInfos[8].Message = "Init meter size and LUT file CRC"; StateInfos[8].Message = "Init meter size and LUT file CRC";
StateInfos[9].State = LutUpdateState.EraseLutFile; StateInfos[9].State = LutUpdateState.EraseLutFile;
@@ -152,6 +152,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
//the package file describes all files needed for a specific release //the package file describes all files needed for a specific release
private String _packageDescriptionFile; private String _packageDescriptionFile;
// manual stop of update process
private Boolean _stopUpdateProcess;
private Int32 _actualUpdateFileCtr;
/// <summary> /// <summary>
/// Enable partial file writes of single parts with gaps in between /// Enable partial file writes of single parts with gaps in between
/// </summary> /// </summary>
@@ -615,7 +619,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
return _actualOperation; return _actualOperation;
} }
private Int32 _actualUpdateFileCtr;
/// <summary> /// <summary>
/// Returns the FW Update state /// Returns the FW Update state
@@ -668,8 +671,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
_genesisMeter?.ReLogin(); _genesisMeter?.ReLogin();
} }
private Boolean _stopUpdateProcess;
/// <summary> /// <summary>
/// Stop the update process /// Stop the update process
/// </summary> /// </summary>
@@ -104,6 +104,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
// error message for display of error reason // error message for display of error reason
public String ErrorMessage; public String ErrorMessage;
// manual stop of update process
private Boolean _stopUpdateProcess;
/// <summary> /// <summary>
/// Register subset needed to adjust for update performance content before update /// Register subset needed to adjust for update performance content before update
/// </summary> /// </summary>
@@ -166,7 +170,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// </remarks> /// </remarks>
public MeterLutUpdate(GenesisMeter genesisMeter) public MeterLutUpdate(GenesisMeter genesisMeter)
{ {
if (genesisMeter == null) return; if (genesisMeter == null)
return;
AssignGenesis(genesisMeter); AssignGenesis(genesisMeter);
if (genesisMeter.MeterAppListVersion.Any(f => f.AppName == "GENESISFLOW" && f.IsInstalled)) if (genesisMeter.MeterAppListVersion.Any(f => f.AppName == "GENESISFLOW" && f.IsInstalled))
@@ -200,7 +205,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// </summary> /// </summary>
public void Dispose() public void Dispose()
{ {
if (_meterFile == null) return; if (_meterFile == null)
return;
_meterFile.OnProcessUpdate -= ProcessUpdate_Event; _meterFile.OnProcessUpdate -= ProcessUpdate_Event;
_meterFile = null; _meterFile = null;
} }
@@ -263,8 +269,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
_genesisMeter?.ReLogin(); _genesisMeter?.ReLogin();
} }
private Boolean _stopUpdateProcess;
/// <summary> /// <summary>
/// Stop the update process /// Stop the update process
/// </summary> /// </summary>
@@ -364,7 +368,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
_lutUpdateState = LutUpdateState.Idle; _lutUpdateState = LutUpdateState.Idle;
_meterFile = new MeterFile(_genesisMeter); _meterFile = new MeterFile(_genesisMeter);
if (_meterFile != null) _meterFile.OnProcessUpdate += ProcessUpdate_Event; if (_meterFile != null)
_meterFile.OnProcessUpdate += ProcessUpdate_Event;
_genesisMeter?.ReLogin(); _genesisMeter?.ReLogin();
_genesisMeter?.SetProcessState(DisplayCodes.FwUpdateActive, false); _genesisMeter?.SetProcessState(DisplayCodes.FwUpdateActive, false);
@@ -398,7 +403,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// </remarks> /// </remarks>
public Boolean ExitPreparation(Boolean returnValue) public Boolean ExitPreparation(Boolean returnValue)
{ {
if (_meterFile != null) _meterFile.OnProcessUpdate -= ProcessUpdate_Event; if (_meterFile != null)
_meterFile.OnProcessUpdate -= ProcessUpdate_Event;
_meterFile = null; _meterFile = null;
ReestablishMeterFileSystem(); ReestablishMeterFileSystem();
@@ -447,12 +453,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
case LutUpdateState.StartInitial: case LutUpdateState.StartInitial:
_updateProcedureRetryCtr = 0; _updateProcedureRetryCtr = 0;
_lutUpdateState = LutUpdateState.PrepareLutDownload; //TODO THW Test only _lutUpdateState = LutUpdateState.EraseLutFile;
break; _lutUpdateState = LutUpdateState.DownloadLutFile;
case LutUpdateState.PrepareLutDownload:
_lutUpdateState =
PrepareLutDownload() ? LutUpdateState.EraseLutFile : LutUpdateState.StepFailed;
break; break;
case LutUpdateState.EraseLutFile: case LutUpdateState.EraseLutFile:
@@ -464,7 +466,12 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
break; break;
case LutUpdateState.UploadLutFile: case LutUpdateState.UploadLutFile:
_lutUpdateState = UploadAndCompareLutFiles() ? LutUpdateState.Idle : LutUpdateState.StepFailed; _lutUpdateState = UploadAndCompareLutFiles() ? LutUpdateState.FinalizeLutDownload : LutUpdateState.StepFailed;
break;
case LutUpdateState.FinalizeLutDownload:
_lutUpdateState =
FinalizeLutDownload() ? LutUpdateState.Idle : LutUpdateState.StepFailed;
break; break;
case LutUpdateState.CompareLutFile: case LutUpdateState.CompareLutFile:
@@ -516,7 +523,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
// check if LUT file contains data // check if LUT file contains data
if (LutFile?.BinData == null || LutFile.BinData.Count < SizeLutFile) if (LutFile?.BinData == null || LutFile.BinData.Count < SizeLutFile)
{ {
ErrorMessage += "File size mismatch!"; ErrorMessage = "File size mismatch!";
return false; return false;
} }
@@ -524,7 +531,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
// extract the identifier and check, if this is a LUT file // extract the identifier and check, if this is a LUT file
LutFile.StrLutFileId = LutFile.StrLutFileId =
Encoding.UTF8.GetString(LutFile.BinData.ToArray(), IndexLutFileId, IndexDataLength); Encoding.UTF8.GetString(LutFile.BinData.ToArray(), IndexLutFileId, IndexDataLength);
if (LutFile.StrLutFileId != StrLutFileId) return false; if (LutFile.StrLutFileId != StrLutFileId)
return false;
LutFile.MeterSize = (MeterSize)LutFile.BinData[IndexMeterSize]; LutFile.MeterSize = (MeterSize)LutFile.BinData[IndexMeterSize];
LutFile.FileCrc = (UInt16)(LutFile.BinData[IndexCrc] + (LutFile.BinData[IndexCrc + 1] << 8)); LutFile.FileCrc = (UInt16)(LutFile.BinData[IndexCrc] + (LutFile.BinData[IndexCrc + 1] << 8));
@@ -541,7 +549,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
var calculatedCrc = Crc16Ccitt.CalculateMsb1021(payload.ToArray()); var calculatedCrc = Crc16Ccitt.CalculateMsb1021(payload.ToArray());
if (calculatedCrc != LutFile.FileCrc) if (calculatedCrc != LutFile.FileCrc)
{ {
ErrorMessage += "CRC mismatch!"; ErrorMessage = "CRC mismatch!";
return false; return false;
} }
@@ -557,54 +565,96 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// <remarks date="2022-Feb-16" author="Thomas Wiedebusch"> /// <remarks date="2022-Feb-16" author="Thomas Wiedebusch">
/// - Initial /// - Initial
/// </remarks> /// </remarks>
private Boolean PrepareLutDownload() private Boolean FinalizeLutDownload()
{ {
var returnValue = true; var returnValue = true;
var retryCtr = 0; var retryCtr = 0;
if (LutFile == null || _genesisMeter == null || _meterFile == null) return false; if (LutFile == null || _genesisMeter == null || _meterFile == null)
//set extended timeout for trigger upgrade response delay return false;
// set extended timeout for trigger upgrade response delay
_genesisMeter.TransmitProtocol.SetResponseTimeout(5000); _genesisMeter.TransmitProtocol.SetResponseTimeout(5000);
do do
{ {
_actualOperation = "Write Lut CRC to meter"; // for repeated entry
_operationCtr++;
if (!_genesisMeter.WriteRegister<UInt32>(Register.Genesisflow.LookupFileCrc, LutFile.FileCrc))
{
ErrorMessage += "Meter LUT CRC could not be set!\n";
_operationCtr--;
returnValue = false;
}
else
{
_operationCtr++;
_actualOperation = "Write meter size";
if (!_genesisMeter.WriteRegister(Register.Genesisflow.MeterSize, new[] { (Byte)LutFile.MeterSize }))
{
ErrorMessage = "Meter size could not be set!\n";
_operationCtr--;
returnValue = false;
}
else
{
_operationCtr++;
_actualOperation = "Store calibration to meter";
if (!_genesisMeter.WriteRegister(Register.Genesisflow.StoreCalibration, 1))
{
ErrorMessage += "Meter store calibration failed!\n";
_operationCtr--;
returnValue = false;
}
}
}
if (!returnValue) if (!returnValue)
{ {
ReestablishMeterFileSystem(); ReestablishMeterFileSystem();
} }
_actualOperation = "Write Lut CRC to meter";
_operationCtr++;
returnValue = _genesisMeter.WriteRegister<UInt32>(Register.Genesisflow.LookupFileCrc, LutFile.FileCrc);
if (!returnValue)
{
const String txt = "Meter LUT CRC could not be set!\n";
ErrorMessage = txt;
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt));
_operationCtr--;
continue;
}
_operationCtr++;
_actualOperation = "Write meter size";
returnValue =
_genesisMeter.WriteRegister(Register.Genesisflow.MeterSize, new[] { (Byte)LutFile.MeterSize });
if (!returnValue)
{
const String txt = "Meter size could not be set!\n";
ErrorMessage = txt;
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt));
_operationCtr--;
continue;
}
_operationCtr++;
_actualOperation = "Store calibration to meter";
returnValue = _genesisMeter.WriteRegister(Register.Genesisflow.StoreCalibration, 1);
if (!returnValue)
{
const String txt = "Meter store calibration failed!\n";
ErrorMessage = txt;
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt));
_operationCtr--;
continue;
}
_operationCtr++;
_actualOperation = "Read LUT CRC";
var lutCrc = RegisterConverter.ConvertTo<UInt32>(
_genesisMeter.ReadRegister(Register.Genesisflow.LookupFileCrc));
if ((lutCrc & 0x80000000) != 0)
{
const String txt = "Meter LUT CRC could not be set!\n";
ErrorMessage = txt;
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt));
_operationCtr--;
returnValue = false;
continue;
}
_operationCtr++;
_actualOperation = "Read meter size";
var meterSize = (MeterSize)RegisterConverter.ConvertTo<Byte>(
_genesisMeter.ReadRegister(Register.Genesisflow.MeterSize));
if (meterSize != LutFile.MeterSize)
{
const String txt = "Meter size could not be set!\n";
ErrorMessage = txt;
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt));
_operationCtr--;
returnValue = false;
continue;
}
ErrorMessage = "";
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs("Meter size and LUT CRC correctly set!\n"));
} while (!returnValue && retryCtr++ < RegisterWriteRetries && !StopUpdateProcess); } while (!returnValue && retryCtr++ < RegisterWriteRetries && !StopUpdateProcess);
//set timeout back to default value // set timeout back to default value
_genesisMeter.TransmitProtocol.SetDefaultResponseTimeout(); _genesisMeter.TransmitProtocol.SetDefaultResponseTimeout();
return returnValue && !StopUpdateProcess; return returnValue && !StopUpdateProcess;
@@ -628,10 +678,18 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
} }
_meterFilesDrive1.Clear(); _meterFilesDrive1.Clear();
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs("\nRead meter files drive 1"));
if (!_meterFile.ReadMeterFileCatalog(out var meterFilesDrive1, MeterFile.StrMeterDrive1, if (!_meterFile.ReadMeterFileCatalog(out var meterFilesDrive1, MeterFile.StrMeterDrive1,
MeterFile.WildcardAll.ToString())) return false; MeterFile.WildcardAll.ToString()))
return false;
_meterFilesDrive1.AddRange(meterFilesDrive1); _meterFilesDrive1.AddRange(meterFilesDrive1);
// inform overlay system of found files
foreach (var meterFile in _meterFilesDrive1)
{
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(meterFile));
}
return true; return true;
} }
@@ -644,20 +702,35 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// </remarks> /// </remarks>
private Boolean EraseFile(String fileDriveName) private Boolean EraseFile(String fileDriveName)
{ {
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs($"\nErasing {fileDriveName}"));
var returnValue = _meterFile.UnlockEraseWriteMeterFile(fileDriveName); var returnValue = _meterFile.UnlockEraseWriteMeterFile(fileDriveName);
//erase returns always TRUE, even if the erasure failed! Check with catalogue // erase returns always TRUE, even if the erasure failed! Check with catalogue
_meterFile.EraseMeterFile(fileDriveName); _meterFile.EraseMeterFile(fileDriveName);
// give the meter a certain time to erase
Thread.Sleep(1000);
if (ReadMeterFilesDrive1()) if (ReadMeterFilesDrive1())
{ {
if (_meterFilesDrive1.Contains(fileDriveName)) if (_meterFilesDrive1.Contains(fileDriveName))
{ {
returnValue = false; returnValue = false;
var txt = $"Failed to erase {fileDriveName}!";
ErrorMessage = txt;
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt));
}
else
{
ErrorMessage = "";
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs($"Successfully erased {fileDriveName}"));
} }
} }
else else
{ {
returnValue = false; returnValue = false;
const String txt = "Meter files read error!";
ErrorMessage = txt;
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt));
} }
return returnValue; return returnValue;
} }
@@ -672,7 +745,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
{ {
//counters for actual process information //counters for actual process information
var retryCtr = 0; var retryCtr = 0;
if (LutFile == null) return false; if (LutFile == null)
return false;
//set extended timeout for trigger upgrade response delay //set extended timeout for trigger upgrade response delay
_genesisMeter.TransmitProtocol.SetResponseTimeout(10000); _genesisMeter.TransmitProtocol.SetResponseTimeout(10000);
@@ -693,13 +767,22 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
{ {
foreach (var fileToErase in filesToErase) foreach (var fileToErase in filesToErase)
{ {
if (!_meterFilesDrive1.Contains(fileToErase)) continue; if (!_meterFilesDrive1.Contains(fileToErase))
continue;
_operationCtr++; _operationCtr++;
_actualOperation = $"Erase {fileToErase}"; _actualOperation = $"Erase {fileToErase}";
if (EraseFile(fileToErase)) continue; var txt = $"LUT file {fileToErase} erased!\n";
if (EraseFile(fileToErase))
{
ErrorMessage = "";
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt));
continue;
}
ErrorMessage += $"LUT file {fileToErase} not erased!\n"; txt = $"LUT file {fileToErase} not erased!\n";
ErrorMessage = txt;
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt));
returnValue = false; returnValue = false;
_operationCtr--; _operationCtr--;
} }
@@ -728,7 +811,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
{ {
//counters for actual process information //counters for actual process information
var retryCtr = 0; var retryCtr = 0;
if (LutFile == null) return false; if (LutFile == null)
return false;
//set extended timeout for trigger upgrade response delay //set extended timeout for trigger upgrade response delay
_genesisMeter.TransmitProtocol.SetResponseTimeout(10000); _genesisMeter.TransmitProtocol.SetResponseTimeout(10000);
@@ -744,14 +828,22 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
{ {
_operationCtr++; _operationCtr++;
_actualOperation = $"Write {fileToDownload}"; _actualOperation = $"Write {fileToDownload}";
// 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();
_meterFile.UnlockEraseWriteMeterFile(fileToDownload); _meterFile.UnlockEraseWriteMeterFile(fileToDownload);
if (_meterFile.WriteMeterFile(fileToDownload, LutFile.BinData.ToArray())) continue; var txt = $"{fileToDownload} successfully written\n";
if (_meterFile.WriteMeterFile(fileToDownload, LutFile.BinData.ToArray()))
{
ErrorMessage = "";
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt));
continue;
}
ErrorMessage += $"Writing of {fileToDownload} failed!\n"; txt = $"Writing of {fileToDownload} failed!\n";
ErrorMessage = txt;
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt));
returnValue = false; returnValue = false;
_operationCtr--; _operationCtr--;
} }
@@ -759,14 +851,20 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
// read all files on drive 1 // read all files on drive 1
_operationCtr++; _operationCtr++;
_actualOperation = "Read installed meter files drive 1"; _actualOperation = "Read installed meter files drive 1";
if (ReadMeterFilesDrive1()) if (ReadMeterFilesDrive1())
{ {
foreach (var checkInstalledFile in filesToDownload) foreach (var checkInstalledFile in filesToDownload)
{ {
if (_meterFilesDrive1.Contains(checkInstalledFile)) continue; if (_meterFilesDrive1.Contains(checkInstalledFile))
{
ErrorMessage = "";
var txt = $"{checkInstalledFile} found in meter\n";
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt));
continue;
}
ErrorMessage += $"LUT file {StrLutMeterFileName} not installed!\n"; ErrorMessage = $"LUT file {StrLutMeterFileName} not installed!\n";
returnValue = false; returnValue = false;
} }
} }
@@ -798,7 +896,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
{ {
//counters for actual process information //counters for actual process information
var retryCtr = 0; var retryCtr = 0;
if (LutFile == null) return false; if (LutFile == null)
return false;
//set extended timeout for trigger upgrade response delay //set extended timeout for trigger upgrade response delay
_genesisMeter.TransmitProtocol.SetResponseTimeout(10000); _genesisMeter.TransmitProtocol.SetResponseTimeout(10000);
@@ -814,7 +913,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
{ {
_operationCtr++; _operationCtr++;
_actualOperation = $"Read {fileToUpload}"; _actualOperation = $"Read {fileToUpload}";
// 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();
@@ -823,11 +922,17 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
// compare the entire buffer which also includes the header of the file // compare the entire buffer which also includes the header of the file
if (!binData.SequenceEqual(LutFile.BinData)) if (!binData.SequenceEqual(LutFile.BinData))
{ {
ErrorMessage += $"Meter LUT file is unequal to downloaded {fileToUpload}!\n"; ErrorMessage = $"Meter LUT file is unequal to downloaded {fileToUpload}!\n";
returnValue = false; returnValue = false;
_operationCtr--; _operationCtr--;
} }
else
{
OnProcessUpdate?.Invoke(this,
new ProcessExecEventArgs($"LUT file {fileToUpload} of meter successfully compared!\n"));
}
continue; continue;
} }
@@ -77,7 +77,7 @@
<HintPath>..\Hardware\WaterMeter\Genesis\GenesisConfig\bin\Debug\NLog.dll</HintPath> <HintPath>..\Hardware\WaterMeter\Genesis\GenesisConfig\bin\Debug\NLog.dll</HintPath>
</Reference> </Reference>
<Reference Include="SIRTCOM"> <Reference Include="SIRTCOM">
<HintPath>..\..\packages\Sirt\SIRTCOM.dll</HintPath> <HintPath>.\SIRTCOM.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
Binary file not shown.
+1 -1
View File
@@ -668,7 +668,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
return; return;
} }
lblOverall.Text = @"Data base connection.."; lblOverall.Text = @"Establish data base connection..";
lblOverall.Visible = true; lblOverall.Visible = true;
Update(); Update();
_currentGenesis?.DisposeMeter(); _currentGenesis?.DisposeMeter();
+105
View File
@@ -0,0 +1,105 @@
namespace Xylem.Common.Ui.GenesisToolBox
{
partial class FrmHistory
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.rtbHistory = new System.Windows.Forms.RichTextBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// rtbHistory
//
this.rtbHistory.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtbHistory.Location = new System.Drawing.Point(3, 53);
this.rtbHistory.Name = "rtbHistory";
this.rtbHistory.Size = new System.Drawing.Size(378, 673);
this.rtbHistory.TabIndex = 31;
this.rtbHistory.Text = "";
this.rtbHistory.TextChanged += new System.EventHandler(this.rtbHistory_TextChanged);
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.Controls.Add(this.rtbHistory, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 111F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(384, 729);
this.tableLayoutPanel1.TabIndex = 38;
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.ColumnCount = 2;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 1;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 44F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(378, 44);
this.tableLayoutPanel2.TabIndex = 36;
//
// FrmHistory
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new System.Drawing.Size(384, 729);
this.ControlBox = false;
this.Controls.Add(this.tableLayoutPanel1);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(400, 768);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(400, 768);
this.Name = "FrmHistory";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "FW-Update Process History";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmHistory_FormClosing);
this.tableLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
public System.Windows.Forms.RichTextBox rtbHistory;
}
}
+37
View File
@@ -0,0 +1,37 @@
using System;
using System.Windows.Forms;
namespace Xylem.Common.Ui.GenesisToolBox
{
/// <summary>
/// History display of update process
/// </summary>
[Serializable]
public partial class FrmHistory : Form
{
/// <summary>
/// Ctor
/// </summary>
public FrmHistory()
{
InitializeComponent();
}
private void FrmHistory_FormClosing(Object sender, FormClosingEventArgs e)
{
//avoid destroying of object
e.Cancel = true;
//instead just hide it
Hide();
}
/// <summary>
/// Select always the last line for the display.
/// </summary>
private void rtbHistory_TextChanged(Object sender, EventArgs e)
{
//rtbHistory.SelectionStart = rtbHistory.Text.Length;
//rtbHistory.ScrollToCaret();
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+188 -7
View File
@@ -9,6 +9,7 @@ using Logic.ProductionToProductMapper.Cordonel;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore; using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using Xylem.Common.Utils.ProcessExec.EventArguments;
namespace Xylem.Common.Ui.GenesisToolBox namespace Xylem.Common.Ui.GenesisToolBox
@@ -42,6 +43,22 @@ namespace Xylem.Common.Ui.GenesisToolBox
private const String StrLutFileInvalid = "LUT FILE INVALID"; private const String StrLutFileInvalid = "LUT FILE INVALID";
private const String StrLutFileValid = "LUT file loaded"; private const String StrLutFileValid = "LUT file loaded";
// external update remarks form
private readonly FrmHistory _frmHistory = new FrmHistory();
private readonly Version _version;
// 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;
//private const String SuccessSign = @"✔";
//private const String FailedSign = @"✘";
private const String StrSeparator = "-----------------------------------------------------" +
"-----------------------------------------------------";
#endregion #endregion
#region FormControls #region FormControls
@@ -54,6 +71,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
var cultureInfo = new CultureInfo("en-GB"); var cultureInfo = new CultureInfo("en-GB");
Thread.CurrentThread.CurrentUICulture = cultureInfo; Thread.CurrentThread.CurrentUICulture = cultureInfo;
Thread.CurrentThread.CurrentCulture = cultureInfo; Thread.CurrentThread.CurrentCulture = cultureInfo;
_version = Assembly.GetExecutingAssembly().GetName().Version;
} }
/// <summary> /// <summary>
@@ -84,11 +102,17 @@ namespace Xylem.Common.Ui.GenesisToolBox
private void FrmLutUpdate_FormClosing(Object sender, FormClosingEventArgs e) private void FrmLutUpdate_FormClosing(Object sender, FormClosingEventArgs e)
{ {
_frmHistory?.Close();
_currentGenesis?.Logout(); _currentGenesis?.Logout();
_meterBatch?.RemoveAllMeters(); _meterBatch?.RemoveAllMeters();
_meterBatch?.Dispose(); _meterBatch?.Dispose();
_meterLutUpdate?.Dispose(); if (_meterLutUpdate != null)
_meterLutUpdate = null; {
_meterLutUpdate.OnProcessUpdate -= ProcessUpdate_Event;
_meterLutUpdate.Dispose();
_meterLutUpdate = null;
}
Dispose(); Dispose();
} }
@@ -134,6 +158,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
btnStopFwUpdate.Enabled = false; btnStopFwUpdate.Enabled = false;
} }
#endregion #endregion
#region BoardControls #region BoardControls
private void Connect() private void Connect()
{ {
@@ -148,7 +173,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
return; return;
} }
lblOverall.Text = @"Data base connection.."; lblOverall.Text = @"Establish data base connection..";
lblOverall.Visible = true; lblOverall.Visible = true;
Update(); Update();
_currentGenesis?.DisposeMeter(); _currentGenesis?.DisposeMeter();
@@ -166,6 +191,19 @@ namespace Xylem.Common.Ui.GenesisToolBox
_currentGenesis._configuration.UseRegisterWatchService = false; _currentGenesis._configuration.UseRegisterWatchService = false;
_currentGenesis._configuration.UseMinMaxCheck = 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);
@@ -193,18 +231,27 @@ namespace Xylem.Common.Ui.GenesisToolBox
tbxMeterFw.Text = _currentGenesis.FwVersion; tbxMeterFw.Text = _currentGenesis.FwVersion;
tbxMeterMeterSize.Text = _currentGenesis.MeterSize; tbxMeterMeterSize.Text = _currentGenesis.MeterSize;
tbxMeterLutCrc.Text = _currentGenesis.LutCrc; tbxMeterLutCrc.Text = _currentGenesis.LutCrc;
LogText("Meter FW Version: " + _currentGenesis.FwVersion);
LogText("Meter LUT CRC: " + _currentGenesis.LutCrc);
LogText("Meter Size: " + _currentGenesis.MeterSize);
lblConnectPcb.ForeColor = Color.Green; lblConnectPcb.ForeColor = Color.Green;
CheckUpdateEnabled(); CheckUpdateEnabled();
_currentGenesis.Logout(); _currentGenesis.Logout();
LogInstalledMeterFw();
})); }));
}).ContinueWith(delegate { ViewProgressPcb(false); }); }).ContinueWith(delegate
{
ViewProgressPcb(false);
});
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message); MessageBox.Show(ex.Message);
LogErrorText(ex.Message);
} }
} }
#endregion #endregion
#region ProcessControls #region ProcessControls
private void ViewProgressPcb(Boolean isActive) private void ViewProgressPcb(Boolean isActive)
{ {
@@ -293,14 +340,17 @@ namespace Xylem.Common.Ui.GenesisToolBox
var txt = StrUpdateErrorMessage; var txt = StrUpdateErrorMessage;
if (!string.IsNullOrEmpty(_meterLutUpdate?.ErrorMessage)) if (!string.IsNullOrEmpty(_meterLutUpdate?.ErrorMessage))
{ {
txt += "\n\n"; txt += "\n";
txt += _meterLutUpdate?.ErrorMessage; txt += _meterLutUpdate?.ErrorMessage;
} }
LogErrorText(txt);
MessageBoxShow(txt, @"FAILED", MessageBoxShow(txt, @"FAILED",
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
else else
{ {
LogSuccessText(StrUpdateSuccessMessage);
MessageBoxShow(StrUpdateSuccessMessage, @"SUCCESS", MessageBoxShow(StrUpdateSuccessMessage, @"SUCCESS",
MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
@@ -308,8 +358,109 @@ namespace Xylem.Common.Ui.GenesisToolBox
} }
} }
/// <summary>
/// Display installed meter FW.
/// </summary>
/// <remarks date="2022-Mar-25" author="Thomas Wiedebusch">
/// - Init.
/// </remarks>
private void LogInstalledMeterFw()
{
if (_currentGenesis == null)
return;
LogText(StrSeparator);
LogText($"PCB ID: {_currentGenesis.PcbId}");
LogText($"Core Version: {_currentGenesis.CoreRevision}");
LogText($"Region and radio: {_currentGenesis.RegionRadio}");
LogText("");
LogText("Installed Applications:");
foreach (var app in _currentGenesis.MeterAppListVersion)
{
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)
{
var appVersion = new CordonelAppVersion(app.AppId, app.StrVersion);
// Copy metrology update permission
if (app.AppName == MeterFwUpdateCapability.MetrologyName &&
_currentGenesis.MetrologyUpgradePermission != MeterFwUpdateCapability.MetrologyUpgradePermitted)
{
appVersion.IsUpdateable = false;
}
}
}
LogText(StrSeparator);
}
/// <summary>
/// Clear history window.
/// </summary>
/// <remarks date="2021-Jan-05" author="Thomas Wiedebusch">
/// - Initial
/// </remarks>
private void ClearHistoryWindow()
{
if (_frmHistory != null && _frmHistory.rtbHistory.InvokeRequired)
{
_frmHistory.rtbHistory.Invoke(new Action(() => { _frmHistory.rtbHistory.Clear(); }));
}
else
_frmHistory?.rtbHistory.Clear();
}
/// <summary>
/// Output exclusively to user update remarks text window.
/// </summary>
/// <remarks date="2021-Apr-26" author="Thomas Wiedebusch">
/// - Color added.
/// </remarks>
private void LogText(String txtHistory)
{
InfoWindowColoredText(txtHistory, ColorDefault);
}
/// <summary>
/// Output exclusively to user update remarks text window.
/// </summary>
private void LogErrorText(String txtHistory)
{
InfoWindowColoredText(txtHistory, ColorProcessFailed);
}
/// <summary>
/// Output exclusively to user update remarks text window.
/// </summary>
private void LogSuccessText(String txtHistory)
{
InfoWindowColoredText(txtHistory, ColorSuccess);
}
/// <summary>
/// Output exclusively to user update remarks text window.
/// </summary>
private void InfoWindowColoredText(String txtHistory, Color color)
{
if (_frmHistory?.rtbHistory == null)
return;
Invoke(new Action(() =>
{
_frmHistory.rtbHistory.SuspendLayout();
_frmHistory.rtbHistory.SelectionStart = _frmHistory.rtbHistory.Text.Length;
_frmHistory.rtbHistory.SelectionLength = 0;
_frmHistory.rtbHistory.SelectionColor = color;
_frmHistory.rtbHistory.AppendText($"{txtHistory}{Environment.NewLine}");
_frmHistory.rtbHistory.SelectionColor = _frmHistory.rtbHistory.ForeColor;
_frmHistory.rtbHistory.ScrollToCaret();
_frmHistory.rtbHistory.ResumeLayout();
}));
}
#endregion #endregion
#region Checks #region Checks
private void CheckUpdateEnabled() private void CheckUpdateEnabled()
{ {
@@ -323,6 +474,23 @@ namespace Xylem.Common.Ui.GenesisToolBox
} }
#endregion #endregion
#region Events
/// <summary>
/// Process update event for displaying messages in historxy window
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <remarks date="2020-Dec-10" author="Thomas Wiedebusch">
/// - Initial
/// </remarks>
public virtual void ProcessUpdate_Event(Object sender, ProcessExecEventArgs e)
{
LogText(e.OverallProcessMessage);
}
#endregion
#region TimerControls #region TimerControls
private void tmrProgressUpdate_Tick(Object sender, EventArgs e) private void tmrProgressUpdate_Tick(Object sender, EventArgs e)
{ {
@@ -341,7 +509,8 @@ namespace Xylem.Common.Ui.GenesisToolBox
lblActualProcess.Text = _meterLutUpdate?.GetActualOperation(); lblActualProcess.Text = _meterLutUpdate?.GetActualOperation();
var overallProgress = (Int32)(_meterLutUpdate?.OverallProcessCtrPercent ?? 0); var overallProgress = (Int32)(_meterLutUpdate?.OverallProcessCtrPercent ?? 0);
if (overallProgress < 0) overallProgress = 0; if (overallProgress < 0)
overallProgress = 0;
barOverallProgressUpdate.Value = overallProgress > 100 ? 100 : overallProgress; barOverallProgressUpdate.Value = overallProgress > 100 ? 100 : overallProgress;
barOverallProgressUpdate.Update(); barOverallProgressUpdate.Update();
@@ -393,10 +562,12 @@ namespace Xylem.Common.Ui.GenesisToolBox
var lutFilePathName = dlgOpenLuFile.FileName; var lutFilePathName = dlgOpenLuFile.FileName;
lblLutFileLoadedInfo.Text = "";
tbxLutFilePathName.Text = lutFilePathName; tbxLutFilePathName.Text = lutFilePathName;
if (_meterLutUpdate == null) if (_meterLutUpdate == null)
{ {
_meterLutUpdate = new MeterLutUpdate(_currentGenesis); _meterLutUpdate = new MeterLutUpdate(_currentGenesis);
_meterLutUpdate.OnProcessUpdate += ProcessUpdate_Event;
} }
if (_meterLutUpdate == null) if (_meterLutUpdate == null)
@@ -411,6 +582,10 @@ namespace Xylem.Common.Ui.GenesisToolBox
tbxFileCrc.Text = $@"0x{_meterLutUpdate.LutFile.FileCrc:X4}"; tbxFileCrc.Text = $@"0x{_meterLutUpdate.LutFile.FileCrc:X4}";
tbxFileMeterSize.Text = MeterSizeConverter.ConvertMeterSizeEnumToSizeName(_meterLutUpdate.LutFile.MeterSize); tbxFileMeterSize.Text = MeterSizeConverter.ConvertMeterSizeEnumToSizeName(_meterLutUpdate.LutFile.MeterSize);
_lutFileValid = true; _lutFileValid = true;
LogText("LUT File Meter Size: " + tbxFileMeterSize.Text);
LogText("LUT File CRC: " + tbxFileCrc.Text);
} }
else else
{ {
@@ -423,6 +598,8 @@ namespace Xylem.Common.Ui.GenesisToolBox
{ {
txt = StrLutFileInvalid; txt = StrLutFileInvalid;
} }
LogErrorText(txt);
lblLutFileLoadedInfo.ForeColor = Color.Red; lblLutFileLoadedInfo.ForeColor = Color.Red;
lblLutFileLoadedInfo.Text = txt; lblLutFileLoadedInfo.Text = txt;
tbxFileCrc.Text = @" --- "; tbxFileCrc.Text = @" --- ";
@@ -447,6 +624,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
return; return;
} }
lblLutFileLoadedInfo.Text = "";
SetControlsDownloadIsOngoing(); SetControlsDownloadIsOngoing();
StartStopDownload(true); StartStopDownload(true);
@@ -458,7 +636,10 @@ namespace Xylem.Common.Ui.GenesisToolBox
{ {
_lutFileSuccessfulWritten = _meterLutUpdate.UpdateMeterLut(); _lutFileSuccessfulWritten = _meterLutUpdate.UpdateMeterLut();
Thread.Sleep(1000); Thread.Sleep(1000);
}).ContinueWith(delegate { StartStopDownload(false); }); }).ContinueWith(delegate
{
StartStopDownload(false);
});
} }
private void btnStopFwUpdate_Click(Object sender, EventArgs e) private void btnStopFwUpdate_Click(Object sender, EventArgs e)
+14 -1
View File
@@ -194,6 +194,12 @@
<Compile Include="FrmFrozenMeter.Designer.cs"> <Compile Include="FrmFrozenMeter.Designer.cs">
<DependentUpon>FrmFrozenMeter.cs</DependentUpon> <DependentUpon>FrmFrozenMeter.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="FrmHistory.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmHistory.Designer.cs">
<DependentUpon>FrmHistory.cs</DependentUpon>
</Compile>
<Compile Include="FrmLutUpdate.cs"> <Compile Include="FrmLutUpdate.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@@ -344,6 +350,9 @@
<EmbeddedResource Include="FrmFrozenMeter.resx"> <EmbeddedResource Include="FrmFrozenMeter.resx">
<DependentUpon>FrmFrozenMeter.cs</DependentUpon> <DependentUpon>FrmFrozenMeter.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="FrmHistory.resx">
<DependentUpon>FrmHistory.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmLutUpdate.resx"> <EmbeddedResource Include="FrmLutUpdate.resx">
<DependentUpon>FrmLutUpdate.cs</DependentUpon> <DependentUpon>FrmLutUpdate.cs</DependentUpon>
<SubType>Designer</SubType> <SubType>Designer</SubType>
@@ -425,7 +434,7 @@
<None Include="FrmRegisterStore.Designer.cs.vsspell" /> <None Include="FrmRegisterStore.Designer.cs.vsspell" />
<None Include="GenesisToolBox_TemporaryKey.pfx" /> <None Include="GenesisToolBox_TemporaryKey.pfx" />
<None Include="meterconfig.json"> <None Include="meterconfig.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\app.manifest" /> <None Include="Properties\app.manifest" />
@@ -552,6 +561,10 @@
<Project>{4b88b0d3-e791-4774-9521-eabeacdc420e}</Project> <Project>{4b88b0d3-e791-4774-9521-eabeacdc420e}</Project>
<Name>Logging</Name> <Name>Logging</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\Utils\ProcessExec\ProcessExec.csproj">
<Project>{2FD60CF1-45CD-4060-B8E5-4F39FBA7F1CB}</Project>
<Name>ProcessExec</Name>
</ProjectReference>
<ProjectReference Include="..\LegacyGenesisControl\LegacyGenCtl.csproj"> <ProjectReference Include="..\LegacyGenesisControl\LegacyGenCtl.csproj">
<Project>{60765bf4-6165-4f2f-8756-1c699826265d}</Project> <Project>{60765bf4-6165-4f2f-8756-1c699826265d}</Project>
<Name>LegacyGenCtl</Name> <Name>LegacyGenCtl</Name>