Merge
This commit is contained in:
Roland Drabesch
2023-03-20 13:50:05 +01:00
26 changed files with 633 additions and 278 deletions
+2 -2
View File
@@ -14,5 +14,5 @@ using System.Reflection;
//[assembly: AssemblyVersion("1.2.*.0")] //[assembly: AssemblyVersion("1.2.*.0")]
[assembly: AssemblyVersion("2.3.8.*")] [assembly: AssemblyVersion("2.4.2.*")]
[assembly: AssemblyFileVersion("2.3.8.0")] [assembly: AssemblyFileVersion("2.4.2.0")]
+1 -1
View File
@@ -155,7 +155,7 @@
</site> </site>
<site name="MeterProcessState" id="2"> <site name="MeterProcessState" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool"> <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> </application>
<bindings> <bindings>
<binding protocol="http" bindingInformation="*:56011:localhost" /> <binding protocol="http" bindingInformation="*:56011:localhost" />
@@ -594,7 +594,7 @@ namespace CordonelAssemblyLine.Model
sbMSG.AppendLine($"Pcb = {meter.PcbId}"); sbMSG.AppendLine($"Pcb = {meter.PcbId}");
sbMSG.AppendLine($"POWERMON_TotalUsedSeconds = {genesisStatus.ExceededLifeTime_s}"); sbMSG.AppendLine($"POWERMON_TotalUsedSeconds = {genesisStatus.ExceededLifeTime_s}");
sbMSG.AppendLine($"POWERMON_TotalUsedCharge = {genesisStatus.DrainedBatteryPower_uAs}"); sbMSG.AppendLine($"POWERMON_TotalUsedCharge = {genesisStatus.DrainedBatteryLoad_uAs}");
sbMSG.AppendLine($"POWERMON_BatteryQuantity = {genesisStatus.BatteryQuantity}"); sbMSG.AppendLine($"POWERMON_BatteryQuantity = {genesisStatus.BatteryQuantity}");
sbMSG.AppendLine($"POWERMON_BatteryMilliAHrRating = {genesisStatus.InitialBatteryLoad_mAh}"); sbMSG.AppendLine($"POWERMON_BatteryMilliAHrRating = {genesisStatus.InitialBatteryLoad_mAh}");
sbMSG.AppendLine(""); sbMSG.AppendLine("");
@@ -904,35 +904,44 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// </returns> /// </returns>
private RequestRecord LoginCommandToMeter(String password, Boolean runImmediately = true) private RequestRecord LoginCommandToMeter(String password, Boolean runImmediately = true)
{ {
var regDef = _configRegister.GetRegisterDefinitionByName(Register.Configexchange.Password); try
StopKeepSession();
//restore password if new password is zero
if (string.IsNullOrEmpty(password))
{ {
password = _password; var regDef = _configRegister.GetRegisterDefinitionByName(Register.Configexchange.Password);
StopKeepSession();
//restore password if new password is zero
if (string.IsNullOrEmpty(password))
{
password = _password;
}
if (string.IsNullOrEmpty(password))
{
throw new AuthenticationException("Password is empty");
}
//set new password
_password = password;
_logger.Debug($"Slot:{Slot} - Login with password");
//Due to password is defined as uint96_t this direct communication will be used instead of
//WriteRegister. The data shouldn't be resorted MSB<->LSB like other unit data types!
var responseRecord = RequestProtocol.CommandToMeter(Commands.MultipleWriteData, regDef,
Encoding.ASCII.GetBytes(password), hideDataInLog: true);
if (runImmediately)
{
RequestProtocolProcess();
}
StartKeepSession();
return responseRecord;
}
catch (Exception e)
{
_logger.Error(e);
} }
if (string.IsNullOrEmpty(password)) return null;
{
throw new AuthenticationException("Password is empty");
}
//set new password
_password = password;
_logger.Debug($"Slot:{Slot} - Login with password");
//Due to password is defined as uint96_t this direct communication will be used instead of
//WriteRegister. The data shouldn't be resorted MSB<->LSB like other unit data types!
var responseRecord = RequestProtocol.CommandToMeter(Commands.MultipleWriteData, regDef,
Encoding.ASCII.GetBytes(password), hideDataInLog: true);
if (runImmediately)
{
RequestProtocolProcess();
}
StartKeepSession();
return responseRecord;
} }
/// <summary> /// <summary>
/// Clear password to force new password reading /// Clear password to force new password reading
@@ -1070,6 +1079,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <param name="password">password string to login</param> /// <param name="password">password string to login</param>
/// <param name="runImmediately"> true = process command; false = add command to list. call /// <param name="runImmediately"> true = process command; false = add command to list. call
/// <see cref="RequestProtocolProcess()"></see> to process login command </param> /// <see cref="RequestProtocolProcess()"></see> to process login command </param>
/// <param name="skipReadMeterFwAndAssignRegisters"></param>
/// <returns></returns> /// <returns></returns>
/// <remarks date="2019JAN01" author="drabesch"> /// <remarks date="2019JAN01" author="drabesch">
/// pass runImmediately for auto login /// pass runImmediately for auto login
@@ -1083,7 +1093,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <remarks date="2023-Mar-06" author="Thomas Wiedebusch"> /// <remarks date="2023-Mar-06" author="Thomas Wiedebusch">
/// - Pulse module deactivated at login. /// - Pulse module deactivated at login.
/// </remarks> /// </remarks>
public Boolean Login(String password, Boolean runImmediately = true) /// <remarks date="2023-Mar-07" author="Thomas Wiedebusch">
/// - REMOVED: Pulse module deactivated at login.
/// - Skip FW readout to quick connect being able to immediately switch off the pulse mode before App detection.
/// </remarks>
public Boolean Login(String password, Boolean runImmediately = true, Boolean skipReadMeterFwAndAssignRegisters = false)
{ {
var backupRetries = CommunicationConfig.RequestRetries; var backupRetries = CommunicationConfig.RequestRetries;
@@ -1113,12 +1127,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
IsDevelopmentUsage = true; IsDevelopmentUsage = true;
} }
if (!DeactivatePulseModule()) if (!skipReadMeterFwAndAssignRegisters)
{ ReadMeterFirmwareAndAssignRegisters();
_logger.Warn($"Slot:{Slot} - Pulse module deactivation failed!");
}
ReadMeterFirmwareAndAssignRegisters();
} }
else else
{ {
@@ -1472,36 +1482,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
} }
} }
/// <summary>
/// The pulse module interrupts and disturbs the IrDA communication. As quick fix the pulse module can be switched off,
/// as soon as a communication could be established. As the pulse output will only be switched on again, if a pulse
/// module is attached to the device, this pulse mode can be switched active instantaneously after deactivation.
/// </summary>
/// <remarks date="2023-Feb-13" author="Roland Drabesch/Thomas Wiedebusch">
/// - Initial.
/// </remarks>
private Boolean DeactivatePulseModule()
{
Boolean retVal;
try
{
var pulseMode = RegisterConverter.ConvertTo<Byte>(ReadRegister(Register.Mertrologyasst.PulseMode));
// if pulse mode is already set to 0 (OFF) return true
if (pulseMode == 0)
return true;
// write pulse mode temporary to 0 (OFF) and wait for result
retVal = WriteRegister(Register.Mertrologyasst.PulseMode, 0);
// instantaneously restore pulse mode to original value
retVal &= WriteRegister(Register.Mertrologyasst.PulseMode, pulseMode);
}
catch (Exception)
{
retVal = false;
}
return retVal;
}
/// <summary> /// <summary>
/// Automatic login to meter enabled if logged out by lost authentication /// Automatic login to meter enabled if logged out by lost authentication
/// </summary> /// </summary>
@@ -1841,41 +1821,51 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
public Boolean WriteRegister<T>(String reg, T value, Boolean waitForResult = true, public Boolean WriteRegister<T>(String reg, T value, Boolean waitForResult = true,
Boolean checkRegister = false, UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode) Boolean checkRegister = false, UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode)
{ {
var regDef = _configRegister.GetRegisterDefinitionByName(reg); try
var data = RegisterConverter.ConvertFrom(value);
_logger.Info($"Slot:{Slot} - Write register({regDef.RegisterName}), " +
$"record({BitConverter.ToString(data.ToArray())})");
PreRegisterWrite(regDef, data);
var command = data.Length > RegisterDefinition.ChunkSize ?
Commands.MultipleWriteData : Commands.WriteData;
var responseRecord = RequestProtocol.CommandToMeter(command, regDef, data,
skipRetryErrorCode: skipRetryErrorCode);
if (!waitForResult && !checkRegister)
{ {
return true; var regDef = _configRegister.GetRegisterDefinitionByName(reg);
} var data = RegisterConverter.ConvertFrom(value);
_logger.Info($"Slot:{Slot} - Write register({regDef.RegisterName}), " +
$"record({BitConverter.ToString(data.ToArray())})");
RequestProtocolProcess(); PreRegisterWrite(regDef, data);
var command = data.Length > RegisterDefinition.ChunkSize ?
Commands.MultipleWriteData : Commands.WriteData;
var responseRecord = RequestProtocol.CommandToMeter(command, regDef, data,
skipRetryErrorCode: skipRetryErrorCode);
if (!waitForResult && !checkRegister)
{
return true;
}
RequestProtocolProcess();
//if register check by read back is not required we return the acknowledge state
if (!checkRegister || regDef.RegisterDetail.Privilege.Lvl8 == Registers.Access.Wo)
{
return responseRecord.Acknowledge == RequestAcknowledgeState.Ok;
}
var registerData = ReadRegister(reg, data.Length, skipRetryErrorCode);
//check if register read was okay and read and written data are EQUAL
if (registerData == null || registerData.Length < data.Length ||
data.Where((t, i) => registerData[i] != t).Any())
{
return false;
}
//if register check by read back is not required we return the acknowledge state
if (!checkRegister || regDef.RegisterDetail.Privilege.Lvl8 == Registers.Access.Wo)
{
return responseRecord.Acknowledge == RequestAcknowledgeState.Ok; return responseRecord.Acknowledge == RequestAcknowledgeState.Ok;
}
var registerData = ReadRegister(reg, data.Length, skipRetryErrorCode); }
//check if register read was okay and read and written data are EQUAL catch (Exception e)
if (registerData == null || registerData.Length < data.Length ||
data.Where((t, i) => registerData[i] != t).Any())
{ {
return false; _logger.Error(e);
} }
return responseRecord.Acknowledge == RequestAcknowledgeState.Ok; return false;
} }
/// <summary> /// <summary>
@@ -1889,25 +1879,34 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode) UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode)
{ {
var regDef = _configRegister.GetRegisterDefinitionByName(reg); try
_configRegister.Set(regDef, null); {
_logger.Info($"Slot:{Slot} - Read register({regDef.RegisterName})"); var regDef = _configRegister.GetRegisterDefinitionByName(reg);
_configRegister.Set(regDef, null);
_logger.Info($"Slot:{Slot} - Read register({regDef.RegisterName})");
if (!expectedLength.HasValue || expectedLength.Value <= RegisterDefinition.ChunkSize) if (!expectedLength.HasValue || expectedLength.Value <= RegisterDefinition.ChunkSize)
{ {
RequestProtocol?.CommandToMeter(Commands.ReadData, regDef, RequestProtocol?.CommandToMeter(Commands.ReadData, regDef,
skipRetryErrorCode: skipRetryErrorCode); skipRetryErrorCode: skipRetryErrorCode);
}
else
{
RequestProtocol?.CommandToMeter(Commands.MultipleReadData, regDef, expectedLength: expectedLength,
skipRetryErrorCode: skipRetryErrorCode);
}
RequestProtocolProcess();
var result = _configRegister.Get(reg);
PostRegisterRead(regDef, result);
return result;
} }
else catch (Exception e)
{ {
RequestProtocol?.CommandToMeter(Commands.MultipleReadData, regDef, expectedLength: expectedLength, _logger.Error(e);
skipRetryErrorCode: skipRetryErrorCode);
} }
RequestProtocolProcess(); return null;
var result = _configRegister.Get(reg);
PostRegisterRead(regDef, result);
return result;
} }
/// <remarks date="2020-Dec-19" author="Thomas Wiedebusch"> /// <remarks date="2020-Dec-19" author="Thomas Wiedebusch">
@@ -277,7 +277,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
} }
if (genesisMeter.MeterAppListVersion.Any(f => f.AppName == "METROLOGYASST" && f.IsInstalled)) if (genesisMeter.MeterAppListVersion.Any(f => f.AppName == "METROLOGYASST" && f.IsInstalled))
{ {
_registersBeforeUpdate.Add(Register.Mertrologyasst.PulseMode, new Byte[] { 0 }); _registersBeforeUpdate.Add(Register.Metrologyasst.PulseMode, new Byte[] { 0 });
} }
//deny access if NA product, because this does not have the radio app installed //deny access if NA product, because this does not have the radio app installed
if (genesisMeter.MeterAppListVersion.Any(f => f.AppName == "SENSUSRADIO" && f.IsInstalled)) if (genesisMeter.MeterAppListVersion.Any(f => f.AppName == "SENSUSRADIO" && f.IsInstalled))
@@ -178,7 +178,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
_registersBeforeUpdate.Add(Register.Genesisflow.SampleRate, new Byte[] { 1 }); _registersBeforeUpdate.Add(Register.Genesisflow.SampleRate, new Byte[] { 1 });
} }
if (genesisMeter.MeterAppListVersion.Any(f => f.AppName == "METROLOGYASST" && f.IsInstalled)) if (genesisMeter.MeterAppListVersion.Any(f => f.AppName == "METROLOGYASST" && f.IsInstalled))
_registersBeforeUpdate.Add(Register.Mertrologyasst.PulseMode, new Byte[] { 0 }); _registersBeforeUpdate.Add(Register.Metrologyasst.PulseMode, new Byte[] { 0 });
//deny access if NA product, because this does not have the radio app installed //deny access if NA product, because this does not have the radio app installed
if (genesisMeter.MeterAppListVersion.Any(f => f.AppName == "SENSUSRADIO" && f.IsInstalled)) if (genesisMeter.MeterAppListVersion.Any(f => f.AppName == "SENSUSRADIO" && f.IsInstalled))
_registersBeforeUpdate.Add(Register.Sensusradio.WakeupInterval, new Byte[] { 6 }); _registersBeforeUpdate.Add(Register.Sensusradio.WakeupInterval, new Byte[] { 6 });
@@ -104,7 +104,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
/// <summary> /// <summary>
/// Drained capacity of all batteries in uAs. /// Drained capacity of all batteries in uAs.
/// </summary> /// </summary>
public UInt64 DrainedBatteryPower_uAs; public UInt64 DrainedBatteryLoad_uAs;
/// <summary> /// <summary>
/// Comment for approval and permissions reasons: /// Comment for approval and permissions reasons:
@@ -72,7 +72,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
status.ExceededLifeTime_s = RegisterConverter.ConvertTo<UInt32>( status.ExceededLifeTime_s = RegisterConverter.ConvertTo<UInt32>(
currentGenesis.ReadRegister(Register.Powermon.BatteryExceededSeconds)); currentGenesis.ReadRegister(Register.Powermon.BatteryExceededSeconds));
status.DrainedBatteryPower_uAs = RegisterConverter.ConvertTo<UInt64>( status.DrainedBatteryLoad_uAs = RegisterConverter.ConvertTo<UInt64>(
currentGenesis.ReadRegister(Register.Powermon.BatteryDrainedLoad, 8)); currentGenesis.ReadRegister(Register.Powermon.BatteryDrainedLoad, 8));
status.BatteryQuantity = RegisterConverter.ConvertTo<Int32>( status.BatteryQuantity = RegisterConverter.ConvertTo<Int32>(
currentGenesis.ReadRegister(Register.Powermon.BatteryQuantity)); currentGenesis.ReadRegister(Register.Powermon.BatteryQuantity));
@@ -105,7 +105,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
var drainedBatteryLoad_rel = 1.0; var drainedBatteryLoad_rel = 1.0;
if (initialBatteryLoad_uAs != 0) if (initialBatteryLoad_uAs != 0)
{ {
drainedBatteryLoad_rel = (Double)status.DrainedBatteryPower_uAs / initialBatteryLoad_uAs; drainedBatteryLoad_rel = (Double)status.DrainedBatteryLoad_uAs / initialBatteryLoad_uAs;
} }
else else
{ {
@@ -79,7 +79,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
public static readonly String FirstHitLvlUp2 = "GENESISFLOW_FirstHitLvlUp2"; public static readonly String FirstHitLvlUp2 = "GENESISFLOW_FirstHitLvlUp2";
public static readonly String FirstHitLvlUp3 = "GENESISFLOW_FirstHitLvlUp3"; public static readonly String FirstHitLvlUp3 = "GENESISFLOW_FirstHitLvlUp3";
public static readonly String StartHit = "GENESISFLOW_StartHit"; public static readonly String StartHit = "GENESISFLOW_StartHit";
public static readonly String NumFirePulses = "GENESISFLOW_NumFirePulses"; public static readonly String NumFirePulses = "GENESISFLOW_NumFirePulses";
public static readonly String LookupFileCrc = "GENESISFLOW_LookupFileCrc"; public static readonly String LookupFileCrc = "GENESISFLOW_LookupFileCrc";
@@ -92,6 +91,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
public static readonly String BatteryDrainedLoad = "POWERMON_TotalUsedCharge"; public static readonly String BatteryDrainedLoad = "POWERMON_TotalUsedCharge";
public static readonly String BatteryInitialLoad = "POWERMON_BatteryMilliAHrRating"; public static readonly String BatteryInitialLoad = "POWERMON_BatteryMilliAHrRating";
public static readonly String BatteryExceededSeconds = "POWERMON_TotalUsedSeconds"; public static readonly String BatteryExceededSeconds = "POWERMON_TotalUsedSeconds";
public static readonly String StoreConfiguration = "POWERMON_StoreConfiguration";
} }
@@ -100,9 +100,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
public static readonly String FrequencyIndicator = "SENSUSRADIO_FrequencyIndicator"; public static readonly String FrequencyIndicator = "SENSUSRADIO_FrequencyIndicator";
public static readonly String WakeupInterval = "SENSUSRADIO_WakeupInterval"; public static readonly String WakeupInterval = "SENSUSRADIO_WakeupInterval";
public static readonly String SystemState = "SENSUSRADIO_SystemState"; public static readonly String SystemState = "SENSUSRADIO_SystemState";
public static readonly String StoreConfiguration = "SENSUSRADIO_StoreConfiguration";
} }
public static class Mertrologyasst public static class Metrologyasst
{ {
public static readonly String PulseMode = "METROLOGYASST_PulseMode"; public static readonly String PulseMode = "METROLOGYASST_PulseMode";
public static readonly String StoreConfiguration = "METROLOGYASST_StoreConfiguration"; public static readonly String StoreConfiguration = "METROLOGYASST_StoreConfiguration";
@@ -112,6 +113,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
{ {
public static readonly String StoreConfiguration = "IRDA_StoreConfiguration"; public static readonly String StoreConfiguration = "IRDA_StoreConfiguration";
} }
public static class Logger
{
public static readonly String StoreConfiguration = "LOGGER_StoreConfiguration";
}
@@ -119,6 +124,24 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
{ {
return new List<String>() return new List<String>()
{ {
System.CheckFwPresence,
System.CheckFwCrc,
System.TriggerFwUpgrade,
System.CoreRevision,
System.MonotonicSeconds,
System.MetrologyUpgradePermission,
Customer.AlarmStatus0,
Customer.AlarmStatus1,
Customer.TriggerAlarmCancel,
Customer.AlarmStatus2,
Customer.AlarmStatus3,
Customer.AlarmStatus4,
Customer.AlarmStatus5,
Customer.AlarmStatus6,
Customer.AlarmStatus7,
Customer.StoreConfiguration,
Configexchange.Privilege, Configexchange.Privilege,
Configexchange.Password, Configexchange.Password,
Configexchange.PcbSerialNumber, Configexchange.PcbSerialNumber,
@@ -131,12 +154,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
Configexchange.SetFilePointerOffset, Configexchange.SetFilePointerOffset,
Configexchange.FileRemove, Configexchange.FileRemove,
System.CheckFwPresence,
System.CheckFwCrc,
System.TriggerFwUpgrade,
System.CoreRevision,
System.MonotonicSeconds,
Genesisflow.TriggerActive, Genesisflow.TriggerActive,
Genesisflow.TriggerIdle, Genesisflow.TriggerIdle,
Genesisflow.LedMode, Genesisflow.LedMode,
@@ -144,9 +161,26 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
Genesisflow.MeterSize, Genesisflow.MeterSize,
Genesisflow.LookupFileCrc, Genesisflow.LookupFileCrc,
Genesisflow.StoreCalibration, Genesisflow.StoreCalibration,
Genesisflow.StoreConfiguration,
Powermon.BatteryVoltage,
Powermon.BatteryQuantity,
Powermon.BatteryDrainedLoad,
Powermon.BatteryInitialLoad,
Powermon.BatteryExceededSeconds,
Powermon.StoreConfiguration,
Sensusradio.WakeupInterval, Sensusradio.WakeupInterval,
Sensusradio.FrequencyIndicator Sensusradio.FrequencyIndicator,
Sensusradio.SystemState,
Sensusradio.StoreConfiguration,
Metrologyasst.PulseMode,
Metrologyasst.StoreConfiguration,
Irda.StoreConfiguration,
Logger.StoreConfiguration
}; };
@@ -121,7 +121,9 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
/// </summary> /// </summary>
/// <param name="password">password for login</param> /// <param name="password">password for login</param>
/// <param name="runImmediately">execute immediately</param> /// <param name="runImmediately">execute immediately</param>
Boolean Login(String password, Boolean runImmediately = true); /// <param name="skipReadMeterFwAndAssignRegisters">skip app readout and register generation to speed up
/// the initial connection process</param>
Boolean Login(String password, Boolean runImmediately = true, Boolean skipReadMeterFwAndAssignRegisters = false);
/// <summary> /// <summary>
/// set up measurement parameter and set meter into test-mode /// set up measurement parameter and set meter into test-mode
@@ -1 +1 @@
5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3 1a3d4919c9c702245832d925951f2b7cb72fc333
+2 -2
View File
@@ -402,7 +402,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
Meter.SetLcdText(true, new Byte[] { 0x00, 0x00, 0x00, 0x01 }); Meter.SetLcdText(true, new Byte[] { 0x00, 0x00, 0x00, 0x01 });
Meter.ResetAlarm(GenesisMeter.Alarm.EMPTY_PIPE);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 }); Meter.ResetAlarm(GenesisMeter.Alarm.EMPTY_PIPE);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
_currentGenesis.WriteRegister(Register.Mertrologyasst.PulseMode, 5, true, true); _currentGenesis.WriteRegister(Register.Metrologyasst.PulseMode, 5, true, true);
var useRadio = true; var useRadio = true;
if (useRadio) if (useRadio)
{ {
@@ -452,7 +452,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
if (_currentGenesis.Login()) if (_currentGenesis.Login())
{ {
_currentGenesis.WriteRegister(Register.Mertrologyasst.PulseMode, 0); _currentGenesis.WriteRegister(Register.Metrologyasst.PulseMode, 0);
button6.Enabled = true; button6.Enabled = true;
button7.Enabled = false; button7.Enabled = false;
MessageBox.Show("Weiter"); MessageBox.Show("Weiter");
+13
View File
@@ -77,6 +77,7 @@
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.tbxFileToEraseDrive = new System.Windows.Forms.TextBox(); this.tbxFileToEraseDrive = new System.Windows.Forms.TextBox();
this.btnEraseFile = new System.Windows.Forms.Button(); this.btnEraseFile = new System.Windows.Forms.Button();
this.btnPulseModeOff = new System.Windows.Forms.Button();
this.grpSetup.SuspendLayout(); this.grpSetup.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
@@ -356,6 +357,7 @@
// //
// groupBox1 // groupBox1
// //
this.groupBox1.Controls.Add(this.btnPulseModeOff);
this.groupBox1.Controls.Add(this.btnTidyFile); this.groupBox1.Controls.Add(this.btnTidyFile);
this.groupBox1.Controls.Add(this.btnGetDateTime); this.groupBox1.Controls.Add(this.btnGetDateTime);
this.groupBox1.Controls.Add(this.btnSetDateTime); this.groupBox1.Controls.Add(this.btnSetDateTime);
@@ -563,6 +565,16 @@
this.btnEraseFile.UseVisualStyleBackColor = true; this.btnEraseFile.UseVisualStyleBackColor = true;
this.btnEraseFile.Click += new System.EventHandler(this.btnEraseFile_Click); this.btnEraseFile.Click += new System.EventHandler(this.btnEraseFile_Click);
// //
// btnPulseModeOff
//
this.btnPulseModeOff.Location = new System.Drawing.Point(10, 205);
this.btnPulseModeOff.Name = "btnPulseModeOff";
this.btnPulseModeOff.Size = new System.Drawing.Size(116, 25);
this.btnPulseModeOff.TabIndex = 40;
this.btnPulseModeOff.Text = "Pulse Mode OFF";
this.btnPulseModeOff.UseVisualStyleBackColor = true;
this.btnPulseModeOff.Click += new System.EventHandler(this.btnPulseModeOff_Click);
//
// FrmLowLevelTools // FrmLowLevelTools
// //
this.AccessibleRole = System.Windows.Forms.AccessibleRole.Sound; this.AccessibleRole = System.Windows.Forms.AccessibleRole.Sound;
@@ -656,5 +668,6 @@
private System.Windows.Forms.Button btnEraseFile; private System.Windows.Forms.Button btnEraseFile;
private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox tbxFileToEraseName; private System.Windows.Forms.TextBox tbxFileToEraseName;
private System.Windows.Forms.Button btnPulseModeOff;
} }
} }
+46 -4
View File
@@ -147,6 +147,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
/// </summary> /// </summary>
private void DisableToolButtons() private void DisableToolButtons()
{ {
btnPulseModeOff.Enabled = false;
btnClearDisplay.Enabled = false; btnClearDisplay.Enabled = false;
btnSetDateTime.Enabled = false; btnSetDateTime.Enabled = false;
btnGetDateTime.Enabled = false; btnGetDateTime.Enabled = false;
@@ -167,6 +168,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
/// </summary> /// </summary>
private void EnableToolButtons() private void EnableToolButtons()
{ {
btnPulseModeOff.Enabled = true;
btnClearDisplay.Enabled = true; btnClearDisplay.Enabled = true;
btnSetDateTime.Enabled = true; btnSetDateTime.Enabled = true;
btnGetDateTime.Enabled = true; btnGetDateTime.Enabled = true;
@@ -905,8 +907,12 @@ namespace Xylem.Common.Ui.GenesisToolBox
_currentGenesis.SetLcdText(true, new Byte[] { 0x00, 0x00, 0x00, 0x00 }); _currentGenesis.SetLcdText(true, new Byte[] { 0x00, 0x00, 0x00, 0x00 });
// store configuration will logout _currentGenesis.WriteRegister(Register.Genesisflow.StoreConfiguration, 1);
btnStoreConfiguration_Click(this, null);
//add a blank line to separate next operation
LogText("");
_currentGenesis.Logout();
LowLevelActionControl(false);
} }
/// <summary> /// <summary>
@@ -1115,8 +1121,12 @@ namespace Xylem.Common.Ui.GenesisToolBox
LogPcAndCordonelTime(); LogPcAndCordonelTime();
// store configuration will logout //add a blank line to separate next operation
btnStoreConfiguration_Click(this, null); LogText("");
// SYSTEM does not support store configuration, just logout
_currentGenesis.Logout();
LowLevelActionControl(false);
} }
/// <summary> /// <summary>
@@ -1457,6 +1467,38 @@ namespace Xylem.Common.Ui.GenesisToolBox
btnEraseFile_Click(this, null); btnEraseFile_Click(this, null);
} }
} }
/// <summary>
/// Switch pulse mode to OFF
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <remarks date="2023-Mar-08" author="Thomas Wiedebusch">
/// - Initial
/// </remarks>
private void btnPulseModeOff_Click(Object sender, EventArgs e)
{
if (_currentGenesis == null)
return;
//reset timer
_startTime = DateTimeOffset.UtcNow;
var msg = @"Switch pulse mode OFF";
LogText(msg);
lblActualProcess.Text = msg;
LowLevelActionControl(true);
_currentGenesis.ReLogin();
_currentGenesis.WriteRegister(Register.Metrologyasst.PulseMode, 0);
_currentGenesis.WriteRegister(Register.Metrologyasst.StoreConfiguration, 1);
//add a blank line to separate next operation
LogText("");
_currentGenesis.Logout();
LowLevelActionControl(false);
}
#endregion #endregion
} }
} }
+1 -1
View File
@@ -2224,7 +2224,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
sbMSG.AppendLine($"Pcb = {_currentGenesis.PcbId}"); sbMSG.AppendLine($"Pcb = {_currentGenesis.PcbId}");
sbMSG.AppendLine($"POWERMON_TotalUsedSeconds = {genesisStatus.ExceededLifeTime_s}"); sbMSG.AppendLine($"POWERMON_TotalUsedSeconds = {genesisStatus.ExceededLifeTime_s}");
sbMSG.AppendLine($"POWERMON_TotalUsedCharge = {genesisStatus.DrainedBatteryPower_uAs}"); sbMSG.AppendLine($"POWERMON_TotalUsedCharge = {genesisStatus.DrainedBatteryLoad_uAs}");
sbMSG.AppendLine($"POWERMON_BatteryQuantity = {genesisStatus.BatteryQuantity}"); sbMSG.AppendLine($"POWERMON_BatteryQuantity = {genesisStatus.BatteryQuantity}");
sbMSG.AppendLine($"POWERMON_BatteryMilliAHrRating = {genesisStatus.InitialBatteryLoad_mAh}"); sbMSG.AppendLine($"POWERMON_BatteryMilliAHrRating = {genesisStatus.InitialBatteryLoad_mAh}");
sbMSG.AppendLine(""); sbMSG.AppendLine("");
@@ -24,6 +24,11 @@ namespace Xylem.ServiceFwUpdate.Common.FwUpdateConfig.Consts
"Firmware ist aktuell!" "Firmware ist aktuell!"
}; };
/// <summary>
/// Name of settings file being able to restores settings on crashed update procedure on next login.
/// </summary>
public const String RestoreSettingsFileName = "RestoreSettings.json";
/// <summary> /// <summary>
/// Name of the file which contains the meter file names that can be erased before the FW-Update /// Name of the file which contains the meter file names that can be erased before the FW-Update
/// to free disk space and have to be restored after the FW-Update /// to free disk space and have to be restored after the FW-Update
@@ -1477,6 +1477,10 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
/// <remarks date="2023-Feb-24" author="Thomas Wiedebusch"> /// <remarks date="2023-Feb-24" author="Thomas Wiedebusch">
/// - Meter size check corrected. /// - Meter size check corrected.
/// </remarks> /// </remarks>
/// <remarks date="2023-Mar-17" author="Thomas Wiedebusch">
/// - FW-packages with multiple meter sizes supported in update capability check,
/// - FW-packages checked for multiple radio frequencies.
/// </remarks>
private String PreSelectFwPackages(CordonelProductionInfosDb cordonelDbInfo) private String PreSelectFwPackages(CordonelProductionInfosDb cordonelDbInfo)
{ {
if (cordonelDbInfo == null) if (cordonelDbInfo == null)
@@ -1495,110 +1499,141 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
return Constants.StrUnknown; return Constants.StrUnknown;
} }
// search in the list of all FW-packages infos for the user selected Id // catch all meter sizes of a different entry but the identical FW-package references by name
foreach (var fw in _fwUpdateDbAccess.DbCordonelFwPackagesInfo) var fwMeterSizes = new List<String>();
{ // catch multiple radio frequencies
// user selected Id Int32? fwRadioFrequencyMhz = null;
if (_fwUpdatePackage.FwPackageInfo.Id != fw.Id) Int32? fwCoreRevisionMax = null;
continue; Int32? fwCoreRevisionMin = null;
Int32? fwMetrologyVersion = null;
var fwRegion = "";
// search in the list of all FW-packages infos for the user selected Id
foreach (var fw in _fwUpdateDbAccess.DbCordonelFwPackagesInfo.Where(
fw => _fwUpdatePackage.FwPackageInfo.Id == fw.Id))
{
// From here the FW-package is detected by its Id
// assign the unique version for all devices, even if these are having a lack of information // assign the unique version for all devices, even if these are having a lack of information
cordonelDbInfo.RequiredReleaseNameVersion = fw.Name; cordonelDbInfo.RequiredReleaseNameVersion = fw.Name;
fwRadioFrequencyMhz = fw.RadioFrequencyMhz;
fwCoreRevisionMax = fw.CoreRevisionMax;
fwCoreRevisionMin = fw.CoreRevisionMin;
fwMetrologyVersion = fw.MetrologyVersion;
fwRegion = fw.Region;
fwMeterSizes.Add(fw.MeterSize);
// As the first package has been found, the loop can be exited.
break;
}
try // Collect all meter sizes and from identical FW-package(s)
foreach (var fw in _fwUpdateDbAccess.DbCordonelFwPackagesInfo.Where(
fw => fw.Name == cordonelDbInfo.RequiredReleaseNameVersion))
{
// on a package with multiple frequency support set the frequency to null to skip radio check
// in the FW-Update SW
if (fw.RadioFrequencyMhz != fwRadioFrequencyMhz)
{ {
var checkPassed = true; fwRadioFrequencyMhz = null;
// if the installed version is unknown or not set, leave the approval to the user }
if (string.IsNullOrEmpty(cordonelDbInfo.CoreRevision) || cordonelDbInfo.CoreRevision == Constants.StrUnknown)
// check multiple meter sizes in the FW-Update SW
if (fwMeterSizes.All(size => size != fw.MeterSize))
{
fwMeterSizes.Add(fw.MeterSize);
}
}
try
{
var checkPassed = true;
// if the installed version is unknown or not set, leave the approval to the user
if (string.IsNullOrEmpty(cordonelDbInfo.CoreRevision) || cordonelDbInfo.CoreRevision == Constants.StrUnknown)
{
cordonelDbInfo.ReasonForUpdateDenial = Resources.StrUpdateCapabilityCheckCore;
checkPassed = false;
}
else
{
// extract the Cordonel core version and validate it
var coreVersion = cordonelDbInfo.CoreRevision;
coreVersion = coreVersion.Replace(".", "");
Int32.TryParse(coreVersion, out var requiredCoreVersion);
if (requiredCoreVersion > fwCoreRevisionMax || requiredCoreVersion < fwCoreRevisionMin)
{ {
cordonelDbInfo.ReasonForUpdateDenial = "|";
cordonelDbInfo.ReasonForUpdateDenial = Resources.StrUpdateCapabilityCheckCore; cordonelDbInfo.ReasonForUpdateDenial = Resources.StrUpdateCapabilityCheckCore;
checkPassed = false; checkPassed = false;
} }
else
{
// extract the Cordonel core version and validate it
var coreVersion = cordonelDbInfo.CoreRevision;
coreVersion = coreVersion.Replace(".", "");
Int32.TryParse(coreVersion, out var requiredCoreVersion);
if (requiredCoreVersion > fw.CoreRevisionMax || requiredCoreVersion < fw.CoreRevisionMin)
{
cordonelDbInfo.ReasonForUpdateDenial = Resources.StrUpdateCapabilityCheckCore;
checkPassed = false;
}
} }
// check the completeness of information in DB of the Cordonel region // check the completeness of information in DB of the Cordonel region
if (string.IsNullOrEmpty(cordonelDbInfo.Region) || cordonelDbInfo.Region != fw.Region) if (string.IsNullOrEmpty(cordonelDbInfo.Region) || cordonelDbInfo.Region != fwRegion)
{
cordonelDbInfo.ReasonForUpdateDenial += "|";
cordonelDbInfo.ReasonForUpdateDenial += Resources.StrUpdateCapabilityCheckRegion;
checkPassed = false;
}
// check radio but skip check for NA region or if FW-package supports all frequencies indicated
// by null for the FW-package info frequency field
if (cordonelDbInfo.Region != "NA" && fwRadioFrequencyMhz != null)
{
// check the radio frequencies
if (string.IsNullOrEmpty(cordonelDbInfo.RadioFrequency)
|| cordonelDbInfo.RadioFrequency == Constants.StrUnknown
|| string.IsNullOrEmpty(fwRadioFrequencyMhz.ToString())
|| cordonelDbInfo.RadioFrequency != fwRadioFrequencyMhz.ToString())
{ {
cordonelDbInfo.ReasonForUpdateDenial += " "; cordonelDbInfo.ReasonForUpdateDenial += "|";
cordonelDbInfo.ReasonForUpdateDenial += Resources.StrUpdateCapabilityCheckRegion; cordonelDbInfo.ReasonForUpdateDenial += Resources.StrUpdateCapabilityCheckRadio;
checkPassed = false; checkPassed = false;
} }
}
// check radio but skip check for NA region or if FW-package supports all frequencies indicated // if meter size does not fit and not for all meter sizes
// by null for the FW-package info frequency field if (cordonelDbInfo.Diameter == Constants.StrUnknown
if (cordonelDbInfo.Region != "NA" && fw.RadioFrequencyMhz != null) || (fwMeterSizes.All(meterSize => meterSize != cordonelDbInfo.Diameter)
{ && fwMeterSizes.Any( meterSize => meterSize != Constants.StrWildcard)))
// signal a non approved version {
if (string.IsNullOrEmpty(cordonelDbInfo.RadioFrequency) cordonelDbInfo.ReasonForUpdateDenial += "|";
|| cordonelDbInfo.RadioFrequency == Constants.StrUnknown cordonelDbInfo.ReasonForUpdateDenial += Resources.StrUpdateCapabilityCheckMeterSize;
|| string.IsNullOrEmpty(fw.RadioFrequencyMhz.ToString()) checkPassed = false;
|| cordonelDbInfo.RadioFrequency != fw.RadioFrequencyMhz.ToString()) }
{
cordonelDbInfo.ReasonForUpdateDenial += " ";
cordonelDbInfo.ReasonForUpdateDenial += Resources.StrUpdateCapabilityCheckRadio;
checkPassed = false;
}
}
// if meter size does not fit and not for all meter sizes // if the installed version is unknown or not set, leave the approval to the user
if (string.IsNullOrEmpty(fw.MeterSize) if (string.IsNullOrEmpty(cordonelDbInfo.Metrology) || cordonelDbInfo.Metrology == Constants.StrUnknown)
|| cordonelDbInfo.Diameter == Constants.StrUnknown {
|| (fw.MeterSize != cordonelDbInfo.Diameter cordonelDbInfo.ReasonForUpdateDenial += "|";
&& fw.MeterSize != Constants.StrWildcard)) cordonelDbInfo.ReasonForUpdateDenial += Resources.StrUpdateCapabilityCheckMetrokogy;
checkPassed = false;
}
else
{
// extract the metrology version and validate it
var metrologyVersion = cordonelDbInfo.Metrology;
metrologyVersion = metrologyVersion.Replace(".", "");
Int32.TryParse(metrologyVersion, out var requiredMetrologyVersion);
if (requiredMetrologyVersion != fwMetrologyVersion)
{ {
cordonelDbInfo.ReasonForUpdateDenial += " "; cordonelDbInfo.ReasonForUpdateDenial += "|";
cordonelDbInfo.ReasonForUpdateDenial += Resources.StrUpdateCapabilityCheckMeterSize;
checkPassed = false;
}
// if the installed version is unknown or not set, leave the approval to the user
if (string.IsNullOrEmpty(cordonelDbInfo.Metrology) || cordonelDbInfo.Metrology == Constants.StrUnknown)
{
cordonelDbInfo.ReasonForUpdateDenial += " ";
cordonelDbInfo.ReasonForUpdateDenial += Resources.StrUpdateCapabilityCheckMetrokogy; cordonelDbInfo.ReasonForUpdateDenial += Resources.StrUpdateCapabilityCheckMetrokogy;
checkPassed = false; checkPassed = false;
} }
else
{
// extract the metrology version and validate it
var metrologyVersion = cordonelDbInfo.Metrology;
metrologyVersion = metrologyVersion.Replace(".", "");
Int32.TryParse(metrologyVersion, out var requiredMetrologyVersion);
if (requiredMetrologyVersion != fw.MetrologyVersion )
{
cordonelDbInfo.ReasonForUpdateDenial += " ";
cordonelDbInfo.ReasonForUpdateDenial += Resources.StrUpdateCapabilityCheckMetrokogy;
checkPassed = false;
}
}
if (checkPassed)
{
cordonelDbInfo.IsRemoved = false;
cordonelDbInfo.IsApproved = true;
}
} }
catch (Exception) if (checkPassed)
{ {
return Constants.StrUnknown; cordonelDbInfo.IsRemoved = false;
cordonelDbInfo.IsApproved = true;
} }
}
return cordonelDbInfo.RequiredReleaseNameVersion; catch (Exception)
{
return Constants.StrUnknown;
} }
return Constants.StrUnknown; return cordonelDbInfo.RequiredReleaseNameVersion;
} }
/// <summary> /// <summary>
@@ -2447,6 +2482,29 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
UiInvoker.ControlEnableInvoker(tabControlSelection, true); UiInvoker.ControlEnableInvoker(tabControlSelection, true);
} }
/// <summary>
/// Remove search items on FW-package pre-selection and deselect FW-package.
/// </summary>
/// <remarks date="2023-Mar-17" author="Thomas Wiedebusch">
/// - Initial.
/// </remarks>
private void DeselectFwPackageAndSearchMask()
{
// clear all search items for FW-Package as all cordonels are removed
_radioSearchItems.Clear();
_regionSearchItems.Clear();
_metrologySearchItems.Clear();
_coreSearchItems.Clear();
_sizeSearchItems.Clear();
// Clear FW-package selection
if (_fwUpdateDbAccess?.DbCordonelFwPackagesInfo != null)
{
foreach (var fw in _fwUpdateDbAccess.DbCordonelFwPackagesInfo)
fw.IsSelected = false;
_fwUpdatePackage = null;
}
}
#endregion --------------------------------------- Tools ------------------------------------------------------ #endregion --------------------------------------- Tools ------------------------------------------------------
#region ------------------------------------------ Threads and Tasks ------------------------------------------ #region ------------------------------------------ Threads and Tasks ------------------------------------------
@@ -2558,8 +2616,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
try try
{ {
// check DB connection in advance to overcome the timing issues for DB service startup // check DB connection in advance to overcome the timing issues for DB service startup
_fwUpdateDbAccess.CheckDbConnection(); _fwUpdateDbAccess.CheckDbConnection();
} }
catch (Exception) catch (Exception)
{ {
@@ -2592,8 +2650,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
try try
{ {
// check DB connection in advance to overcome the timing issues for DB service startup // check DB connection in advance to overcome the timing issues for DB service startup
_fwUpdateDbAccess.CheckDbConnection(); _fwUpdateDbAccess.CheckDbConnection();
GetAllUpdateOperatorsFromDb(); GetAllUpdateOperatorsFromDb();
} }
catch (Exception) catch (Exception)
@@ -2622,8 +2680,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
try try
{ {
// check DB connection in advance to overcome the timing issues for DB service startup // check DB connection in advance to overcome the timing issues for DB service startup
_fwUpdateDbAccess.CheckDbConnection(); _fwUpdateDbAccess.CheckDbConnection();
GetLicenseFromDb(); GetLicenseFromDb();
} }
catch (Exception) catch (Exception)
@@ -2657,10 +2715,10 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
try try
{ {
// check DB connection in advance to overcome the timing issues for DB service startup // check DB connection in advance to overcome the timing issues for DB service startup
_fwUpdateDbAccess.CheckDbConnection(); _fwUpdateDbAccess.CheckDbConnection();
// load the packages information // load the packages information
GetCordonelFwPackagesInfosFromDb(); GetCordonelFwPackagesInfosFromDb();
} }
catch (Exception) catch (Exception)
{ {
@@ -2689,8 +2747,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
try try
{ {
// check DB connection in advance to overcome the timing issues for DB service startup // check DB connection in advance to overcome the timing issues for DB service startup
_fwUpdateDbAccess.CheckDbConnection(); _fwUpdateDbAccess.CheckDbConnection();
GetAndDisplaySingleReportFromDb(); GetAndDisplaySingleReportFromDb();
} }
catch (Exception) catch (Exception)
@@ -2718,8 +2776,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
try try
{ {
// check DB connection in advance to overcome the timing issues for DB service startup // check DB connection in advance to overcome the timing issues for DB service startup
_fwUpdateDbAccess.CheckDbConnection(); _fwUpdateDbAccess.CheckDbConnection();
GetReportsFromDb(); GetReportsFromDb();
} }
catch (Exception) catch (Exception)
@@ -2748,8 +2806,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
try try
{ {
// check DB connection in advance to overcome the timing issues for DB service startup // check DB connection in advance to overcome the timing issues for DB service startup
_fwUpdateDbAccess.CheckDbConnection(); _fwUpdateDbAccess.CheckDbConnection();
GetFwUpdateSafesInfosFromDb(); GetFwUpdateSafesInfosFromDb();
} }
catch (Exception) catch (Exception)
@@ -2784,8 +2842,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
try try
{ {
// check DB connection in advance to overcome the timing issues for DB service startup // check DB connection in advance to overcome the timing issues for DB service startup
_fwUpdateDbAccess.CheckDbConnection(); _fwUpdateDbAccess.CheckDbConnection();
GetAllCordonelCustomersFromDb(); GetAllCordonelCustomersFromDb();
} }
catch (Exception) catch (Exception)
@@ -2820,8 +2878,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
try try
{ {
// check DB connection in advance to overcome the timing issues for DB service startup // check DB connection in advance to overcome the timing issues for DB service startup
_fwUpdateDbAccess.CheckDbConnection(); _fwUpdateDbAccess.CheckDbConnection();
GetAllCordonelSerialNumbersOfOrderFromDb(); GetAllCordonelSerialNumbersOfOrderFromDb();
} }
catch (Exception) catch (Exception)
@@ -2853,8 +2911,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
try try
{ {
// check DB connection in advance to overcome the timing issues for DB service startup // check DB connection in advance to overcome the timing issues for DB service startup
_fwUpdateDbAccess.CheckDbConnection(); _fwUpdateDbAccess.CheckDbConnection();
GetAllCordonelOrdersOfCustomerFromDb(); GetAllCordonelOrdersOfCustomerFromDb();
} }
catch (Exception) catch (Exception)
@@ -3783,6 +3841,9 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
/// - Preselect order number and position to last production number to simplify update order generation, /// - Preselect order number and position to last production number to simplify update order generation,
/// this will cause the update order-pos = production order-pos.. /// this will cause the update order-pos = production order-pos..
/// </remarks> /// </remarks>
/// <remarks date="2023-Mar-17" author="Thomas Wiedebusch">
/// - Clear all search items for FW-package selection and deselect the FW-package if cordonel count is 0.
/// </remarks>
private void gridViewCordonelsSelection_CellClick(Object sender, DataGridViewCellEventArgs e) private void gridViewCordonelsSelection_CellClick(Object sender, DataGridViewCellEventArgs e)
{ {
try try
@@ -3793,14 +3854,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
return; return;
} }
// clear all search items for FW-Package selection // the e.RowIndex is referenced to the (sorted) data grid view
_radioSearchItems.Clear();
_regionSearchItems.Clear();
_metrologySearchItems.Clear();
_coreSearchItems.Clear();
_sizeSearchItems.Clear();
// the e.RowIndex is referenced to the (sorted) data grid view
var cordSelect = new CordonelProductionInfosDb(); var cordSelect = new CordonelProductionInfosDb();
for (var columnIndex = 0; columnIndex < gridViewCordonelSelection.ColumnCount; for (var columnIndex = 0; columnIndex < gridViewCordonelSelection.ColumnCount;
columnIndex++) columnIndex++)
@@ -3840,12 +3894,12 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
if (_cordonelProductionPreSelectInfos.All(x => x.PcbId != cordSelect.PcbId)) if (_cordonelProductionPreSelectInfos.All(x => x.PcbId != cordSelect.PcbId))
_cordonelProductionPreSelectInfos.Add(cordSearch); _cordonelProductionPreSelectInfos.Add(cordSearch);
// fill text box for update order // fill text box for update order
if (cordSearch.CustomerOrderNumber > 0 ) if (cordSearch.CustomerOrderNumber > 0)
{ {
tbxOrderNumber.Text = cordSearch.CustomerOrderNumber.ToString(); tbxOrderNumber.Text = cordSearch.CustomerOrderNumber.ToString();
} }
// fill text box for update position // fill text box for update position
if (cordSearch.CustomerOrderPos > 0 ) if (cordSearch.CustomerOrderPos > 0)
{ {
tbxOrderPosition.Text = cordSearch.CustomerOrderPos.ToString(); tbxOrderPosition.Text = cordSearch.CustomerOrderPos.ToString();
} }
@@ -3901,6 +3955,11 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
}// Search the cordonel in the production search list }// Search the cordonel in the production search list
} }
if (_cordonelProductionPreSelectInfos == null || _cordonelProductionPreSelectInfos.Count == 0)
{
DeselectFwPackageAndSearchMask();
}
_cordonelsPropertyChanged = false; _cordonelsPropertyChanged = false;
} }
catch (Exception) catch (Exception)
@@ -4302,6 +4361,10 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
/// <remarks date="2021-Apr-17" author="Thomas Wiedebusch"> /// <remarks date="2021-Apr-17" author="Thomas Wiedebusch">
/// - Production pre select infos from production search infos. /// - Production pre select infos from production search infos.
/// </remarks> /// </remarks>
/// <remarks date="2023-Mar-17" author="Thomas Wiedebusch">
/// - Clear all search items for FW-package selection and deselect the FW-package as on customer change
/// everything needs to be renewed.
/// </remarks>
private void gridViewCustomerSelection_CellClick(Object sender, DataGridViewCellEventArgs e) private void gridViewCustomerSelection_CellClick(Object sender, DataGridViewCellEventArgs e)
{ {
try try
@@ -4311,6 +4374,9 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
return; return;
} }
// remove FW-package on customer change
DeselectFwPackageAndSearchMask();
// the e.RowIndex is referenced to the (sorted) data grid view // the e.RowIndex is referenced to the (sorted) data grid view
var customerNumber = 0L; var customerNumber = 0L;
for (var columnIndex = 0; columnIndex < gridViewCustomerSelection.ColumnCount; columnIndex++) for (var columnIndex = 0; columnIndex < gridViewCustomerSelection.ColumnCount; columnIndex++)
@@ -145,6 +145,11 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// path and name of the installed applications // path and name of the installed applications
private String _pathNameCordonelAppVersionFile; private String _pathNameCordonelAppVersionFile;
// path and name of the restore settings file on crashed application or interrupted update
private String _pathNameCordonelRegisterRestoreSettingsFile;
// Register subset needed to adjust for update performance content before update
private Dictionary<String, Byte[]> _pulseModeRegistersRestore = new Dictionary<String, Byte[]>();
// loading the lists of meter files which shall be erased before the FW-Update and restored after. // loading the lists of meter files which shall be erased before the FW-Update and restored after.
private MeterFilesEraseRestore _meterFilesEraseRestore; private MeterFilesEraseRestore _meterFilesEraseRestore;
@@ -370,6 +375,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
case ProcessState.FirmwareUpdateSuccess: case ProcessState.FirmwareUpdateSuccess:
ReleaseDisplay(); ReleaseDisplay();
RestoreRegisters();
FwUpdateSuccessMessage(); FwUpdateSuccessMessage();
_processState = ProcessState.Idle; _processState = ProcessState.Idle;
break; break;
@@ -979,9 +985,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
try try
{ {
if (_cordonelDeviceInfos == null if (_cordonelDeviceInfos == null
|| _cordonelFirmwarePackage?.FwPackageInfo == null || _cordonelFirmwarePackage?.FwPackageInfo == null
|| _cordonelFirmwarePackage.BinaryApplicationFiles == null || _cordonelFirmwarePackage.BinaryApplicationFiles == null
|| _cordonelFirmwarePackage.BinaryApplicationFiles.Count == 0 || _cordonelFirmwarePackage.BinaryApplicationFiles.Count == 0
|| _cordonelFirmwarePackage.PackageDescriptionFile == null) || _cordonelFirmwarePackage.PackageDescriptionFile == null)
{ {
@@ -997,7 +1003,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
{ {
// here the firmware package is valid, encode content // here the firmware package is valid, encode content
var encoding = new ASCIIEncoding(); var encoding = new ASCIIEncoding();
var packageFile = var packageFile =
encoding.GetString(_cordonelFirmwarePackage.PackageDescriptionFile.FileContent.ToArray()); encoding.GetString(_cordonelFirmwarePackage.PackageDescriptionFile.FileContent.ToArray());
// setup package description file in FwUpdate class // setup package description file in FwUpdate class
@@ -1211,8 +1217,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// set information of required and detected versions, check failed! // set information of required and detected versions, check failed!
LogText(StrSeparator); LogText(StrSeparator);
LogErrorText(Resources.StrCoreRevision); LogErrorText(Resources.StrCoreRevision);
LogErrorText(@"Minimum :" + _meterFwUpdate.CoreRevisionMinimum/100 + ":" + _meterFwUpdate.CoreRevisionMinimum%100); LogErrorText(@"Minimum :" + _meterFwUpdate.CoreRevisionMinimum / 100 + ":" + _meterFwUpdate.CoreRevisionMinimum % 100);
LogErrorText(@"Maximum :" + _meterFwUpdate.CoreRevisionMaximum/100 + "." + _meterFwUpdate.CoreRevisionMaximum%100 ); LogErrorText(@"Maximum :" + _meterFwUpdate.CoreRevisionMaximum / 100 + "." + _meterFwUpdate.CoreRevisionMaximum % 100);
LogErrorText(@"Cordonel :" + GenesisMeter.BuildFwVersionString(_currentGenesis.CoreRevision)); LogErrorText(@"Cordonel :" + GenesisMeter.BuildFwVersionString(_currentGenesis.CoreRevision));
InfoProcessFailed(lblCordonelUpdateCapability, Resources.StrCordonelUpdateCapabilityCoreFailed); InfoProcessFailed(lblCordonelUpdateCapability, Resources.StrCordonelUpdateCapabilityCoreFailed);
_processState = ProcessState.Error; _processState = ProcessState.Error;
@@ -1279,12 +1285,12 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// extract the package information // extract the package information
var fwPackRegion = _cordonelFirmwarePackage.FwPackageInfo.Region; var fwPackRegion = _cordonelFirmwarePackage.FwPackageInfo.Region;
var fwPackRadioFrequencyMhz = _cordonelFirmwarePackage.FwPackageInfo.RadioFrequencyMhz; var fwPackRadioFrequencyMhz = _cordonelFirmwarePackage.FwPackageInfo.RadioFrequencyMhz;
// region // region
if (!string.IsNullOrEmpty(fwPackRegion)) if (!string.IsNullOrEmpty(fwPackRegion))
{ {
// accept region if identical, on undefined installed region or support for all regions // accept region if identical, on undefined installed region or support for all regions
if (_currentGenesis.Region == fwPackRegion if (_currentGenesis.Region == fwPackRegion
|| Constants.StrWildcard == fwPackRegion || Constants.StrWildcard == fwPackRegion
|| Constants.StrUnknown == _currentGenesis.Region) || Constants.StrUnknown == _currentGenesis.Region)
{ {
@@ -1303,7 +1309,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// if radio frequency is null the region is "NA" or the fw package serves all frequencies, // if radio frequency is null the region is "NA" or the fw package serves all frequencies,
// if the radio frequency is explicit set, it has to be verified against the preset value in the Cordonel // if the radio frequency is explicit set, it has to be verified against the preset value in the Cordonel
if (fwPackRadioFrequencyMhz == null || fwPackRadioFrequencyMhz == _currentGenesis.RadioFrequencyMhz if (fwPackRadioFrequencyMhz == null || fwPackRadioFrequencyMhz == _currentGenesis.RadioFrequencyMhz
|| _currentGenesis.RadioFrequencyMhz == null) || _currentGenesis.RadioFrequencyMhz == null)
{ {
InfoProcessSuccess(null, Resources.StrCordonelUpdateCapabilityRadioSucceeded); InfoProcessSuccess(null, Resources.StrCordonelUpdateCapabilityRadioSucceeded);
@@ -1317,8 +1323,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
LogErrorText(@"Cordonel: " + _currentGenesis.RadioFrequencyMhz + " MHz"); LogErrorText(@"Cordonel: " + _currentGenesis.RadioFrequencyMhz + " MHz");
InfoProcessFailed(lblCordonelUpdateCapability, Resources.StrCordonelUpdateCapabilityRadioFailed); InfoProcessFailed(lblCordonelUpdateCapability, Resources.StrCordonelUpdateCapabilityRadioFailed);
} }
if (!retVal) _processState = ProcessState.Error; if (!retVal)
_processState = ProcessState.Error;
return retVal; return retVal;
} }
@@ -1331,7 +1338,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// for this update capability check. /// for this update capability check.
/// </summary> /// </summary>
/// <returns>true if meter size is approved</returns> /// <returns>true if meter size is approved</returns>
/// <remarks date="2023-Feb-23" author="Thomas Wiedebusch"> /// <remarks date="2023-Feb-23" author="Thomas Wiedebusch">
/// - Initial. /// - Initial.
/// </remarks> /// </remarks>
private Boolean MeterSizeUpdateCapability() private Boolean MeterSizeUpdateCapability()
@@ -1343,7 +1350,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// extract the package information // extract the package information
var fwPackMeterSizes = _cordonelFirmwarePackage.FwPackageInfo.MeterSizes; var fwPackMeterSizes = _cordonelFirmwarePackage.FwPackageInfo.MeterSizes;
// meter size // meter size
if (fwPackMeterSizes != null && fwPackMeterSizes.Count > 0) if (fwPackMeterSizes != null && fwPackMeterSizes.Count > 0)
{ {
@@ -1351,7 +1358,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// if fw package supports all meter sizes or the meter size is unknown // if fw package supports all meter sizes or the meter size is unknown
if (fwPackMeterSizes.Any(size => size == _currentGenesis.MeterSize) if (fwPackMeterSizes.Any(size => size == _currentGenesis.MeterSize)
|| fwPackMeterSizes.Any(size => size == Constants.StrWildcard) || fwPackMeterSizes.Any(size => size == Constants.StrWildcard)
|| Constants.StrUnknown == _currentGenesis.MeterSize ) || Constants.StrUnknown == _currentGenesis.MeterSize)
{ {
InfoProcessSuccess(null, Resources.StrCordonelUpdateCapabilityMeterSizeSucceeded); InfoProcessSuccess(null, Resources.StrCordonelUpdateCapabilityMeterSizeSucceeded);
} }
@@ -1365,7 +1372,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
foreach (var size in fwPackMeterSizes) foreach (var size in fwPackMeterSizes)
{ {
msg += size; msg += size;
if (--cnt > 0) msg += ", "; if (--cnt > 0)
msg += ", ";
} }
LogErrorText(Resources.StrFwPackageInfo + msg); LogErrorText(Resources.StrFwPackageInfo + msg);
LogErrorText(@"Cordonel: " + _currentGenesis.MeterSize); LogErrorText(@"Cordonel: " + _currentGenesis.MeterSize);
@@ -1373,7 +1381,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
} }
} }
if (!retVal) _processState = ProcessState.Error; if (!retVal)
_processState = ProcessState.Error;
return retVal; return retVal;
} }
@@ -1541,6 +1550,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// 3. login /// 3. login
/// 4. read if not 0x01. /// 4. read if not 0x01.
/// </remarks> /// </remarks>
/// <remarks date="2023-Mar-07" author="Thomas Wiedebusch">
/// - Handle SystemState 0 = OFF
/// </remarks>
private Boolean ActivateRadio() private Boolean ActivateRadio()
{ {
if (_currentGenesis == null) if (_currentGenesis == null)
@@ -1550,7 +1562,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
try try
{ {
// read initially if radio is NOT in production mode (0x01), where it sends unencrypted radio telegrams // read initially if radio is NOT in production mode (0x01), where it sends unencrypted radio telegrams
if ( 0x01 != RegisterConverter.ConvertTo<Int32>(_currentGenesis.ReadRegister(Register.Sensusradio.SystemState))) var radioSystemState =
RegisterConverter.ConvertTo<Int32>(_currentGenesis.ReadRegister(Register.Sensusradio.SystemState));
if (radioSystemState != 0x01 && radioSystemState != 0)
{ {
LogSuccessText(Resources.StrRadioAlreadyActive); LogSuccessText(Resources.StrRadioAlreadyActive);
retVal = true; retVal = true;
@@ -1589,6 +1603,96 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
return retVal; return retVal;
} }
/// <summary>
/// The pulse module interrupts and disturbs the IrDA communication. As quick fix the pulse module can be switched off,
/// as soon as a communication could be established. As the pulse output will only be switched on again, if a pulse
/// module is attached to the device, this pulse mode can be switched active instantaneously after deactivation.
/// </summary>
/// <remarks date="2023-Mar-07" author="Roland Drabesch/Thomas Wiedebusch">
/// - Initial.
/// </remarks>
private Boolean DeactivatePulseModule()
{
var retVal = false;
try
{
if (!_currentGenesis.IsLoggedOn)
_currentGenesis.ReLogin();
// create path and name for register setup reminder for this PcbId
_pathNameCordonelRegisterRestoreSettingsFile = Path.Combine(FwUpdateConfig.ReportedPath,
$"{_currentGenesis.PcbId}_" + FwUpdateConfig.RestoreSettingsFileName);
var pulseMode =
RegisterConverter.ConvertTo<Byte>(_currentGenesis.ReadRegister(Register.Metrologyasst.PulseMode));
// if pulse mode is already set to 0 (OFF) this could be initial setup or a indication of a crashed update
if (pulseMode == 0)
{
LogText(Resources.StrPulseModeInactive);
// check if a file exists with settings from a previous update
if (File.Exists(_pathNameCordonelRegisterRestoreSettingsFile))
{
var fileData = File.ReadAllText(_pathNameCordonelRegisterRestoreSettingsFile);
_pulseModeRegistersRestore = JsonConvert.DeserializeObject<Dictionary<String, Byte[]>>(fileData);
}
retVal = true;
}
//if retVal is true, the pulse mode is switched OFF, no further action is required
if (!retVal)
{
// safe the pulse setting
_pulseModeRegistersRestore.Add(Register.Metrologyasst.PulseMode, new[] { pulseMode });
// Create new file as for report only one version is allowed
var serializedData = JsonConvert.SerializeObject(_pulseModeRegistersRestore);
var asciiStream = Encoding.UTF8.GetBytes(serializedData);
File.WriteAllBytes(_pathNameCordonelRegisterRestoreSettingsFile, asciiStream);
// write pulse mode temporary to 0 (OFF) and wait for result
retVal = _currentGenesis.WriteRegister(Register.Metrologyasst.PulseMode, 0);
LogText(Resources.StrPulseModeTemporaryDeactivated);
}
}
catch (Exception )
{
retVal = false;
}
_currentGenesis.Logout();
return retVal;
}
/// <summary>
/// Restore all listed registers.
/// </summary>
/// <remarks date="2023-Mar-07" author="Roland Drabesch/Thomas Wiedebusch">
/// - Initial.
/// </remarks>
private Boolean RestoreRegisters()
{
var retVal = true;
try
{
if (!_currentGenesis.IsLoggedOn)
_currentGenesis.ReLogin();
foreach (var item in _pulseModeRegistersRestore)
{
retVal &= _currentGenesis.WriteRegister(item.Key, item.Value);
}
retVal &= _currentGenesis.WriteRegister(Register.Metrologyasst.StoreConfiguration, 1);
if (retVal && _pulseModeRegistersRestore.Any(x => x.Key == Register.Metrologyasst.PulseMode))
LogText(Resources.StrPulseModeRestored);
}
catch (Exception )
{
retVal = false;
}
_currentGenesis.Logout();
return retVal;
}
/// <summary> /// <summary>
/// Store configurations with logging of success or failed. /// Store configurations with logging of success or failed.
/// </summary> /// </summary>
@@ -1601,7 +1705,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
return false; return false;
_currentGenesis.ReLogin(); _currentGenesis.ReLogin();
Boolean retVal; Boolean retVal;
if ( _currentGenesis.StoreAllConfigurations()) if (_currentGenesis.StoreAllConfigurations())
{ {
LogSuccessText(Resources.StrStoreConfigSuccess); LogSuccessText(Resources.StrStoreConfigSuccess);
retVal = true; retVal = true;
@@ -1635,7 +1739,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// deactivate LED, not needed to get measurements during the update or on repeated start after system // deactivate LED, not needed to get measurements during the update or on repeated start after system
// failure. This overwrites the settings in _meterFwUpdate. // failure. This overwrites the settings in _meterFwUpdate.
_currentGenesis.WriteRegister(Register.Genesisflow.LedMode, new[] { (Byte)LedMode.Off }); _currentGenesis.WriteRegister(Register.Genesisflow.LedMode, new[] { (Byte)LedMode.Off });
_currentGenesis.WriteRegister(Register.Genesisflow.StoreConfiguration, 1); _currentGenesis.WriteRegister(Register.Genesisflow.StoreConfiguration, 1);
LogText(Resources.StrDisplayReleased); LogText(Resources.StrDisplayReleased);
_currentGenesis.Logout(); _currentGenesis.Logout();
} }
@@ -2435,7 +2539,6 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// try to login to check if meter is ready after reboot procedure // try to login to check if meter is ready after reboot procedure
_currentGenesis.ReLogin(); _currentGenesis.ReLogin();
_processState = _currentGenesis.IsLoggedOn ? successExitState : errorExitState; _processState = _currentGenesis.IsLoggedOn ? successExitState : errorExitState;
// change first the process state, otherwise the timer may switch the bar on again // change first the process state, otherwise the timer may switch the bar on again
@@ -2654,6 +2757,49 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
SetOverallProgressDisplayOn(Resources.StrConnecting); SetOverallProgressDisplayOn(Resources.StrConnecting);
} }
/// <summary>
/// Common login and special setup procedure, as this is needed for login with password level 8
/// and for login with skeleton key:
/// - Initial login without register readout being able to quick switch off the pulse mode,
/// - Switch off the pulse mode on initial connection,
/// - Activate the radio,
/// - Release the display to normal operation,
/// - Store all configurations on initial connection.
/// </summary>
/// <param name="password">lvl8 or skeleton</param>
/// <param name="initialLogin">initial connection</param>
/// <returns>true if successfully executed</returns>
/// <remarks date="2023-Mar-07" author="Thomas Wiedebusch">
/// - Initial
/// </remarks>
private Boolean LoginAndSpecialSetupProcedure(String password, Boolean initialLogin)
{
// login without reading all registers and FW keeping the communication to a minimum to switch
// the pulse mode OFF before reading all installed apps, which will be unpredictable on activated
// pulse module
var retVal = _currentGenesis.Login(password, skipReadMeterFwAndAssignRegisters: initialLogin);
if (!retVal)
return false;
// switch the pulse module inactive
if (initialLogin)
DeactivatePulseModule();
// login with reading out all installed applications
retVal = _currentGenesis.Login(password);
if (_currentGenesis.RadioFrequencyMhz != null)
ActivateRadio();
// display to normal operation
ReleaseDisplay();
// safe all settings from RAM to FLASH to keep those for reboot
if (initialLogin)
StoreConfigurations();
return retVal;
}
/// <summary> /// <summary>
/// Execution of connect to water-meter. /// Execution of connect to water-meter.
/// </summary> /// </summary>
@@ -2692,15 +2838,19 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// <remarks date="2023-Mar-01" author="Thomas Wiedebusch"> /// <remarks date="2023-Mar-01" author="Thomas Wiedebusch">
/// - "Release Display" before "Store Configuration". /// - "Release Display" before "Store Configuration".
/// </remarks> /// </remarks>
/// <remarks date="2023-Mar-07" author="Thomas Wiedebusch">
/// - "Deactivate Pulse Mode" at initial login to avoid interference of pulses to IrDA communication.
/// </remarks>
private Boolean ExecConnect() private Boolean ExecConnect()
{ {
// logout if already logged in into meter var initialLogin = false;
if (_currentGenesis.IsLoggedOn) // read out the PCB ID from water-meter to open the password container of this device
_currentGenesis.Logout();
//read out the PCB ID from water-meter to open the password container of this device
if (string.IsNullOrEmpty(_currentGenesis.PcbId)) if (string.IsNullOrEmpty(_currentGenesis.PcbId))
{
// if the PcbId is unknown, it is an initial login
initialLogin = true;
_currentGenesis.GetPcbId(); _currentGenesis.GetPcbId();
}
// search the PCB ID and extract password for login // search the PCB ID and extract password for login
String password = null; String password = null;
@@ -2729,11 +2879,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// this login may be time consuming on readout of application information // this login may be time consuming on readout of application information
// first try to login with password Level 8, this is needed if the password file is installed // first try to login with password Level 8, this is needed if the password file is installed
if (_currentGenesis.Login(password)) if (LoginAndSpecialSetupProcedure(password, initialLogin))
{ {
if (_currentGenesis.RadioFrequencyMhz != null) ActivateRadio();
ReleaseDisplay();
StoreConfigurations();
_passwordFileIsCorrupted = false; _passwordFileIsCorrupted = false;
return true; return true;
} }
@@ -2752,11 +2899,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// wait that long, otherwise the Cordonel locks for 2s, 4s, 8s, 16s and so on on every retry! // wait that long, otherwise the Cordonel locks for 2s, 4s, 8s, 16s and so on on every retry!
Thread.Sleep(5000); Thread.Sleep(5000);
if (_currentGenesis.Login(skeletonKey)) // use the skeleton key for login as the password file may not be installed or invalid
if (LoginAndSpecialSetupProcedure(skeletonKey, initialLogin))
{ {
if (_currentGenesis.RadioFrequencyMhz != null) ActivateRadio();
ReleaseDisplay();
StoreConfigurations();
return true; return true;
} }
@@ -2812,6 +2957,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// <remarks date="2021-Apr-20" author="Thomas Wiedebusch"> /// <remarks date="2021-Apr-20" author="Thomas Wiedebusch">
/// - Final login message produced to log password file validation. /// - Final login message produced to log password file validation.
/// </remarks> /// </remarks>
/// <remarks date="2023-Mar-07" author="Thomas Wiedebusch">
/// - Enable connect if error.
/// </remarks>
private void FinalConnect(Boolean success, IReadOnlyList<Object> exitProcessStateObjects) private void FinalConnect(Boolean success, IReadOnlyList<Object> exitProcessStateObjects)
{ {
ObjectsToProcessStates(exitProcessStateObjects, out var successExitState, out var errorExitState, ObjectsToProcessStates(exitProcessStateObjects, out var successExitState, out var errorExitState,
@@ -2833,6 +2981,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
_processState = errorExitState; _processState = errorExitState;
// change first the process state, otherwise the timer may switch the bar on again // change first the process state, otherwise the timer may switch the bar on again
SetOverallProgressDisplayOff(); SetOverallProgressDisplayOff();
SetDisableDownloadAndEnableConnect();
return; return;
} }
@@ -2847,15 +2996,15 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// if authentication succeeded, the cordonel port detection must have succeeded in advance, // if authentication succeeded, the cordonel port detection must have succeeded in advance,
// this information might get lost on Connect() without previous port scan. // this information might get lost on Connect() without previous port scan.
InfoProcessSuccess(lblCordonelDetection, Resources.StrCordonelDetectSucceeded); InfoProcessSuccess(lblCordonelDetection, Resources.StrCordonelDetectSucceeded);
InfoProcessSuccess(lblCordonelAuthentication, _finalLoginAfterUpdate InfoProcessSuccess(lblCordonelAuthentication, _finalLoginAfterUpdate
? Resources.StrPasswordFileValid ? Resources.StrPasswordFileValid
: Resources.StrCordonelAuthenticationSucceeded); : Resources.StrCordonelAuthenticationSucceeded);
// use here direct text assignment to avoid x or v before label // use here direct text assignment to avoid x or v before label
UiInvoker.ControlInvoker(lblConnectPcb, ColorSuccess, UiInvoker.ControlInvoker(lblConnectPcb, ColorSuccess,
Resources.StrPartPcbConnected + @" " + _currentGenesis.PcbId); Resources.StrPartPcbConnected + @" " + _currentGenesis.PcbId);
UiInvoker.ControlInvoker(lblCoreRevision, ColorDefault, UiInvoker.ControlInvoker(lblCoreRevision, ColorDefault,
Resources.StrCoreRevision + @" " + Resources.StrCoreRevision + @" " +
$"{GenesisMeter.BuildFwVersionString(_currentGenesis.CoreRevision)}"); $"{GenesisMeter.BuildFwVersionString(_currentGenesis.CoreRevision)}");
// avoid report again on final login after update // avoid report again on final login after update
if (!_finalLoginAfterUpdate && BuildReportFiles()) if (!_finalLoginAfterUpdate && BuildReportFiles())
@@ -3753,6 +3902,6 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
#endregion --------------------------------------- Language --------------------------------------------------- #endregion --------------------------------------- Language ---------------------------------------------------
} }
} }
@@ -853,6 +853,33 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Pulse mode is inactive..
/// </summary>
internal static string StrPulseModeInactive {
get {
return ResourceManager.GetString("StrPulseModeInactive", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Original pulse mode restored..
/// </summary>
internal static string StrPulseModeRestored {
get {
return ResourceManager.GetString("StrPulseModeRestored", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Pulse mode temporary deactivated..
/// </summary>
internal static string StrPulseModeTemporaryDeactivated {
get {
return ResourceManager.GetString("StrPulseModeTemporaryDeactivated", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Failed to activate the radio in customer mode!. /// Looks up a localized string similar to Failed to activate the radio in customer mode!.
/// </summary> /// </summary>
@@ -529,4 +529,13 @@
<data name="StrDisplayReleased" xml:space="preserve"> <data name="StrDisplayReleased" xml:space="preserve">
<value>Display freigegeben für Volumen- und Durchflußanzeige.</value> <value>Display freigegeben für Volumen- und Durchflußanzeige.</value>
</data> </data>
</root> <data name="StrPulseModeInactive" xml:space="preserve">
<value>Pulsmodus ist ausgeschaltet.</value>
</data>
<data name="StrPulseModeRestored" xml:space="preserve">
<value>Orginal Pulsmodus wiederhergestellt.</value>
</data>
<data name="StrPulseModeTemporaryDeactivated" xml:space="preserve">
<value>Pulsmodus vorrübergehend ausgeschaltet.</value>
</data>
</root>
@@ -529,4 +529,13 @@
<data name="StrDisplayReleased" xml:space="preserve"> <data name="StrDisplayReleased" xml:space="preserve">
<value>Display released to accumulator- and flow-display.</value> <value>Display released to accumulator- and flow-display.</value>
</data> </data>
<data name="StrPulseModeInactive" xml:space="preserve">
<value>Pulse mode is inactive.</value>
</data>
<data name="StrPulseModeRestored" xml:space="preserve">
<value>Original pulse mode restored.</value>
</data>
<data name="StrPulseModeTemporaryDeactivated" xml:space="preserve">
<value>Pulse mode temporary deactivated.</value>
</data>
</root> </root>