143 lines
4.6 KiB
C#
143 lines
4.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
|
|
|
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
|
{
|
|
/// <summary>
|
|
/// Power correction file stored as reminder and log to meter
|
|
/// </summary>
|
|
public class MeterPowerCorrectionFile
|
|
{
|
|
/// <summary>
|
|
/// Drive and name for power correction file stored on meter
|
|
/// </summary>
|
|
public const String StrMeterPowCorrFileName = "1\\powcorr";
|
|
|
|
|
|
private readonly GenesisMeter _currentGenesis;
|
|
private readonly MeterFile _meterFile;
|
|
private const Int32 MeterPwrCorrFileLengthIndex = 0;
|
|
private const Int32 MeterPwrCorrFileLengthSize = 2;
|
|
private const Int32 MeterPwrCorrFileCrcIndex = MeterPwrCorrFileLengthIndex + MeterPwrCorrFileLengthSize;
|
|
private const Int32 MeterPwrCorrFileCrcSize= 2;
|
|
private const Int32 MeterPwrCorrFileDataIndex = MeterPwrCorrFileCrcIndex + MeterPwrCorrFileCrcSize;
|
|
|
|
private List<Byte>_meterBinData = new List<Byte>();
|
|
|
|
/// <summary>
|
|
/// Detected FW version before maintenance
|
|
/// </summary>
|
|
public UInt32 ActualFwVersion { get; set; }
|
|
|
|
/// <summary>
|
|
/// Date time UTC at time of maintenance
|
|
/// </summary>
|
|
public DateTime? ActualDateTimeUtc { get; set; }
|
|
|
|
/// <summary>
|
|
/// Total used seconds before maintenance
|
|
/// </summary>
|
|
public UInt32 ActualTotalUsedSeconds_s { get; set; }
|
|
|
|
/// <summary>
|
|
/// Total used charge of batteries before maintenance
|
|
/// </summary>
|
|
public UInt64 ActualTotalUsedCharge_uAs { get; set; }
|
|
|
|
/// <summary>
|
|
/// Actual detected radio system state at maintenance
|
|
/// </summary>
|
|
public Byte? ActualRadioSystemState { get; set; }
|
|
|
|
/// <summary>
|
|
/// Detection of pulse adapter installation
|
|
/// </summary>
|
|
public Boolean ActualPulseAdapterIsInstalled { get; set; }
|
|
|
|
/// <summary>
|
|
/// Pulse mode during maintenance
|
|
/// </summary>
|
|
public Byte ActualPulseMode { get; set; }
|
|
|
|
/// <summary>
|
|
/// Pulse distribution during maintenance
|
|
/// </summary>
|
|
public Boolean ActualPulseEvenDistribution { get; set; }
|
|
|
|
/// <summary>
|
|
/// FW version for the update
|
|
/// </summary>
|
|
public UInt32 RequiredFwVersion { get; set; }
|
|
|
|
/// <summary>
|
|
/// Calculated pulse report length
|
|
/// </summary>
|
|
public UInt32 PulseReportLength { get; set; }
|
|
|
|
/// <summary>
|
|
/// Total used seconds after EOL and before maintenance
|
|
/// </summary>
|
|
public UInt32 AfterProductionTotalUsedSeconds_s { get; set; }
|
|
|
|
/// <summary>
|
|
/// Overestimated total used charge before maintenance
|
|
/// </summary>
|
|
public UInt64 OverestimatedTotalUsedCharge_uAs { get; set; }
|
|
|
|
/// <summary>
|
|
/// Lowest threshold for total used charge calculated during maintenance
|
|
/// </summary>
|
|
public UInt64 MinimumTotalUsedCharge_uAs { get; set; }
|
|
|
|
/// <summary>
|
|
/// Corrected total used charge during maintenance
|
|
/// </summary>
|
|
public UInt64 CorrectedTotalUsedCharge_uAs { get; set; }
|
|
|
|
/// <summary>
|
|
/// Size of power correction file
|
|
/// </summary>
|
|
public UInt32 MeterPowerCorrectionFileSize { get; set; }
|
|
|
|
/// <summary>
|
|
/// CRC of power correction file
|
|
/// </summary>
|
|
public UInt32 MeterPowerCorrectionCRC { get; set; }
|
|
|
|
/// <summary>
|
|
/// Ctor
|
|
/// </summary>
|
|
/// <param name="currentGenesis"></param>
|
|
/// <remarks date="2024-May-08" author="Thomas Wiedebusch">
|
|
/// - Initial.
|
|
/// </remarks>
|
|
public MeterPowerCorrectionFile(GenesisMeter currentGenesis)
|
|
{
|
|
_currentGenesis = currentGenesis;
|
|
_meterFile = new MeterFile(_currentGenesis);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Read power correction meter file.
|
|
/// </summary>
|
|
/// <returns>true: file found</returns>
|
|
/// <remarks date="2024-May-08" author="Thomas Wiedebusch">
|
|
/// - Initial
|
|
/// </remarks>
|
|
public Boolean ReadPowCorrMeterFile()
|
|
{
|
|
if (_currentGenesis == null || _meterFile == null)
|
|
return false;
|
|
|
|
var retVal = _currentGenesis.ReLogin();
|
|
if (retVal)
|
|
{
|
|
retVal = _meterFile.ReadMeterFile(StrMeterPowCorrFileName, out _meterBinData);
|
|
}
|
|
|
|
return retVal;
|
|
}
|
|
}
|
|
}
|