Refactor water meter handling in SequenceBase and FlyingStartMassCollectionSeq:
- Enhance logic for enabling/disabling channels based on water meter data. - Introduce Q3 calibration validation in `GenesisSmartReader` with configurable thresholds. - Update `GenesisCfgCtrl` UI to disable certain inputs.
This commit is contained in:
parent
009aefb7c9
commit
93459ccfab
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("3.9.3054.1")]
|
||||
[assembly: AssemblyFileVersion("3.9.3054.1")]
|
||||
[assembly: AssemblyVersion("3.9.3055.1")]
|
||||
[assembly: AssemblyFileVersion("3.9.3055.1")]
|
||||
|
||||
@ -237,6 +237,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader
|
||||
//
|
||||
this.checkBox_EnableShowChanels.Checked = true;
|
||||
this.checkBox_EnableShowChanels.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.checkBox_EnableShowChanels.Enabled = false;
|
||||
this.checkBox_EnableShowChanels.Location = new System.Drawing.Point(351, 147);
|
||||
this.checkBox_EnableShowChanels.Name = "checkBox_EnableShowChanels";
|
||||
this.checkBox_EnableShowChanels.Size = new System.Drawing.Size(238, 24);
|
||||
@ -246,6 +247,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader
|
||||
//
|
||||
// tBBeginDataFlush
|
||||
//
|
||||
this.tBBeginDataFlush.Enabled = false;
|
||||
this.tBBeginDataFlush.Location = new System.Drawing.Point(474, 105);
|
||||
this.tBBeginDataFlush.MaxLength = 8;
|
||||
this.tBBeginDataFlush.Name = "tBBeginDataFlush";
|
||||
|
||||
@ -3876,7 +3876,82 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
private bool isQ3CalibValid = false;
|
||||
private double q3Calib = 0;
|
||||
|
||||
public bool Q3CalibValid { get => isQ3CalibValid; }
|
||||
public double Q3CalibValue { get => q3Calib; }
|
||||
|
||||
public void GetQ3Calibration(double refVolume, double refTime, double initCalibFactor)
|
||||
{
|
||||
|
||||
isQ3CalibValid = false;
|
||||
q3Calib = 0.0;
|
||||
|
||||
if (_rawStartEndByChannel == null || NoSamples == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//-- calculation --
|
||||
OptoTelegramRaw[][] recalculatedVariablesByChannel = new OptoTelegramRaw[ChannelCount][];
|
||||
for (int channel = 0; channel < ChannelCount; channel++)
|
||||
{
|
||||
recalculatedVariablesByChannel[channel] = new OptoTelegramRaw[2];
|
||||
}
|
||||
|
||||
//recalc channels into ref time
|
||||
for (int iChannel = 0; iChannel < ChannelCount; iChannel++)
|
||||
{
|
||||
|
||||
if (_rawStartEndByChannel[iChannel] == null || _rawStartEndByChannel[iChannel].Length < 2)
|
||||
continue;
|
||||
|
||||
var channelStartRecord = _rawStartEndByChannel[iChannel][0];
|
||||
var channelEndRecord = _rawStartEndByChannel[iChannel][_rawStartEndByChannel[iChannel].Length - 1];
|
||||
|
||||
recalculatedVariablesByChannel[iChannel][0] = new OptoTelegramRaw();
|
||||
recalculatedVariablesByChannel[iChannel][1] = new OptoTelegramRaw();
|
||||
|
||||
recalculatedVariablesByChannel[iChannel][0].Copy(channelStartRecord);
|
||||
recalculatedVariablesByChannel[iChannel][1].Copy(channelEndRecord);
|
||||
|
||||
var channelDeltaTime = _rawStartEndByChannel[iChannel][1].TimestampExt - _rawStartEndByChannel[iChannel][0].TimestampExt;
|
||||
var channelDeltaVolume = _rawStartEndByChannel[iChannel][1].VolumeRawExt - _rawStartEndByChannel[iChannel][0].VolumeRawExt;
|
||||
|
||||
if (channelDeltaVolume != 0 && channelDeltaTime != 0)
|
||||
{
|
||||
double timeCoef = refTime / channelDeltaTime;
|
||||
double recalculatedDeltaVolume = channelDeltaVolume * timeCoef;
|
||||
|
||||
recalculatedVariablesByChannel[iChannel][1].VolumeRawExt =
|
||||
recalculatedVariablesByChannel[iChannel][0].VolumeRawExt + recalculatedDeltaVolume;
|
||||
}
|
||||
|
||||
recalculatedVariablesByChannel[iChannel][0].TimestampExt = 0;
|
||||
recalculatedVariablesByChannel[iChannel][1].TimestampExt = refTime;
|
||||
}
|
||||
|
||||
|
||||
//calculation
|
||||
|
||||
double scaling = 15625.0f;
|
||||
q3Calib = (refVolume / (AverageCachedVolume(_rawStartEndByChannel, 0)/scaling)) * initCalibFactor;
|
||||
|
||||
|
||||
//~-- calculation --~
|
||||
|
||||
//validation - result finish
|
||||
double diffPercent = Math.Abs((q3Calib - initCalibFactor) / initCalibFactor) * 100.0;
|
||||
isQ3CalibValid = (diffPercent <= 5.0); // max different 5%
|
||||
if (!isQ3CalibValid)
|
||||
{
|
||||
q3Calib = 0.0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1283,11 +1283,13 @@ namespace TBF.Rig.Sequences
|
||||
BatchRslts.Batch.WaterMeters[i] != null)
|
||||
{
|
||||
bool Disabled = BatchRslts.Batch.WaterMeters[i].Disabled;
|
||||
bool bChanel = false;
|
||||
if (Disabled &&
|
||||
BatchRslts.Batch.WaterMeters[i].SerialNr != null &&
|
||||
BatchRslts.Batch.WaterMeters[i].SerialNr.Contains("_CH")) //write channels
|
||||
{
|
||||
Disabled = false;
|
||||
bChanel = true;
|
||||
}
|
||||
|
||||
if (Disabled)
|
||||
@ -1298,10 +1300,25 @@ namespace TBF.Rig.Sequences
|
||||
if (!wm.Compound() && !wm.HeatMeter())
|
||||
{
|
||||
/// If this is a single meter
|
||||
|
||||
Results.Entities.MeterTestRslt mtrRslt = ProcessData.BatchRslts.GetMeterTestRslt(tstRslt.Name(), i, CompoundMeterId.Single);
|
||||
Results.Entities.MeterTestRslt mtrRslt = null;
|
||||
bool wmDisabled = wm.Disabled;
|
||||
try
|
||||
{
|
||||
wm.Disabled = false;
|
||||
if (!bChanel)
|
||||
mtrRslt = ProcessData.BatchRslts.GetMeterTestRslt(tstRslt.Name(), i, CompoundMeterId.Single);
|
||||
else
|
||||
{
|
||||
mtrRslt = wm.GetMeterTestRslt(tstRslt.Name(), CompoundMeterId.Single);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { }
|
||||
finally
|
||||
{
|
||||
wm.Disabled = wmDisabled;
|
||||
}
|
||||
|
||||
if (mtrRslt != null)
|
||||
if (mtrRslt != null)
|
||||
{
|
||||
bool isCamera = (mtrRslt.RegReaderType == (int)RegisterReaderType.Camera);
|
||||
|
||||
|
||||
@ -1390,33 +1390,38 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection
|
||||
MeterTestRslt meterTestRsltChX = new MeterTestRslt(chXWaterMeter, meterRslt.TestRslt, (CompoundMeterId)meterRslt.CompoundMeterId);
|
||||
chXWaterMeter.MeterTestRslts.Add(meterTestRsltChX);
|
||||
MeterTestRslt chanelXMeterRslt = BatchRslts.GetMeterTestRslt(testName, wmNrChX-1, Common.CompoundMeterId.Single);
|
||||
chanelXMeterRslt.CopyContentFrom(meterRslt);
|
||||
if (iCH == 0)
|
||||
|
||||
if (chanelXMeterRslt != null)
|
||||
{
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartCh1,
|
||||
genesisSmart.TimestampSecEndCh1, genesisSmart.VolumeLtrStartCh1, genesisSmart.VolumeLtrEndCh1);
|
||||
}else if (iCH == 1)
|
||||
{
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartCh2,
|
||||
genesisSmart.TimestampSecEndCh2, genesisSmart.VolumeLtrStartCh2, genesisSmart.VolumeLtrEndCh2);
|
||||
}
|
||||
else if (iCH == 2)
|
||||
{
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartCh3,
|
||||
genesisSmart.TimestampSecEndCh3, genesisSmart.VolumeLtrStartCh3, genesisSmart.VolumeLtrEndCh3);
|
||||
}
|
||||
chanelXMeterRslt?.CopyContentFrom(meterRslt);
|
||||
if (iCH == 0)
|
||||
{
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartCh1,
|
||||
genesisSmart.TimestampSecEndCh1, genesisSmart.VolumeLtrStartCh1, genesisSmart.VolumeLtrEndCh1);
|
||||
}
|
||||
else if (iCH == 1)
|
||||
{
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartCh2,
|
||||
genesisSmart.TimestampSecEndCh2, genesisSmart.VolumeLtrStartCh2, genesisSmart.VolumeLtrEndCh2);
|
||||
}
|
||||
else if (iCH == 2)
|
||||
{
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartCh3,
|
||||
genesisSmart.TimestampSecEndCh3, genesisSmart.VolumeLtrStartCh3, genesisSmart.VolumeLtrEndCh3);
|
||||
}
|
||||
|
||||
if (!genesisSmart.EnableShowChanels)
|
||||
{
|
||||
waterMeterParent.Disabled = true;
|
||||
meterTestRsltChX.TestDone = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
meterTestRsltChX.TestDone = true;
|
||||
}
|
||||
meterTestRsltChX.Passed = meterRslt.Passed;
|
||||
if (!genesisSmart.EnableShowChanels)
|
||||
{
|
||||
chXWaterMeter.Disabled = !genesisSmart.EnableShowChanels;
|
||||
meterTestRsltChX.TestDone = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
meterTestRsltChX.TestDone = true;
|
||||
}
|
||||
|
||||
meterTestRsltChX.Passed = meterRslt.Passed;
|
||||
}
|
||||
}
|
||||
|
||||
private static void CalculateMeterResults(MeterTestRslt meterRslt, IRegReaderDatastream dstrReader, TestRslt tstRslt, double dstrReaderTimestampSecStart, double dstrReaderTimestampSecEnd, double dstrReaderVolumeLtrStart, double dstrReaderVolumeLtrEnd)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user