TestMethods.PMaxTest bug fix : when pump reached 100% PMaxTest started regardless of the pressure.
This commit is contained in:
@@ -20,12 +20,14 @@ namespace TBF.Rig.TestMethods.PMaxTest
|
||||
public float PressureLo; /// Presure range low limit in [bar]
|
||||
public float PressureHi; /// Presure range high limit in [bar]
|
||||
public int DurationPMax; /// Duration of the test in [s]
|
||||
public int PressSetTimeout; /// Pressure setting timeout [s]
|
||||
|
||||
public override void InitializeAll()
|
||||
{
|
||||
PressureLo = 5.0f; /// [bar]
|
||||
PressureHi = 6.0f; /// [bar]
|
||||
DurationPMax = 60;
|
||||
DurationPMax = 60; /// [s]
|
||||
PressSetTimeout = 300; /// [s]
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +35,8 @@ namespace TBF.Rig.TestMethods.PMaxTest
|
||||
{
|
||||
Strings.Pressure_lo_bar,
|
||||
Strings.Pressure_hi_bar,
|
||||
Strings.Duration_s,
|
||||
string.Format("PMaxTest {0}", Strings.Duration_s),
|
||||
"Pressure setting timeout, 0=off [s]",
|
||||
};
|
||||
public override string ParamName(int i) { return paramNames[i]; }
|
||||
public override int ParamsCount() { return paramNames.Length; }
|
||||
@@ -45,7 +48,8 @@ namespace TBF.Rig.TestMethods.PMaxTest
|
||||
case 0: return PressureLo.ToString(); /// [bar]
|
||||
case 1: return PressureHi.ToString(); /// [bar]
|
||||
case 2: return DurationPMax.ToString();
|
||||
default: return string.Empty;
|
||||
case 3: return PressSetTimeout.ToString();
|
||||
default: return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +60,7 @@ namespace TBF.Rig.TestMethods.PMaxTest
|
||||
case 0: PressureLo = Utils.ParseUFloat(strValue); return CfgUpdateFlags.None;
|
||||
case 1: PressureHi = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None;
|
||||
case 2: DurationPMax = int.Parse(strValue); return CfgUpdateFlags.None;
|
||||
case 3: PressSetTimeout = int.Parse(strValue); return CfgUpdateFlags.None;
|
||||
default: return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
@@ -73,9 +78,12 @@ namespace TBF.Rig.TestMethods.PMaxTest
|
||||
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
|
||||
break;
|
||||
case 2:
|
||||
if (int.TryParse(strValue, out iDummy)) return true;
|
||||
if (int.TryParse(strValue, out iDummy) && iDummy >= 1 && iDummy <= 300) return true;
|
||||
break;
|
||||
default:
|
||||
case 3:
|
||||
if (int.TryParse(strValue, out iDummy) && iDummy >= 0 && iDummy <= 900) return true;
|
||||
break;
|
||||
default:
|
||||
message = "Invalid index";
|
||||
return false;
|
||||
}
|
||||
@@ -89,7 +97,8 @@ namespace TBF.Rig.TestMethods.PMaxTest
|
||||
prms.PressureLo = this.PressureLo;
|
||||
prms.PressureHi = this.PressureHi;
|
||||
prms.DurationPMax = this.DurationPMax;
|
||||
}
|
||||
prms.PressSetTimeout = this.PressSetTimeout;
|
||||
}
|
||||
|
||||
public IParamsProvider Clone()
|
||||
{
|
||||
|
||||
@@ -109,9 +109,7 @@ namespace TBF.Rig.TestMethods.PMaxTest
|
||||
//------------------------------------------------
|
||||
|
||||
float pumpPower = test.PumpPower;
|
||||
int startTime = StateMachine.Time;
|
||||
|
||||
while (true)
|
||||
while (true)
|
||||
{
|
||||
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(pumpPower);
|
||||
|
||||
@@ -123,41 +121,55 @@ namespace TBF.Rig.TestMethods.PMaxTest
|
||||
do {
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
|
||||
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
if (e.Contains(Event.Next)) goto pressure_set;
|
||||
}
|
||||
while (e.Contains(Event.TimerBusy));
|
||||
if (TestAndLogUiCmdStop(test,e))
|
||||
{
|
||||
/// User pressed 'Stop' button
|
||||
retVal = Event.UiCmdStop;
|
||||
goto stopTest;
|
||||
}
|
||||
|
||||
//UiBridge.Bridge.OnEvent(this, string.Format("time = {0}, pump_power = {1}%, pressure_up = {2}bar, pressure_down = {3}bar\r\n",
|
||||
// StateMachine.Time - startTime,
|
||||
// pumpPower.ToString("F0"),
|
||||
// PressUp.ToString(),
|
||||
// PressDown.ToString()));
|
||||
if (testParams.PressSetTimeout > 0 && DateTime.Now - TestStartTime >= new TimeSpan(0, 0, testParams.PressSetTimeout))
|
||||
{
|
||||
/// Pressure setting timeout
|
||||
retVal = Event.RecoverableError;
|
||||
goto stopTest;
|
||||
}
|
||||
}
|
||||
while (e.Contains(Event.TimerBusy) && !e.Contains(Event.Next));
|
||||
|
||||
float step = (pumpPower < 40.0f) ? 4.7f : ((pumpPower < 60.0f) ? 3.3f : ((pumpPower < 80.0f) ? 2.2f : ((pumpPower < 90.0f) ? 1.5f : 1.2f)));
|
||||
|
||||
if (PressDown.Val < testParams.PressureLo)
|
||||
if (e.Contains(Event.Next))
|
||||
{
|
||||
/// 'Next' button pressed (in debug mode) => Quit the loop and continue in PMaxTest
|
||||
break;
|
||||
}
|
||||
else if (PressDown.Val < testParams.PressureLo)
|
||||
{
|
||||
if (pumpPower == 100.0f) break; /// Already at max. pump power -> Quit loop
|
||||
pumpPower = Math.Min(pumpPower + step, 100.0f); /// Limit max. power to 100%
|
||||
/// Low pressure => Increase the pump power, limit max. power to 100%
|
||||
pumpPower = Math.Min(pumpPower + step, 100.0f);
|
||||
}
|
||||
else if (PressDown.Val > testParams.PressureHi)
|
||||
{
|
||||
if (pumpPower == 0) break; /// Already at min. pump power -> Quit loop
|
||||
pumpPower = Math.Max(pumpPower - step, 0); /// Limit min. power to 0%
|
||||
/// Hi pressure => Decrease the pump power, limit min. power to 0%
|
||||
pumpPower = Math.Max(pumpPower - step, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
break; /// Pressure is in the range -> Quit loop
|
||||
/// Pressure is in the required range => Quit the loop and continue in PMaxTest
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pressure_set:
|
||||
///
|
||||
/// Pressure is set, PMaxTest start
|
||||
///
|
||||
int flowSetTime = (int)Math.Round((DateTime.Now - TestStartTime).TotalSeconds);
|
||||
|
||||
StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0);
|
||||
UpdateAllStatistics(StateMachine.Time);
|
||||
|
||||
startTime = StateMachine.Time;
|
||||
int startTime = StateMachine.Time;
|
||||
int endTime = startTime + testParams.DurationPMax;
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -179,19 +191,17 @@ namespace TBF.Rig.TestMethods.PMaxTest
|
||||
|
||||
int remainingTime = Math.Max(endTime - StateMachine.Time, 0);
|
||||
if (remainingTime > 60)
|
||||
{
|
||||
Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime / 60, "min", remainingTime % 60, Strings.sec));
|
||||
}
|
||||
else
|
||||
{
|
||||
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
|
||||
}
|
||||
}
|
||||
while (e.Contains(Event.TimerBusy));
|
||||
|
||||
/// Test completed
|
||||
StopRecordingStatistics();
|
||||
TestEndTime = DateTime.Now;
|
||||
///
|
||||
/// PMaxTest completed
|
||||
///
|
||||
TestEndTime = DateTime.Now;
|
||||
StopRecordingStatistics();
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Test_completed);
|
||||
@@ -205,8 +215,7 @@ namespace TBF.Rig.TestMethods.PMaxTest
|
||||
///
|
||||
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
|
||||
|
||||
bool stopCycle = false;
|
||||
if (tstRslt != null)
|
||||
if (tstRslt != null)
|
||||
{
|
||||
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
|
||||
UpdateTempPressDensAmb(tstRslt);
|
||||
@@ -216,8 +225,8 @@ namespace TBF.Rig.TestMethods.PMaxTest
|
||||
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
|
||||
tstRslt.StartTime = TestStartTime;
|
||||
tstRslt.EndTime = TestEndTime;
|
||||
tstRslt.FlowSetTime = 0;
|
||||
tstRslt.TestTime = Convert.ToDouble(testParams.DurationPMax); /// [s] measurement time
|
||||
tstRslt.FlowSetTime = flowSetTime; /// [s] FlowSetTime is pressure set time in this case
|
||||
tstRslt.TestTime = Convert.ToDouble(testParams.DurationPMax); /// [s] PMaxTest time
|
||||
tstRslt.PulsesMaster = 0; /// Pulses of the master flow meter (test total)
|
||||
tstRslt.MassStartRaw = 0;
|
||||
tstRslt.MassStart = 0;
|
||||
@@ -300,8 +309,6 @@ namespace TBF.Rig.TestMethods.PMaxTest
|
||||
/// Append the results to the CSV-file
|
||||
allResults.Info(TestResult2CsvLine(testName, test.Part));
|
||||
|
||||
if (stopCycle) retVal = Event.ErrorFlagsStop;
|
||||
|
||||
stopTest:
|
||||
|
||||
StopRecordingStatistics();
|
||||
|
||||
Reference in New Issue
Block a user