MeterFile: VerifyMeterFile for binary compare of given file with file in Genesis Meter
This commit is contained in:
@@ -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" />
|
||||||
|
|||||||
@@ -1296,15 +1296,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
var versionString = fm.IsInstalled
|
var versionString = fm.IsInstalled
|
||||||
? $"V: {fm.StrVersion} - CRC: 0x{fm.Crc:X4}" : "Not installed";
|
? $"V: {fm.StrVersion} - CRC: 0x{fm.Crc:X4}" : "Not installed";
|
||||||
_logger.Info($"AppId: 0x{fm.AppId:X2} - {versionString} - AppName: {fm.AppName}");
|
_logger.Info($"AppId: 0x{fm.AppId:X2} - {versionString} - AppName: {fm.AppName}");
|
||||||
if (fm.AppName.ToUpper() == "SENSUSRADIO" && fm.IsInstalled)
|
|
||||||
{
|
|
||||||
var radioFrequency = ReadRegister(Register.Sensusradio.FrequencyIndicator);
|
|
||||||
var tmpList = radioFrequency.ToList();
|
|
||||||
tmpList.Reverse();
|
|
||||||
|
|
||||||
var strRawResult = BitConverter.ToString(tmpList.ToArray());
|
|
||||||
RegionRadio = $"EMEA_{strRawResult}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Info($"Meter size: {MeterSize}");
|
_logger.Info($"Meter size: {MeterSize}");
|
||||||
|
|||||||
@@ -545,26 +545,30 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Meter file verification against given data
|
/// Meter file verification against given data
|
||||||
|
/// Takes into account, that the read file is always integer dividable by 4 due to the chunk size
|
||||||
|
/// of the write and read access to the Genesis.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fileName">file name as string</param>
|
/// <param name="fileName">file name as string</param>
|
||||||
/// <param name="dataBytes">data to store</param>
|
/// <param name="dataBytes">data to store</param>
|
||||||
/// <returns>true: file found and verified</returns>
|
/// <returns>true: file found and verified</returns>
|
||||||
/// <remarks date="2019-Jun-20" author="Thomas Wiedebusch">
|
/// <remarks date="2022-Apr-06" author="Thomas Wiedebusch">
|
||||||
/// - Initial
|
/// - Initial
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <remarks date="2022-Apr-01" author="Thomas Wiedebusch">
|
|
||||||
/// - Add a NULL at the end of the file name.
|
|
||||||
/// </remarks>
|
|
||||||
public Boolean VerifyMeterFile(String fileName, Byte[] dataBytes)
|
public Boolean VerifyMeterFile(String fileName, Byte[] dataBytes)
|
||||||
{
|
{
|
||||||
//add file name delimiter
|
var returnValue = true;
|
||||||
fileName += StringDelimiter;
|
|
||||||
|
|
||||||
if (!OpenMeterFile(fileName, StrOpenFileReadOnlyMode))
|
if (!ReadMeterFile(fileName, out var binData, dataBytes.Length)) return true;
|
||||||
return false;
|
|
||||||
//TODO THW implement
|
// compare the entire buffer which also includes the header of the file, remind the original
|
||||||
//read raw data from meter
|
// buffer may be smaller due to the chunk size of the communication (always dividable by 4),
|
||||||
return true;
|
// meaning the receive buffer is always and integer of this chunk size!
|
||||||
|
if (dataBytes.Where((t, ctr) => t != binData[ctr]).Any())
|
||||||
|
{
|
||||||
|
returnValue = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -887,6 +887,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
/// <remarks date="2022-Apr-01" author="Thomas Wiedebusch">
|
/// <remarks date="2022-Apr-01" author="Thomas Wiedebusch">
|
||||||
/// - Take the different size of original and receive buffer, which is an integer division by 4, into account.
|
/// - Take the different size of original and receive buffer, which is an integer division by 4, into account.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
/// <remarks date="2022-Apr-06" author="Thomas Wiedebusch">
|
||||||
|
/// - Exported file compare to <see cref="MeterFile"/>.
|
||||||
|
/// </remarks>
|
||||||
private Boolean UploadAndCompareLutFiles()
|
private Boolean UploadAndCompareLutFiles()
|
||||||
{
|
{
|
||||||
//counters for actual process information
|
//counters for actual process information
|
||||||
@@ -911,31 +914,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|||||||
// logout and re-login to clear all ongoing processes and clear the Genesis buffers
|
// logout and re-login to clear all ongoing processes and clear the Genesis buffers
|
||||||
ReestablishMeterFileSystem();
|
ReestablishMeterFileSystem();
|
||||||
|
|
||||||
if (_meterFile.ReadMeterFile(fileToUpload, out var binData, SizeLutFile))
|
if (!_meterFile.VerifyMeterFile(fileToUpload, LutFile.BinData.ToArray()))
|
||||||
{
|
{
|
||||||
// compare the entire buffer which also includes the header of the file, remind the original
|
|
||||||
// buffer may be smaller due to the chunk size of the communication (always dividable by 4),
|
|
||||||
// meaning the receive buffer is always and integer of this chunk size!
|
|
||||||
if (LutFile.BinData.Where((t, ctr) => t != binData[ctr]).Any())
|
|
||||||
{
|
|
||||||
ErrorMessage = $"Meter LUT file is unequal to downloaded {fileToUpload}!";
|
ErrorMessage = $"Meter LUT file is unequal to downloaded {fileToUpload}!";
|
||||||
returnValue = false;
|
returnValue = false;
|
||||||
_operationCtr--;
|
_operationCtr--;
|
||||||
}
|
|
||||||
|
|
||||||
if (returnValue)
|
|
||||||
{
|
|
||||||
OnProcessUpdate?.Invoke(this,
|
|
||||||
new ProcessExecEventArgs($"LUT file {fileToUpload} of meter successfully compared!"));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
OnProcessUpdate?.Invoke(this,
|
||||||
ErrorMessage += $"Reading of {fileToUpload} failed!";
|
new ProcessExecEventArgs($"LUT file {fileToUpload} of meter successfully compared!"));
|
||||||
returnValue = false;
|
|
||||||
_operationCtr--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
46bd00889699f5a20a4981a22f62b66368323855
|
7ac73abb7afd9e6ddc0520a1568581c7ed0afd36
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
0d85a5b3a7561b41163c20e5dc7713bcd0d65555
|
f64d563def603c89cafafa61a3219ba97e1e344c
|
||||||
|
|||||||
Reference in New Issue
Block a user