|
|
|
@@ -47,6 +47,12 @@ namespace TBF.BenchControl.TestMethods.Adjustment
|
|
|
|
|
modelessDlg.Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CloseWMErrorsForm()
|
|
|
|
|
{
|
|
|
|
|
UiBridge.Bridge.OnCloseModelessForm(this, null);
|
|
|
|
|
modelessDlg = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adjustment method sequence
|
|
|
|
|
/// </summary>
|
|
|
|
@@ -321,10 +327,6 @@ namespace TBF.BenchControl.TestMethods.Adjustment
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
if (mode == Config.Entities.DebugMode.Simulate)
|
|
|
|
|
{
|
|
|
|
|
/// TODO: Reimplement
|
|
|
|
|
//tstRslt = MakeSimulated(test, 1, simulatedError);
|
|
|
|
|
simulatedError *= 0.6f;
|
|
|
|
|
|
|
|
|
|
State.Create(string.Format("{0}({1}) : Simulating the test", test.Method, test.Name))
|
|
|
|
|
.AddOperation(checkUiOp)
|
|
|
|
|
.AddOperations(readTempPressOps)
|
|
|
|
@@ -332,8 +334,16 @@ namespace TBF.BenchControl.TestMethods.Adjustment
|
|
|
|
|
.EnterState();
|
|
|
|
|
do {
|
|
|
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
if (e.Contains(Event.Error))
|
|
|
|
|
{
|
|
|
|
|
retVal = Event.Error;
|
|
|
|
|
goto stopTest;
|
|
|
|
|
}
|
|
|
|
|
if (TestAndLogUiCmdStop(test,e))
|
|
|
|
|
{
|
|
|
|
|
retVal = Event.UiCmdStop;
|
|
|
|
|
goto stopTest;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (!e.Contains(Event.TimerExpired));
|
|
|
|
|
}
|
|
|
|
@@ -365,9 +375,18 @@ namespace TBF.BenchControl.TestMethods.Adjustment
|
|
|
|
|
//--------------------------------
|
|
|
|
|
switch (ReadRegistersTempPressAmbient(measureOperations, true))
|
|
|
|
|
{
|
|
|
|
|
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
|
|
|
|
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
|
|
|
|
case Event.MeasurementCompleted: goto one_test_completed;
|
|
|
|
|
case Event.Error:
|
|
|
|
|
{
|
|
|
|
|
retVal = Event.Error;
|
|
|
|
|
goto stopTest;
|
|
|
|
|
}
|
|
|
|
|
case Event.UiCmdStop:
|
|
|
|
|
{
|
|
|
|
|
retVal = Event.UiCmdStop;
|
|
|
|
|
goto stopTest;
|
|
|
|
|
}
|
|
|
|
|
case Event.MeasurementCompleted:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RefFreq.Val = cBrd.ReferenceFreq;
|
|
|
|
@@ -377,113 +396,134 @@ namespace TBF.BenchControl.TestMethods.Adjustment
|
|
|
|
|
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
|
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
|
|
|
|
|
}
|
|
|
|
|
/// Measurement loop - end
|
|
|
|
|
/// Measurement loop - end
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
one_test_completed:
|
|
|
|
|
one_test_completed:
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
Bridge.OnActivity(this, Strings.Adjustment_in_progress);
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
Bridge.OnActivity(this, Strings.Adjustment_in_progress);
|
|
|
|
|
//------------------------------------------------
|
|
|
|
|
|
|
|
|
|
TestEndTime = DateTime.Now;
|
|
|
|
|
TestEndTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
|
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
|
|
|
|
|
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
|
|
|
|
|
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// Populate TestResult data entity with data
|
|
|
|
|
///
|
|
|
|
|
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
|
|
|
|
|
///
|
|
|
|
|
/// Populate TestResult data entity with data
|
|
|
|
|
///
|
|
|
|
|
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
|
|
|
|
|
|
|
|
|
|
if (tstRslt != null)
|
|
|
|
|
{
|
|
|
|
|
UpdateTempPressDensAmb(tstRslt);
|
|
|
|
|
if (tstRslt != null)
|
|
|
|
|
{
|
|
|
|
|
UpdateTempPressDensAmb(tstRslt);
|
|
|
|
|
|
|
|
|
|
/// Main results
|
|
|
|
|
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
|
|
|
|
|
tstRslt.StartTime = TestStartTime;
|
|
|
|
|
tstRslt.EndTime = TestEndTime;
|
|
|
|
|
tstRslt.FlowSetTime = flowSetTime;
|
|
|
|
|
tstRslt.TestTime = cBrd.TTime; /// [s] measurement time
|
|
|
|
|
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total)
|
|
|
|
|
tstRslt.MassStartRaw = 0;
|
|
|
|
|
tstRslt.MassStart = 0;
|
|
|
|
|
tstRslt.MassEndRaw = 0;
|
|
|
|
|
tstRslt.MassEnd = 0;
|
|
|
|
|
tstRslt.FlowMass = 0; /// [kg/h]
|
|
|
|
|
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
|
|
|
|
|
tstRslt.Buoyancy = Config.Formulas.Buoyancy();
|
|
|
|
|
tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
|
|
|
|
|
tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient
|
|
|
|
|
tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume, rangeIx); /// Corrected master pulses per liter
|
|
|
|
|
tstRslt.ConstMaster = tstRslt.ConstMasterCorr; /// Corrected master pulses per liter
|
|
|
|
|
tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3]
|
|
|
|
|
tstRslt.ErrorMaster = 0.0f; /// Cannot be determined without the collected water mass measurement
|
|
|
|
|
/// Main results
|
|
|
|
|
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
|
|
|
|
|
tstRslt.StartTime = TestStartTime;
|
|
|
|
|
tstRslt.EndTime = TestEndTime;
|
|
|
|
|
tstRslt.FlowSetTime = flowSetTime;
|
|
|
|
|
if (mode == Config.Entities.DebugMode.Simulate)
|
|
|
|
|
{
|
|
|
|
|
tstRslt.TestTime = tstRslt.TestData.TargetTime;
|
|
|
|
|
tstRslt.PulsesMaster = Convert.ToDouble(tstRslt.TestData.TargetVolume / LtrPerRefPulse);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tstRslt.TestTime = cBrd.TTime; /// [s] measurement time
|
|
|
|
|
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total)
|
|
|
|
|
}
|
|
|
|
|
tstRslt.MassStartRaw = 0;
|
|
|
|
|
tstRslt.MassStart = 0;
|
|
|
|
|
tstRslt.MassEndRaw = 0;
|
|
|
|
|
tstRslt.MassEnd = 0;
|
|
|
|
|
tstRslt.FlowMass = 0; /// [kg/h]
|
|
|
|
|
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
|
|
|
|
|
tstRslt.Buoyancy = Config.Formulas.Buoyancy();
|
|
|
|
|
tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
|
|
|
|
|
tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient
|
|
|
|
|
tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume, rangeIx); /// Corrected master pulses per liter
|
|
|
|
|
tstRslt.ConstMaster = tstRslt.ConstMasterCorr; /// Corrected master pulses per liter
|
|
|
|
|
tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3]
|
|
|
|
|
tstRslt.ErrorMaster = 0.0f; /// Cannot be determined without the collected water mass measurement
|
|
|
|
|
|
|
|
|
|
tstRslt.FlowMean = (float)RefFlowStat.Average;
|
|
|
|
|
tstRslt.FlowStart = (float)RefFlowStat.First;
|
|
|
|
|
tstRslt.FlowEnd = (float)RefFlowStat.Last;
|
|
|
|
|
tstRslt.FlowMin = (float)RefFlowStat.Min;
|
|
|
|
|
tstRslt.FlowMax = (float)RefFlowStat.Max;
|
|
|
|
|
tstRslt.FlowMean = (float)RefFlowStat.Average;
|
|
|
|
|
tstRslt.FlowStart = (float)RefFlowStat.First;
|
|
|
|
|
tstRslt.FlowEnd = (float)RefFlowStat.Last;
|
|
|
|
|
tstRslt.FlowMin = (float)RefFlowStat.Min;
|
|
|
|
|
tstRslt.FlowMax = (float)RefFlowStat.Max;
|
|
|
|
|
|
|
|
|
|
tstRslt.DiverterStart = 0;
|
|
|
|
|
tstRslt.DiverterEnd = 0;
|
|
|
|
|
tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0;
|
|
|
|
|
tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, false, 0, 0) : 0;
|
|
|
|
|
tstRslt.DiverterStart = 0;
|
|
|
|
|
tstRslt.DiverterEnd = 0;
|
|
|
|
|
tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0;
|
|
|
|
|
tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, false, 0, 0) : 0;
|
|
|
|
|
|
|
|
|
|
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, CompoundMeterId.Single);
|
|
|
|
|
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
|
|
|
|
|
|
|
|
|
|
if (meterRslt != null && regReader != null)
|
|
|
|
|
{
|
|
|
|
|
meterRslt.RegReaderType = (int)regReader.RegisterReaderType;
|
|
|
|
|
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
|
|
|
|
|
meterRslt.VolumeStart = 0; /// liter
|
|
|
|
|
meterRslt.VolumeEnd = 0; /// liter
|
|
|
|
|
|
|
|
|
|
if (mode == Config.Entities.DebugMode.Simulate)
|
|
|
|
|
{
|
|
|
|
|
meterRslt.PulsesMeter = tstRslt.VolumeCTV * (1.0 + (i - 5) * 0.001);
|
|
|
|
|
meterRslt.PulsesMaster = tstRslt.PulsesMaster;
|
|
|
|
|
meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse;
|
|
|
|
|
meterRslt.VolumeRef = tstRslt.VolumeCTV;
|
|
|
|
|
meterRslt.TestTime = tstRslt.TestTime;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses);
|
|
|
|
|
meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses);
|
|
|
|
|
meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter
|
|
|
|
|
meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter
|
|
|
|
|
meterRslt.TestTime = cBrd.ImpulseTime(i + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
meterRslt.Error = Config.Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
|
|
|
|
|
meterRslt.Passed = (meterRslt.Error >= test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime) + test.Uncertainty)
|
|
|
|
|
&& (meterRslt.Error <= test.GetErrLimHi(tstRslt.VolumeCTV, tstRslt.TestTime) - test.Uncertainty);
|
|
|
|
|
meterRslt.TestDone = true;
|
|
|
|
|
tstRslt.TestDone = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tstRslt.Components = Results.Entities.Components
|
|
|
|
|
.UpdateList(BatchRslts.ComponentsList,
|
|
|
|
|
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
|
|
|
|
|
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
|
|
|
|
|
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
|
|
|
|
|
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
|
|
|
|
|
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
|
|
|
|
|
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
|
|
|
|
|
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
|
|
|
|
|
|
|
|
|
|
/// Update water meter error flags
|
|
|
|
|
if (ErrorFlagsComp != null)
|
|
|
|
|
{
|
|
|
|
|
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, CompoundMeterId.Single);
|
|
|
|
|
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
|
|
|
|
|
|
|
|
|
|
if (meterRslt != null && regReader != null)
|
|
|
|
|
{
|
|
|
|
|
meterRslt.RegReaderType = (int)regReader.RegisterReaderType;
|
|
|
|
|
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
|
|
|
|
|
meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses);
|
|
|
|
|
meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses);
|
|
|
|
|
meterRslt.VolumeStart = 0; /// liter
|
|
|
|
|
meterRslt.VolumeEnd = 0; /// liter
|
|
|
|
|
meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter
|
|
|
|
|
meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter
|
|
|
|
|
meterRslt.TestTime = cBrd.ImpulseTime(i + 1);
|
|
|
|
|
meterRslt.Error = Config.Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
|
|
|
|
|
meterRslt.Passed = (meterRslt.Error >= test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime) + test.Uncertainty)
|
|
|
|
|
&& (meterRslt.Error <= test.GetErrLimHi(tstRslt.VolumeCTV, tstRslt.TestTime) - test.Uncertainty);
|
|
|
|
|
meterRslt.TestDone = true;
|
|
|
|
|
tstRslt.TestDone = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tstRslt.Components = Results.Entities.Components
|
|
|
|
|
.UpdateList(BatchRslts.ComponentsList,
|
|
|
|
|
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
|
|
|
|
|
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
|
|
|
|
|
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
|
|
|
|
|
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
|
|
|
|
|
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
|
|
|
|
|
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
|
|
|
|
|
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
|
|
|
|
|
|
|
|
|
|
/// Update water meter error flags
|
|
|
|
|
if (ErrorFlagsComp != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
|
|
|
|
|
if (BatchRslts.WaterMeters[i] != null)
|
|
|
|
|
{
|
|
|
|
|
if (BatchRslts.WaterMeters[i] != null)
|
|
|
|
|
{
|
|
|
|
|
BatchRslts.WaterMeters[i].ErrorFlags = ErrorFlagsComp.GetWMtrErrorFlags(BatchRslts.WaterMeters[i].MeterTestRslts);
|
|
|
|
|
}
|
|
|
|
|
BatchRslts.WaterMeters[i].ErrorFlags = ErrorFlagsComp.GetWMtrErrorFlags(BatchRslts.WaterMeters[i].MeterTestRslts);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Update results
|
|
|
|
|
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt));
|
|
|
|
|
}
|
|
|
|
|
/// Add data - end
|
|
|
|
|
/// Update results
|
|
|
|
|
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt));
|
|
|
|
|
}
|
|
|
|
|
/// Add data - end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Update modeless dialog error information
|
|
|
|
@@ -520,6 +560,11 @@ namespace TBF.BenchControl.TestMethods.Adjustment
|
|
|
|
|
|
|
|
|
|
stopTestWOStoppingDivGateEtc:
|
|
|
|
|
|
|
|
|
|
if (modelessDlg is GenericDevices.IHasCompleted && !(modelessDlg as GenericDevices.IHasCompleted).Completed)
|
|
|
|
|
{
|
|
|
|
|
CloseWMErrorsForm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new List<Event> { retVal };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|