Increment assembly version to 3.9.3121.3, enhance debug logging in PrepareQ3Calibration and related methods, improve calibration factor handling with multi-value support, add exception handling for simulated DB responses, and refine Q3 calibration logic in GenesisSmartReader.
This commit is contained in:
parent
0f407920ac
commit
8b025a0fca
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("3.9.3121.1")]
|
||||
[assembly: AssemblyFileVersion("3.9.3121.1")]
|
||||
[assembly: AssemblyVersion("3.9.3121.3")]
|
||||
[assembly: AssemblyFileVersion("3.9.3121.3")]
|
||||
|
||||
@ -1751,7 +1751,36 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
|
||||
log.Debug("PrepareQ3Calibration() - Start, Head: " + genesisHead?.Name);
|
||||
if (genesisHead != null && genesisHead.DebugLevel == DebugMode.Simulate)
|
||||
{
|
||||
log.Debug("PrepareQ3Calibration() - Simulated response");
|
||||
log.Debug("PrepareQ3Calibration() - Simulated response - Config: " + cfg.ToString() + " Test: " + test.ToString() + " WaterMeter: " + wm.ToString());
|
||||
try
|
||||
{
|
||||
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(test.Name, test.Part);
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 0)
|
||||
{
|
||||
tstRslt.CalibFactorResultsToSave.Clear();
|
||||
}
|
||||
if (tstRslt.CalibFactorResultsToSave.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < genesisHead.ChannelsCount; i++)
|
||||
{
|
||||
tstRslt.CalibFactorResultsToSave.Add(new TestRsltCalibFactor()
|
||||
{
|
||||
Stored = false,
|
||||
CalibFactorIndex = i,
|
||||
BaseCalibFactor = 15625,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
log.Debug($" Calib factor from Text1: {wm.WaterMeterData.Text1}");
|
||||
log.Debug($" Calib factor from Text2: {wm.WaterMeterData.Text2}");
|
||||
log.Debug($" Calib factor from Text3: {wm.WaterMeterData.Text3}");
|
||||
}
|
||||
}catch(Exception ex)
|
||||
{
|
||||
log.Error($"PrepareQ3Calibration() - Simulated DB Exception: {ex.Message}");
|
||||
}
|
||||
|
||||
return ResultOk;//"Simulated Connect";
|
||||
}
|
||||
|
||||
@ -1767,7 +1796,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
|
||||
log.Error($"PrepareQ3Calibration({genesisHead?.Name}) - Missing Test");
|
||||
return "PrepareQ3Calibration - Missing Test";
|
||||
}
|
||||
|
||||
|
||||
return Task.Run(() => PrepareQ3Calibration_Async(genesisHead, cfg, test, wm))
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
@ -1799,6 +1828,8 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Results.Entities.TestRslt tstRslt = null;
|
||||
|
||||
try
|
||||
@ -1841,15 +1872,31 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
|
||||
byte valueLed = (ledMode == LedState.active) ? (byte)6 : (byte)0;
|
||||
//TODO BUMI - implement variable values for Q3Channel
|
||||
UInt16 valueSampleRate = 10;
|
||||
|
||||
log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Calib Factors from Dialog - Text1:{wm?.WaterMeterData?.Text1} Text2:{ wm?.WaterMeterData?.Text2}, Text3: {wm?.WaterMeterData?.Text3}");
|
||||
// try get Calib factors directly from Process settings
|
||||
if (!string.IsNullOrEmpty(wm?.WaterMeterData?.Text1) &&
|
||||
!string.IsNullOrEmpty(wm?.WaterMeterData?.Text2) &&
|
||||
!string.IsNullOrEmpty(wm?.WaterMeterData?.Text3))
|
||||
{
|
||||
int.TryParse(wm?.WaterMeterData?.Text1, out int calibFactor1);
|
||||
int.TryParse(wm?.WaterMeterData?.Text2, out int calibFactor2);
|
||||
int.TryParse(wm?.WaterMeterData?.Text3, out int calibFactor3);
|
||||
genesisSmartReader?.SetQ3Calibration(new double[]{calibFactor1,calibFactor2,calibFactor3});
|
||||
}
|
||||
else
|
||||
{
|
||||
genesisSmartReader?.SetQ3Calibration(new double[]{15625.0d,15625.0d,15625.0d});
|
||||
}
|
||||
|
||||
//TODO BUMI - implement variable values for Q3Channel - be shure is implemented in Head
|
||||
string prepareMeterSizeAndCalibration = await PrepareMeterSizeAndCalibration(genesisSmartReader, cfg, gciBridge, tstRslt, token);
|
||||
if (prepareMeterSizeAndCalibration != ResultOk)
|
||||
{
|
||||
log.Error($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - prepareMeterSizeAndCalibration failed. Result: {prepareMeterSizeAndCalibration}");
|
||||
return prepareMeterSizeAndCalibration;
|
||||
}
|
||||
|
||||
//string prepareMeterSizeAndCalibration = await PrepareMeterSizeAndCalibration(genesisSmartReader, cfg, gciBridge, tstRslt, token);
|
||||
// if (prepareMeterSizeAndCalibration != ResultOk)
|
||||
// {
|
||||
// log.Error($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - prepareMeterSizeAndCalibration failed. Result: {prepareMeterSizeAndCalibration}");
|
||||
// return prepareMeterSizeAndCalibration;
|
||||
// }
|
||||
|
||||
ushort calibrationFactor1 = Convert.ToUInt16(genesisSmartReader?.Q3CalibValue[0]);
|
||||
log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Start - Set CalFactor1: {calibrationFactor1}");
|
||||
var CalFactor1AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor1, calibrationFactor1, false, false, token);
|
||||
|
||||
@ -3997,8 +3997,8 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug($"Inputs: refVolume={refVolume}, refTime={refTime}, initCalibFactor={initCalibFactor}");
|
||||
|
||||
log.Debug($"Inputs: refVolume={refVolume}, refTime={refTime}, initCalibFactors={string.Join(",", initCalibFactor)}");
|
||||
|
||||
if (_rawStartEndByChannel == null)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user