As sent to Munich

This commit is contained in:
Milan Hanajik
2014-08-01 08:36:17 +02:00
parent 836daaa5a1
commit fd2db3e229
20 changed files with 254 additions and 131 deletions
@@ -104,7 +104,7 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection
while (!e.Contains(Event.FlowReached));
flow_set:
int time = StateMachine.CurrentTime;
int time = StateMachine.Time;
float currentFlow = refFlow.Val;
//------------------------------------------------
@@ -124,6 +124,9 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
set_flow:
int flowSetTime0 = StateMachine.Time;
float estFlowSetTime = 10.0f;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_the_flow);
//------------------------------------------------
@@ -135,6 +138,11 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
do
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stop;
}
while (!e.Contains(Event.ValvesSet));
@@ -147,12 +155,17 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
do
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stop;
if (e.Contains(Event.RegulValveTimeOut)) goto error;
}
while (!e.Contains(Event.FlowReached));
int time = StateMachine.CurrentTime;
int time = StateMachine.Time;
float currentFlow = refFlow.Val;
/// Extract cameras from the current sensors path, add operations to the detection state
@@ -238,6 +251,8 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
AccumulateAveragedData();
refFreq.Val = cBrd.ReferenceFreq;
refFlow.Val = cBrd.ReferenceFlow;
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
@@ -247,11 +262,10 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
}
log.Info(logstr);
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, 10.0f, test.TstTime);
TestProgressEventArgs data = GetTestProgressData(test, tstRslt, cBrd.EtPulses(0), cBrd.TTime, progress);
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
TestProgressEventArgs data = GetTestProgressData(test, tstRslt, cBrd, cBrd.TTime, progress);
data.WmVolume[2] = data.WmVolume[0] + data.WmVolume[1];
data.WmErrPct[2] = Formulas.ErrorFromVolumes(data.WmVolume[2], data.Volume);
if (data.Volume.Valid) { data.WmErrPct[2] = Formulas.ErrorFromVolumes(data.WmVolume[2], data.Volume.Val); }
Bridge.OnTestProgress(this, data);
}
/// Measurement loop - end
@@ -14,6 +14,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
public float RelativeQto; /// Tested flow high range related to the detected flow
public float RateOfChange; /// Each step is calculated as (TargetQfrom - Qfrom) * RateOfChange, text form is displayed in % (*100)
public float DetectionThreshold;/// Drop of frequency for the detection, text form is displayed in % (*100)
public int SupressTrills;
string[] paramNames = new string[]
{
@@ -22,6 +23,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
Strings.RelativeQto,
Strings.RateOfChangePct,
Strings.DetectionThresholdPct,
Strings.SupressWMTrills,
};
public string ParamName(int i) { return paramNames[i]; }
@@ -34,6 +36,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
case 2: return RelativeQto.ToString();
case 3: return (100.0f * RateOfChange).ToString();
case 4: return (100.0f * DetectionThreshold).ToString();
case 5: return SupressTrills.ToString();
default: return string.Empty;
}
}
@@ -47,6 +50,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
case 2: RelativeQto = Utils.ParseSFloat(strValue); return;
case 3: RateOfChange = Utils.ParseUFloat(strValue) / 100.0f; return;
case 4: DetectionThreshold = Utils.ParseUFloat(strValue) / 100.0f; return;
case 5: SupressTrills = int.Parse(strValue); return;
default: return;
}
}
@@ -56,6 +60,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
message = string.Empty;
float dummy;
int idummy;
switch (i)
{
case 0:
@@ -67,6 +72,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
case 2:
if (Utils.TryParseSFloat(strValue, out dummy)) return true;
break;
case 5:
if (int.TryParse(strValue, out idummy)) return true;
break;
default:
message = "Invalid index";
return false;
@@ -125,6 +125,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
switching_flow_detection:
int flowSetTime0 = StateMachine.Time;
float estFlowSetTime = 100.0f;
/// Extract cameras from the current sensors path, add operations to the detection state
IList<IOperation> measureOperations = new List<IOperation>();
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
@@ -145,6 +148,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
do
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stop;
}
while (!e.Contains(Event.ValvesSet));
@@ -158,6 +166,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
do
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stop;
if (e.Contains(Event.RegulValveTimeOut)) goto error;
}
@@ -181,8 +194,8 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
/// Current values
flowsForDetection[0] = refFlow.Val;
pulseFreqsForDetection[0] = 0.0f;
int startTime = StateMachine.CurrentTime;
int lastTime = StateMachine.CurrentTime;
int startTime = StateMachine.Time;
int lastTime = StateMachine.Time;
/// Detection parameters
float rvPulse = (testParams.TargetQ > (test.Qfrom + test.Qto) / 2.0f) ? 0.05f : -0.05f; // rise or fall?
@@ -203,6 +216,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
do
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stop;
}
while (!e.Contains(Event.PositionReached));
@@ -223,11 +241,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
case Event.UiCmdStop: goto stop;
}
int time = StateMachine.CurrentTime;
int time = StateMachine.Time;
int diff = WMPulses[1] - lastWMPulses[1];
flowsForDetection[0] = cBrd.ReferenceFreq * outPath.FlowMeter.NominalFlow / 2000.0f;
pulseFreqsForDetection[0] = (float)diff / (float)(time - lastTime);
lastTime = StateMachine.CurrentTime;
lastTime = StateMachine.Time;
if ((flowsForDetection[0] > 0) && (flowsForDetection[DetectionBufferSize - 1] > 0))
{
@@ -313,20 +331,31 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
float Qave_lps = (qfrom_test + qto_test) / 7.2f;
tstRslt.TstTime = tstRslt.Volume / Qave_lps;
float relativeQave = (testParams.RelativeQfrom + testParams.RelativeQto) / 2.0f;
bool goBackToInitFlow = ((rvPulse > 0) && (relativeQave < 0)) ||
((rvPulse < 0) && (relativeQave > 0));
//--------------------------------
State.Create("CombinedWithDetection : Switching flow detected, going back")
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, refFlow, 600)) /// timeout = 10 min.
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.UiCmdStop)) goto stop;
if (e.Contains(Event.RegulValveTimeOut)) goto error;
}
while (!e.Contains(Event.FlowReached));
if (goBackToInitFlow)
{
//--------------------------------
State.Create("CombinedWithDetection : Switching flow detected, going back")
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, refFlow, 600)) /// timeout = 10 min.
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stop;
if (e.Contains(Event.RegulValveTimeOut)) goto error;
}
while (!e.Contains(Event.FlowReached));
}
//--------------------------------
State.Create("CombinedWithDetection : Going to the test flow")
@@ -339,6 +368,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
do
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stop;
//if (e.Contains(Event.FlowTimeOut)) goto do_detection;
}
@@ -432,10 +466,10 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
log.Info(logstr);
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, 10.0f, test.TstTime);
TestProgressEventArgs data = GetTestProgressData(test, tstRslt, cBrd.EtPulses(0), cBrd.TTime, progress);
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
TestProgressEventArgs data = GetTestProgressData(test, tstRslt, cBrd, cBrd.TTime, progress);
data.WmVolume[2] = data.WmVolume[0] + data.WmVolume[1];
data.WmErrPct[2] = Formulas.ErrorFromVolumes(data.WmVolume[2], data.Volume);
if (data.Volume.Valid) { data.WmErrPct[2] = Formulas.ErrorFromVolumes(data.WmVolume[2], data.Volume.Val); }
Bridge.OnTestProgress(this, data);
}
/// Measurement loop - end
@@ -490,6 +524,15 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
}
while (!e.Contains(Event.PreviousStopped));
///
/// Optionally supress pulses from the large water meter
///
if (testParams.SupressTrills > 0)
{
WMPulses[0] = 0;
tstRslt.Meters[0].PulsesMeter = 0;
}
///
/// Populate TestRasult data entity with data
///
@@ -115,6 +115,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
set_flow:
int flowSetTime0 = StateMachine.Time;
float estFlowSetTime = 10.0f;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_the_flow);
//------------------------------------------------
@@ -126,6 +129,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
do
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stop;
}
while (!e.Contains(Event.ValvesSet));
@@ -138,6 +146,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
do
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stop;
if (e.Contains(Event.RegulValveTimeOut)) goto error;
if (e.Contains(Event.Next)) goto flow_set;
@@ -145,7 +158,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
while (!e.Contains(Event.FlowReached));
flow_set:
int time = StateMachine.CurrentTime;
int time = StateMachine.Time;
float currentFlow = refFlow.Val;
/// Extract cameras from the current sensors path, add operations to the detection state
@@ -245,8 +258,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
log.Info(logstr);
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, 10.0f, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd.EtPulses(0), cBrd.TTime, progress));
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, cBrd.TTime, progress));
}
/// Measurement loop - end