ReSharper: - GenesisFile
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Consts/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Cordonel/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=dispached/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Drabesch/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Drahbesch/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=FFFF/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Flexnet/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=FLEXNETVERSION/@EntryIndexedValue">True</s:Boolean>
|
||||
@@ -26,4 +28,5 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=RFID/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=SENSUSRADIO/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Thermo/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Uart/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Uart/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Wiedebusch/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Properties;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Consts
|
||||
{
|
||||
|
||||
@@ -969,20 +969,18 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// <summary>
|
||||
/// Load file from memory
|
||||
/// </summary>
|
||||
/// <param name="Name">origin Name</param>
|
||||
/// /// <param name="StreamData">list of bytes of the file strean</param>
|
||||
/// <param name="name">origin Name</param>
|
||||
/// <param name="streamData">list of bytes of the file strean</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2022-Feb-15" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean LoadLutFromStream(String Name, List<Byte> StreamData )
|
||||
public Boolean LoadLutFromStream(String name, List<Byte> streamData )
|
||||
{
|
||||
|
||||
|
||||
LutFile = null;
|
||||
LutFile = new MeterLutFile(Name)
|
||||
LutFile = new MeterLutFile(name)
|
||||
{
|
||||
BinData = StreamData
|
||||
BinData = streamData
|
||||
};
|
||||
|
||||
// validate the file
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
///// <remarks date="2019-Mai-15" author="Thomas Wiedebusch">
|
||||
///// - Initial.
|
||||
///// </remarks>
|
||||
///// <remarks date="2020-Mai-15" author="Roland Drahbesh">
|
||||
///// <remarks date="2020-Mai-15" author="Roland Drabesch">
|
||||
///// - Insert of Level 3 password with skeletonKey,
|
||||
///// - SHA 1 of passwords.
|
||||
///// </remarks>
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
#region Variables
|
||||
|
||||
// Template of FLEXNETVERSION has to be modified for version, version string and CRC
|
||||
private static readonly Byte[] TemplateUpg18File =
|
||||
private static readonly Byte[] TemplateUpgradeFile =
|
||||
{
|
||||
0x41, 0x50, 0x50, 0x3E, 0x83, 0xBA, 0x47, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00,
|
||||
@@ -39,7 +39,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
};
|
||||
|
||||
// upgrade file for FLEXNETVERSION
|
||||
private Byte[] _upg18File;
|
||||
private Byte[] _upgradeFile;
|
||||
|
||||
// FLEXNETVERSION application Id
|
||||
private const Byte FlexnetVersionAppId = 0x18;
|
||||
@@ -54,7 +54,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
public event EventHandler<ProcessExecEventArgs> OnProcessUpdate;
|
||||
|
||||
//disk and name of lookup file
|
||||
private const String StrFlexnetUpgradeFileName = "1\\upg18";
|
||||
private static readonly String StrFlexnetUpgradeFileName = $"1\\upg{FlexnetVersionAppId:X2}";
|
||||
|
||||
//update reties for files
|
||||
private const Int32 FileWriteRetries = 1;
|
||||
@@ -83,9 +83,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
private MeterResetPsuState _meterResetPsuState;
|
||||
private MeterResetPsuState _backupMeterResetPsuState;
|
||||
|
||||
// Look up table file
|
||||
public MeterLutFile LutFile;
|
||||
|
||||
// number of operations for over all access
|
||||
private const Int32 NumberOfOperations = 11;
|
||||
private Int32 _operationCtr;
|
||||
@@ -291,7 +288,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// </remarks>
|
||||
public void ResetAll()
|
||||
{
|
||||
LutFile = null;
|
||||
//remove the update stop action
|
||||
StopUpdateProcess = false;
|
||||
|
||||
@@ -509,8 +505,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
}
|
||||
|
||||
// generate the upgrade file based on the template
|
||||
_upg18File = new Byte[TemplateUpg18File.Length];
|
||||
Buffer.BlockCopy(TemplateUpg18File, 0, _upg18File, 0, _upg18File.Length);
|
||||
_upgradeFile = new Byte[TemplateUpgradeFile.Length];
|
||||
Buffer.BlockCopy(TemplateUpgradeFile, 0, _upgradeFile, 0, _upgradeFile.Length);
|
||||
|
||||
// rebuild numerical version out of the string because the FLEXNETVERSION version cannot be used
|
||||
// as it does lose the "B" information on conversion which is represented with the mask 0x80.
|
||||
@@ -537,21 +533,21 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
strVersion = "R";
|
||||
}
|
||||
|
||||
_upg18File[MeterFwUpdate.FileAppVersionIndex] = (Byte)(hexVersion & 0xFF);
|
||||
_upg18File[MeterFwUpdate.FileAppVersionIndex + 1] = (Byte)((hexVersion & 0xFF00) >> 8);
|
||||
_upgradeFile[MeterFwUpdate.FileAppVersionIndex] = (Byte)(hexVersion & 0xFF);
|
||||
_upgradeFile[MeterFwUpdate.FileAppVersionIndex + 1] = (Byte)((hexVersion & 0xFF00) >> 8);
|
||||
|
||||
// build the version string and copy it to the upgrade file
|
||||
strVersion += $"{charVersion[0]}.{charVersion[1]}.{charVersion[2]}{charVersion[3]}";
|
||||
var upg18Idx = FlexVersionStringIndex;
|
||||
foreach (var t in strVersion)
|
||||
{
|
||||
_upg18File[upg18Idx] = Convert.ToByte(t);
|
||||
_upgradeFile[upg18Idx] = Convert.ToByte(t);
|
||||
upg18Idx++;
|
||||
}
|
||||
|
||||
// take the payload starting with version index
|
||||
var payload = new Byte[_upg18File.Length - MeterFwUpdate.FileAppVersionIndex];
|
||||
Buffer.BlockCopy(_upg18File, MeterFwUpdate.FileAppVersionIndex, payload, 0, payload.Length);
|
||||
var payload = new Byte[_upgradeFile.Length - MeterFwUpdate.FileAppVersionIndex];
|
||||
Buffer.BlockCopy(_upgradeFile, MeterFwUpdate.FileAppVersionIndex, payload, 0, payload.Length);
|
||||
var calculatedCrc = Crc16Ccitt.CalculateMsb1021(payload);
|
||||
|
||||
// avoid replacement wit invalid generated FLEXNETVERSION
|
||||
@@ -561,8 +557,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
}
|
||||
|
||||
// replace the CRC
|
||||
_upg18File[MeterFwUpdate.FileAppCrcIndex] = (Byte)(calculatedCrc & 0xFF);
|
||||
_upg18File[MeterFwUpdate.FileAppCrcIndex + 1] = (Byte)((calculatedCrc & 0xFF00) >> 8);
|
||||
_upgradeFile[MeterFwUpdate.FileAppCrcIndex] = (Byte)(calculatedCrc & 0xFF);
|
||||
_upgradeFile[MeterFwUpdate.FileAppCrcIndex + 1] = (Byte)((calculatedCrc & 0xFF00) >> 8);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -577,7 +573,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
private Boolean DownloadUpgradeFile()
|
||||
{
|
||||
//initiate upgrade by writing the upgrade control file
|
||||
if (_upg18File == null || _upg18File.Length != TemplateUpg18File.Length ||
|
||||
if (_upgradeFile == null || _upgradeFile.Length != TemplateUpgradeFile.Length ||
|
||||
!_meterFile.UnlockEraseWriteMeterFile(StrFlexnetUpgradeFileName))
|
||||
{
|
||||
return false;
|
||||
@@ -590,7 +586,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
//write file and retry if not successful
|
||||
do
|
||||
{
|
||||
returnValue = _meterFile.WriteMeterFile(StrFlexnetUpgradeFileName, _upg18File);
|
||||
returnValue = _meterFile.WriteMeterFile(StrFlexnetUpgradeFileName, _upgradeFile);
|
||||
|
||||
if (!returnValue)
|
||||
{
|
||||
@@ -598,7 +594,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
}
|
||||
} while (!returnValue && retryCtr++ < FileWriteRetries && !StopUpdateProcess);
|
||||
|
||||
_upg18File = null;
|
||||
_upgradeFile = null;
|
||||
return !StopUpdateProcess && returnValue;
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user