Merge branch 'main' of https://slm.sms-esaap.com/la_operations/laa_production into main
This commit is contained in:
@@ -1036,20 +1036,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
return Login(_password);
|
||||
}
|
||||
|
||||
/// <remarks date="2018JAN08" author="drabesch">
|
||||
/// Get password from server
|
||||
/// </remarks>
|
||||
public Boolean QuickLogin()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_password) || string.IsNullOrEmpty(PcbId))
|
||||
{
|
||||
var password = GetPassword();
|
||||
return !string.IsNullOrEmpty(password) && Login(password, true, true);
|
||||
}
|
||||
|
||||
return Login(_password, true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Login with identical password as last time
|
||||
/// </summary>
|
||||
@@ -1087,7 +1073,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Starting a timer to keep session active,
|
||||
/// starting the <see cref="KeepSessionThreadLoop"/>.
|
||||
@@ -1095,7 +1080,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
/// <param name="password">password string to login</param>
|
||||
/// <param name="runImmediately"> true = process command; false = add command to list. call
|
||||
/// <see cref="RequestProtocolProcess()"></see> to process login command </param>
|
||||
/// <param name="quickLogin"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2019JAN01" author="drabesch">
|
||||
/// pass runImmediately for auto login
|
||||
@@ -1103,7 +1087,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
/// <remarks date="2021-Feb-02" author="Thomas Wiedebusch">
|
||||
/// - Avoid retries during login, a retry will lock the Genesis for 2s, 4s, 8s, 16s and so on.
|
||||
/// </remarks>
|
||||
public Boolean Login(String password, Boolean runImmediately = true, Boolean quickLogin = false)
|
||||
/// <remarks date="2023-Feb-20" author="Thomas Wiedebusch">
|
||||
/// - Quick login removed.
|
||||
/// </remarks>
|
||||
public Boolean Login(String password, Boolean runImmediately = true)
|
||||
{
|
||||
|
||||
var backupRetries = CommunicationConfig.RequestRetries;
|
||||
@@ -1128,17 +1115,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
_logger.Info($"Slot:{Slot} - Successful logged in to meter");
|
||||
StartKeepSession();
|
||||
|
||||
if (quickLogin)
|
||||
{
|
||||
WriteRegister(Register.Mertrologyasst.PulseMode, 0, true, true);
|
||||
//avoid access if radio app is not installed
|
||||
if (RadioFrequencyMhz != null)
|
||||
{
|
||||
WriteRegister(Register.Sensusradio.WakeupInterval, 6, true, true);
|
||||
WriteRegister("SENSUSRADIO_SystemState", 1, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (Configuration != null && !Configuration.ProductionMode)
|
||||
{
|
||||
IsDevelopmentUsage = true;
|
||||
@@ -1200,7 +1176,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
public Int32? CoreRevision;
|
||||
|
||||
/// <summary>
|
||||
/// This is the FLEXNET version which describes the entire packet.
|
||||
/// This is the FLEXNETVERSION version which describes the entire packet.
|
||||
/// </summary>
|
||||
public String FwVersion;
|
||||
|
||||
@@ -1215,7 +1191,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
public String MeterSize;
|
||||
|
||||
/// <summary>
|
||||
/// Region (EMEA or NA).
|
||||
/// Region (EMEA, NA or China).
|
||||
/// </summary>
|
||||
public String Region;
|
||||
|
||||
@@ -1248,9 +1224,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
LutCrc = $@"0x{lutCrc:X4}";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception)// exception will be thrown if register is not present on versions without LUT
|
||||
{
|
||||
// ignored
|
||||
LutCrc = Constants.StrUnknown;
|
||||
}
|
||||
|
||||
//read meter size
|
||||
@@ -1258,32 +1234,32 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
ReadRegister(Register.Genesisflow.MeterSize)));
|
||||
|
||||
//read radio frequency
|
||||
Region = "NA";
|
||||
Region = Constants.StrUnknown;
|
||||
RadioFrequencyMhz = null;
|
||||
try
|
||||
{
|
||||
var radioFrequencyRaw = ReadRegister(Register.Sensusradio.FrequencyIndicator);
|
||||
if (radioFrequencyRaw != null )
|
||||
if (radioFrequencyRaw != null)
|
||||
{
|
||||
Region = "EMEA";
|
||||
RadioFrequencyMhz = RegisterConverter.ConvertTo<Int32>(radioFrequencyRaw);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception) // exception will be thrown on uninstalled SENSUSRADIO
|
||||
{
|
||||
// ignored
|
||||
Region = "NA";
|
||||
}
|
||||
|
||||
// check meter size string contains "DN", because if "US" it cannot be an EMEA version
|
||||
if ((Region.Contains("NA") && MeterSize.Contains("DN")) ||
|
||||
(Region.Contains("EMEA") && MeterSize.Contains("US")))
|
||||
{
|
||||
Region = "?";
|
||||
MeterSize = "?";
|
||||
LutCrc = "?";
|
||||
Region = Constants.StrUnknown;
|
||||
MeterSize = Constants.StrUnknown;
|
||||
LutCrc = Constants.StrUnknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reading all applications which can be found in the configuration.json and have been stored
|
||||
/// to the meter register dictionary in advance.
|
||||
@@ -1313,6 +1289,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
/// <remarks date="2023-Jan-16" author="Thomas Wiedebusch">
|
||||
/// - Checked meter size string for "DN", than it cannot be an EMEA version.
|
||||
/// </remarks>
|
||||
/// <remarks date="2023-Feb-13" author="Thomas Wiedebusch">
|
||||
/// - Removed retry as this will be handled by the <see cref="RequestProtocol"/>.
|
||||
/// </remarks>
|
||||
private void ReadMeterFirmwareAndAssignRegisters()
|
||||
{
|
||||
//avoid overwriting of list if this already exits
|
||||
@@ -1329,39 +1308,32 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
UInt16 readFwCrc = 0;
|
||||
var isInstalled = false;
|
||||
var versionString = "";
|
||||
var recount = 4;
|
||||
while (recount > 0)
|
||||
if (WriteRegister(Register.System.CheckFwPresence, appVersionToRead.AppId))
|
||||
{
|
||||
recount -= 1;
|
||||
//read version, skip retries on SYSTEM 0x04-> FW nor present is a valid feedback
|
||||
var readFwVersionBytes = ReadRegister(Register.System.CheckFwPresence, 4);
|
||||
|
||||
if (WriteRegister(Register.System.CheckFwPresence, appVersionToRead.AppId))
|
||||
//the FW version as Uint32 will be used for comparison with the configuration.json
|
||||
if (readFwVersionBytes != null && readFwVersionBytes.Length > 0)
|
||||
{
|
||||
//read version, skip retries on SYSTEM 0x04-> FW nor present is a valid feedback
|
||||
var readFwVersionBytes = ReadRegister(Register.System.CheckFwPresence, 4);
|
||||
readFwVersion = (UInt32)(((readFwVersionBytes[1] & 0xF0) >> 4) * 10 +
|
||||
(readFwVersionBytes[1] & 0x0F)) * 100;
|
||||
readFwVersion += (UInt32)(((readFwVersionBytes[0] & 0xF0) >> 4) * 10 +
|
||||
(readFwVersionBytes[0] & 0x0F));
|
||||
//build the version string, because e.g. FLEXNETVERSION is one application which does not
|
||||
//follow the same rule. After the upper conversion, the hexadecimal outline will be lost
|
||||
versionString = BuildFwVersionString(readFwVersionBytes[1], readFwVersionBytes[0]);
|
||||
if (appVersionToRead.AppName == "FLEXNETVERSION")
|
||||
FwVersion = versionString;
|
||||
|
||||
//the FW version as Uint32 will be used for comparison with the configuration.json
|
||||
if (readFwVersionBytes != null && readFwVersionBytes.Length > 0)
|
||||
if (readFwVersion != 0)
|
||||
{
|
||||
readFwVersion = (UInt32)(((readFwVersionBytes[1] & 0xF0) >> 4) * 10 +
|
||||
(readFwVersionBytes[1] & 0x0F)) * 100;
|
||||
readFwVersion += (UInt32)(((readFwVersionBytes[0] & 0xF0) >> 4) * 10 +
|
||||
(readFwVersionBytes[0] & 0x0F));
|
||||
//build the version string, because e.g. FLEXNETVERSION is one application which does not
|
||||
//follow the same rule. After the upper conversion, the hexadecimal outline will be lost
|
||||
versionString = BuildFwVersionString(readFwVersionBytes[1], readFwVersionBytes[0]);
|
||||
if (appVersionToRead.AppName == "FLEXNETVERSION")
|
||||
FwVersion = versionString;
|
||||
|
||||
if (readFwVersion != 0)
|
||||
isInstalled = true;
|
||||
//write application Id to CRC register
|
||||
if (WriteRegister(Register.System.CheckFwCrc, appVersionToRead.AppId))
|
||||
{
|
||||
|
||||
isInstalled = true;
|
||||
//write application Id to CRC register
|
||||
if (WriteRegister(Register.System.CheckFwCrc, appVersionToRead.AppId))
|
||||
{
|
||||
readFwCrc = RegisterConverter.ConvertTo<UInt16>(ReadRegister(Register.System.CheckFwCrc));
|
||||
}
|
||||
break;
|
||||
readFwCrc = RegisterConverter.ConvertTo<UInt16>(ReadRegister(Register.System.CheckFwCrc));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1381,7 +1353,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
}
|
||||
|
||||
CheckRegionSizeLutCrc();
|
||||
|
||||
|
||||
//read metrology upgrade permission
|
||||
MetrologyUpgradePermission = RegisterConverter.ConvertTo<Byte>(
|
||||
ReadRegister(Register.System.MetrologyUpgradePermission));
|
||||
@@ -1445,9 +1417,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
continue;
|
||||
}
|
||||
if (registerToCheck.Key.RegisterDetail.Version.Last != null &&
|
||||
(registerToCheck.Key.RegisterDetail.Version.First != null &&
|
||||
(registerToCheck.Key.RegisterDetail.Version.First.Value <= currentGroup.Version &&
|
||||
registerToCheck.Key.RegisterDetail.Version.Last.Value >= currentGroup.Version)))
|
||||
registerToCheck.Key.RegisterDetail.Version.First != null &&
|
||||
registerToCheck.Key.RegisterDetail.Version.First.Value <= currentGroup.Version &&
|
||||
registerToCheck.Key.RegisterDetail.Version.Last.Value >= currentGroup.Version)
|
||||
{
|
||||
registerToCheck.Key.IsAvailable = true;
|
||||
_configRegister.MeterRegisterDic.TryAdd(registerToCheck.Key, null);
|
||||
@@ -1491,7 +1463,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
{
|
||||
var registerAddForOldConfigs = registerToPotentialAdd.GroupBy(item => item.GetIdent())
|
||||
.Select(grp => grp.Aggregate((max, cur) =>
|
||||
(max == null || cur.RegisterDetail.Version.Last > max.RegisterDetail.Version.Last) ?
|
||||
(max == null || cur.RegisterDetail.Version.Last > max.RegisterDetail.Version.Last) ?
|
||||
cur : max));
|
||||
|
||||
foreach (var registerAddOldConfig in registerAddForOldConfigs)
|
||||
@@ -2195,7 +2167,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
}
|
||||
|
||||
// Wait for storing
|
||||
Thread.Sleep(400);
|
||||
Thread.Sleep(500);
|
||||
//TODO enable this for R1.2.x
|
||||
if (a.Key.AppName == "SENSUSRADIO" || a.Key.AppName == "NA2WALARMS")
|
||||
{
|
||||
@@ -2224,7 +2196,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
return false;
|
||||
}
|
||||
|
||||
return allConfigRegisters == 0;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Xylem.Common.CommonCore.Consts;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Properties;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes;
|
||||
@@ -28,7 +29,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
/// <summary>
|
||||
/// PCB ID for post update for comparison
|
||||
/// </summary>
|
||||
private String _pcbIdPostUpdate = "?";
|
||||
private String _pcbIdPostUpdate = Constants.StrUnknown;
|
||||
|
||||
/// <summary>
|
||||
/// Register content before update
|
||||
|
||||
@@ -115,7 +115,6 @@
|
||||
<Compile Include="MeterLutUpdate.cs" />
|
||||
<Compile Include="MeterFwUpdate.cs" />
|
||||
<Compile Include="MeterFwUpdateCapability.cs" />
|
||||
<Compile Include="MeterFwUpdateRuler.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="MeterFile.cs" />
|
||||
<Compile Include="MeterPwdFile.cs" />
|
||||
@@ -131,6 +130,10 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\CommonCore\CommonCore.csproj">
|
||||
<Project>{1B02C79E-0B19-43E2-8F6B-71EF0C786C97}</Project>
|
||||
<Name>CommonCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\Logic.PrdoctionToProductMapper\Logic.ProductionToProductMapper.csproj">
|
||||
<Project>{D0C859D9-D55E-4E85-AC50-0FF31B1CE50D}</Project>
|
||||
<Name>Logic.ProductionToProductMapper</Name>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xylem.Common.CommonCore.Consts;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig;
|
||||
@@ -101,11 +102,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// </summary>
|
||||
public const Char StringDelimiter = '\0';
|
||||
|
||||
/// <summary>
|
||||
/// Wildcard for search all.
|
||||
/// </summary>
|
||||
public const String WildcardAll = "*";
|
||||
|
||||
/// <summary>
|
||||
/// Processed bytes counter
|
||||
/// </summary>
|
||||
@@ -498,7 +494,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// <remarks date="2023-Jan-04" author="Thomas Wiedebusch">
|
||||
/// - Default wildcard.
|
||||
/// </remarks>
|
||||
public Boolean ReadMeterFileCatalog(out List<String> files, String drive, String wildcard = WildcardAll)
|
||||
public Boolean ReadMeterFileCatalog(out List<String> files, String drive, String wildcard = Constants.StrWildcard)
|
||||
{
|
||||
files = new List<String>();
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// The name of the metrology application.
|
||||
/// </summary>
|
||||
public const String MetrologyName = "GENESISFLOW";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the metrology upgrade is allowed or the version is already installed.
|
||||
/// The application description file "ADF" has to be read in advance as this contains the "GENSISFLOW" version.
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Definition of releases and update dependencies.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class MeterFwUpdateRuler
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the release e.g. R1067. referenced as FLEXNETVERSION AppId 0x18
|
||||
/// </summary>
|
||||
public String Release;
|
||||
/// <summary>
|
||||
/// Region EMEA or NA
|
||||
/// </summary>
|
||||
public String Region;
|
||||
/// <summary>
|
||||
/// Core version minimum
|
||||
/// </summary>
|
||||
public String CoreVersionMin;
|
||||
/// <summary>
|
||||
/// Core version maximum
|
||||
/// </summary>
|
||||
public String CoreVersionMax;
|
||||
/// <summary>
|
||||
/// Version of metrology, as this may not permitted to update, referenced as GENESISFLOW AppId 0x0F,
|
||||
/// the update capability of the metrology will be flagged by SYSTEM UpgradePermissions Id 0x0E:
|
||||
/// 0xFF upgrade is permitted, all others the metrology updated is strictly forbidden!
|
||||
/// </summary>
|
||||
public String MetrologyVersion;
|
||||
/// <summary>
|
||||
/// Radio frequency in MHz referenced a SENSUSRADIO AppId 0x10, Register FrequencyIndicator Id 0x05
|
||||
/// values: default 433, minimum 433, maximum 868
|
||||
/// </summary>
|
||||
public String RadioFrequencyMhz;
|
||||
/// <summary>
|
||||
/// Meter size e.g. DN40, DN50, or null if for all sizes
|
||||
/// </summary>
|
||||
public List<String> MeterSizes;
|
||||
/// <summary>
|
||||
/// Name of person which approves the release
|
||||
/// </summary>
|
||||
public String ApproverName;
|
||||
/// <summary>
|
||||
/// Date of approval
|
||||
/// </summary>
|
||||
public DateTime? ApprovalDate;
|
||||
}
|
||||
}
|
||||
@@ -65,11 +65,22 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MeterPwdHandlerDb.cs" />
|
||||
<Compile Include="MeterPwdDb.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\CommonCore.Configuration\CommonCore.Configuration.csproj">
|
||||
<Project>{9EB1F659-6F73-4F65-BCAB-4114FD94F5FC}</Project>
|
||||
<Name>CommonCore.Configuration</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\SoftwareAccessHelper\SoftwareAccessHelper.csproj">
|
||||
<Project>{A33E3C6D-EAAE-4A20-A0EE-F9E6922FD029}</Project>
|
||||
<Name>SoftwareAccessHelper</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -37,6 +37,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisPwd
|
||||
/// </summary>
|
||||
public String Skeleton = "";
|
||||
/// <summary>
|
||||
/// Password, which is the Skeleton, if password file not installed, or the PwdLevel8, if the password file is installed .
|
||||
/// </summary>
|
||||
public String Password = "";
|
||||
/// <summary>
|
||||
/// List of hashes.
|
||||
/// </summary>
|
||||
public List<Byte[]> ListOfHashes = new List<Byte[]>();
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Xylem.Common.CommonCore.Configuration;
|
||||
using Xylem.Common.Logic.SoftwareAccessHelper;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisPwd
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for meter password handler DB interfaces.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public static class MeterPwdHandlerDb
|
||||
{
|
||||
/// <summary>
|
||||
/// Acquires the actual password from DB. Initially, this is the Skeleton-Key, if the password file is
|
||||
/// written it is the Lvl8Pwd.
|
||||
/// </summary>
|
||||
/// <param name="pcbId">input the PcbId</param>
|
||||
/// <param name="password">output of password</param>
|
||||
/// <returns>true if successfully executed</returns>
|
||||
/// <remarks date="2023-Feb-23" author="Roland Drabesch/Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public static Boolean GetPasswordFromDb(String pcbId, out String password)
|
||||
{
|
||||
var url = ServiceUrls.GenesisGetPasswordServiceUrl();
|
||||
password = "";
|
||||
|
||||
try
|
||||
{
|
||||
var http = (HttpWebRequest)WebRequest.Create(url + pcbId);
|
||||
var response = (HttpWebResponse)http.GetResponse();
|
||||
var responseStream = response.GetResponseStream();
|
||||
if (responseStream == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
using (var sr = new StreamReader(responseStream))
|
||||
{
|
||||
var responseJson = sr.ReadToEnd();
|
||||
password = responseJson.Trim('"');
|
||||
}
|
||||
}
|
||||
catch (Exception )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collect order number, radio address, skeleton key, password hashes and passwords from DB.
|
||||
/// </summary>
|
||||
/// <param name="pcbId">input the PcbId</param>
|
||||
/// <param name="passwordContainer">output of passwordContainer</param>
|
||||
/// <returns>true if successfully executed</returns>
|
||||
/// <remarks date="2023-Feb-23" author="Roland Drabesch/Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public static Boolean SetPwdFromSkeletonToLvl8inDd(String pcbId, MeterPwdDb passwordContainer)
|
||||
{
|
||||
try
|
||||
{
|
||||
var newPwd = Encoding.UTF8.GetString(passwordContainer.ListOfPasswords.Last());
|
||||
var passwordSetServiceUrl = ServiceUrls.GenesisSetPasswordServiceUrl();
|
||||
|
||||
var responseJson = LocalWebRequest.GetRequest(passwordSetServiceUrl + pcbId + "&Password=" + newPwd, 8000);
|
||||
if (responseJson.ToLower().Contains("store"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Collect order number, radio address, skeleton key, password hashes and passwords from DB.
|
||||
/// </summary>
|
||||
/// <param name="pcbId">input the PcbId</param>
|
||||
/// <param name="passwordContainer">output of passwordContainer</param>
|
||||
/// <returns>true if successfully executed</returns>
|
||||
/// <remarks date="2023-Feb-23" author="Roland Drabesch/Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public static Boolean RequestPwdFileFromDb(String pcbId, out MeterPwdDb passwordContainer)
|
||||
{
|
||||
passwordContainer = new MeterPwdDb();
|
||||
try
|
||||
{
|
||||
var url = ServiceUrls.GenesisGetPasswordContainerServiceUrl();
|
||||
|
||||
var requestResponse = LocalWebRequest.GetRequestWithError(url + pcbId, out var errorCode, 20000, isRetry: true);
|
||||
if (errorCode == HttpStatusCode.OK.GetHashCode())
|
||||
{
|
||||
passwordContainer = JsonConvert.DeserializeObject<MeterPwdDb>(requestResponse);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
|
||||
/// </summary>
|
||||
public Int32 AdditionalRetryTimeoutMs;
|
||||
|
||||
private Int32 _timeOutMs;
|
||||
private Int32 _maxTimeOutMs;
|
||||
|
||||
private readonly String _ident;
|
||||
|
||||
@@ -215,38 +215,41 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
|
||||
|
||||
//set timeout for one communication trial adding the transmit protocol specific timeout and
|
||||
//increase the timeout with each retry
|
||||
_timeOutMs = _recordInProcess.ResponseTimeoutMs + AdditionalRetryTimeoutMs +
|
||||
_maxTimeOutMs = _recordInProcess.ResponseTimeoutMs + AdditionalRetryTimeoutMs +
|
||||
CommunicationConfig.ResponseTimeoutMs * (_recordInProcess.RetryCtr + 1);
|
||||
//start initial communication or retry
|
||||
OnRecordReadyToSend?.Invoke(this, new ListBytePortDataEventArgs(_recordInProcess.EncodedRequestData));
|
||||
|
||||
//time reminder of request record
|
||||
var requestTimeUtc = DateTimeOffset.UtcNow;
|
||||
Int32 responseTimeMs;
|
||||
Int32 actualResponseWaitTimeMs;
|
||||
|
||||
//wait for communication acknowledge or until timeout, this also handles the inter record send delay
|
||||
do
|
||||
{
|
||||
//minimum delay is the inter record send delay
|
||||
Thread.Sleep(interRecordSendDelayMs);
|
||||
var timeoutTimeUtc = DateTimeOffset.UtcNow;
|
||||
var timeSpan = timeoutTimeUtc - requestTimeUtc;
|
||||
var actualTimeUtc = DateTimeOffset.UtcNow;
|
||||
//actual time difference from request to now
|
||||
var timeSpan = actualTimeUtc - requestTimeUtc;
|
||||
//avoid total milliseconds below zero at time overflow
|
||||
if (timeSpan.TotalMilliseconds < 0)
|
||||
{
|
||||
requestTimeUtc = DateTimeOffset.UtcNow;
|
||||
}
|
||||
responseTimeMs = (Int32)timeSpan.TotalMilliseconds;
|
||||
actualResponseWaitTimeMs = (Int32)timeSpan.TotalMilliseconds;
|
||||
|
||||
} while (_recordInProcess.Acknowledge != RequestAcknowledgeState.Ok &&
|
||||
_recordInProcess.SkipRetryErrorCode != _recordInProcess.ResponseErrorCode &&
|
||||
_timeOutMs > responseTimeMs);
|
||||
_maxTimeOutMs > actualResponseWaitTimeMs);
|
||||
|
||||
//if timeout value reaches zero, the response hasn't been received or the delay until
|
||||
//next communication needed to be hold
|
||||
if (_timeOutMs <= responseTimeMs)
|
||||
if (_maxTimeOutMs <= actualResponseWaitTimeMs)
|
||||
{
|
||||
_logger.Error(_recordInProcess.Acknowledge == RequestAcknowledgeState.NoResponse
|
||||
? $"{_ident} Response timeout({responseTimeMs}ms)"
|
||||
: $"{_ident} Communication delay({responseTimeMs}ms)");
|
||||
? $"{_ident} Response timeout({actualResponseWaitTimeMs}ms)"
|
||||
: $"{_ident} Communication delay({actualResponseWaitTimeMs}ms)");
|
||||
}
|
||||
|
||||
//skip loop to handle re-authorization
|
||||
@@ -395,28 +398,32 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
|
||||
/// <remarks date="2022-Oct-04" author="T.Wiedebusch">
|
||||
/// - On wakeup message exit this routine.
|
||||
/// </remarks>
|
||||
/// <remarks date="2023-Feb-13" author="T.Wiedebusch">
|
||||
/// - Early exit on _recordInProcess == null,
|
||||
/// - Wakeup message retries from 5 to 2,
|
||||
/// - Removed error base from error code decision as error base is only the AppId
|
||||
/// </remarks>
|
||||
public override void DecodeRecord(IPortDataEventArgs data)
|
||||
{
|
||||
if (_recordInProcess == null) return;
|
||||
//new request has to be analyzed
|
||||
_recordInProcess.Acknowledge = RequestAcknowledgeState.NotDecoded;
|
||||
//the request response record covers the entire request protocol
|
||||
var responseRecord = GetTransmitProtocol().DecodeDataForLogicLayer((List<Byte>)data.GetData());
|
||||
|
||||
//if the current record is invalid or on protocol decoding failure
|
||||
if (null == _recordInProcess || responseRecord.Count == 0)
|
||||
//on protocol decoding failure
|
||||
if (responseRecord.Count == 0)
|
||||
{
|
||||
if (_recordInProcess != null)
|
||||
_recordInProcess.Acknowledge = RequestAcknowledgeState.DecodingError;
|
||||
_recordInProcess.Acknowledge = RequestAcknowledgeState.DecodingError;
|
||||
_logger.Debug($"{_ident} Message decoding error.");
|
||||
//reset timeout to a normal value if timeout is extremely high but response received
|
||||
if (_timeOutMs > CommunicationConfig.BusyTimeoutMs)
|
||||
_timeOutMs = CommunicationConfig.BusyTimeoutMs;
|
||||
if (_maxTimeOutMs > CommunicationConfig.BusyTimeoutMs)
|
||||
_maxTimeOutMs = CommunicationConfig.BusyTimeoutMs;
|
||||
return;
|
||||
}
|
||||
|
||||
//avoid wakeup retry on acknowledged record
|
||||
if (responseRecord.Count == WakeupMessage.Length
|
||||
&& null != _recordInProcess
|
||||
&& RequestAcknowledgeState.Ok != _recordInProcess.Acknowledge)
|
||||
{
|
||||
// check for wakeup message
|
||||
@@ -431,7 +438,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
|
||||
{
|
||||
_recordInProcess.Acknowledge = RequestAcknowledgeState.WakeupMessage;
|
||||
//initiate a single retry on wakeup message response
|
||||
if ( _recordInProcess.WakeupMessageRetryCtr < 5)
|
||||
if ( _recordInProcess.WakeupMessageRetryCtr < 2)
|
||||
{
|
||||
_recordInProcess.WakeupMessageRetryCtr++;
|
||||
_logger.Debug($"{_ident} Wakeup message({_recordInProcess.WakeupMessageRetryCtr}) received");
|
||||
@@ -446,8 +453,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
|
||||
// reset retry counter to get all required retries
|
||||
_recordInProcess.RetryCtr = -1;
|
||||
//reset timeout to a normal value if timeout is extremely high but response received
|
||||
if (_timeOutMs > CommunicationConfig.BusyTimeoutMs)
|
||||
_timeOutMs = CommunicationConfig.BusyTimeoutMs;
|
||||
if (_maxTimeOutMs > CommunicationConfig.BusyTimeoutMs)
|
||||
_maxTimeOutMs = CommunicationConfig.BusyTimeoutMs;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -501,7 +508,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
|
||||
}
|
||||
|
||||
//examine error code, if base (AppId) is not 0 the reason 0 may be an error!!!!
|
||||
if (_recordInProcess.ResponseErrorBase != 0 || _recordInProcess.ResponseErrorReason != 0)
|
||||
if (/*_recordInProcess.ResponseErrorBase != 0 ||*/ _recordInProcess.ResponseErrorReason != 0)
|
||||
{
|
||||
_logger.Warn($"{_ident} Error code received(0x{_recordInProcess.ResponseErrorBase:X2}" +
|
||||
$"{_recordInProcess.ResponseErrorReason:X2})");
|
||||
|
||||
@@ -96,6 +96,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
|
||||
{
|
||||
public static readonly String FrequencyIndicator = "SENSUSRADIO_FrequencyIndicator";
|
||||
public static readonly String WakeupInterval = "SENSUSRADIO_WakeupInterval";
|
||||
public static readonly String SystemState = "SENSUSRADIO_SystemState";
|
||||
}
|
||||
|
||||
public static class Mertrologyasst
|
||||
|
||||
@@ -121,8 +121,7 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
|
||||
/// </summary>
|
||||
/// <param name="password">password for login</param>
|
||||
/// <param name="runImmediately">execute immediately</param>
|
||||
/// <param name="quickLogin">speed up login</param>
|
||||
Boolean Login(String password, Boolean runImmediately = true, Boolean quickLogin = false);
|
||||
Boolean Login(String password, Boolean runImmediately = true);
|
||||
|
||||
/// <summary>
|
||||
/// set up measurement parameter and set meter into test-mode
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3
|
||||
1a3d4919c9c702245832d925951f2b7cb72fc333
|
||||
|
||||
Reference in New Issue
Block a user