GenesisMeter: - deactivation of pulse output at login
This commit is contained in:
@@ -960,7 +960,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
/// <remarks date="2023-Jan-19" author="T.Wiedebusch">
|
/// <remarks date="2023-Jan-19" author="T.Wiedebusch">
|
||||||
/// - Password had been reset to empty string if read from file, corrected!
|
/// - Password had been reset to empty string if read from file, corrected!
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <remarks date="2023-Feb-28" author="T.Wiedebusch">
|
/// <remarks date="2023-Feb-28" author="T.Wiedebusch">
|
||||||
/// - Used <see cref="MeterPwdHandlerDb.GetPasswordFromDb"/>
|
/// - Used <see cref="MeterPwdHandlerDb.GetPasswordFromDb"/>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
private String GetPassword()
|
private String GetPassword()
|
||||||
@@ -991,12 +991,13 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
_logger.Info($"Slot:{Slot} - Cannot get password from GenesisPasswordService, " +
|
_logger.Info($"Slot:{Slot} - Cannot get password from GenesisPasswordService, " +
|
||||||
$"URL({ServiceUrls.GenesisGetPasswordServiceUrl() + PcbId}))");
|
$"URL({ServiceUrls.GenesisGetPasswordServiceUrl() + PcbId}))");
|
||||||
// try to read the password from an offline password file
|
// try to read the password from an offline password file
|
||||||
if (!File.Exists(ProgramConfig.OfflineInfoFile)) return password;
|
if (!File.Exists(ProgramConfig.OfflineInfoFile))
|
||||||
|
return password;
|
||||||
|
|
||||||
var listOfOfflinePasswords = JsonConvert.DeserializeObject<List<OfflinePasswordItem>>(
|
var listOfOfflinePasswords = JsonConvert.DeserializeObject<List<OfflinePasswordItem>>(
|
||||||
File.ReadAllText(ProgramConfig.OfflineInfoFile));
|
File.ReadAllText(ProgramConfig.OfflineInfoFile));
|
||||||
password = listOfOfflinePasswords.First(x => x.PcbId == PcbId).Password;
|
password = listOfOfflinePasswords.First(x => x.PcbId == PcbId).Password;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(password))
|
if (!string.IsNullOrEmpty(password))
|
||||||
{
|
{
|
||||||
_logger.Info($"Slot:{Slot} - Got password for PcbId:{PcbId} from password file!");
|
_logger.Info($"Slot:{Slot} - Got password for PcbId:{PcbId} from password file!");
|
||||||
@@ -1079,6 +1080,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
/// <remarks date="2023-Feb-20" author="Thomas Wiedebusch">
|
/// <remarks date="2023-Feb-20" author="Thomas Wiedebusch">
|
||||||
/// - Quick login removed.
|
/// - Quick login removed.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
/// <remarks date="2023-Mar-06" author="Thomas Wiedebusch">
|
||||||
|
/// - Pulse module deactivated at login.
|
||||||
|
/// </remarks>
|
||||||
public Boolean Login(String password, Boolean runImmediately = true)
|
public Boolean Login(String password, Boolean runImmediately = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1109,12 +1113,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
IsDevelopmentUsage = true;
|
IsDevelopmentUsage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!DeactivatePulseModule())
|
||||||
|
{
|
||||||
|
_logger.Warn($"Slot:{Slot} - Pulse module deactivation failed!");
|
||||||
|
}
|
||||||
ReadMeterFirmwareAndAssignRegisters();
|
ReadMeterFirmwareAndAssignRegisters();
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.Warn($"Slot:{Slot} - Login to meter failed");
|
_logger.Warn($"Slot:{Slot} - Login to meter failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
CommunicationConfig.RequestRetries = backupRetries;
|
CommunicationConfig.RequestRetries = backupRetries;
|
||||||
@@ -1464,6 +1472,36 @@ 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>
|
||||||
|
|||||||
Reference in New Issue
Block a user