(1) IPlotter interface used in Statistics, (2) Plotter class, (3) Start/Stop statistics in all test methods, (4) Flow simulation in FlyingStartMassCollection (DebugMode.Inherit).

This commit is contained in:
Milan Hanajik 2018-02-11 16:31:25 +01:00
parent e0fb7927ed
commit 5f17dabb0b
22 changed files with 367 additions and 75 deletions

View File

@ -0,0 +1,16 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
namespace TBF.BenchControl.GenericDevices
{
public interface IPlotter
{
int StartGraph(int batchNr, string testName, int repetition);
void UpdateGraph(int graphId, float x, float y);
void StopGraph(int graphId);
}
}

View File

@ -0,0 +1,77 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Collections.Generic;
using log4net;
namespace TBF.BenchControl.Sequences
{
public class Plotter : BenchControl.GenericDevices.IPlotter
{
static readonly ILog log = LogManager.GetLogger(typeof(Plotter));
static readonly Dictionary<int, BinaryWriter> writers = new Dictionary<int, BinaryWriter>();
static int nextGraphId = 1;
readonly string caption;
///
public Plotter(string caption)
{
this.caption = caption;
}
public int StartGraph(int batchNr, string testName, int repetition)
{
try
{
int graphId = nextGraphId++;
string directory = Path.Combine(TBF.Program.GraphsDir, batchNr.ToString(), testName, repetition.ToString());
Directory.CreateDirectory(directory);
writers.Add(graphId, new BinaryWriter(File.Open(Path.Combine(directory, caption), FileMode.Create)));
log.InfoFormat("Graph file #{0} successfully created (batch={1} test={2} repet={3} caption={4})",
graphId, batchNr, testName, repetition, caption);
return graphId;
}
catch (Exception exc)
{
log.ErrorFormat("Failed to create a graph file (batch={0} test={1} repet={2} caption={3}): {4}",
batchNr, testName, repetition, caption, exc.Message);
return 0;
}
}
public void UpdateGraph(int graphId, float x, float y)
{
try
{
BinaryWriter writer = writers[graphId];
writer.Write(x);
writer.Write(y);
}
catch (Exception exc)
{
log.ErrorFormat("Failed to update graph file #{0}: {1}", graphId, exc.Message);
}
}
public void StopGraph(int graphId)
{
try
{
BinaryWriter writer = writers[graphId];
writer.Close();
writers.Remove(graphId);
}
catch (Exception exc)
{
log.ErrorFormat("Failed to close graph file #{0}: {1}", graphId, exc.Message);
}
}
}
}

View File

@ -77,49 +77,49 @@ namespace TBF.BenchControl.Sequences
/// ///
/// Statistics of 'continuous' variables (temperature, pressure, flow, etc.) /// Statistics of 'continuous' variables (temperature, pressure, flow, etc.)
/// ///
public static Statistics AmbTempStat = new Statistics(); public static Statistics AmbTempStat = new Statistics(new Plotter("Ambient temperature"));
public static Statistics AmbPressStat = new Statistics(); public static Statistics AmbPressStat = new Statistics(new Plotter("Ambient pressure"));
public static Statistics AmbHumiStat = new Statistics(); public static Statistics AmbHumiStat = new Statistics(new Plotter("Ambient humidity"));
public static Statistics TempUpStat = new Statistics(0, 5, true); public static Statistics TempUpStat = new Statistics(0, 5, true, new Plotter("Temperature up"));
public static Statistics TempDownStat = new Statistics(0, 5, true); public static Statistics TempDownStat = new Statistics(0, 5, true, new Plotter("Temperature down"));
public static Statistics TempDiffStat = new Statistics(0, 5, true); public static Statistics TempDiffStat = new Statistics(0, 5, true);
public static Statistics TempDivStat = new Statistics(0, 5, true); public static Statistics TempDivStat = new Statistics(0, 5, true, new Plotter("Temperature div"));
public static Statistics PressUpStat = new Statistics(5, 5, true); public static Statistics PressUpStat = new Statistics(5, 5, true, new Plotter("Pressure up"));
public static Statistics PressDownStat = new Statistics(5, 5, true); public static Statistics PressDownStat = new Statistics(5, 5, true, new Plotter("Pressure down"));
public static Statistics PressDeltaStat = new Statistics(5, 5, true); public static Statistics PressDeltaStat = new Statistics(5, 5, true);
public static Statistics RefFlowStat = new Statistics(5, 5, true); public static Statistics RefFlowStat = new Statistics(5, 5, true, new Plotter("Flow"));
public static Statistics TempRefHiStat = new Statistics(); public static Statistics TempRefHiStat = new Statistics();
public static Statistics TempRefLoStat = new Statistics(); public static Statistics TempRefLoStat = new Statistics();
public static Statistics Energy = new Statistics(); public static Statistics Energy = new Statistics();
public static Statistics VolumeForEnergy = new Statistics(); public static Statistics VolumeForEnergy = new Statistics();
public static int lastEnergyUpdateTime; public static int lastEnergyUpdateTime;
public static int machineTimeStart; public static int machineTimeStart;
public static int lastMachineTime; public static int lastMachineTime;
protected static void ClearAllStatistics(int machineTime) protected static void StartNewStatistics(int machineTime, int batchNr, string testName, int repetition)
{ {
lastMachineTime = machineTimeStart = machineTime; lastMachineTime = machineTimeStart = machineTime;
AmbTempStat.Clear(); AmbTempStat.Start(batchNr, testName, repetition);
AmbPressStat.Clear(); AmbPressStat.Start(batchNr, testName, repetition);
AmbHumiStat.Clear(); AmbHumiStat.Start(batchNr, testName, repetition);
TempUpStat.Clear(); TempUpStat.Start(batchNr, testName, repetition);
TempDownStat.Clear(); TempDownStat.Start(batchNr, testName, repetition);
TempDiffStat.Clear(); TempDiffStat.Start(batchNr, testName, repetition);
TempDivStat.Clear(); TempDivStat.Start(batchNr, testName, repetition);
PressUpStat.Clear(); PressUpStat.Start(batchNr, testName, repetition);
PressDownStat.Clear(); PressDownStat.Start(batchNr, testName, repetition);
PressDeltaStat.Clear(); PressDeltaStat.Start(batchNr, testName, repetition);
RefFlowStat.Clear(); RefFlowStat.Start(batchNr, testName, repetition);
TempRefHiStat.Clear(); TempRefHiStat.Start(batchNr, testName, repetition);
TempRefLoStat.Clear(); TempRefLoStat.Start(batchNr, testName, repetition);
Energy.Clear(); Energy.Start(batchNr, testName, repetition);
VolumeForEnergy.Clear(); VolumeForEnergy.Start(batchNr, testName, repetition);
lastEnergyUpdateTime = 0; lastEnergyUpdateTime = 0;
} }
@ -148,5 +148,26 @@ namespace TBF.BenchControl.Sequences
lastMachineTime = machineTime; lastMachineTime = machineTime;
} }
protected static void StopRecordingStatistics()
{
AmbTempStat.Stop();
AmbPressStat.Stop();
AmbHumiStat.Stop();
TempUpStat.Stop();
TempDownStat.Stop();
TempDiffStat.Stop();
TempDivStat.Stop();
PressUpStat.Stop();
PressDownStat.Stop();
PressDeltaStat.Stop();
RefFlowStat.Stop();
TempRefHiStat.Stop();
TempRefLoStat.Stop();
Energy.Stop();
VolumeForEnergy.Stop();
}
} }
} }

View File

@ -1130,8 +1130,11 @@ namespace TBF.BenchControl.Sequences
tstRslt.TempDownMax = 20.0f; tstRslt.TempDownMax = 20.0f;
tstRslt.TempDivMax = 20.0f; tstRslt.TempDivMax = 20.0f;
tstRslt.FlowMean = 0; /// TODO tstRslt.FlowMean = (float)RefFlowStat.Average;
tstRslt.FlowMax = 0; /// TODO tstRslt.FlowStart = (float)RefFlowStat.First;
tstRslt.FlowEnd = (float)RefFlowStat.Last;
tstRslt.FlowMin = (float)RefFlowStat.Min;
tstRslt.FlowMax = (float)RefFlowStat.Max;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++) for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{ {
@ -1235,9 +1238,11 @@ namespace TBF.BenchControl.Sequences
tstRslt.TempDownMax = 20.0f; tstRslt.TempDownMax = 20.0f;
tstRslt.TempDivMax = 20.0f; tstRslt.TempDivMax = 20.0f;
tstRslt.FlowMean = 0; /// TODO tstRslt.FlowMean = (float)RefFlowStat.Average;
tstRslt.FlowMax = 0; /// TODO tstRslt.FlowStart = (float)RefFlowStat.First;
tstRslt.FlowEnd = (float)RefFlowStat.Last;
tstRslt.FlowMin = (float)RefFlowStat.Min;
tstRslt.FlowMax = (float)RefFlowStat.Max;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++) for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{ {

View File

@ -1,14 +1,16 @@
using System; using System;
using TBF.BenchControl.GenericDevices;
namespace TBF.BenchControl.Sequences namespace TBF.BenchControl.Sequences
{ {
public class Statistics public class Statistics
{ {
public readonly int SkippedSamplesCount; /// 0 = do not skip any samples public readonly int SkippedSamplesCount; /// 0 = do not skip any samples
public readonly int FilterSize; /// 0 = no filter public readonly int FilterSize; /// 0 = no filter
public readonly bool MedianFilter; /// true - median filter instead of average public readonly bool MedianFilter; /// true - median filter instead of average
public readonly IPlotter plotter;
bool recordingInProgress;
double[] fifo; double[] fifo;
double[] sorted; double[] sorted;
double first; double first;
@ -16,42 +18,58 @@ namespace TBF.BenchControl.Sequences
double min; double min;
double max; double max;
double sum; double sum;
UInt32 totalCount; /// Number of samples passed to Update() int totalCount; /// Number of samples passed to Update()
UInt32 count; /// Number of processed and filtered samples int count; /// Number of processed and filtered samples
UInt32 fifoCount; /// Number of samples inserted into FIFO int fifoCount; /// Number of samples inserted into FIFO
int graphId;
public bool RecordingIProgress { get { return recordingInProgress; } }
public double First { get { return first; } } public double First { get { return first; } }
public double Last { get { return last; } } public double Last { get { return last; } }
public double Min { get { return (count > 0) ? min : 0; } } /// 0 when there were no samples public double Min { get { return (count > 0) ? min : 0; } } /// 0 when there were no samples
public double Max { get { return (count > 0) ? max : 0; } } /// 0 when there were no samples public double Max { get { return (count > 0) ? max : 0; } } /// 0 when there were no samples
public double Average { get { return (count > 0) ? (sum / (double)count) : 0; } } public double Average { get { return (count > 0) ? (sum / (double)count) : 0; } }
public UInt32 Count { get { return count; } } public int Count { get { return count; } }
public double Sum { get { return sum; } } public double Sum { get { return sum; } }
public Statistics(int skippedSamplesCount, int filterSize, bool medianFilter) public Statistics(int skippedSamplesCount, int filterSize, bool medianFilter, IPlotter plotter)
{ {
this.SkippedSamplesCount = skippedSamplesCount; this.SkippedSamplesCount = skippedSamplesCount;
this.FilterSize = filterSize; this.FilterSize = filterSize;
this.MedianFilter = medianFilter; this.MedianFilter = medianFilter;
this.plotter = plotter;
Clear(); if (filterSize > 0)
if (FilterSize > 0)
{ {
fifo = new double[FilterSize]; fifo = new double[FilterSize];
sorted = new double[FilterSize]; sorted = new double[FilterSize];
} }
recordingInProgress = false;
} }
public Statistics() : this(0, 0, false) public Statistics(int skippedSamplesCount, int filterSize, bool medianFilter)
: this(skippedSamplesCount, filterSize, medianFilter, new DummyPlotter())
{ {
} }
public Statistics(IPlotter plotter)
: this(0, 0, false, plotter)
{
}
public Statistics()
: this(0, 0, false, new DummyPlotter())
{
}
/// <summary> /// <summary>
/// Resets statistics /// Resets statistics and start collecting
/// </summary> /// </summary>
public void Clear() public void Start(int batchNr, string testName, int repetition)
{ {
sum = 0; sum = 0;
min = double.MaxValue; min = double.MaxValue;
@ -61,6 +79,22 @@ namespace TBF.BenchControl.Sequences
totalCount = 0; totalCount = 0;
count = 0; count = 0;
fifoCount = 0; fifoCount = 0;
recordingInProgress = true;
graphId = plotter.StartGraph(batchNr, testName, repetition);
}
/// <summary>
/// Resets statistics
/// </summary>
public void Stop()
{
if (recordingInProgress)
{
recordingInProgress = false;
plotter.StopGraph(graphId);
}
} }
@ -88,11 +122,14 @@ namespace TBF.BenchControl.Sequences
/// <param name="value">New value</param> /// <param name="value">New value</param>
public void Update(double value) public void Update(double value)
{ {
if (totalCount >= SkippedSamplesCount) if (recordingInProgress)
{ {
Process(value); if (totalCount >= SkippedSamplesCount)
{
Process(value);
}
totalCount++;
} }
totalCount++;
} }
@ -112,6 +149,8 @@ namespace TBF.BenchControl.Sequences
if (value < min) min = filteredValue; if (value < min) min = filteredValue;
if (value > max) max = filteredValue; if (value > max) max = filteredValue;
plotter.UpdateGraph(graphId, (float)(count + SkippedSamplesCount + FilterSize / 2), (float)value);
count++; count++;
} }
} }
@ -162,4 +201,13 @@ namespace TBF.BenchControl.Sequences
} }
} }
} }
class DummyPlotter : IPlotter
{
public DummyPlotter() { }
public int StartGraph(int batchNr, string testName, int repetition) { return 1; }
public void UpdateGraph(int graphId, float x, float y) { }
public void StopGraph(int graphId) { }
}
} }

View File

@ -326,7 +326,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment
queryEnd1 = cBrd.QueryMeasurementEndOp(); queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp(); queryEnd2 = cBrd.QueryMeasurementEndOp();
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
/// Measurement loop - begin /// Measurement loop - begin
while (true) while (true)

View File

@ -491,7 +491,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
queryEnd1 = cBrd.QueryMeasurementEndOp(); queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp(); queryEnd2 = cBrd.QueryMeasurementEndOp();
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
int estimtdEndTime = StateMachine.Time + (int)test.TstTime; int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
/// Read the diverter switch time /// Read the diverter switch time

View File

@ -267,7 +267,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
queryEnd1 = cBrd.QueryMeasurementEndOp(); queryEnd1 = cBrd.QueryMeasurementEndOp();
int estimtdEndTime = StateMachine.Time + (int)test.TstTime; int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
/// Measurement loop - begin /// Measurement loop - begin
State.Create(string.Format("{0}({1}) : Reading watermeters", test.Method, test.Name)) State.Create(string.Format("{0}({1}) : Reading watermeters", test.Method, test.Name))
@ -323,6 +323,8 @@ namespace TBF.BenchControl.TestMethods.Endurance
test_completed: test_completed:
StopRecordingStatistics();
//------------------------------------------------ //------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed); Bridge.OnActivity(this, Strings.Test_completed);
//------------------------------------------------ //------------------------------------------------
@ -492,7 +494,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
while (!e.Contains(Event.PreviousStopped)); while (!e.Contains(Event.PreviousStopped));
int estimtdEndTime = StateMachine.Time + (int)test.TstTime; int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
/// ///
@ -642,6 +644,8 @@ namespace TBF.BenchControl.TestMethods.Endurance
stopTest: stopTest:
StopRecordingStatistics();
/// ///
/// Quit this sequence /// Quit this sequence
/// ///

View File

@ -325,7 +325,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
queryEnd1 = cBrd.QueryMeasurementEndOp(); queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp(); queryEnd2 = cBrd.QueryMeasurementEndOp();
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
int estimtdEndTime = StateMachine.Time + (int)test.TstTime; int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
/// Measurement loop - begin /// Measurement loop - begin
@ -368,6 +368,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
test_completed: test_completed:
StopRecordingStatistics();
State.Create("FixedStartAdvanced : Closing the start/stop valve at the end of the fixed start test") State.Create("FixedStartAdvanced : Closing the start/stop valve at the end of the fixed start test")
.AddOperation(checkUiOp) .AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve)) .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve))
@ -587,6 +589,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
stopTest: stopTest:
StopRecordingStatistics();
/// ///
/// Quit this sequence /// Quit this sequence
/// ///

View File

@ -614,8 +614,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEvaluation
queryEnd1 = cBrd.QueryMeasurementEndOp(); queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp(); queryEnd2 = cBrd.QueryMeasurementEndOp();
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
int estimtdEndTime = StateMachine.Time + (int)test.TstTime; int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
/// Measurement loop - begin /// Measurement loop - begin
do do
@ -692,6 +692,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEvaluation
test_completed: test_completed:
StopRecordingStatistics();
EndTime = (double)StateMachine.Time; EndTime = (double)StateMachine.Time;
State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name)) State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name))
@ -944,6 +946,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEvaluation
stopTest: stopTest:
StopRecordingStatistics();
/// ///
/// Quit this sequence /// Quit this sequence
/// ///

View File

@ -611,8 +611,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
queryEnd1 = cBrd.QueryMeasurementEndOp(); queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp(); queryEnd2 = cBrd.QueryMeasurementEndOp();
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
int estimtdEndTime = StateMachine.Time + (int)test.TstTime; int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
/// Measurement loop - begin /// Measurement loop - begin
do do
@ -689,6 +689,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
test_completed: test_completed:
StopRecordingStatistics();
EndTime = (double)StateMachine.Time; EndTime = (double)StateMachine.Time;
State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name)) State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name))
@ -1148,6 +1150,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
stopTest: stopTest:
StopRecordingStatistics();
/// ///
/// Quit this sequence /// Quit this sequence
/// ///

View File

@ -416,7 +416,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
queryEnd1 = cBrd.QueryMeasurementEndOp(); queryEnd1 = cBrd.QueryMeasurementEndOp();
int estimtdEndTime = StateMachine.Time + (int)test.TstTime; int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
/// Measurement loop - begin /// Measurement loop - begin
State.Create("Read water meters") State.Create("Read water meters")
@ -490,6 +490,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
test_completed: test_completed:
StopRecordingStatistics();
//------------------------------------------------ //------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed); Bridge.OnActivity(this, Strings.Test_completed);
//------------------------------------------------ //------------------------------------------------
@ -754,6 +756,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
stopTest: stopTest:
StopRecordingStatistics();
/// ///
/// Quit this sequence /// Quit this sequence
/// ///

View File

@ -582,7 +582,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl
queryEnd1 = cBrd.QueryMeasurementEndOp(); /// ??? queryEnd1 = cBrd.QueryMeasurementEndOp(); /// ???
int estimtdEndTime = StateMachine.Time + (int)((repetitionNr == 1) ? test.TstTime : (test.TstTime * nextTestVolume / test.Volume)); int estimtdEndTime = StateMachine.Time + (int)((repetitionNr == 1) ? test.TstTime : (test.TstTime * nextTestVolume / test.Volume));
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
if (repetitionNr == 1) if (repetitionNr == 1)
{ {
@ -667,6 +667,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl
test_completed: test_completed:
StopRecordingStatistics();
if (repetitionNr == 1) if (repetitionNr == 1)
{ {
/// ///
@ -1093,6 +1095,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl
stopTest: stopTest:
StopRecordingStatistics();
/// ///
/// Quit this sequence /// Quit this sequence
/// ///

View File

@ -585,7 +585,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders);
int estimtdEndTime = StateMachine.Time + (int)test.TstTime; int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
/// Read the diverter switch time /// Read the diverter switch time
switchTimeStart = 0.001f * (float)cBrd.DivTime(0); switchTimeStart = 0.001f * (float)cBrd.DivTime(0);
@ -667,6 +667,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged
test_completed: test_completed:
StopRecordingStatistics();
/// ///
/// (Berlin:) Water is stopped immediately after the test and before the 2nd mass measurement in case: /// (Berlin:) Water is stopped immediately after the test and before the 2nd mass measurement in case:
/// - no 'transition sequence after test' is used /// - no 'transition sequence after test' is used
@ -1061,6 +1063,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged
stopTest: stopTest:
StopRecordingStatistics();
/// ///
/// Quit this sequence /// Quit this sequence
/// ///

View File

@ -90,8 +90,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
//------------------------------------------------------------------- //-------------------------------------------------------------------
State.Create(string.Format("{0}({1}) : Simulation", test.Method, test.Name)) State.Create(string.Format("{0}({1}) : Simulation", test.Method, test.Name))
.AddOperation(checkUiOp) .AddOperation(checkUiOp)
.EnterState(); .EnterState();
e = StateMachine.WaitRunDevsRunOps(); e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test, e)) retVal = Event.UiCmdStop; if (TestAndLogUiCmdStop(test, e)) retVal = Event.UiCmdStop;
@ -101,6 +101,67 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
retListSim.Add(retVal); retListSim.Add(retVal);
return retListSim; return retListSim;
} }
else if (debugLevel == Config.Entities.DebugMode.Inherit)
{
///
/// Test method with flow chart simulation
///
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
/// Simulate flow
StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
IntBox remainingTime = new IntBox((int)test.TstTime);
State.Create(string.Format("{0}({1}) : Simulation", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(new Operations.TimerOp((int)test.TstTime, remainingTime))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; }
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
if (remainingTime.Val > 60)
{
Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime.Val / 60, "min", remainingTime.Val % 60, Strings.sec));
}
else
{
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime.Val));
}
//------------------------------------------------
RefFlow.Val = (1.0 + 0.2 * Math.Sin(2 * Math.PI * (float)remainingTime.Val / test.TstTime)) * (test.Qfrom + test.Qto) / 2.0;
UpdateAllStatistics(StateMachine.Time);
}
while (!e.Contains(Event.TimerExpired));
StopRecordingStatistics();
if (retVal != Event.UiCmdStop)
{
float errorPctBase = -1.0f;
if (test.Name.ToLower().Contains("q3")) errorPctBase = -0.5f;
else if (test.Name.ToLower().Contains("q2")) errorPctBase = 0.5f;
else if (test.Name.ToLower().Contains("q1")) errorPctBase = -5.1f;
MakeSimulated(test.Name, test.Repeats, repetitionNr, 0, errorPctBase + repetitionNr * 0.1f);
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Completed));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, BatchRslts.GetTestRslt(Results.Utils.GetTestName(test.Name, 1, 1), 0)));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
}
/// Create a list with one item 'retVal' (default is Event.Done) and return it
IList<Event> retListSim = new List<Event>(1);
retListSim.Add(retVal);
return retListSim;
}
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
@ -573,7 +634,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders);
int estimtdEndTime = StateMachine.Time + (int)test.TstTime; int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
/// Read the diverter switch time /// Read the diverter switch time
switchTimeStart = 0.001f * (float)cBrd.DivTime(0); switchTimeStart = 0.001f * (float)cBrd.DivTime(0);
@ -655,6 +716,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
test_completed: test_completed:
StopRecordingStatistics();
/// ///
/// (Berlin:) Water is stopped immediately after the test and before the 2nd mass measurement in case: /// (Berlin:) Water is stopped immediately after the test and before the 2nd mass measurement in case:
/// - no 'transition sequence after test' is used /// - no 'transition sequence after test' is used
@ -1071,6 +1134,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
stopTest: stopTest:
StopRecordingStatistics(); /// Make sure graph files are closed
/// ///
/// Quit this sequence /// Quit this sequence
/// ///

View File

@ -121,7 +121,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
pressure_set: pressure_set:
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
UpdateAllStatistics(StateMachine.Time); UpdateAllStatistics(StateMachine.Time);
startTime = StateMachine.Time; startTime = StateMachine.Time;
@ -216,7 +216,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
TestStartTime = DateTime.Now; TestStartTime = DateTime.Now;
startTime = StateMachine.Time; startTime = StateMachine.Time;
estimtdEndTime = startTime + testParams.DurationLeak; estimtdEndTime = startTime + testParams.DurationLeak;
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
//------------------------------------------------ //------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress); Bridge.OnActivity(this, Strings.Test_in_progress);
@ -255,6 +255,8 @@ namespace TBF.BenchControl.TestMethods.LeakTest
test_completed: test_completed:
StopRecordingStatistics();
//------------------------------------------------ //------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed); Bridge.OnActivity(this, Strings.Test_completed);
//------------------------------------------------ //------------------------------------------------
@ -364,6 +366,8 @@ namespace TBF.BenchControl.TestMethods.LeakTest
stopTest: stopTest:
StopRecordingStatistics();
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter));
/// ///

View File

@ -122,7 +122,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
pressure_set: pressure_set:
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
UpdateAllStatistics(StateMachine.Time); UpdateAllStatistics(StateMachine.Time);
startTime = StateMachine.Time; startTime = StateMachine.Time;
@ -166,6 +166,8 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
test_completed: test_completed:
StopRecordingStatistics();
TestEndTime = DateTime.Now; TestEndTime = DateTime.Now;
//------------------------------------------------ //------------------------------------------------
@ -275,6 +277,8 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
stopTest: stopTest:
StopRecordingStatistics();
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter));
/// ///

View File

@ -206,7 +206,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
queryEnd1 = cBrd.QueryMeasurementEndOp(); queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp(); queryEnd2 = cBrd.QueryMeasurementEndOp();
ClearAllStatistics(StateMachine.Time); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
/// Read the diverter switch time /// Read the diverter switch time
switchTimeStart = 0.001f * (float)cBrd.DivTime(0); switchTimeStart = 0.001f * (float)cBrd.DivTime(0);
@ -233,6 +233,9 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
/// Measurement loop - end /// Measurement loop - end
test_completed: test_completed:
StopRecordingStatistics();
State.Create("ReferenceFlowmeterCalibration : Waiting before mass measurement") State.Create("ReferenceFlowmeterCalibration : Waiting before mass measurement")
.AddOperation(checkUiOp) .AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp)) .AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
@ -378,6 +381,8 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
stopTest: stopTest:
StopRecordingStatistics();
/// ///
/// Quit this sequence /// Quit this sequence
/// ///

View File

@ -54,10 +54,10 @@ namespace TBF.Boxes
/// string.Format(FormatEx, val.ToString(Format)) /// string.Format(FormatEx, val.ToString(Format))
/// If the value is invalid, the conversion result is 'FormatInvalid'. /// If the value is invalid, the conversion result is 'FormatInvalid'.
/// ///
public string Format = null; /// Used as an argument of ToString.) function public string Format = null; /// Used as an argument of ToString.) function
public string FormatEx = "{0}"; /// Used as the first argument of string.Format(...), can be modified to contain units, etc. public string FormatEx = "{0}"; /// Used as the first argument of string.Format(...), can be modified to contain units, etc.
public string FormatInvalid = "---"; public string FormatInvalid = "---";
public float Factor = 1.0f; public float Factor = 1.0f; /// Factor is used when converting to/from string by ToString(), UpdateParam() and ValidateParam()
public float LimitLo = float.MinValue; public float LimitLo = float.MinValue;
public float LimitHi = float.MaxValue; public float LimitHi = float.MaxValue;

View File

@ -16,7 +16,8 @@ namespace TBF
public class Program public class Program
{ {
public const string HomeDir = "C:\\Tbf\\"; /// Contains subdirectories Results, Logs, Images, ... public const string HomeDir = "C:\\Tbf\\"; /// Contains subdirectories Results, Logs, Images, ...
public const string ImagesDir = "C:\\Tbf\\Images\\"; public const string GraphsDir = "C:\\Tbf\\Graphs\\";
public const string ImagesDir = "C:\\Tbf\\Images\\";
public const string TempImagesDir = "C:\\Tbf\\Images\\Temp\\"; public const string TempImagesDir = "C:\\Tbf\\Images\\Temp\\";
/// log4net /// log4net

15
TBF/Screens/Graph.cs Normal file
View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TBF.Screens
{
public class Graph
{
public Graph(string fileName)
{
}
}
}

View File

@ -523,6 +523,7 @@
<Compile Include="BenchControl\GenericDevices\ICameraDisplay.cs" /> <Compile Include="BenchControl\GenericDevices\ICameraDisplay.cs" />
<Compile Include="BenchControl\GenericDevices\IDataEntryForCamera.cs" /> <Compile Include="BenchControl\GenericDevices\IDataEntryForCamera.cs" />
<Compile Include="BenchControl\GenericDevices\IErrorFlags.cs" /> <Compile Include="BenchControl\GenericDevices\IErrorFlags.cs" />
<Compile Include="BenchControl\GenericDevices\IPlotter.cs" />
<Compile Include="BenchControl\GenericDevices\IRoiForFixedStart.cs" /> <Compile Include="BenchControl\GenericDevices\IRoiForFixedStart.cs" />
<Compile Include="BenchControl\GenericDevices\IScaleCfg.cs" /> <Compile Include="BenchControl\GenericDevices\IScaleCfg.cs" />
<Compile Include="BenchControl\GenericDevices\ICalibInfoCfg.cs" /> <Compile Include="BenchControl\GenericDevices\ICalibInfoCfg.cs" />
@ -865,6 +866,7 @@
<DependentUpon>WriterCfgCtrl.cs</DependentUpon> <DependentUpon>WriterCfgCtrl.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="BenchControl\Sequences\DeferredTestEvaluationData.cs" /> <Compile Include="BenchControl\Sequences\DeferredTestEvaluationData.cs" />
<Compile Include="BenchControl\Sequences\Plotter.cs" />
<Compile Include="BenchControl\Sequences\Statistics.cs" /> <Compile Include="BenchControl\Sequences\Statistics.cs" />
<Compile Include="BenchControl\Sequences\ProcessData.cs" /> <Compile Include="BenchControl\Sequences\ProcessData.cs" />
<Compile Include="BenchControl\TestMethods\Adjustment\WMErrorsForm12.cs"> <Compile Include="BenchControl\TestMethods\Adjustment\WMErrorsForm12.cs">
@ -1573,6 +1575,7 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Strings.zh-CN.resx</DependentUpon> <DependentUpon>Strings.zh-CN.resx</DependentUpon>
</Compile> </Compile>
<Compile Include="Screens\Graph.cs" />
<Compile Include="Screens\GraphsTabPageCtrl.cs"> <Compile Include="Screens\GraphsTabPageCtrl.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>