revert merge and

This commit is contained in:
Roland Drabesch
2022-04-06 13:36:43 +02:00
parent 152e775310
commit 81e7e16653
@@ -29,17 +29,15 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
private Int32 _fileWriteTimeOutMs = ExtendedFileIoTimeoutMs; private Int32 _fileWriteTimeOutMs = ExtendedFileIoTimeoutMs;
private readonly GenesisMeter _currentGenesis; private readonly GenesisMeter _currentGenesis;
private Int32 _filePointer;
//TODO THW test only private const String StrNewFileReadWriteMode = "wb+"; //TODO THW test only private const String StrNewFileReadWriteMode = "wb+";
//wb open file for writing in binary mode, if file exists its contents will be overwritten, //wb open file for writing in binary mode, if file exists its contents will be overwritten,
//if file does not exist it will be created //if file does not exist it will be created
private const String StrNewFileReadWriteMode = "wb"; private const String StrNewFileReadWriteMode = "wb";
//Open for reading in binary mode. If the file does not exist, fopen( ) returns NULL //Open for reading in binary mode. If the file does not exist, fopen( ) returns NULL
public Int32 _filePointer;
private const String StrOpenFileReadOnlyMode = "rb"; private const String StrOpenFileReadOnlyMode = "rb";
//Open for both reading and writing in binary mode. If the file does not exist, fopen( ) returns NULL //Open for both reading and writing in binary mode. If the file does not exist, fopen( ) returns NULL
private const String StrOpenFileReadWriteMode = "wb+"; private const String StrOpenFileReadWriteMode = "rb+";
private String _fileName; private String _fileName;
private Int32 _overallBytesCtr; private Int32 _overallBytesCtr;
@@ -349,38 +347,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
if (returnValue) if (returnValue)
{ {
// optical.fseek(handle, 0, 2)
//numbytes = optical.ftell(handle)
//optical.fseek(handle, 0, 0)
//set register write retries to 0 to avoid doubling of records //set register write retries to 0 to avoid doubling of records
CommunicationConfig.RequestRetries = 0; CommunicationConfig.RequestRetries = 0;
_currentGenesis.TransmitProtocol.SetResponseTimeout(ExtendedFileIoTimeoutMs); _currentGenesis.TransmitProtocol.SetResponseTimeout(ExtendedFileIoTimeoutMs);
//int fixedReadBackCount;
//if (readBackCount.HasValue)
//{
// fixedReadBackCount = readBackCount.Value;
//}
//else
//{
// _currentGenesis.WriteRegister("CONFIGEXCHANGE_FSeek", _filePointer, false);
// _currentGenesis.WriteRegister("CONFIGEXCHANGE_FSeek", 0, false);
// _currentGenesis.WriteRegister("CONFIGEXCHANGE_FSeek", 2, false);
// _currentGenesis.WriteRegister("CONFIGEXCHANGE_FTell", _filePointer, false);
// fixedReadBackCount = RegisterConverter.ConvertTo<Int32>(_currentGenesis.ReadRegister("CONFIGEXCHANGE_FTell")) + 1;
// _currentGenesis.WriteRegister("CONFIGEXCHANGE_FSeek", _filePointer, false);
// _currentGenesis.WriteRegister("CONFIGEXCHANGE_FSeek", 0, false);
// _currentGenesis.WriteRegister("CONFIGEXCHANGE_FSeek", 0, false);
//}
//write size to 1 //write size to 1
_currentGenesis.WriteRegister(Register.Configexchange.FileRead, 1, false); _currentGenesis.WriteRegister(Register.Configexchange.FileRead, 1, false);
//write counts to expected length //write counts to expected length
@@ -389,12 +359,12 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
_currentGenesis.WriteRegister(Register.Configexchange.FileRead, _filePointer); _currentGenesis.WriteRegister(Register.Configexchange.FileRead, _filePointer);
//the preceding routine needs to wait for response, else this is always true! //the preceding routine needs to wait for response, else this is always true!
while (readBackCount > 0 && !_stopProcess) // while (fixedReadBackCount > 0 && returnValue) while (readBackCount > 0 && !_stopProcess)
{ {
var remainingData = RegisterConverter.ConvertTo<Int32>( var remainingData = RegisterConverter.ConvertTo<Int32>(
_currentGenesis.ReadRegister(Register.Configexchange.FileRead)); _currentGenesis.ReadRegister(Register.Configexchange.FileRead));
// fixedReadBackCount = remainingData > 0 ? fixedReadBackCount - remainingData : 0; readBackCount = remainingData > 0 ? readBackCount - remainingData : 0;
while (remainingData > 0) while (remainingData > 0)
{ {
@@ -455,8 +425,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
{ {
// remind entry key as this will be changed with the read back // remind entry key as this will be changed with the read back
var lastKey = key; var lastKey = key;
//\\logindex".format(drive)
var searchPattern = wildcard + drive; var searchPattern = drive + wildcard;
_currentGenesis.WriteRegister(Register.Configexchange.Catalogue, searchPattern); _currentGenesis.WriteRegister(Register.Configexchange.Catalogue, searchPattern);
_currentGenesis.WriteRegister(Register.Configexchange.Catalogue, key); _currentGenesis.WriteRegister(Register.Configexchange.Catalogue, key);
@@ -786,7 +756,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// - Retries changed for and back, /// - Retries changed for and back,
/// - Timeout changed for and back. /// - Timeout changed for and back.
/// </remarks> /// </remarks>
public Boolean OpenMeterFile(String fileName, String accessMode) private Boolean OpenMeterFile(String fileName, String accessMode)
{ {
//check if logged on to meter and access level is as expected //check if logged on to meter and access level is as expected
if (_currentGenesis == null || !_currentGenesis.IsLoggedOn) if (_currentGenesis == null || !_currentGenesis.IsLoggedOn)