Bug fixes: (1) simulation, (2) when BenchInfo==null, (3) ProcessData.RefPulses updated, (4) ProcessTabPages, etc.

This commit is contained in:
Milan Hanajik
2016-02-15 22:48:44 +01:00
parent 92bcd46549
commit 462ed568de
21 changed files with 68 additions and 54 deletions
@@ -297,7 +297,7 @@ namespace TBF.BenchControl.Elde
float pwFactor = 1.0f;
/// Increment reference flow meters
for (int i = 0; i < Config.Data.WMsCount; i++)
for (int i = 0; i <= Config.Data.WMsCount; i++)
{
etPulses[i] += (int)referenceFreq;
if (etPulses[i] > totalRefPulses)
@@ -309,9 +309,15 @@ namespace TBF.BenchControl.Elde
}
/// Increment water meters
for (int i = 1; i < Config.Data.WMsCount; i++)
for (int i = 1; i <= Config.Data.WMsCount; i++)
{
const float wmPulsesPerLiter = 10.0f;
float wmPulsesPerLiter = 0;
if ((BenchControl.Sequences.ProcessData.RegisterReaders[i - 1] != null) &&
(BenchControl.Sequences.ProcessData.BatchRslts.WaterMeters.Length >= i) &&
(BenchControl.Sequences.ProcessData.BatchRslts.WaterMeters[i - 1] != null))
{
wmPulsesPerLiter = (float)BenchControl.Sequences.ProcessData.RegisterReaders[i-1].PulsesPerLtr;
}
wMeterPulsesF[i] += errFactor[i] * pwFactor * ((float)rand.Next(100) + 450.0f) * wmPulsesPerLiter * TestBenchSim.GetSimFlow() / 1800.0f;
wMeterPulses[i] = (UInt16)wMeterPulsesF[i];
}
@@ -41,7 +41,7 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
: base(cfg)
{
registerReaderCfg = cfg;
ltrsPerPulse = (cfg.ProcParams.PulsesPerLtr <= float.Epsilon) ? 0 : (1 / cfg.ProcParams.PulsesPerLtr);
ltrsPerPulse = (cfg.ProcParams.PulsesPerLtr <= float.Epsilon) ? 1.0 : (1 / cfg.ProcParams.PulsesPerLtr);
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
@@ -44,7 +44,7 @@ namespace TBF.BenchControl.Elde.RegisterReader
: base(cfg)
{
registerReaderCfg = cfg;
ltrsPerPulse = (cfg.ProcParams.PulsesPerLtr <= float.Epsilon) ? 0 : (1 / cfg.ProcParams.PulsesPerLtr);
ltrsPerPulse = (cfg.ProcParams.PulsesPerLtr <= float.Epsilon) ? 1.0 : (1 / cfg.ProcParams.PulsesPerLtr);
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
@@ -41,6 +41,8 @@ namespace TBF.BenchControl.Operations
/// <summary>Start this operation</summary>
public void Start()
{
Sequences.ProcessData.RefPulses = StateMachine.ControlBoard.EtPulses(0);
for (int i = 0; i < readersCount; i++)
{
if (readRegOps[i] != null) readRegOps[i].Start();
@@ -53,6 +55,8 @@ namespace TBF.BenchControl.Operations
bool allDone = true;
bool anyError = false;
Sequences.ProcessData.RefPulses = StateMachine.ControlBoard.EtPulses(0);
for (int i = 0; i < readersCount; i++)
{
if (readRegOps[i] != null)
@@ -260,7 +260,8 @@ namespace TBF.BenchControl.Sequences
}
/// Prepare empty results
BatchRslts = Results.BatchResults.NewFromProcedure(Program.LocalSettings.BatchNr, BenchInfo.TestBenchId,
BatchRslts = Results.BatchResults.NewFromProcedure(Program.LocalSettings.BatchNr,
(BenchInfo != null) ? BenchInfo.TestBenchId : 1,
User.CurrentUser.Name, Program.Version,
StateMachine.Procedure, waterMeterData, waterMeterParts);
@@ -17,8 +17,8 @@ namespace TBF.BenchControl.Sequences
public static FloatBox PressureUp = new FloatBox() { Name = "Pressure In", Format = "F3", Factor = 0.01f };
public static FloatBox PressureDown = new FloatBox() { Name = "Pressure Out", Format = "F3", Factor = 0.01f };
public static float LtrPerRefPulse; /// to calculate the ref.volume
public static IntBox RefCount = new IntBox() { Name = "RefCount" };
public static float LtrPerRefPulse; /// to calculate the ref.volume
public static int RefPulses;
public static FloatBox RefFreq = new FloatBox() { Name = "RefFreq", Format = "F2" };
public static FloatBox RefFlow = new FloatBox() { Name = "RefFlow", Format = "F2" }; /// [m3/h]
@@ -54,7 +54,7 @@ namespace TBF.BenchControl.Sequences
if (RegisterReaders[i] != null) RegisterReaders[i].Clear();
}
RefCount.Clear();
RefPulses = 0;
RefFreq.Clear();
RefFlow.Clear();
Mass.Clear();
@@ -865,8 +865,8 @@ namespace TBF.BenchControl.Sequences
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -989,8 +989,8 @@ namespace TBF.BenchControl.Sequences
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -322,8 +322,8 @@ namespace TBF.BenchControl.TestMethods.Adjustment
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -445,8 +445,8 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -624,8 +624,8 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -544,8 +544,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -572,8 +572,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -543,8 +543,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -298,8 +298,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -178,6 +178,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasureOp());
}
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("FlyingStartMassCollection : Waiting before 1st mass measurement")
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
@@ -203,9 +206,6 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
LogProcessHeader(processDataLogger, "Start mass");
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("FlyingStartMassCollection : Measuring the start mass")
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
@@ -321,7 +321,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
/// Measurement loop - end
test_completed:
State.Create("FlyingStartMassCollection : Waiting before 2nd mass measurement")
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("FlyingStartMassCollection : Waiting before 2nd mass measurement")
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
.AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut))
@@ -346,9 +349,6 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
LogProcessHeader(processDataLogger, "End mass");
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("FlyingStartMassCollection : Measuring the end mass")
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
@@ -485,8 +485,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -363,8 +363,8 @@ namespace TBF.BenchControl.TestMethods.LeakTest
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -277,8 +277,8 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -362,8 +362,8 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components(BenchInfo.TestBenchId,
BenchInfo.TestBenchName,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
@@ -415,8 +415,9 @@ namespace TBF.Screens
///
/// Available only during a test
///
refPulsesLabel.Text = ProcessData.RefCount.ToString();
double refVolume = ProcessData.LtrPerRefPulse * (double)ProcessData.RefCount.Val;
refPulsesLabel.Text = ProcessData.RefPulses.ToString();
double refVolume = ProcessData.LtrPerRefPulse * (double)ProcessData.RefPulses;
refVolumeLabel.Text = refVolume.ToString("F2");
float massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val;
massDiffLabel.Text = massDiff.ToString("F3");
@@ -435,7 +436,7 @@ namespace TBF.Screens
pulses[i].Text = rr.WMPulses.ToString();
refPulses[i].Text = rr.WMRefPulses.ToString();
volume[i].Text = rr.WMVolume.ToString("F1");
error[i].Text = BenchControl.Formulas.ErrorFromVolumes(rr.WMVolume, refVolume).ToString("F1");
error[i].Text = BenchControl.Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.LtrPerRefPulse).ToString("F1");
}
}
}
@@ -454,7 +455,7 @@ namespace TBF.Screens
pulses[i].Text = rr.WMPulses.ToString();
refPulses[i].Text = rr.WMRefPulses.ToString();
volume[i].Text = rr.WMVolume.ToString("F1");
error[i].Text = BenchControl.Formulas.ErrorFromVolumes(rr.WMVolume, refVolume).ToString("F1");
error[i].Text = BenchControl.Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.LtrPerRefPulse).ToString("F1");
compoundVolume += rr.WMVolume;
}
}
@@ -444,8 +444,9 @@ namespace TBF.Screens
///
/// Available only during a test
///
refPulsesLabel.Text = ProcessData.RefCount.ToString();
double refVolume = ProcessData.LtrPerRefPulse * (double)ProcessData.RefCount.Val;
refPulsesLabel.Text = ProcessData.RefPulses.ToString();
double refVolume = ProcessData.LtrPerRefPulse * (double)ProcessData.RefPulses;
refVolumeLabel.Text = refVolume.ToString("F2");
float massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val;
massDiffLabel.Text = massDiff.ToString("F3");
@@ -464,7 +465,7 @@ namespace TBF.Screens
pulses[i].Text = rr.WMPulses.ToString();
refPulses[i].Text = rr.WMRefPulses.ToString();
volume[i].Text = rr.WMVolume.ToString("F1");
error[i].Text = BenchControl.Formulas.ErrorFromVolumes(rr.WMVolume, refVolume).ToString("F1");
error[i].Text = BenchControl.Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.LtrPerRefPulse).ToString("F1");
}
}
}
@@ -483,7 +484,7 @@ namespace TBF.Screens
pulses[i].Text = rr.WMPulses.ToString();
refPulses[i].Text = rr.WMRefPulses.ToString();
volume[i].Text = rr.WMVolume.ToString("F1");
error[i].Text = BenchControl.Formulas.ErrorFromVolumes(rr.WMVolume, refVolume).ToString("F1");
error[i].Text = BenchControl.Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.LtrPerRefPulse).ToString("F1");
compoundVolume += rr.WMVolume;
}
}
@@ -402,8 +402,9 @@ namespace TBF.Screens
///
/// Available only during a test
///
refPulsesLabel.Text = ProcessData.RefCount.ToString();
double refVolume = ProcessData.LtrPerRefPulse * (double)ProcessData.RefCount.Val;
refPulsesLabel.Text = ProcessData.RefPulses.ToString();
double refVolume = ProcessData.LtrPerRefPulse * (double)ProcessData.RefPulses;
refVolumeLabel.Text = refVolume.ToString("F2");
float massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val;
massDiffLabel.Text = massDiff.ToString("F3");
@@ -422,7 +423,7 @@ namespace TBF.Screens
pulses[i].Text = rr.WMPulses.ToString();
refPulses[i].Text = rr.WMRefPulses.ToString();
volume[i].Text = rr.WMVolume.ToString("F1");
error[i].Text = BenchControl.Formulas.ErrorFromVolumes(rr.WMVolume, refVolume).ToString("F1");
error[i].Text = BenchControl.Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.LtrPerRefPulse).ToString("F1");
}
}
}
@@ -441,7 +442,7 @@ namespace TBF.Screens
pulses[i].Text = rr.WMPulses.ToString();
refPulses[i].Text = rr.WMRefPulses.ToString();
volume[i].Text = rr.WMVolume.ToString("F1");
error[i].Text = BenchControl.Formulas.ErrorFromVolumes(rr.WMVolume, refVolume).ToString("F1");
error[i].Text = BenchControl.Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.LtrPerRefPulse).ToString("F1");
compoundVolume += rr.WMVolume;
}
}