2015-04-15 18:32:56 +00:00
///
2016-10-18 09:49:32 +00:00
/// Copyright (c) 2013-2016 Sensus Metering Systems
2015-04-15 18:32:56 +00:00
///
using System ;
2014-09-06 15:34:26 +00:00
using System.Collections.Generic ;
using System.Text ;
using log4net ;
using TBF.BenchControl ;
using TBF.Boxes ;
using TBF.Resources ;
using TBF.UiBridge ;
namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
{
public class ReferenceFlowmeterCalibrationSeq : Sequences . SequenceBase
{
private static readonly ILog log = LogManager . GetLogger ( typeof ( ReferenceFlowmeterCalibrationSeq ) ) ;
/// <summary>
/// Flying start mass collection method sequence
/// </summary>
/// <param name="test">Test entity</param>
/// <returns>
/// Event.Done . . . . . . . OK
/// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP
/// Event.OpArgumentError . Target flow is out of range
/// Event.Error . . . . . . Unspecified error
/// </returns>
2016-12-10 11:40:35 +00:00
public IList < Event > Execute ( Config . Entities . Test test , bool outerLoopMode , int outerLoopCounter )
2014-09-06 15:34:26 +00:00
{
Elde . ControlBoardDev cBrd = StateMachine . ControlBoard ;
2016-01-03 01:05:35 +00:00
IList < Event > e = new List < Event > ( ) ; /// Events from currently running operations
Event retVal = Event . Done ;
checkUiOp = new Operations . CheckUIOp ( true ) ; /// Runs in more then one state
2014-09-06 15:34:26 +00:00
2016-12-10 11:40:35 +00:00
LtrPerRefPulse = outPath . FlowMeter . LtrPerPulse ; /// [ltr/pulse], nominal flow in [m3/h]
2014-09-06 15:34:26 +00:00
2016-01-03 01:05:35 +00:00
/// Notes:
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
/// float timeSec = 3600.0f * timeHr;
/// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
2016-02-10 18:24:10 +00:00
int totalPulses = ( int ) ( test . Volume / LtrPerRefPulse + 0.5f ) ;
2014-09-06 15:34:26 +00:00
2016-10-18 09:49:32 +00:00
processDataLoggingOp = new TBF . BenchControl . Operations . ProcessDataLoggingOp ( processDataLogger , this , false ) ;
2016-01-03 01:05:35 +00:00
2016-12-10 11:40:35 +00:00
int repetitionNr = outerLoopMode ? outerLoopCounter : 1 ; /// First test: repetitionNr=1
2014-09-06 15:34:26 +00:00
//====================================
// Transition or SetRoute - Start
//====================================
2015-05-22 08:29:56 +00:00
switch ( Transition ( transitionBefore , TransitionContext . BeforeTest ) )
2014-09-06 15:34:26 +00:00
{
2016-01-03 01:05:35 +00:00
case Event . Error : { retVal = Event . Error ; goto stopTest ; }
case Event . UiCmdStop : { retVal = Event . UiCmdStop ; goto stopTest ; }
2014-09-06 15:34:26 +00:00
}
//====================================
2016-01-03 01:05:35 +00:00
loop :
2014-09-06 15:34:26 +00:00
/// Start the test, initialize test results
Bridge . OnTestSelected ( this , new TestSelectedEventArgs ( test , repetitionNr , inPath , benchPath , outPath , sensPath , totalPulses ) ) ;
2016-01-03 01:05:35 +00:00
string testName = Results . Utils . GetTestName ( test . Name , test . Repeats , repetitionNr ) ;
TestStartTime = DateTime . Now ;
2017-05-05 10:41:15 +00:00
TestProgressEventArgs . SetEstimatedTimes ( new int [ ] { 1 , 1 , 1 , 30 , 0 , Convert . ToInt32 ( test . TstTime ) + 15 , 0 , 0 } ) ;
2016-01-08 18:18:45 +00:00
Bridge . OnTestProgress ( this , new TestProgressEventArgs ( test , repetitionNr , Config . Entities . Progress . JustStarted ) ) ;
2014-09-06 15:34:26 +00:00
2016-01-08 18:18:45 +00:00
Bridge . OnTestProgress ( this , new TestProgressEventArgs ( test , repetitionNr , Config . Entities . Progress . FlowSetting ) ) ;
2015-02-01 18:30:00 +00:00
int flowSetTime0 = StateMachine . Time ;
//------------------------------------------------
Bridge . OnActivity ( this , Strings . Setting_the_flow ) ;
//------------------------------------------------
if ( inPath . Pump is GenericDevices . IPumpFM ) ( inPath . Pump as GenericDevices . IPumpFM ) . TurnOn ( test . PumpPower ) ;
State . Create ( "ReferenceFlowmeterCalibration : Starting the pump" )
. AddOperation ( checkUiOp )
. AddOperation ( new Operations . TimerOp ( 5 ) )
. EnterState ( ) ;
do
{
e = StateMachine . WaitRunDevsRunOps ( ) ;
2016-02-10 18:24:10 +00:00
Bridge . OnProcessData ( this , new ProcessDataEventArgs ( test , repetitionNr , Config . Entities . Progress . FlowSetting ) ) ;
2016-01-08 18:18:45 +00:00
Bridge . OnTestProgress ( this , new TestProgressEventArgs ( test , repetitionNr , Config . Entities . Progress . FlowSetting ) ) ;
2015-02-01 18:30:00 +00:00
2016-04-14 07:16:20 +00:00
if ( TestAndLogUiCmdStop ( test , e ) ) { retVal = Event . UiCmdStop ; goto stopTest ; }
2015-02-01 18:30:00 +00:00
}
while ( ! e . Contains ( Event . TimerExpired ) ) ;
State . Create ( "ReferenceFlowmeterCalibration : Starting the pump" )
. AddOperation ( checkUiOp )
. AddOperation ( cBrd . SetValvesOp ( inPath . Pump , null ) )
. EnterState ( ) ;
do
{
e = StateMachine . WaitRunDevsRunOps ( ) ;
2016-02-10 18:24:10 +00:00
Bridge . OnProcessData ( this , new ProcessDataEventArgs ( test , repetitionNr , Config . Entities . Progress . FlowSetting ) ) ;
2016-01-08 18:18:45 +00:00
Bridge . OnTestProgress ( this , new TestProgressEventArgs ( test , repetitionNr , Config . Entities . Progress . FlowSetting ) ) ;
2015-02-01 18:30:00 +00:00
2016-04-14 07:16:20 +00:00
if ( TestAndLogUiCmdStop ( test , e ) ) { retVal = Event . UiCmdStop ; goto stopTest ; }
2015-02-01 18:30:00 +00:00
}
while ( ! e . Contains ( Event . ValvesSet ) ) ;
2017-06-08 13:42:47 +00:00
if ( ! test . DoDraining ) /// If condition met => skip measuring and force emptying
2016-01-03 01:05:35 +00:00
{
2014-09-06 15:34:26 +00:00
///
2016-01-03 01:05:35 +00:00
/// Measure the weight and skip emptying if there is enough room in the tank
2014-09-06 15:34:26 +00:00
///
2017-04-24 07:44:11 +00:00
State . Create ( "ReferenceFlowmeterCalibration : Measuring mass of water in the tank" )
2016-01-03 01:05:35 +00:00
. AddOperation ( checkUiOp )
2017-03-28 21:47:32 +00:00
. AddOperation ( outPath . Scale . ReadMassOp ( ref Mass ) )
2016-01-03 01:05:35 +00:00
. EnterState ( ) ;
do
{
e = StateMachine . WaitRunDevsRunOps ( ) ;
2016-02-10 18:24:10 +00:00
Bridge . OnProcessData ( this , new ProcessDataEventArgs ( test , repetitionNr , Config . Entities . Progress . FlowSetting ) ) ;
2016-01-08 18:18:45 +00:00
Bridge . OnTestProgress ( this , new TestProgressEventArgs ( test , repetitionNr , Config . Entities . Progress . FlowSetting ) ) ;
2016-01-03 01:05:35 +00:00
if ( e . Contains ( Event . Error ) ) { retVal = Event . Error ; goto stopTest ; }
2016-04-14 07:16:20 +00:00
if ( TestAndLogUiCmdStop ( test , e ) ) { retVal = Event . UiCmdStop ; goto stopTest ; }
2016-01-03 01:05:35 +00:00
}
while ( ! e . Contains ( Event . BalanceDone ) ) ;
2016-10-07 12:06:54 +00:00
double estimatedEndMass = Mass . Val + test . Volume ;
2017-03-28 21:47:32 +00:00
if ( estimatedEndMass < outPath . Scale . Capacity * Constants . TankFullFactor )
2016-01-03 01:05:35 +00:00
{
goto set_flow ; /// Enough room in the tank -> skip emptying
}
}
2014-09-06 15:34:26 +00:00
///
/// Empty the water tank
///
2017-03-29 07:22:39 +00:00
switch ( DrainTheTank ( outPath . Scale . DrainValve , outPath . Scale ) )
2014-09-06 15:34:26 +00:00
{
2016-01-03 01:05:35 +00:00
case Event . Error : { retVal = Event . Error ; goto stopTest ; }
case Event . UiCmdStop : { retVal = Event . UiCmdStop ; goto stopTest ; }
2014-09-06 15:34:26 +00:00
}
2016-01-03 01:05:35 +00:00
set_flow :
2014-09-06 15:34:26 +00:00
2016-01-03 01:05:35 +00:00
//--------------------------------
2014-09-06 15:34:26 +00:00
State . Create ( "ReferenceFlowmeterCalibration : Setting the flow" )
. AddOperation ( checkUiOp )
2015-12-20 19:48:50 +00:00
. AddOperation ( outPath . RegulValve . SetFlowOp ( outPath . FlowMeter , test . Qfrom , test . Qto , outPath . PidCoef , RefFlow , 600 ) ) /// timeout = 10 min.
2014-09-06 15:34:26 +00:00
. EnterState ( ) ;
do
{
e = StateMachine . WaitRunDevsRunOps ( ) ;
2016-02-10 18:24:10 +00:00
Bridge . OnProcessData ( this , new ProcessDataEventArgs ( test , repetitionNr , Config . Entities . Progress . FlowSetting ) ) ;
2016-01-08 18:18:45 +00:00
Bridge . OnTestProgress ( this , new TestProgressEventArgs ( test , repetitionNr , Config . Entities . Progress . FlowSetting ) ) ;
2014-09-06 15:34:26 +00:00
2016-01-03 01:05:35 +00:00
if ( e . Contains ( Event . OpArgumentError ) ) { retVal = Event . OpArgumentError ; goto stopTest ; }
2016-04-14 07:16:20 +00:00
if ( TestAndLogUiCmdStop ( test , e ) ) { retVal = Event . UiCmdStop ; goto stopTest ; }
2015-01-12 04:56:19 +00:00
if ( e . Contains ( Event . RegulValveTimeOut ) )
{
Bridge . OnError ( this , Strings . Timeout ) ;
retVal = Event . Done ;
goto stopTest ;
}
if ( e . Contains ( Event . Next ) ) goto flow_set ;
2014-09-06 15:34:26 +00:00
}
while ( ! e . Contains ( Event . FlowReached ) ) ;
2016-01-03 01:05:35 +00:00
flow_set :
2016-01-08 18:18:45 +00:00
int flowSetTime = StateMachine . Time - flowSetTime0 ;
2016-10-07 14:22:36 +00:00
double currentFlow = RefFlow . Val ;
2014-09-06 15:34:26 +00:00
2016-01-03 01:05:35 +00:00
//------------------------------------------------
Bridge . OnActivity ( this , Strings . Measuring_the_weight ) ;
//------------------------------------------------
2014-09-06 15:34:26 +00:00
State . Create ( "ReferenceFlowmeterCalibration : Measuring the start mass" )
. AddOperation ( checkUiOp )
2016-10-18 16:48:20 +00:00
. AddOperation ( benchPath . TempMtrUp . ReadTempOp ( ref TempUp ) )
. AddOperation ( benchPath . TempMtrDown . ReadTempOp ( ref TempDown ) )
2016-01-03 01:05:35 +00:00
. AddOperation ( outPath . TempDiv . ReadTempOp ( ref TempDiv ) )
2016-10-18 16:48:20 +00:00
. AddOperation ( benchPath . PressMtrUp . ReadPressureOp ( ref PressUp ) )
. AddOperation ( benchPath . PressMtrDown . ReadPressureOp ( ref PressDown ) )
2016-11-17 07:48:52 +00:00
. AddOperation ( benchPath . PressMtrDelta = = null ? null : benchPath . PressMtrDelta . ReadPressureOp ( ref PressDelta ) )
2016-01-03 01:05:35 +00:00
. AddOperation ( ( StateMachine . Ambient ! = null )
2016-10-18 16:48:20 +00:00
? StateMachine . Ambient . ReadAmbientOp ( AmbTemp , AmbPress , AmbHumi ) : null )
2017-03-28 21:47:32 +00:00
. AddOperation ( outPath . Scale . ReadStableMassOp ( ref StartMass , test . MassRepeats , test . MassSpread , test . MassMethod ) )
2016-01-03 01:05:35 +00:00
. AddOperation ( cBrd . UpdateTankWeightOp ( ) )
. AddOperation ( processDataLoggingOp )
. EnterState ( ) ;
2014-09-06 15:34:26 +00:00
do
{
e = StateMachine . WaitRunDevsRunOps ( ) ;
2016-01-03 01:05:35 +00:00
if ( e . Contains ( Event . Error ) ) { retVal = Event . Error ; goto stopTest ; }
2016-04-14 07:16:20 +00:00
if ( TestAndLogUiCmdStop ( test , e ) ) { retVal = Event . UiCmdStop ; goto stopTest ; }
2014-09-06 15:34:26 +00:00
}
while ( ! e . Contains ( Event . BalanceDone ) ) ;
2016-02-10 18:24:10 +00:00
Mass . Val = StartMass . Val ;
2014-09-06 15:34:26 +00:00
2016-01-03 01:05:35 +00:00
//------------------------------------------------
Bridge . OnActivity ( this , Strings . Test_in_progress ) ;
//------------------------------------------------
2014-09-06 15:34:26 +00:00
State . Create ( "ReferenceFlowmeterCalibration : Starting the test" )
. AddOperation ( checkUiOp )
2016-01-03 01:05:35 +00:00
. AddOperation ( cBrd . StartMeasurementOp ( outPath , Elde . TestMethods . Diverter | Elde . TestMethods . Synchro ,
2015-09-22 16:39:00 +00:00
test . Qfrom , test . Qto , totalPulses , ( float ) test . TolerRed ) )
2014-09-06 15:34:26 +00:00
. EnterState ( ) ;
do
{
e = StateMachine . WaitRunDevsRunOps ( ) ;
2016-01-03 01:05:35 +00:00
if ( e . Contains ( Event . Error ) ) { retVal = Event . Error ; goto stopTest ; }
2016-04-14 07:16:20 +00:00
if ( TestAndLogUiCmdStop ( test , e ) ) { retVal = Event . UiCmdStop ; goto stopTest ; }
2014-09-06 15:34:26 +00:00
}
while ( ! e . Contains ( Event . MeasurementStarted ) ) ;
/// Measurement loop - preparation
2016-02-13 15:47:15 +00:00
readRegistersOp = new Operations . ReadMoreRegistersOp ( sensPath . RegisterReaders ) ;
2016-01-03 01:05:35 +00:00
queryEnd1 = cBrd . QueryMeasurementEndOp ( ) ;
2014-09-06 15:34:26 +00:00
queryEnd2 = cBrd . QueryMeasurementEndOp ( ) ;
2017-05-18 11:22:11 +00:00
ClearAllStatistics ( StateMachine . Time ) ;
2014-09-06 15:34:26 +00:00
2016-01-03 01:05:35 +00:00
/// Measurement loop - begin
2014-09-06 15:34:26 +00:00
while ( true )
{
2016-01-03 01:05:35 +00:00
//--------------------------------
switch ( ReadRegistersTempPressAmbient ( null , true ) )
2014-09-06 15:34:26 +00:00
{
2016-06-15 15:04:25 +00:00
case Event . Error : { retVal = Event . Error ; goto stopTest ; }
case Event . UiCmdStop : { retVal = Event . UiCmdStop ; goto stopTest ; }
2014-09-06 15:34:26 +00:00
case Event . MeasurementCompleted : goto test_completed ;
}
2016-01-03 01:05:35 +00:00
RefFreq . Val = cBrd . ReferenceFreq ;
RefFlow . Val = cBrd . ReferenceFlow ;
2017-05-18 11:22:11 +00:00
UpdateAllStatistics ( StateMachine . Time ) ;
2014-09-06 15:34:26 +00:00
2016-02-10 18:24:10 +00:00
Bridge . OnProcessData ( this , new ProcessDataEventArgs ( test , repetitionNr , Config . Entities . Progress . Test ) ) ;
2016-01-08 18:18:45 +00:00
Bridge . OnTestProgress ( this , new TestProgressEventArgs ( test , repetitionNr , Config . Entities . Progress . Test ) ) ;
2014-09-06 15:34:26 +00:00
}
2016-01-03 01:05:35 +00:00
/// Measurement loop - end
test_completed :
State . Create ( "ReferenceFlowmeterCalibration : Waiting before mass measurement" )
. AddOperation ( checkUiOp )
2016-10-18 16:48:20 +00:00
. AddOperation ( benchPath . TempMtrUp . ReadTempOp ( ref TempUp ) )
. AddOperation ( benchPath . TempMtrDown . ReadTempOp ( ref TempDown ) )
2016-01-03 01:05:35 +00:00
. AddOperation ( outPath . TempDiv . ReadTempOp ( ref TempDiv ) )
2016-10-18 16:48:20 +00:00
. AddOperation ( benchPath . PressMtrUp . ReadPressureOp ( ref PressUp ) )
. AddOperation ( benchPath . PressMtrDown . ReadPressureOp ( ref PressDown ) )
2016-11-17 07:48:52 +00:00
. AddOperation ( benchPath . PressMtrDelta = = null ? null : benchPath . PressMtrDelta . ReadPressureOp ( ref PressDelta ) )
2016-01-03 01:05:35 +00:00
. AddOperation ( readRegistersOp )
. AddOperation ( ( StateMachine . Ambient ! = null )
2016-10-18 16:48:20 +00:00
? StateMachine . Ambient . ReadAmbientOp ( AmbTemp , AmbPress , AmbHumi ) : null )
2017-03-28 21:47:32 +00:00
. AddOperation ( outPath . Scale . ReadMassOp ( ref Mass ) )
2016-01-03 01:05:35 +00:00
. AddOperation ( cBrd . UpdateTankWeightOp ( ) )
. AddOperation ( processDataLoggingOp )
. AddOperation ( new Operations . TimerOp ( test . TimeStop2Mass ) )
. EnterState ( ) ;
do
{
e = StateMachine . WaitRunDevsRunOps ( ) ;
if ( e . Contains ( Event . Error ) ) { retVal = Event . Error ; goto stopTest ; }
2016-04-14 07:16:20 +00:00
if ( TestAndLogUiCmdStop ( test , e ) ) { retVal = Event . UiCmdStop ; goto stopTest ; }
2016-01-03 01:05:35 +00:00
}
while ( ! e . Contains ( Event . TimerExpired ) ) ;
//------------------------------------------------
Bridge . OnActivity ( this , Strings . Measuring_the_weight ) ;
//------------------------------------------------
2014-09-06 15:34:26 +00:00
State . Create ( "ReferenceFlowmeterCalibration : Measuring the end mass" )
. AddOperation ( checkUiOp )
2016-10-18 16:48:20 +00:00
. AddOperation ( benchPath . TempMtrUp . ReadTempOp ( ref TempUp ) )
. AddOperation ( benchPath . TempMtrDown . ReadTempOp ( ref TempDown ) )
2016-01-03 01:05:35 +00:00
. AddOperation ( outPath . TempDiv . ReadTempOp ( ref TempDiv ) )
2016-10-18 16:48:20 +00:00
. AddOperation ( benchPath . PressMtrUp . ReadPressureOp ( ref PressUp ) )
. AddOperation ( benchPath . PressMtrDown . ReadPressureOp ( ref PressDown ) )
2016-11-17 07:48:52 +00:00
. AddOperation ( benchPath . PressMtrDelta = = null ? null : benchPath . PressMtrDelta . ReadPressureOp ( ref PressDelta ) )
2016-01-03 01:05:35 +00:00
. AddOperation ( ( StateMachine . Ambient ! = null )
2016-10-18 16:48:20 +00:00
? StateMachine . Ambient . ReadAmbientOp ( AmbTemp , AmbPress , AmbHumi ) : null )
2017-03-28 21:47:32 +00:00
. AddOperation ( outPath . Scale . ReadStableMassOp ( ref EndMass , test . MassRepeats , test . MassSpread , test . MassMethod ) )
2016-01-03 01:05:35 +00:00
. AddOperation ( cBrd . UpdateTankWeightOp ( ) )
. AddOperation ( processDataLoggingOp )
. EnterState ( ) ;
2014-09-06 15:34:26 +00:00
do
{
e = StateMachine . WaitRunDevsRunOps ( ) ;
2016-01-03 01:05:35 +00:00
if ( e . Contains ( Event . Error ) ) { retVal = Event . Error ; goto stopTest ; }
2016-04-14 07:16:20 +00:00
if ( TestAndLogUiCmdStop ( test , e ) ) { retVal = Event . UiCmdStop ; goto stopTest ; }
2014-09-06 15:34:26 +00:00
}
while ( ! e . Contains ( Event . BalanceDone ) ) ;
2016-01-03 01:05:35 +00:00
///
TestEndTime = DateTime . Now ;
2014-09-06 15:34:26 +00:00
//------------------------------------------------
Bridge . OnActivity ( this , Strings . Test_completed ) ;
//------------------------------------------------
2016-01-03 01:05:35 +00:00
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
2015-06-25 02:45:04 +00:00
if ( UIFlowControl . Stop = = WaitBeginFormClosed ( ) ) goto stopTest ;
2015-01-15 05:34:36 +00:00
2014-09-06 15:34:26 +00:00
///
/// Populate TestResult data entity with data
///
2016-01-03 01:05:35 +00:00
Results . Entities . TestRslt tstRslt = BatchRslts . GetTestRslt ( testName , test . Part ) ;
if ( tstRslt ! = null )
2014-09-06 15:34:26 +00:00
{
2017-05-10 08:43:33 +00:00
UpdateTempPressDensAmb ( tstRslt ) ;
2016-01-03 01:05:35 +00:00
/// Main results
tstRslt . StartTime = TestStartTime ;
tstRslt . EndTime = TestEndTime ;
tstRslt . FlowSetTime = flowSetTime ;
tstRslt . TestTime = cBrd . TTime ; /// [s] measurement time
2016-12-16 12:07:54 +00:00
tstRslt . PulsesMaster = Convert . ToDouble ( cBrd . EtPulses ( 0 ) ) ; /// Pulses of the master flow meter (test total)
tstRslt . MassStartRaw = StartMass . Val ;
2017-03-28 21:47:32 +00:00
tstRslt . MassStart = Formulas . CorrectedValue ( tstRslt . MassStartRaw , outPath . Scale . Corrections ) ;
2016-02-10 18:24:10 +00:00
tstRslt . MassEndRaw = EndMass . Val ;
2017-03-28 21:47:32 +00:00
tstRslt . MassEnd = Formulas . CorrectedValue ( tstRslt . MassEndRaw , outPath . Scale . Corrections ) ;
2016-01-03 01:05:35 +00:00
tstRslt . FlowMass = 3600.0 * ( tstRslt . MassEnd - tstRslt . MassStart ) / tstRslt . TestTime ; /// [kg/h]
2016-02-10 18:24:10 +00:00
tstRslt . FlowVolume = 3.6 * LtrPerRefPulse * tstRslt . PulsesMaster / tstRslt . TestTime ; /// [m3/h]
2017-06-29 10:48:14 +00:00
tstRslt . VolumeCTV = TBF . BenchControl . Formulas . Buoyancy ( ) * ( tstRslt . MassEnd - tstRslt . MassStart ) / tstRslt . DensityOut ; /// [l] 1000.0f is because density is in [kg/m3]
2016-02-10 18:24:10 +00:00
tstRslt . VolumeMaster = LtrPerRefPulse * tstRslt . PulsesMaster ; /// [l] volume from the master flow meter
tstRslt . ConstMaster = LtrPerRefPulse * tstRslt . VolumeCTV / tstRslt . VolumeMaster ; /// Corrected master pulses per liter
2016-01-03 01:05:35 +00:00
tstRslt . ErrorMaster = Formulas . ErrorFromVolumes ( tstRslt . VolumeMaster , tstRslt . VolumeCTV ) ;
2017-05-18 11:22:11 +00:00
tstRslt . FlowMean = ( float ) RefFlowStat . Average ;
2017-05-25 12:06:05 +00:00
tstRslt . FlowMin = ( float ) RefFlowStat . Min ;
tstRslt . FlowMax = ( float ) RefFlowStat . Max ;
2016-08-02 12:48:18 +00:00
2016-01-03 01:05:35 +00:00
/// Update flowmeter constant with the measured one
if ( outPath . FlowMeter . Idx1 > 0 & & outPath . FlowMeter . Idx1 < = ReferenceFlowmetersCount )
{
2016-02-10 18:24:10 +00:00
CalibratedLtrPerRefPulse [ outPath . FlowMeter . Idx1 - 1 ] = Convert . ToSingle ( tstRslt . ConstMaster ) ;
2016-01-03 01:05:35 +00:00
log . InfoFormat ( "Updating LtrPerRefPulse[{0}] = {1}" , outPath . FlowMeter . Idx1 - 1 , tstRslt . ConstMaster ) ;
}
2016-01-08 18:18:45 +00:00
tstRslt . Components = Results . Entities . Components
. UpdateList ( BatchRslts . ComponentsList ,
2016-02-15 21:48:44 +00:00
new Results . Entities . Components ( ( BenchInfo ! = null ) ? BenchInfo . TestBenchId : 1 ,
( BenchInfo ! = null ) ? BenchInfo . TestBenchName : "testbench" ,
2016-01-08 18:18:45 +00:00
inPath . Pump ! = null ? inPath . Pump . Name : string . Empty ,
outPath . FlowMeter ! = null ? outPath . FlowMeter . Name : string . Empty ,
2017-03-28 21:47:32 +00:00
outPath . Scale ! = null ? outPath . Scale . Name : string . Empty ,
2016-01-08 18:18:45 +00:00
outPath . RegulValve ! = null ? outPath . RegulValve . Name : string . Empty ,
outPath . Diverter ! = null ? outPath . Diverter . Name : string . Empty ) ) ;
2014-09-06 15:34:26 +00:00
2016-02-13 18:25:43 +00:00
/// Update results
Bridge . OnTestCompleted ( this , new TestCompletedEventArgs ( testName , tstRslt ) ) ;
}
2014-09-06 15:34:26 +00:00
2016-01-08 18:18:45 +00:00
Bridge . OnTestProgress ( this , new TestProgressEventArgs ( test , repetitionNr , Config . Entities . Progress . TransitionAfter ) ) ;
2014-09-06 15:34:26 +00:00
/// Append the results to the CSV-file
2016-01-03 01:05:35 +00:00
allResults . Info ( TestResult2CsvLine ( testName , test . Part ) ) ;
2014-09-06 15:34:26 +00:00
2017-05-05 10:41:15 +00:00
Bridge . OnTestProgress ( this , new TestProgressEventArgs ( test , repetitionNr ,
( retVal = = Event . Done ) ? Config . Entities . Progress . Completed : Config . Entities . Progress . Aborted ) ) ;
2014-09-06 15:34:26 +00:00
2016-12-10 11:40:35 +00:00
if ( ! outerLoopMode & & ( + + repetitionNr < = test . Repeats ) )
2014-09-06 15:34:26 +00:00
{
goto loop ;
}
stopTest :
///----------------------///
/// Quit this sequence ///
///----------------------///
State . Create ( "ReferenceFlowmeterCalibration : Stopping diverter, gate, etc." )
. AddOperation ( checkUiOp )
. AddOperation ( cBrd . StopPreviousOp ( ) )
. EnterState ( ) ;
do
{
e = StateMachine . WaitRunDevsRunOps ( ) ;
2016-04-14 07:16:20 +00:00
if ( TestAndLogUiCmdStop ( test , e ) ) { retVal = Event . UiCmdStop ; goto stopTest ; }
2014-09-06 15:34:26 +00:00
}
while ( ! e . Contains ( Event . PreviousStopped ) ) ;
/// Transition sequence at the end of test
/// Prevent overwriting 'retVal' in case it was set to non-default value earlier
2016-02-07 21:27:32 +00:00
switch ( Transition ( transitionAfter , ( retVal = = Event . Done ) ? TransitionContext . AfterTest : TransitionContext . Stop ) )
2014-09-06 15:34:26 +00:00
{
2016-02-07 21:27:32 +00:00
case Event . Error : { if ( retVal = = Event . Done ) retVal = Event . Error ; break ; }
2014-09-06 15:34:26 +00:00
case Event . UiCmdStop : { if ( retVal = = Event . Done ) retVal = Event . UiCmdStop ; break ; }
}
2017-05-05 10:41:15 +00:00
Bridge . OnTestProgress ( this , new TestProgressEventArgs ( test , repetitionNr ,
( retVal = = Event . Done ) ? Config . Entities . Progress . Completed : Config . Entities . Progress . Aborted ) ) ;
2014-09-06 15:34:26 +00:00
/// Create a list with one item 'retVal' (default is Event.Done) and return it
2015-02-02 22:18:28 +00:00
IList < Event > retList = new List < Event > ( 1 ) ;
2014-09-06 15:34:26 +00:00
retList . Add ( retVal ) ;
return retList ;
}
}
}