Increment assembly version to 3.9.3124.3, implement GetEachMeterTestRslt method, enhance error handling in calibration-related methods, refine Q3 calibration data simulation and storage logic, and improve debug logging across Genesis operations.
This commit is contained in:
parent
0b246b2ff5
commit
2d8cc912a3
@ -188,6 +188,15 @@ namespace Results
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public MeterTestRslt GetEachMeterTestRslt(string name, int wmNr0, CompoundMeterId meterId)
|
||||
{
|
||||
if (Batch.WaterMeters != null && Batch.WaterMeters.Count > wmNr0)
|
||||
{
|
||||
return Batch.WaterMeters[wmNr0].GetMeterTestRslt(name, meterId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -602,9 +602,10 @@ namespace Results.Entities
|
||||
foreach (var mtr in MeterTestRslts)
|
||||
{
|
||||
if ((mtr.CompoundMeterId == (byte)CompoundMeterId.Single || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound || mtr.CompoundMeterId == (byte)CompoundMeterId.HeatMeterEnergy)
|
||||
&& mtr.TestDone
|
||||
&& (mtr.Q3Channel != 0 ||
|
||||
(mtr.TestDone
|
||||
&& (mtr.Publish() != Publish.Never)
|
||||
&& (mtr.Publish() != Publish.Internal))
|
||||
&& (mtr.Publish() != Publish.Internal))))
|
||||
{
|
||||
testNames.Add(mtr.Name());
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ namespace Results.Forms
|
||||
|
||||
public void Update(Results.Entities.WaterMeter wMtr)
|
||||
{
|
||||
if (wMtr == null || wMtr.Disabled)
|
||||
if (wMtr == null || (wMtr.Disabled && wMtr.Q3Channel == 0))
|
||||
{
|
||||
/// Water meter position is disabled
|
||||
this.disabled = true;
|
||||
|
||||
@ -81,7 +81,7 @@ namespace Results.Forms
|
||||
|
||||
public void Update(Results.Entities.WaterMeter wMtr)
|
||||
{
|
||||
if (wMtr == null || wMtr.Disabled)
|
||||
if (wMtr == null || (wMtr.Disabled && wMtr.Q3Channel == 0))
|
||||
{
|
||||
/// Water meter position is disabled
|
||||
this.disabled = true;
|
||||
@ -114,8 +114,11 @@ namespace Results.Forms
|
||||
lView.Items.Clear();
|
||||
foreach (var mtr in wMtr.MeterTestRslts)
|
||||
{
|
||||
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Publish.Never
|
||||
&& mtr.Publish() != Publish.Internal)
|
||||
if (mtr != null && mtr.IsPilotRslt() &&
|
||||
(mtr.Q3Channel!=0 || (mtr.TestDone &&
|
||||
mtr.Publish() != Publish.Never &&
|
||||
mtr.Publish() != Publish.Internal)
|
||||
) )
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem(testNames[ix++]);
|
||||
|
||||
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("3.9.3121.3")]
|
||||
[assembly: AssemblyFileVersion("3.9.3121.3")]
|
||||
[assembly: AssemblyVersion("3.9.3124.3")]
|
||||
[assembly: AssemblyFileVersion("3.9.3124.3")]
|
||||
|
||||
@ -13,6 +13,7 @@ using TBF.Rig.GenericDevices;
|
||||
using TBF.Boxes;
|
||||
using TBF.Resources;
|
||||
using TBF.Rig.RegisterReaders.GenesisRegReader.implementations;
|
||||
using TBF.Rig.Sequences;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
|
||||
using TBF.UiBridge;
|
||||
|
||||
@ -947,7 +948,9 @@ namespace TBF.Rig.TestMethods.FlyingStart
|
||||
{
|
||||
WaterMeter waterMeterParent = BatchRslts.Batch.WaterMeters[i];
|
||||
int wmNrChX = (i*CountCh) + BatchRslts.WMPositionsCount + iCH + 1;
|
||||
String sSerialNr = waterMeterParent.SerialNr + "_CH" + (iCH + 1);
|
||||
String sSerialNr =
|
||||
(string.IsNullOrEmpty(waterMeterParent.SerialNr) ? (i+1).ToString() : waterMeterParent.SerialNr) +
|
||||
"_CH" + (iCH + 1);
|
||||
WaterMeter chXWaterMeter = null;
|
||||
//------ add new water meter to batch ------
|
||||
if (BatchRslts.Batch.WaterMeters.Count < wmNrChX || BatchRslts.Batch.WaterMeters[wmNrChX-1] == null)
|
||||
@ -993,66 +996,86 @@ namespace TBF.Rig.TestMethods.FlyingStart
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartRawCh1,
|
||||
genesisSmart.TimestampSecEndRawCh1, genesisSmart.VolumeLtrStartRawCh1, genesisSmart.VolumeLtrEndRawCh1);
|
||||
|
||||
TestRsltCalibFactor testRsltCalibFactor = null;
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 0)
|
||||
try
|
||||
{
|
||||
testRsltCalibFactor = tstRslt.CalibFactorResultsToSave[0];
|
||||
}
|
||||
else
|
||||
TestRsltCalibFactor testRsltCalibFactor = null;
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 0)
|
||||
{
|
||||
testRsltCalibFactor = tstRslt.CalibFactorResultsToSave[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
//store in table
|
||||
testRsltCalibFactor = new TestRsltCalibFactor();
|
||||
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
|
||||
}
|
||||
|
||||
testRsltCalibFactor.TestRslt = chanelXMeterRslt.TestRslt;
|
||||
testRsltCalibFactor.TimeStart = genesisSmart.TimestampSecStartRawCh1;
|
||||
testRsltCalibFactor.TimeEnd = genesisSmart.TimestampSecEndRawCh1;
|
||||
testRsltCalibFactor.VolumeStart = genesisSmart.VolumeLtrStartRawCh1;
|
||||
testRsltCalibFactor.VolumeEnd = genesisSmart.VolumeLtrEndRawCh1;
|
||||
}catch (Exception ex)
|
||||
{
|
||||
//store in table
|
||||
testRsltCalibFactor = new TestRsltCalibFactor();
|
||||
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
|
||||
log.Error("Error in store to DB result set CH1", ex);
|
||||
}
|
||||
testRsltCalibFactor.TestRslt = chanelXMeterRslt.TestRslt;
|
||||
testRsltCalibFactor.TimeStart = genesisSmart.TimestampSecStartRawCh1;
|
||||
testRsltCalibFactor.TimeEnd = genesisSmart.TimestampSecEndRawCh1;
|
||||
testRsltCalibFactor.VolumeStart = genesisSmart.VolumeLtrStartRawCh1;
|
||||
testRsltCalibFactor.VolumeEnd = genesisSmart.VolumeLtrEndRawCh1;
|
||||
}
|
||||
else if (iCH == 1)
|
||||
{
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartRawCh2,
|
||||
genesisSmart.TimestampSecEndRawCh2, genesisSmart.VolumeLtrStartRawCh2, genesisSmart.VolumeLtrEndRawCh2);
|
||||
|
||||
TestRsltCalibFactor testRsltCalibFactor = null;
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 1)
|
||||
|
||||
try
|
||||
{
|
||||
testRsltCalibFactor = tstRslt.CalibFactorResultsToSave[1];
|
||||
}
|
||||
else
|
||||
TestRsltCalibFactor testRsltCalibFactor = null;
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 1)
|
||||
{
|
||||
testRsltCalibFactor = tstRslt.CalibFactorResultsToSave[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
//store in table
|
||||
testRsltCalibFactor = new TestRsltCalibFactor();
|
||||
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
|
||||
}
|
||||
|
||||
testRsltCalibFactor.TestRslt = chanelXMeterRslt.TestRslt;
|
||||
testRsltCalibFactor.TimeStart = genesisSmart.TimestampSecStartRawCh2;
|
||||
testRsltCalibFactor.TimeEnd = genesisSmart.TimestampSecEndRawCh2;
|
||||
testRsltCalibFactor.VolumeStart = genesisSmart.VolumeLtrStartRawCh2;
|
||||
testRsltCalibFactor.VolumeEnd = genesisSmart.VolumeLtrEndRawCh2;
|
||||
}catch (Exception ex)
|
||||
{
|
||||
//store in table
|
||||
testRsltCalibFactor = new TestRsltCalibFactor();
|
||||
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
|
||||
log.Error("Error in store to DB result set CH2", ex);
|
||||
}
|
||||
testRsltCalibFactor.TestRslt = chanelXMeterRslt.TestRslt;
|
||||
testRsltCalibFactor.TimeStart = genesisSmart.TimestampSecStartRawCh2;
|
||||
testRsltCalibFactor.TimeEnd = genesisSmart.TimestampSecEndRawCh2;
|
||||
testRsltCalibFactor.VolumeStart = genesisSmart.VolumeLtrStartRawCh2;
|
||||
testRsltCalibFactor.VolumeEnd = genesisSmart.VolumeLtrEndRawCh2;
|
||||
}
|
||||
else if (iCH == 2)
|
||||
{
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartRawCh3,
|
||||
genesisSmart.TimestampSecEndRawCh3, genesisSmart.VolumeLtrStartRawCh3, genesisSmart.VolumeLtrEndRawCh3);
|
||||
|
||||
TestRsltCalibFactor testRsltCalibFactor = null;
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 2)
|
||||
try
|
||||
{
|
||||
testRsltCalibFactor = tstRslt.CalibFactorResultsToSave[2];
|
||||
}
|
||||
else
|
||||
TestRsltCalibFactor testRsltCalibFactor = null;
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 2)
|
||||
{
|
||||
testRsltCalibFactor = tstRslt.CalibFactorResultsToSave[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
//store in table
|
||||
testRsltCalibFactor = new TestRsltCalibFactor();
|
||||
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
|
||||
}
|
||||
|
||||
testRsltCalibFactor.TestRslt = chanelXMeterRslt.TestRslt;
|
||||
testRsltCalibFactor.TimeStart = genesisSmart.TimestampSecStartRawCh3;
|
||||
testRsltCalibFactor.TimeEnd = genesisSmart.TimestampSecEndRawCh3;
|
||||
testRsltCalibFactor.VolumeStart = genesisSmart.VolumeLtrStartRawCh3;
|
||||
testRsltCalibFactor.VolumeEnd = genesisSmart.VolumeLtrEndRawCh3;
|
||||
}catch (Exception ex)
|
||||
{
|
||||
//store in table
|
||||
testRsltCalibFactor = new TestRsltCalibFactor();
|
||||
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
|
||||
log.Error("Error in store to DB result set CH3", ex);
|
||||
}
|
||||
testRsltCalibFactor.TestRslt = chanelXMeterRslt.TestRslt;
|
||||
testRsltCalibFactor.TimeStart = genesisSmart.TimestampSecStartRawCh3;
|
||||
testRsltCalibFactor.TimeEnd = genesisSmart.TimestampSecEndRawCh3;
|
||||
testRsltCalibFactor.VolumeStart = genesisSmart.VolumeLtrStartRawCh3;
|
||||
testRsltCalibFactor.VolumeEnd = genesisSmart.VolumeLtrEndRawCh3;
|
||||
}
|
||||
|
||||
if (!genesisSmart.EnableShowChanels)
|
||||
@ -1071,18 +1094,29 @@ namespace TBF.Rig.TestMethods.FlyingStart
|
||||
|
||||
private static void CalculateMeterResults(MeterTestRslt meterRslt, IRegReaderDatastream dstrReader, TestRslt tstRslt, double dstrReaderTimestampSecStart, double dstrReaderTimestampSecEnd, double dstrReaderVolumeLtrStart, double dstrReaderVolumeLtrEnd)
|
||||
{
|
||||
meterRslt.TimestampStart = dstrReaderTimestampSecStart;
|
||||
meterRslt.TimestampEnd = !dstrReader.NoSamples
|
||||
? dstrReaderTimestampSecEnd
|
||||
: (dstrReaderTimestampSecStart + tstRslt.TestTime);
|
||||
meterRslt.TestTime = meterRslt.TimestampEnd - meterRslt.TimestampStart;
|
||||
meterRslt.VolumeStart = dstrReaderVolumeLtrStart; /// liter
|
||||
meterRslt.VolumeEnd = dstrReaderVolumeLtrEnd; /// liter
|
||||
meterRslt.VolumeMeter =
|
||||
Math.Abs(dstrReaderVolumeLtrEnd - dstrReaderVolumeLtrStart);
|
||||
meterRslt.VolumeRef = tstRslt.TestTime==0? tstRslt.VolumeCTV : tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
|
||||
meterRslt.PulsesMaster = tstRslt.TestTime == 0? tstRslt.PulsesMaster :
|
||||
tstRslt.PulsesMaster * meterRslt.TestTime / tstRslt.TestTime;
|
||||
try
|
||||
{
|
||||
meterRslt.TimestampStart = dstrReaderTimestampSecStart;
|
||||
meterRslt.TimestampEnd = !dstrReader.NoSamples
|
||||
? dstrReaderTimestampSecEnd
|
||||
: (dstrReaderTimestampSecStart + tstRslt.TestTime);
|
||||
meterRslt.TestTime = meterRslt.TimestampEnd - meterRslt.TimestampStart;
|
||||
meterRslt.VolumeStart = dstrReaderVolumeLtrStart; /// liter
|
||||
meterRslt.VolumeEnd = dstrReaderVolumeLtrEnd; /// liter
|
||||
meterRslt.VolumeMeter =
|
||||
Math.Abs(dstrReaderVolumeLtrEnd - dstrReaderVolumeLtrStart);
|
||||
meterRslt.VolumeRef = tstRslt.TestTime == 0
|
||||
? tstRslt.VolumeCTV
|
||||
: tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
|
||||
meterRslt.PulsesMaster = tstRslt.TestTime == 0
|
||||
? tstRslt.PulsesMaster
|
||||
: tstRslt.PulsesMaster * meterRslt.TestTime / tstRslt.TestTime;
|
||||
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter,
|
||||
meterRslt.VolumeRef); // Error based on volume difference
|
||||
}catch(Exception ex)
|
||||
{
|
||||
log.Error($"Error in calculate meter results, meterRslt.Name:{meterRslt.Name()} Calculation Bug Detail:", ex);
|
||||
}
|
||||
}
|
||||
|
||||
IList<Event> Simulate(Config.Entities.Test test, int repetitionNr, bool isLastRepetition,
|
||||
@ -1108,6 +1142,14 @@ namespace TBF.Rig.TestMethods.FlyingStart
|
||||
else if (test.Name.ToLower().Contains("q2")) MakeSimulated(test, 1, 0, 0.5f);
|
||||
else if (test.Name.ToLower().Contains("q1")) MakeSimulated(test, 1, 0, -5.1f);
|
||||
else MakeSimulated(test, 1, 0, 0.9f);
|
||||
|
||||
//TODO bumi do simulate foe Q3 Calibration
|
||||
///
|
||||
/// Single meters
|
||||
///
|
||||
SimulateQ3CalibrationData(test,1, 0, -5.1f);
|
||||
|
||||
|
||||
|
||||
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Completed));
|
||||
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, BatchRslts.GetTestRslt(Results.Utils.GetTestName(test.Name, 1, 1), 0)));
|
||||
@ -1124,5 +1166,46 @@ namespace TBF.Rig.TestMethods.FlyingStart
|
||||
|
||||
return new List<Event> { TestAndLogUiCmdStop(test, e) ? Event.UiCmdStop : Event.Done };
|
||||
}
|
||||
|
||||
private void SimulateQ3CalibrationData(Test test,int repetitionNr, int part, float errorPctBase)
|
||||
{
|
||||
string testName = test.Name;
|
||||
string fullTestName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
|
||||
|
||||
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(fullTestName, part);
|
||||
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
|
||||
|
||||
|
||||
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
|
||||
{
|
||||
if (!test.IsPartCompatible(Utils.PartNr(i + 1, BatchRslts.Batch.Compound))) continue;
|
||||
|
||||
Results.Entities.MeterTestRslt meterRslt =
|
||||
BatchRslts.GetMeterTestRslt(testName, i, Common.CompoundMeterId.Single);
|
||||
GenericDevices.IRegReader regReader = sensPath.RegisterReaders[i];
|
||||
TBF.Rig.RegisterReaders.GenesisRegReader.implementations.GenesisSmartReader GenesisSmart =
|
||||
regReader as TBF.Rig.RegisterReaders.GenesisRegReader.implementations.GenesisSmartReader;
|
||||
|
||||
|
||||
if (GenesisSmart != null)
|
||||
{
|
||||
log.Debug("GenesisSmart - store data on end!");
|
||||
int CH1 = 0, CH2 = 1, CH3 = 2;
|
||||
|
||||
CalculateMeterResults(meterRslt, GenesisSmart, tstRslt, GenesisSmart.TimestampSecStart,
|
||||
GenesisSmart.TimestampSecEnd, GenesisSmart.VolumeLtrStart, GenesisSmart.VolumeLtrEnd);
|
||||
|
||||
//Init Calculate Calibration
|
||||
GenesisSmart.RefVolume = meterRslt.VolumeRef;
|
||||
GenesisSmart.RefTime = meterRslt.TestTime;
|
||||
|
||||
//Store Raw Calibration Data to database
|
||||
WaterMeterParentCopy(i, CH1, testName, meterRslt, GenesisSmart, tstRslt);
|
||||
WaterMeterParentCopy(i, CH2, testName, meterRslt, GenesisSmart, tstRslt);
|
||||
WaterMeterParentCopy(i, CH3, testName, meterRslt, GenesisSmart, tstRslt);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ using TBF.Rig.GenericDevices;
|
||||
using TBF.Rig.RegisterReaders.GenesisRegReader.implementations;
|
||||
using TBF.Rig.RegisterReaders.PoseidonReader;
|
||||
using TBF.Rig.RegisterReaders.PoseidonReader.implementations;
|
||||
using TBF.Rig.Sequences;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
|
||||
using TBF.UiBridge;
|
||||
|
||||
@ -1353,154 +1354,211 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection
|
||||
GenesisSmartReader genesisSmart,
|
||||
TestRslt tstRslt)
|
||||
{
|
||||
WaterMeter waterMeterParent = BatchRslts.Batch.WaterMeters[i];
|
||||
int wmNrChX = (i*CountCh) + BatchRslts.WMPositionsCount + iCH + 1;
|
||||
String sSerialNr = waterMeterParent.SerialNr + "_CH" + (iCH + 1);
|
||||
WaterMeter chXWaterMeter = null;
|
||||
//------ add new water meter to batch ------
|
||||
if (BatchRslts.Batch.WaterMeters.Count < wmNrChX || BatchRslts.Batch.WaterMeters[wmNrChX-1] == null)
|
||||
try
|
||||
{
|
||||
log.Debug("add new water meter to batch, CH = " + (iCH + 1) + " CH = " + wmNrChX);
|
||||
chXWaterMeter = new WaterMeter()
|
||||
WaterMeter waterMeterParent = BatchRslts.Batch.WaterMeters[i];
|
||||
int wmNrChX = (i * CountCh) + BatchRslts.WMPositionsCount + iCH + 1;
|
||||
String sSerialNr =
|
||||
(string.IsNullOrEmpty(waterMeterParent.SerialNr) ? (i+1).ToString() : waterMeterParent.SerialNr) +
|
||||
"_CH" + (iCH + 1);
|
||||
WaterMeter chXWaterMeter = null;
|
||||
//------ add new water meter to batch ------
|
||||
if (BatchRslts.Batch.WaterMeters.Count < wmNrChX || BatchRslts.Batch.WaterMeters[wmNrChX - 1] == null)
|
||||
{
|
||||
Batch = BatchRslts.Batch,
|
||||
WaterMeterData = waterMeterParent.WaterMeterData,
|
||||
MeterTestRslts = new List<MeterTestRslt>(),
|
||||
SerialNr = sSerialNr,
|
||||
WMPosition = wmNrChX,
|
||||
YearOfProduction = 0,
|
||||
Disabled = false,
|
||||
};
|
||||
chXWaterMeter.CopyContentFrom(waterMeterParent);
|
||||
log.Debug("add new water meter to batch, CH = " + (iCH + 1) + " CH = " + wmNrChX);
|
||||
chXWaterMeter = new WaterMeter()
|
||||
{
|
||||
MeterTestRslts = new List<MeterTestRslt>(),
|
||||
};
|
||||
//This will delete each setting before
|
||||
chXWaterMeter.CopyContentFrom(waterMeterParent);
|
||||
|
||||
chXWaterMeter.SerialNr = sSerialNr;
|
||||
chXWaterMeter.WMPosition = wmNrChX;
|
||||
chXWaterMeter.YearOfProduction = waterMeterParent.YearOfProduction;
|
||||
chXWaterMeter.Disabled = false;
|
||||
chXWaterMeter.Batch = BatchRslts.Batch;
|
||||
chXWaterMeter.WaterMeterData = waterMeterParent.WaterMeterData;
|
||||
|
||||
chXWaterMeter.SerialNr = sSerialNr;
|
||||
chXWaterMeter.WMPosition = wmNrChX;
|
||||
chXWaterMeter.Q3Channel = iCH+1;
|
||||
chXWaterMeter.YearOfProduction = waterMeterParent.YearOfProduction;
|
||||
chXWaterMeter.Disabled = false;
|
||||
|
||||
|
||||
BatchRslts.Batch.WaterMeters.Add(chXWaterMeter);
|
||||
}
|
||||
else
|
||||
{
|
||||
chXWaterMeter = BatchRslts.Batch.WaterMeters[wmNrChX-1];
|
||||
}
|
||||
//~------ add new water meter to batch ------~
|
||||
|
||||
//create copy of meterRslt and add to additionalResultsByChannel
|
||||
MeterTestRslt meterTestRsltChX = new MeterTestRslt(chXWaterMeter, meterRslt.TestRslt, (CompoundMeterId)meterRslt.CompoundMeterId);
|
||||
chXWaterMeter.MeterTestRslts.Add(meterTestRsltChX);
|
||||
MeterTestRslt chanelXMeterRslt = BatchRslts.GetMeterTestRslt(testName, wmNrChX-1, Common.CompoundMeterId.Single);
|
||||
|
||||
if (chanelXMeterRslt != null)
|
||||
{
|
||||
chanelXMeterRslt?.CopyContentFrom(meterRslt);
|
||||
if (iCH == 0)
|
||||
{
|
||||
chanelXMeterRslt.Q3Channel = 1;
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartRawCh1,
|
||||
genesisSmart.TimestampSecEndRawCh1, genesisSmart.VolumeLtrStartRawCh1, genesisSmart.VolumeLtrEndRawCh1);
|
||||
|
||||
TestRsltCalibFactor testRsltCalibFactor = null;
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 0)
|
||||
{
|
||||
testRsltCalibFactor = tstRslt.CalibFactorResultsToSave[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
//store in table
|
||||
testRsltCalibFactor = new TestRsltCalibFactor();
|
||||
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
|
||||
testRsltCalibFactor.CalibFactorIndex = 1;
|
||||
}
|
||||
|
||||
testRsltCalibFactor.TestRslt = chanelXMeterRslt.TestRslt;
|
||||
testRsltCalibFactor.TimeStart = genesisSmart.TimestampSecStartRawCh1;
|
||||
testRsltCalibFactor.TimeEnd = genesisSmart.TimestampSecEndRawCh1;
|
||||
testRsltCalibFactor.VolumeStart = genesisSmart.VolumeLtrStartRawCh1;
|
||||
testRsltCalibFactor.VolumeEnd = genesisSmart.VolumeLtrEndRawCh1;
|
||||
testRsltCalibFactor.Error = chanelXMeterRslt.Error;
|
||||
}
|
||||
else if (iCH == 1)
|
||||
{
|
||||
chanelXMeterRslt.Q3Channel = 2;
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartRawCh2,
|
||||
genesisSmart.TimestampSecEndRawCh2, genesisSmart.VolumeLtrStartRawCh2, genesisSmart.VolumeLtrEndRawCh2);
|
||||
|
||||
TestRsltCalibFactor testRsltCalibFactor = null;
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 1)
|
||||
{
|
||||
testRsltCalibFactor = tstRslt.CalibFactorResultsToSave[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
//store in table
|
||||
testRsltCalibFactor = new TestRsltCalibFactor();
|
||||
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
|
||||
testRsltCalibFactor.CalibFactorIndex = 2;
|
||||
}
|
||||
|
||||
testRsltCalibFactor.TestRslt = chanelXMeterRslt.TestRslt;
|
||||
testRsltCalibFactor.TimeStart = genesisSmart.TimestampSecStartRawCh2;
|
||||
testRsltCalibFactor.TimeEnd = genesisSmart.TimestampSecEndRawCh2;
|
||||
testRsltCalibFactor.VolumeStart = genesisSmart.VolumeLtrStartRawCh2;
|
||||
testRsltCalibFactor.VolumeEnd = genesisSmart.VolumeLtrEndRawCh2;
|
||||
testRsltCalibFactor.Error = chanelXMeterRslt.Error;
|
||||
}
|
||||
else if (iCH == 2)
|
||||
{
|
||||
chanelXMeterRslt.Q3Channel = 3;
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartRawCh3,
|
||||
genesisSmart.TimestampSecEndRawCh3, genesisSmart.VolumeLtrStartRawCh3, genesisSmart.VolumeLtrEndRawCh3);
|
||||
|
||||
TestRsltCalibFactor testRsltCalibFactor = null;
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 2)
|
||||
{
|
||||
testRsltCalibFactor = tstRslt.CalibFactorResultsToSave[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
//store in table
|
||||
testRsltCalibFactor = new TestRsltCalibFactor();
|
||||
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
|
||||
testRsltCalibFactor.CalibFactorIndex = 3;
|
||||
}
|
||||
|
||||
testRsltCalibFactor.TestRslt = chanelXMeterRslt.TestRslt;
|
||||
testRsltCalibFactor.TimeStart = genesisSmart.TimestampSecStartRawCh3;
|
||||
testRsltCalibFactor.TimeEnd = genesisSmart.TimestampSecEndRawCh3;
|
||||
testRsltCalibFactor.VolumeStart = genesisSmart.VolumeLtrStartRawCh3;
|
||||
testRsltCalibFactor.VolumeEnd = genesisSmart.VolumeLtrEndRawCh3;
|
||||
testRsltCalibFactor.Error = chanelXMeterRslt.Error;
|
||||
}
|
||||
|
||||
if (!genesisSmart.EnableShowChanels)
|
||||
{
|
||||
chXWaterMeter.Disabled = !genesisSmart.EnableShowChanels;
|
||||
meterTestRsltChX.TestDone = false;
|
||||
BatchRslts.Batch.WaterMeters.Add(chXWaterMeter);
|
||||
}
|
||||
else
|
||||
{
|
||||
meterTestRsltChX.TestDone = true;
|
||||
chXWaterMeter = BatchRslts.Batch.WaterMeters[wmNrChX - 1];
|
||||
|
||||
|
||||
chXWaterMeter.Batch = BatchRslts.Batch;
|
||||
chXWaterMeter.WaterMeterData = waterMeterParent.WaterMeterData;
|
||||
chXWaterMeter.SerialNr = sSerialNr;
|
||||
chXWaterMeter.WMPosition = wmNrChX;
|
||||
chXWaterMeter.Q3Channel = iCH+1;
|
||||
chXWaterMeter.YearOfProduction = waterMeterParent.YearOfProduction;
|
||||
chXWaterMeter.Disabled = false;
|
||||
}
|
||||
//~------ add new water meter to batch ------~
|
||||
|
||||
meterTestRsltChX.Passed = meterRslt.Passed;
|
||||
//create copy of meterRslt and add to additionalResultsByChannel
|
||||
MeterTestRslt meterTestRsltChX = new MeterTestRslt(chXWaterMeter, meterRslt.TestRslt,
|
||||
(CompoundMeterId)meterRslt.CompoundMeterId);
|
||||
chXWaterMeter.MeterTestRslts.Add(meterTestRsltChX);
|
||||
MeterTestRslt chanelXMeterRslt =
|
||||
BatchRslts.GetMeterTestRslt(testName, wmNrChX - 1, Common.CompoundMeterId.Single);
|
||||
|
||||
if (chanelXMeterRslt != null)
|
||||
{
|
||||
chanelXMeterRslt?.CopyContentFrom(meterRslt);
|
||||
if (iCH == 0)
|
||||
{
|
||||
chanelXMeterRslt.Q3Channel = 1;
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt,
|
||||
genesisSmart.TimestampSecStartRawCh1,
|
||||
genesisSmart.TimestampSecEndRawCh1, genesisSmart.VolumeLtrStartRawCh1,
|
||||
genesisSmart.VolumeLtrEndRawCh1);
|
||||
|
||||
try
|
||||
{
|
||||
TestRsltCalibFactor testRsltCalibFactor = null;
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 0)
|
||||
{
|
||||
testRsltCalibFactor = tstRslt.CalibFactorResultsToSave[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
//store in table
|
||||
testRsltCalibFactor = new TestRsltCalibFactor();
|
||||
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
|
||||
testRsltCalibFactor.CalibFactorIndex = 1;
|
||||
}
|
||||
|
||||
testRsltCalibFactor.TestRslt = chanelXMeterRslt.TestRslt;
|
||||
testRsltCalibFactor.TimeStart = genesisSmart.TimestampSecStartRawCh1;
|
||||
testRsltCalibFactor.TimeEnd = genesisSmart.TimestampSecEndRawCh1;
|
||||
testRsltCalibFactor.VolumeStart = genesisSmart.VolumeLtrStartRawCh1;
|
||||
testRsltCalibFactor.VolumeEnd = genesisSmart.VolumeLtrEndRawCh1;
|
||||
testRsltCalibFactor.Error = chanelXMeterRslt.Error;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error("Error in store to DB result set CH1", ex);
|
||||
}
|
||||
}
|
||||
else if (iCH == 1)
|
||||
{
|
||||
chanelXMeterRslt.Q3Channel = 2;
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt,
|
||||
genesisSmart.TimestampSecStartRawCh2,
|
||||
genesisSmart.TimestampSecEndRawCh2, genesisSmart.VolumeLtrStartRawCh2,
|
||||
genesisSmart.VolumeLtrEndRawCh2);
|
||||
try
|
||||
{
|
||||
|
||||
TestRsltCalibFactor testRsltCalibFactor = null;
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 1)
|
||||
{
|
||||
testRsltCalibFactor = tstRslt.CalibFactorResultsToSave[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
//store in table
|
||||
testRsltCalibFactor = new TestRsltCalibFactor();
|
||||
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
|
||||
testRsltCalibFactor.CalibFactorIndex = 2;
|
||||
}
|
||||
|
||||
testRsltCalibFactor.TestRslt = chanelXMeterRslt.TestRslt;
|
||||
testRsltCalibFactor.TimeStart = genesisSmart.TimestampSecStartRawCh2;
|
||||
testRsltCalibFactor.TimeEnd = genesisSmart.TimestampSecEndRawCh2;
|
||||
testRsltCalibFactor.VolumeStart = genesisSmart.VolumeLtrStartRawCh2;
|
||||
testRsltCalibFactor.VolumeEnd = genesisSmart.VolumeLtrEndRawCh2;
|
||||
testRsltCalibFactor.Error = chanelXMeterRslt.Error;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error("Error in store to DB result set CH2", ex);
|
||||
}
|
||||
}
|
||||
else if (iCH == 2)
|
||||
{
|
||||
chanelXMeterRslt.Q3Channel = 3;
|
||||
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt,
|
||||
genesisSmart.TimestampSecStartRawCh3,
|
||||
genesisSmart.TimestampSecEndRawCh3, genesisSmart.VolumeLtrStartRawCh3,
|
||||
genesisSmart.VolumeLtrEndRawCh3);
|
||||
|
||||
try
|
||||
{
|
||||
TestRsltCalibFactor testRsltCalibFactor = null;
|
||||
if (tstRslt.CalibFactorResultsToSave.Count > 2)
|
||||
{
|
||||
testRsltCalibFactor = tstRslt.CalibFactorResultsToSave[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
//store in table
|
||||
testRsltCalibFactor = new TestRsltCalibFactor();
|
||||
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
|
||||
testRsltCalibFactor.CalibFactorIndex = 3;
|
||||
}
|
||||
|
||||
testRsltCalibFactor.TestRslt = chanelXMeterRslt.TestRslt;
|
||||
testRsltCalibFactor.TimeStart = genesisSmart.TimestampSecStartRawCh3;
|
||||
testRsltCalibFactor.TimeEnd = genesisSmart.TimestampSecEndRawCh3;
|
||||
testRsltCalibFactor.VolumeStart = genesisSmart.VolumeLtrStartRawCh3;
|
||||
testRsltCalibFactor.VolumeEnd = genesisSmart.VolumeLtrEndRawCh3;
|
||||
testRsltCalibFactor.Error = chanelXMeterRslt.Error;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error("Error in store to DB result set CH3", ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!genesisSmart.EnableShowChanels)
|
||||
{
|
||||
chXWaterMeter.Disabled = !genesisSmart.EnableShowChanels;
|
||||
//meterTestRsltChX.TestDone = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
chXWaterMeter.Disabled = false;
|
||||
meterTestRsltChX.TestDone = true;
|
||||
}
|
||||
|
||||
meterTestRsltChX.Passed = meterRslt.Passed;
|
||||
}
|
||||
}catch(Exception ex)
|
||||
{
|
||||
log.Error("Error in WaterMeterParentCopy", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CalculateMeterResults(MeterTestRslt meterRslt, IRegReaderDatastream dstrReader, TestRslt tstRslt, double dstrReaderTimestampSecStart, double dstrReaderTimestampSecEnd, double dstrReaderVolumeLtrStart, double dstrReaderVolumeLtrEnd)
|
||||
{
|
||||
meterRslt.TimestampStart = dstrReaderTimestampSecStart;
|
||||
meterRslt.TimestampEnd = !dstrReader.NoSamples
|
||||
? dstrReaderTimestampSecEnd
|
||||
: (dstrReaderTimestampSecStart + tstRslt.TestTime);
|
||||
meterRslt.TestTime = meterRslt.TimestampEnd - meterRslt.TimestampStart;
|
||||
meterRslt.VolumeStart = dstrReaderVolumeLtrStart; /// liter
|
||||
meterRslt.VolumeEnd = dstrReaderVolumeLtrEnd; /// liter
|
||||
meterRslt.VolumeMeter = Math.Abs(dstrReaderVolumeLtrEnd - dstrReaderVolumeLtrStart);
|
||||
meterRslt.VolumeRef = tstRslt.TestTime==0? tstRslt.VolumeCTV : tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
|
||||
meterRslt.PulsesMaster = tstRslt.TestTime == 0? tstRslt.PulsesMaster :
|
||||
tstRslt.PulsesMaster * meterRslt.TestTime / tstRslt.TestTime;
|
||||
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); // Error based on volume difference
|
||||
try
|
||||
{
|
||||
meterRslt.TimestampStart = dstrReaderTimestampSecStart;
|
||||
meterRslt.TimestampEnd = !dstrReader.NoSamples
|
||||
? dstrReaderTimestampSecEnd
|
||||
: (dstrReaderTimestampSecStart + tstRslt.TestTime);
|
||||
meterRslt.TestTime = meterRslt.TimestampEnd - meterRslt.TimestampStart;
|
||||
meterRslt.VolumeStart = dstrReaderVolumeLtrStart; /// liter
|
||||
meterRslt.VolumeEnd = dstrReaderVolumeLtrEnd; /// liter
|
||||
meterRslt.VolumeMeter = Math.Abs(dstrReaderVolumeLtrEnd - dstrReaderVolumeLtrStart);
|
||||
meterRslt.VolumeRef = tstRslt.TestTime == 0
|
||||
? tstRslt.VolumeCTV
|
||||
: tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
|
||||
meterRslt.PulsesMaster = tstRslt.TestTime == 0
|
||||
? tstRslt.PulsesMaster
|
||||
: tstRslt.PulsesMaster * meterRslt.TestTime / tstRslt.TestTime;
|
||||
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter,
|
||||
meterRslt.VolumeRef); // Error based on volume difference
|
||||
}catch(Exception ex)
|
||||
{
|
||||
log.Error($"Error in calculate meter results, meterRslt.Name:{meterRslt.Name()} Calculation Bug Detail:", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1543,6 +1601,12 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection
|
||||
|
||||
MakeSimulated(test, repetitionNr, test.Part, errorPctBase + repetitionNr * 0.1f);
|
||||
}
|
||||
|
||||
//TODO bumi do simulate foe Q3 Calibration
|
||||
///
|
||||
/// Single meters
|
||||
///
|
||||
SimulateQ3CalibrationData(test,1, 0, -5.1f);
|
||||
|
||||
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Completed));
|
||||
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, BatchRslts.GetTestRslt(Results.Utils.GetTestName(test.Name, 1, 1), 0)));
|
||||
@ -1560,6 +1624,64 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection
|
||||
return new List<Event> { TestAndLogUiCmdStop(test, e) ? Event.UiCmdStop : Event.Done };
|
||||
}
|
||||
|
||||
private void SimulateQ3CalibrationData(Test test,int repetitionNr, int part, float errorPctBase)
|
||||
{
|
||||
string testName = test.Name;
|
||||
string fullTestName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
|
||||
|
||||
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(fullTestName, part);
|
||||
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
|
||||
|
||||
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
|
||||
{
|
||||
if (WaterMeters.Count > i && WaterMeters[i] != null)
|
||||
WaterMeters[i].SerialNr = "Simul_" + (i + 1).ToString();
|
||||
}
|
||||
|
||||
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
|
||||
{
|
||||
if (!test.IsPartCompatible(Utils.PartNr(i + 1, BatchRslts.Batch.Compound))) continue;
|
||||
|
||||
Results.Entities.MeterTestRslt meterRslt =
|
||||
BatchRslts.GetEachMeterTestRslt(testName, i, Common.CompoundMeterId.Single);
|
||||
if (meterRslt == null) continue;
|
||||
if (meterRslt?.WaterMeter == null) continue;
|
||||
if (string.IsNullOrEmpty(meterRslt.WaterMeter.SerialNr))
|
||||
{
|
||||
meterRslt.WaterMeter.SerialNr = "Simul_" + (i + 1).ToString();
|
||||
meterRslt.WaterMeter.SerialNrAux = "Simul_" + (i + 1).ToString();
|
||||
log.Debug("Simul_SerialNr: " + meterRslt.WaterMeter.SerialNr);
|
||||
}
|
||||
|
||||
GenericDevices.IRegReader regReader = sensPath.RegisterReaders[i];
|
||||
TBF.Rig.RegisterReaders.GenesisRegReader.implementations.GenesisSmartReader GenesisSmart =
|
||||
regReader as TBF.Rig.RegisterReaders.GenesisRegReader.implementations.GenesisSmartReader;
|
||||
|
||||
|
||||
if (GenesisSmart != null)
|
||||
{
|
||||
log.Debug("GenesisSmart - store data on end!");
|
||||
int CH1 = 0, CH2 = 1, CH3 = 2;
|
||||
|
||||
CalculateMeterResults(meterRslt, GenesisSmart, tstRslt, GenesisSmart.TimestampSecStart,
|
||||
GenesisSmart.TimestampSecEnd, GenesisSmart.VolumeLtrStart, GenesisSmart.VolumeLtrEnd);
|
||||
|
||||
//Init Calculate Calibration
|
||||
GenesisSmart.RefVolume = meterRslt.VolumeRef;
|
||||
GenesisSmart.RefTime = meterRslt.TestTime;
|
||||
|
||||
//Store Raw Calibration Data to database
|
||||
WaterMeterParentCopy(i, CH1, testName, meterRslt, GenesisSmart, tstRslt);
|
||||
log.Debug($"GenesisSmart - i:{i}, CH1:{CH1}, testName:{testName}, meterRslt:{meterRslt.Id}, GenesisSmart:{GenesisSmart.Name}, tstRslt:{tstRslt.Id}");
|
||||
WaterMeterParentCopy(i, CH2, testName, meterRslt, GenesisSmart, tstRslt);
|
||||
log.Debug($"GenesisSmart - i:{i}, CH2:{CH2}, testName:{testName}, meterRslt:{meterRslt.Id}, GenesisSmart:{GenesisSmart.Name}, tstRslt:{tstRslt.Id}");
|
||||
WaterMeterParentCopy(i, CH3, testName, meterRslt, GenesisSmart, tstRslt);
|
||||
log.Debug($"GenesisSmart - i:{i}, CH3:{CH3}, testName:{testName}, meterRslt:{meterRslt.Id}, GenesisSmart:{GenesisSmart.Name}, tstRslt:{tstRslt.Id}");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IList<Event> Simulate2(Config.Entities.Test test, int repetitionNr, bool isLastRepetition,
|
||||
Compound.CombinedTestParams compoundTestParams,
|
||||
|
||||
@ -48,6 +48,16 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection.Single
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (DebugLevel == DebugMode.Simulate &&
|
||||
test.Name.ToLower().Contains("q3")
|
||||
)
|
||||
{
|
||||
//Q3 Test - calibration data
|
||||
return new FlyingStartMassCollectionSeq().Execute(test, repetNr, isLastRepetition,
|
||||
testMethodCfg.TestParams.DelayedStart, null, null, DebugLevel);
|
||||
}
|
||||
|
||||
/// DebugLevel == DebugMode.Simulate
|
||||
(new FlyingStartMassCollectionSeq()).MakeSimulatedTrivial(test, repetNr, test.Part);
|
||||
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetNr, Progress.Completed));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user