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

View File

@ -154,7 +154,7 @@ namespace TBF.BenchControl.Elde.RegulValve
opState = OpState.ValveMoveToFlow; opState = OpState.ValveMoveToFlow;
} }
expireTime = StateMachine.CurrentTime + timeout; expireTime = StateMachine.Time + timeout;
if (expireTime < 0) expireTime = int.MaxValue; if (expireTime < 0) expireTime = int.MaxValue;
TestMethods tm = 0; TestMethods tm = 0;
@ -238,7 +238,7 @@ namespace TBF.BenchControl.Elde.RegulValve
opState = OpState.FlowReached; opState = OpState.FlowReached;
return Event.FlowReached; return Event.FlowReached;
} }
else if (StateMachine.CurrentTime > expireTime) else if (StateMachine.Time > expireTime)
{ {
return Event.RegulValveTimeOut; return Event.RegulValveTimeOut;
} }

View File

@ -67,7 +67,7 @@ namespace TBF.BenchControl.Elde.RegulValve
{ {
firstRun = true; firstRun = true;
positionReached = false; positionReached = false;
expireTime = StateMachine.CurrentTime + timeout; expireTime = StateMachine.Time + timeout;
log.InfoFormat("Start(): RV#={0}, reqPosLo={1}%, reqPosHi={2}%", regulValveNr, posLoPct.ToString("F1"), posHiPct.ToString("F1")); log.InfoFormat("Start(): RV#={0}, reqPosLo={1}%, reqPosHi={2}%", regulValveNr, posLoPct.ToString("F1"), posHiPct.ToString("F1"));
} }
@ -106,7 +106,7 @@ namespace TBF.BenchControl.Elde.RegulValve
positionReached = true; positionReached = true;
return Event.PositionReached; return Event.PositionReached;
} }
else if (StateMachine.CurrentTime > expireTime) else if (StateMachine.Time > expireTime)
{ {
return Event.RegulValveTimeOut; return Event.RegulValveTimeOut;
} }

View File

@ -167,7 +167,7 @@ namespace TBF.BenchControl.Elde.Valve
public void Start() public void Start()
{ {
controlBoard.SetValves(switchPoints[0].MasksOpen, switchPoints[0].MasksClose); controlBoard.SetValves(switchPoints[0].MasksOpen, switchPoints[0].MasksClose);
swStartTime = StateMachine.CurrentTime; swStartTime = StateMachine.Time;
nextIx = 1; nextIx = 1;
} }
@ -179,7 +179,7 @@ namespace TBF.BenchControl.Elde.Valve
{ {
if (nextIx >= switchPoints.Count) return Event.ValvesSet; if (nextIx >= switchPoints.Count) return Event.ValvesSet;
if (StateMachine.CurrentTime >= swStartTime + switchPoints[nextIx].TimeSec) if (StateMachine.Time >= swStartTime + switchPoints[nextIx].TimeSec)
{ {
controlBoard.SetValves(switchPoints[nextIx].MasksOpen, switchPoints[nextIx].MasksClose); controlBoard.SetValves(switchPoints[nextIx].MasksOpen, switchPoints[nextIx].MasksClose);
nextIx++; nextIx++;

View File

@ -64,7 +64,7 @@ namespace TBF.BenchControl.Greco
temperature = 20.0f; temperature = 20.0f;
humidity = 40.0f; humidity = 40.0f;
pressure = 1.0f; pressure = 1.0f;
msrmntTimeStamp = StateMachine.CurrentTime; msrmntTimeStamp = StateMachine.Time;
msrmntState = BenchControl.MsrmntState.Valid; msrmntState = BenchControl.MsrmntState.Valid;
return; return;
} }
@ -82,7 +82,7 @@ namespace TBF.BenchControl.Greco
{ {
if (ambientCfg.DebugLevel == Entities.DebugMode.Simulate) if (ambientCfg.DebugLevel == Entities.DebugMode.Simulate)
{ {
msrmntTimeStamp = StateMachine.CurrentTime; msrmntTimeStamp = StateMachine.Time;
return; return;
} }
@ -124,7 +124,7 @@ namespace TBF.BenchControl.Greco
temperature = t; temperature = t;
humidity = h; humidity = h;
pressure = p; pressure = p;
msrmntTimeStamp = StateMachine.CurrentTime; msrmntTimeStamp = StateMachine.Time;
msrmntState = MsrmntState.Valid; msrmntState = MsrmntState.Valid;
log.InfoFormat("Msrmnt OK: time = {0}, temp={1}, humi={2}, pres={3}", msrmntTimeStamp, t, h, p); log.InfoFormat("Msrmnt OK: time = {0}, temp={1}, humi={2}, pres={3}", msrmntTimeStamp, t, h, p);

View File

@ -223,7 +223,7 @@ namespace TBF.BenchControl.MettlerToledo
mass = GetSimMass(balanceNr); mass = GetSimMass(balanceNr);
Masses[balanceNr] = mass; Masses[balanceNr] = mass;
msrmntState = MsrmntState.Valid; msrmntState = MsrmntState.Valid;
msrmntTimeStamp = StateMachine.CurrentTime; msrmntTimeStamp = StateMachine.Time;
return; return;
} }
@ -242,7 +242,7 @@ namespace TBF.BenchControl.MettlerToledo
int eolPos = currentBuffer.IndexOf("\r\n"); int eolPos = currentBuffer.IndexOf("\r\n");
if (eolPos >= 0) if (eolPos >= 0)
{ {
msrmntTimeStamp = StateMachine.CurrentTime; msrmntTimeStamp = StateMachine.Time;
/// Get part of theh string before EOL /// Get part of theh string before EOL
string received = currentBuffer.Substring(0, eolPos); string received = currentBuffer.Substring(0, eolPos);

View File

@ -68,7 +68,7 @@ namespace TBF.BenchControl.MettlerToledo
Masses[balanceNr] = mass; Masses[balanceNr] = mass;
serialNumber = "1234567890"; serialNumber = "1234567890";
msrmntState = MsrmntState.Valid; msrmntState = MsrmntState.Valid;
msrmntTimeStamp = StateMachine.CurrentTime; msrmntTimeStamp = StateMachine.Time;
return; return;
} }
@ -84,7 +84,7 @@ namespace TBF.BenchControl.MettlerToledo
if (stringBuilder.ToString().EndsWith("\r\n")) if (stringBuilder.ToString().EndsWith("\r\n"))
{ {
msrmntTimeStamp = StateMachine.CurrentTime; msrmntTimeStamp = StateMachine.Time;
string received = stringBuilder.ToString(); string received = stringBuilder.ToString();

View File

@ -47,12 +47,12 @@ namespace TBF.BenchControl.Operations
{ {
timeExpired = false; timeExpired = false;
timerStarted = true; timerStarted = true;
expireTime = StateMachine.CurrentTime + timerTime; expireTime = StateMachine.Time + timerTime;
} }
public Event Run() public Event Run()
{ {
if (timerStarted && !timeExpired && StateMachine.CurrentTime >= expireTime) if (timerStarted && !timeExpired && StateMachine.Time >= expireTime)
{ {
timeExpired = true; timeExpired = true;
return eventExpired; return eventExpired;

View File

@ -98,14 +98,22 @@ namespace TBF.BenchControl.Sequences
static SequenceBase() static SequenceBase()
{ {
results = new List<Entities.TestResult>(); results = new List<Entities.TestResult>();
}
///------------------------------------------------------------ WMVolumes = new FloatBox[Program.WMsCount];
/// Test related (instance) variables. WMErrors = new FloatBox[Program.WMsCount];
/// Created when test sequence is open. for (int i = 0; i < Program.WMsCount; i++)
/// They persist during all repetitions of the same test {
///------------------------------------------------------------ WMVolumes[i] = new FloatBox() { Name = string.Format("Volume{0}", i), Format = "F2" };
protected BenchControl.FeedingPath inPath; WMErrors[i] = new FloatBox() { Name = string.Format("Error{0}", i), Format = "F2" };
}
}
///------------------------------------------------------------
/// Test related (instance) variables.
/// Created when test sequence is open.
/// They persist during all repetitions of the same test
///------------------------------------------------------------
protected BenchControl.FeedingPath inPath;
protected BenchControl.BenchPath benchPath; protected BenchControl.BenchPath benchPath;
protected BenchControl.OutputPath outPath; protected BenchControl.OutputPath outPath;
protected BenchControl.MetersPath sensPath; protected BenchControl.MetersPath sensPath;
@ -113,18 +121,17 @@ namespace TBF.BenchControl.Sequences
protected Entities.TransitionSequence transitionStart; protected Entities.TransitionSequence transitionStart;
protected Entities.TransitionSequence transitionStop; protected Entities.TransitionSequence transitionStop;
#region Temperature_Pressure_Humidity #region Temperature_Pressure_Humidity
protected FloatBox tempIn = new FloatBox() { Name = "Temperature In", Format = "F1" }; protected static FloatBox tempIn = new FloatBox() { Name = "Temperature In", Format = "F1" };
protected FloatBox tempOut = new FloatBox() { Name = "Temperature Out", Format = "F1" }; protected static FloatBox tempOut = new FloatBox() { Name = "Temperature Out", Format = "F1" };
protected FloatBox tempDiv = new FloatBox() { Name = "Temperature Div", Format = "F1" }; protected static FloatBox tempDiv = new FloatBox() { Name = "Temperature Div", Format = "F1" };
protected static FloatBox pressIn = new FloatBox() { Name = "Pressure In", Format = "F3", Factor = 0.01f };
protected FloatBox pressIn = new FloatBox() { Name = "Pressure In", Format = "F1" }; protected static FloatBox pressOut = new FloatBox() { Name = "Pressure Out", Format = "F3", Factor = 0.01f };
protected FloatBox pressOut = new FloatBox() { Name = "Pressure Out", Format = "F1" }; protected static FloatBox airTemperature = new FloatBox() { Name = "Ambient Temperature", Format = "F1" };
protected static FloatBox airPressure = new FloatBox() { Name = "Ambient Pressure", Format = "F1" };
protected FloatBox airTemperature = new FloatBox() { Name = "Ambient Temperature", Format = "F1" }; protected static FloatBox airHumidity = new FloatBox() { Name = "Ambient Humidity", Format = "F1" };
protected FloatBox airPressure = new FloatBox() { Name = "Ambient Pressure", Format = "F1" };
protected FloatBox airHumidity = new FloatBox() { Name = "Ambient Humidity", Format = "F1" };
/// ///
protected float tempInSum; protected float tempInSum;
protected float tempOutSum; protected float tempOutSum;
@ -183,10 +190,6 @@ namespace TBF.BenchControl.Sequences
#endregion #endregion
protected bool ticTac = false;
protected int[] WMPulses = new int[Program.WMsCount];
protected int[] WMRefPulses = new int[Program.WMsCount];
protected IOperation readRegisters1; protected IOperation readRegisters1;
protected IOperation readRegisters2; protected IOperation readRegisters2;
@ -195,25 +198,42 @@ namespace TBF.BenchControl.Sequences
protected IOperation checkUiOp; protected IOperation checkUiOp;
protected IntBox refCount = new IntBox() { Name = "RefCount" }; protected bool ticTac = false;
protected FloatBox refFreq = new FloatBox() { Name = "RefFreq", Format = "F2" }; protected int[] WMPulses = new int[Program.WMsCount];
protected FloatBox refFlow = new FloatBox() { Name = "RefFlow", Format = "F2" }; protected int[] WMRefPulses = new int[Program.WMsCount];
protected FloatBox mass = new FloatBox() { Name = "Mass", Format = "F1" };
protected FloatBox startMass = new FloatBox() { Name = "Start Mass", Format = "F1" }; protected static FloatBox[] WMVolumes;
protected FloatBox endMass = new FloatBox() { Name = "End Mass", Format = "F1" }; protected static FloatBox[] WMErrors;
protected static IntBox refCount = new IntBox() { Name = "RefCount" };
protected static FloatBox refFreq = new FloatBox() { Name = "RefFreq", Format = "F2" };
protected static FloatBox refFlow = new FloatBox() { Name = "RefFlow", Format = "F2" };
protected static FloatBox mass = new FloatBox() { Name = "Mass", Format = "F1" };
protected static FloatBox startMass = new FloatBox() { Name = "Start Mass", Format = "F1" };
protected static FloatBox endMass = new FloatBox() { Name = "End Mass", Format = "F1" };
/// <summary> /// <summary>
/// To clear process values at the beginning of each test /// To clear process values at the beginning of each test
/// </summary> /// </summary>
protected void ClearProcessValues() protected void ClearProcessValues()
{ {
//if (WMPulses != null) { for (int i = 0; i < WMPulses.Length; i++) WMPulses[i] = 0; }
//if (WMRefPulses != null) { for (int i = 0; i < WMRefPulses.Length; i++) WMPulses[i] = 0; }
for (int i = 0; i < Program.WMsCount; i++)
{
WMPulses[i] = 0;
WMPulses[i] = 0;
WMVolumes[i].Clear();
WMErrors[i].Clear();
}
refCount.Clear(); refCount.Clear();
refFreq.Clear(); refFreq.Clear();
refFlow.Clear(); refFlow.Clear();
mass.Clear(); mass.Clear();
startMass.Clear(); startMass.Clear();
endMass.Clear(); endMass.Clear();
} }
/// <summary> /// <summary>
@ -438,8 +458,7 @@ namespace TBF.BenchControl.Sequences
/// <param name="time">Current test time in [s]</param> /// <param name="time">Current test time in [s]</param>
/// <param name="progress">Current progress 0 .. 1.0f</param> /// <param name="progress">Current progress 0 .. 1.0f</param>
/// <returns>Data for the UI</returns> /// <returns>Data for the UI</returns>
protected TestProgressEventArgs GetTestProgressData(Entities.Test test, Entities.TestResult tstRslt, protected TestProgressEventArgs GetTestProgressData(Entities.Test test, Entities.TestResult tstRslt, Elde.ControlBoardDev cBrd, float time, float progress)
int currentRefPulses, float time, float progress)
{ {
TestProgressEventArgs data = new TestProgressEventArgs(); TestProgressEventArgs data = new TestProgressEventArgs();
@ -448,25 +467,30 @@ namespace TBF.BenchControl.Sequences
//float ltrPerRefPulse = outPath.FlowMeter.NominalFlow / 7200.0f; /// [ltr/pulse] //float ltrPerRefPulse = outPath.FlowMeter.NominalFlow / 7200.0f; /// [ltr/pulse]
float refPulsesPerLtr = 7200.0f / outPath.FlowMeter.NominalFlow; /// [pulse/ltr] float refPulsesPerLtr = 7200.0f / outPath.FlowMeter.NominalFlow; /// [pulse/ltr]
data.RefPulses = currentRefPulses; data.RefPulses = cBrd.EtPulses(0);
data.Flow = refFlow.Val;
data.Volume = Formulas.VolumeFromPulses(currentRefPulses, refPulsesPerLtr); refFreq.Val = cBrd.ReferenceFreq;
data.FlowMtrFreq = refFreq;
data.Flow = refFlow;
data.Volume = new FloatBox() { Name = "Volume", Format = "F1", Val = Formulas.VolumeFromPulses(data.RefPulses, refPulsesPerLtr) };
data.Time = time; data.Time = time;
data.Mass = mass.Val; data.StartMass = startMass;
data.Mass = mass;
data.Progress = progress; data.Progress = progress;
float estCurrentTime = TimeEstimateBeginRpts + ((float)(tstRslt.RepetitionNr - 1) + progress) * TimeEstimateOneTest; float estCurrentTime = TimeEstimateBeginRpts + ((float)(tstRslt.RepetitionNr - 1) + progress) * TimeEstimateOneTest;
data.OveralProgress = estCurrentTime / TimeEstimateTotal; data.OveralProgress = estCurrentTime / TimeEstimateTotal;
data.Tin = tempIn.Val; data.Tin = tempIn;
data.Tout = tempOut.Val; data.Tout = tempOut;
data.Tdiv = tempDiv.Val; data.Tdiv = tempDiv;
data.Pin = pressIn.Val; data.Pin = pressIn;
data.Pout = pressOut.Val; data.Pout = pressOut;
data.AmbientTemp = airTemperature.Val; data.AmbientTemp = airTemperature;
data.AmbientPressure = airPressure.Val; data.AmbientPressure = airPressure;
data.AmbientHumidity = airHumidity.Val; data.AmbientHumidity = airHumidity;
for (int i = 0; i < Program.WMsCount; i++) for (int i = 0; i < Program.WMsCount; i++)
{ {
@ -475,7 +499,7 @@ namespace TBF.BenchControl.Sequences
data.WmPulses[i] = WMPulses[i]; data.WmPulses[i] = WMPulses[i];
data.WmRefPulses[i] = WMRefPulses[i]; data.WmRefPulses[i] = WMRefPulses[i];
data.WmVolume[i] = Formulas.VolumeFromPulses(WMPulses[i], sensPath.RegisterReaders[i].PulsesPerLtr); data.WmVolume[i] = Formulas.VolumeFromPulses(WMPulses[i], sensPath.RegisterReaders[i].PulsesPerLtr);
data.WmErrPct[i] = Formulas.ErrorFromVolumes(data.WmVolume[i], data.Volume); if (data.Volume.Valid) { data.WmErrPct[i] = Formulas.ErrorFromVolumes(data.WmVolume[i], data.Volume.Val); }
} }
} }

View File

@ -108,7 +108,7 @@ namespace TBF.BenchControl
/// <summary> /// <summary>
/// Current state name /// Current state name
/// </summary> /// </summary>
public static int CurrentTime { get { return currentTimeSec; } } public static int Time { get { return currentTimeSec; } }
/// <summary> /// <summary>
/// Constructor /// Constructor

View File

@ -104,7 +104,7 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection
while (!e.Contains(Event.FlowReached)); while (!e.Contains(Event.FlowReached));
flow_set: flow_set:
int time = StateMachine.CurrentTime; int time = StateMachine.Time;
float currentFlow = refFlow.Val; float currentFlow = refFlow.Val;
//------------------------------------------------ //------------------------------------------------

View File

@ -124,6 +124,9 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
set_flow: set_flow:
int flowSetTime0 = StateMachine.Time;
float estFlowSetTime = 10.0f;
//------------------------------------------------ //------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_the_flow); Bridge.OnActivity(this, Strings.Setting_the_flow);
//------------------------------------------------ //------------------------------------------------
@ -135,6 +138,11 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
do do
{ {
e = StateMachine.WaitRunDevsRunOps(); 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.UiCmdStop)) goto stop;
} }
while (!e.Contains(Event.ValvesSet)); while (!e.Contains(Event.ValvesSet));
@ -147,12 +155,17 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
do do
{ {
e = StateMachine.WaitRunDevsRunOps(); 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.UiCmdStop)) goto stop;
if (e.Contains(Event.RegulValveTimeOut)) goto error; if (e.Contains(Event.RegulValveTimeOut)) goto error;
} }
while (!e.Contains(Event.FlowReached)); while (!e.Contains(Event.FlowReached));
int time = StateMachine.CurrentTime; int time = StateMachine.Time;
float currentFlow = refFlow.Val; float currentFlow = refFlow.Val;
/// Extract cameras from the current sensors path, add operations to the detection state /// Extract cameras from the current sensors path, add operations to the detection state
@ -238,6 +251,8 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
AccumulateAveragedData(); AccumulateAveragedData();
refFreq.Val = cBrd.ReferenceFreq;
refFlow.Val = cBrd.ReferenceFlow;
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq, string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow); cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
@ -247,11 +262,10 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
} }
log.Info(logstr); log.Info(logstr);
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, 10.0f, test.TstTime); TestProgressEventArgs data = GetTestProgressData(test, tstRslt, cBrd, cBrd.TTime, progress);
TestProgressEventArgs data = GetTestProgressData(test, tstRslt, cBrd.EtPulses(0), cBrd.TTime, progress);
data.WmVolume[2] = data.WmVolume[0] + data.WmVolume[1]; 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); Bridge.OnTestProgress(this, data);
} }
/// Measurement loop - end /// Measurement loop - end

View File

@ -14,6 +14,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
public float RelativeQto; /// Tested flow high range related to the detected flow 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 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 float DetectionThreshold;/// Drop of frequency for the detection, text form is displayed in % (*100)
public int SupressTrills;
string[] paramNames = new string[] string[] paramNames = new string[]
{ {
@ -22,6 +23,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
Strings.RelativeQto, Strings.RelativeQto,
Strings.RateOfChangePct, Strings.RateOfChangePct,
Strings.DetectionThresholdPct, Strings.DetectionThresholdPct,
Strings.SupressWMTrills,
}; };
public string ParamName(int i) { return paramNames[i]; } public string ParamName(int i) { return paramNames[i]; }
@ -34,6 +36,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
case 2: return RelativeQto.ToString(); case 2: return RelativeQto.ToString();
case 3: return (100.0f * RateOfChange).ToString(); case 3: return (100.0f * RateOfChange).ToString();
case 4: return (100.0f * DetectionThreshold).ToString(); case 4: return (100.0f * DetectionThreshold).ToString();
case 5: return SupressTrills.ToString();
default: return string.Empty; default: return string.Empty;
} }
} }
@ -47,6 +50,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
case 2: RelativeQto = Utils.ParseSFloat(strValue); return; case 2: RelativeQto = Utils.ParseSFloat(strValue); return;
case 3: RateOfChange = Utils.ParseUFloat(strValue) / 100.0f; return; case 3: RateOfChange = Utils.ParseUFloat(strValue) / 100.0f; return;
case 4: DetectionThreshold = Utils.ParseUFloat(strValue) / 100.0f; return; case 4: DetectionThreshold = Utils.ParseUFloat(strValue) / 100.0f; return;
case 5: SupressTrills = int.Parse(strValue); return;
default: return; default: return;
} }
} }
@ -56,6 +60,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
message = string.Empty; message = string.Empty;
float dummy; float dummy;
int idummy;
switch (i) switch (i)
{ {
case 0: case 0:
@ -67,6 +72,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
case 2: case 2:
if (Utils.TryParseSFloat(strValue, out dummy)) return true; if (Utils.TryParseSFloat(strValue, out dummy)) return true;
break; break;
case 5:
if (int.TryParse(strValue, out idummy)) return true;
break;
default: default:
message = "Invalid index"; message = "Invalid index";
return false; return false;

View File

@ -125,6 +125,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
switching_flow_detection: switching_flow_detection:
int flowSetTime0 = StateMachine.Time;
float estFlowSetTime = 100.0f;
/// Extract cameras from the current sensors path, add operations to the detection state /// Extract cameras from the current sensors path, add operations to the detection state
IList<IOperation> measureOperations = new List<IOperation>(); IList<IOperation> measureOperations = new List<IOperation>();
for (int i = 0; i < sensPath.RegisterReaders.Length; i++) for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
@ -145,6 +148,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
do do
{ {
e = StateMachine.WaitRunDevsRunOps(); 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.UiCmdStop)) goto stop;
} }
while (!e.Contains(Event.ValvesSet)); while (!e.Contains(Event.ValvesSet));
@ -158,6 +166,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
do do
{ {
e = StateMachine.WaitRunDevsRunOps(); 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.UiCmdStop)) goto stop;
if (e.Contains(Event.RegulValveTimeOut)) goto error; if (e.Contains(Event.RegulValveTimeOut)) goto error;
} }
@ -181,8 +194,8 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
/// Current values /// Current values
flowsForDetection[0] = refFlow.Val; flowsForDetection[0] = refFlow.Val;
pulseFreqsForDetection[0] = 0.0f; pulseFreqsForDetection[0] = 0.0f;
int startTime = StateMachine.CurrentTime; int startTime = StateMachine.Time;
int lastTime = StateMachine.CurrentTime; int lastTime = StateMachine.Time;
/// Detection parameters /// Detection parameters
float rvPulse = (testParams.TargetQ > (test.Qfrom + test.Qto) / 2.0f) ? 0.05f : -0.05f; // rise or fall? 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 do
{ {
e = StateMachine.WaitRunDevsRunOps(); 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.UiCmdStop)) goto stop;
} }
while (!e.Contains(Event.PositionReached)); while (!e.Contains(Event.PositionReached));
@ -223,11 +241,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
case Event.UiCmdStop: goto stop; case Event.UiCmdStop: goto stop;
} }
int time = StateMachine.CurrentTime; int time = StateMachine.Time;
int diff = WMPulses[1] - lastWMPulses[1]; int diff = WMPulses[1] - lastWMPulses[1];
flowsForDetection[0] = cBrd.ReferenceFreq * outPath.FlowMeter.NominalFlow / 2000.0f; flowsForDetection[0] = cBrd.ReferenceFreq * outPath.FlowMeter.NominalFlow / 2000.0f;
pulseFreqsForDetection[0] = (float)diff / (float)(time - lastTime); pulseFreqsForDetection[0] = (float)diff / (float)(time - lastTime);
lastTime = StateMachine.CurrentTime; lastTime = StateMachine.Time;
if ((flowsForDetection[0] > 0) && (flowsForDetection[DetectionBufferSize - 1] > 0)) 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; float Qave_lps = (qfrom_test + qto_test) / 7.2f;
tstRslt.TstTime = tstRslt.Volume / Qave_lps; tstRslt.TstTime = tstRslt.Volume / Qave_lps;
float relativeQave = (testParams.RelativeQfrom + testParams.RelativeQto) / 2.0f;
bool goBackToInitFlow = ((rvPulse > 0) && (relativeQave < 0)) ||
((rvPulse < 0) && (relativeQave > 0));
//-------------------------------- if (goBackToInitFlow)
State.Create("CombinedWithDetection : Switching flow detected, going back") {
.AddOperation(checkUiOp) //--------------------------------
.AddOperations(measureOperations) State.Create("CombinedWithDetection : Switching flow detected, going back")
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, refFlow, 600)) /// timeout = 10 min. .AddOperation(checkUiOp)
.EnterState(); .AddOperations(measureOperations)
do .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, refFlow, 600)) /// timeout = 10 min.
{ .EnterState();
e = StateMachine.WaitRunDevsRunOps(); do
if (e.Contains(Event.UiCmdStop)) goto stop; {
if (e.Contains(Event.RegulValveTimeOut)) goto error; e = StateMachine.WaitRunDevsRunOps();
}
while (!e.Contains(Event.FlowReached)); 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") State.Create("CombinedWithDetection : Going to the test flow")
@ -339,6 +368,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
do do
{ {
e = StateMachine.WaitRunDevsRunOps(); 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.UiCmdStop)) goto stop;
//if (e.Contains(Event.FlowTimeOut)) goto do_detection; //if (e.Contains(Event.FlowTimeOut)) goto do_detection;
} }
@ -432,10 +466,10 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
log.Info(logstr); log.Info(logstr);
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, 10.0f, test.TstTime); float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
TestProgressEventArgs data = GetTestProgressData(test, tstRslt, cBrd.EtPulses(0), cBrd.TTime, progress); TestProgressEventArgs data = GetTestProgressData(test, tstRslt, cBrd, cBrd.TTime, progress);
data.WmVolume[2] = data.WmVolume[0] + data.WmVolume[1]; 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); Bridge.OnTestProgress(this, data);
} }
/// Measurement loop - end /// Measurement loop - end
@ -490,6 +524,15 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
} }
while (!e.Contains(Event.PreviousStopped)); 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 /// Populate TestRasult data entity with data
/// ///

View File

@ -115,6 +115,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
set_flow: set_flow:
int flowSetTime0 = StateMachine.Time;
float estFlowSetTime = 10.0f;
//------------------------------------------------ //------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_the_flow); Bridge.OnActivity(this, Strings.Setting_the_flow);
//------------------------------------------------ //------------------------------------------------
@ -126,6 +129,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
do do
{ {
e = StateMachine.WaitRunDevsRunOps(); 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.UiCmdStop)) goto stop;
} }
while (!e.Contains(Event.ValvesSet)); while (!e.Contains(Event.ValvesSet));
@ -138,6 +146,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
do do
{ {
e = StateMachine.WaitRunDevsRunOps(); 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.UiCmdStop)) goto stop;
if (e.Contains(Event.RegulValveTimeOut)) goto error; if (e.Contains(Event.RegulValveTimeOut)) goto error;
if (e.Contains(Event.Next)) goto flow_set; if (e.Contains(Event.Next)) goto flow_set;
@ -145,7 +158,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
while (!e.Contains(Event.FlowReached)); while (!e.Contains(Event.FlowReached));
flow_set: flow_set:
int time = StateMachine.CurrentTime; int time = StateMachine.Time;
float currentFlow = refFlow.Val; float currentFlow = refFlow.Val;
/// Extract cameras from the current sensors path, add operations to the detection state /// 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); log.Info(logstr);
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, 10.0f, test.TstTime); float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd.EtPulses(0), cBrd.TTime, progress)); Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, cBrd.TTime, progress));
} }
/// Measurement loop - end /// Measurement loop - end

View File

@ -1635,6 +1635,15 @@ namespace TBF.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Supress WM trills.
/// </summary>
internal static string SupressWMTrills {
get {
return ResourceManager.GetString("SupressWMTrills", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Switching flow detection. /// Looks up a localized string similar to Switching flow detection.
/// </summary> /// </summary>

View File

@ -750,4 +750,7 @@
<data name="Volume_and_error_selection" xml:space="preserve"> <data name="Volume_and_error_selection" xml:space="preserve">
<value>Volumen und Fehlergrenzen</value> <value>Volumen und Fehlergrenzen</value>
</data> </data>
<data name="SupressWMTrills" xml:space="preserve">
<value>Supress trills</value>
</data>
</root> </root>

View File

@ -811,4 +811,7 @@
<data name="Selected_results" xml:space="preserve"> <data name="Selected_results" xml:space="preserve">
<value>Selected results:</value> <value>Selected results:</value>
</data> </data>
<data name="SupressWMTrills" xml:space="preserve">
<value>Supress WM trills</value>
</data>
</root> </root>

View File

@ -157,16 +157,16 @@ namespace TBF.Screens
measurementTbl2Col2.SetData(0, data.RefPulses); measurementTbl2Col2.SetData(0, data.RefPulses);
measurementTbl2Col2.SetData(1, data.Time.ToString("F1")); measurementTbl2Col2.SetData(1, data.Time.ToString("F1"));
measurementTbl2Col2.SetData(3, data.Tin.ToString("F2")); measurementTbl2Col2.SetData(3, data.Tin.ToString());
measurementTbl2Col2.SetData(4, data.Tout.ToString("F2")); measurementTbl2Col2.SetData(4, data.Tout.ToString());
measurementTbl2Col2.SetData(5, data.Tdiv.ToString("F2")); measurementTbl2Col2.SetData(5, data.Tdiv.ToString());
measurementTbl2Col2.SetData(6, data.Pin); measurementTbl2Col2.SetData(6, data.Pin.ToString());
measurementTbl2Col2.SetData(7, data.Pout); measurementTbl2Col2.SetData(7, data.Pout.ToString());
measurementTbl2Col2.SetData(8, data.Flow.ToString("F3")); measurementTbl2Col2.SetData(8, data.Flow.ToString());
measurementTbl3Row2.SetData(0, data.AmbientTemp); measurementTbl3Row2.SetData(0, data.AmbientTemp.ToString());
measurementTbl3Row2.SetData(1, data.AmbientPressure); measurementTbl3Row2.SetData(1, data.AmbientPressure.ToString());
measurementTbl3Row2.SetData(2, data.AmbientHumidity); measurementTbl3Row2.SetData(2, data.AmbientHumidity.ToString());
//measurementBar1.FValue = data.Progress; //measurementBar1.FValue = data.Progress;
} }

View File

@ -168,17 +168,17 @@ namespace TBF.Screens
void OnTestProgress(object sender, TestProgressEventArgs args) void OnTestProgress(object sender, TestProgressEventArgs args)
{ {
/// Top part /// Top part
airTempLabel.Text = args.AmbientTemp.ToString("F1"); airTempLabel.Text = args.AmbientTemp.ToString();
airPressLabel.Text = args.AmbientPressure.ToString("F1"); airPressLabel.Text = args.AmbientPressure.ToString();
airHumiLabel.Text = args.AmbientHumidity.ToString("F1"); airHumiLabel.Text = args.AmbientHumidity.ToString();
refPulsesLabel.Text = args.RefPulses.ToString(); refPulsesLabel.Text = args.RefPulses.ToString();
refFreqLabel.Text = args.FlowMtrFreq.ToString("F1"); refFreqLabel.Text = args.FlowMtrFreq.ToString();
refFlowLabel.Text = args.Flow.ToString("F2"); refFlowLabel.Text = args.Flow.ToString();
refVolumeLabel.Text = args.Volume.ToString("F2"); refVolumeLabel.Text = args.Volume.ToString();
regValvePosLabel.Text = args.RegValvePos.ToString("F1"); //regValvePosLabel.Text = args.RegValvePos.ToString();
tDivLabel.Text = args.Tdiv.ToString("F2"); tDivLabel.Text = args.Tdiv.ToString();
/// Bottom part /// Bottom part
pulses1Label.Text = args.WmPulses[0].ToString(); pulses1Label.Text = args.WmPulses[0].ToString();
@ -187,20 +187,24 @@ namespace TBF.Screens
refPulses1Label.Text = args.WmRefPulses[0].ToString(); refPulses1Label.Text = args.WmRefPulses[0].ToString();
refPulses2Label.Text = args.WmRefPulses[1].ToString(); refPulses2Label.Text = args.WmRefPulses[1].ToString();
refPulses3Label.Text = args.WmRefPulses[2].ToString(); refPulses3Label.Text = args.WmRefPulses[2].ToString();
volume1Label.Text = args.WmVolume[0].ToString("F2"); volume1Label.Text = args.WmVolume[0].ToString();
volume2Label.Text = args.WmVolume[1].ToString("F2"); volume2Label.Text = args.WmVolume[1].ToString();
volume3Label.Text = args.WmVolume[2].ToString("F2"); volume3Label.Text = args.WmVolume[2].ToString();
error1Label.Text = args.WmErrPct[0].ToString("F2"); error1Label.Text = args.WmErrPct[0].ToString();
error2Label.Text = args.WmErrPct[1].ToString("F2"); error2Label.Text = args.WmErrPct[1].ToString();
error3Label.Text = args.WmErrPct[2].ToString("F2"); error3Label.Text = args.WmErrPct[2].ToString();
tInLabel.Text = args.Tin.ToString("F2"); tInLabel.Text = args.Tin.ToString();
tOutLabel.Text = args.Tout.ToString("F2"); tOutLabel.Text = args.Tout.ToString();
prInLabel.Text = args.Pin.ToString("F1"); prInLabel.Text = args.Pin.ToString();
prOutLabel.Text = args.Pout.ToString("F1"); prOutLabel.Text = args.Pout.ToString();
massLabel.Text = args.Mass.ToString("F1"); massLabel.Text = args.Mass.ToString();
massDiffLabel.Text = (args.Mass - args.TestResult.MassStartRaw).ToString("F1");
if (args.Mass.Valid && args.StartMass.Valid)
{
massDiffLabel.Text = (args.Mass.Val - args.StartMass.Val).ToString(args.Mass.Format);
}
} }
void OnTestCompleted(object sender, TestCompletedEventArgs args) void OnTestCompleted(object sender, TestCompletedEventArgs args)
@ -232,7 +236,7 @@ namespace TBF.Screens
refPulsesLabel.Text = tRes.PulsesMaster.ToString("F0"); refPulsesLabel.Text = tRes.PulsesMaster.ToString("F0");
//refFreqLabel.Text = tstRslt. //refFreqLabel.Text = tstRslt.
refFlowLabel.Text = tRes.FlowMass.ToString("F2"); refFlowLabel.Text = (tRes.FlowMass / 1000.0f).ToString("F2");
refVolumeLabel.Text = tRes.VolumeCTV.ToString("F2"); refVolumeLabel.Text = tRes.VolumeCTV.ToString("F2");
//regValvePosLabel.Text = tstRslt. //regValvePosLabel.Text = tstRslt.
//massLabel.Text = tstRslt. //massLabel.Text = tstRslt.

View File

@ -1,4 +1,5 @@
using System; using System;
using TBF.Boxes;
namespace TBF.UiBridge namespace TBF.UiBridge
{ {
@ -8,21 +9,22 @@ namespace TBF.UiBridge
public float OveralProgress; public float OveralProgress;
public int RefPulses; public int RefPulses;
public float RegValvePos; public FloatBox RegValvePos;
public float FlowMtrFreq; public FloatBox FlowMtrFreq;
public float Flow; public FloatBox Flow;
public float Volume; public FloatBox Volume;
public float Time; public float Time;
public float Mass; public FloatBox Mass;
public FloatBox StartMass;
public float Tin; public FloatBox Tin;
public float Tout; public FloatBox Tout;
public float Tdiv; public FloatBox Tdiv;
public float Pin; public FloatBox Pin;
public float Pout; public FloatBox Pout;
public float AmbientTemp; public FloatBox AmbientTemp;
public float AmbientPressure; public FloatBox AmbientPressure;
public float AmbientHumidity; public FloatBox AmbientHumidity;
public int[] WmPulses = new int[Program.WMsCount]; public int[] WmPulses = new int[Program.WMsCount];
public int[] WmRefPulses = new int[Program.WMsCount]; public int[] WmRefPulses = new int[Program.WMsCount];