TestMethods.PMaxTest bug fix : when pump reached 100% PMaxTest started regardless of the pressure.

This commit is contained in:
Milan Hanajik 2021-07-02 10:52:46 +02:00
parent d51ff414ca
commit 300dabc800
2 changed files with 64 additions and 49 deletions

View File

@ -16,15 +16,17 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(PMaxTestParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
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 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]
}
@ -32,7 +34,8 @@ namespace TBF.BenchControl.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; }
@ -44,7 +47,8 @@ namespace TBF.BenchControl.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;
}
}
@ -55,6 +59,7 @@ namespace TBF.BenchControl.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;
}
}
@ -72,9 +77,12 @@ namespace TBF.BenchControl.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;
}
@ -88,7 +96,8 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
prms.PressureLo = this.PressureLo;
prms.PressureHi = this.PressureHi;
prms.DurationPMax = this.DurationPMax;
}
prms.PressSetTimeout = this.PressSetTimeout;
}
public IParamsProvider Clone()
{

View File

@ -1,13 +1,10 @@
///
/// Copyright (c) 2015-2019 Sensus Slovensko a.s.
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Text;
using log4net;
using Config.Entities;
using TBF.BenchControl;
using TBF.Boxes;
using TBF.Resources;
using TBF.UiBridge;
@ -89,9 +86,7 @@ namespace TBF.BenchControl.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);
@ -103,41 +98,55 @@ namespace TBF.BenchControl.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;
//------------------------------------------------
@ -159,23 +168,17 @@ namespace TBF.BenchControl.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));
/// Measurement loop - end
test_completed:
StopRecordingStatistics();
TestEndTime = DateTime.Now;
///
/// PMaxTest completed
///
TestEndTime = DateTime.Now;
StopRecordingStatistics();
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed);
@ -199,8 +202,8 @@ namespace TBF.BenchControl.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;
@ -292,9 +295,12 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
///
/// Quit this sequence
///
if (isLastRepetition || retVal == Event.UiCmdStop || retVal == Event.OpArgumentError
|| retVal == Event.RecoverableError || retVal == Event.ErrorFlagsStop
|| retVal == Event.Error || retVal == Event.ConfigurationError)
if (isLastRepetition || retVal == Event.UiCmdStop
|| retVal == Event.OpArgumentError
|| retVal == Event.RecoverableError
|| retVal == Event.ErrorFlagsStop
|| retVal == Event.Error
|| retVal == Event.ConfigurationError)
{
State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name))
.AddOperation(checkUiOp)