Sequences.FloatStatistics -> Sequences.Statistics: use double internally, provide double Sum property.

This commit is contained in:
Milan Hanajik
2016-08-19 14:33:32 +02:00
parent 50194001d9
commit ef5bbe737c
4 changed files with 45 additions and 23 deletions
@@ -41,7 +41,9 @@ namespace TBF.BenchControl.Operations
/// <summary>Start this operation</summary> /// <summary>Start this operation</summary>
public void Start() public void Start()
{ {
int oriRefPulses = Sequences.ProcessData.RefPulses;
Sequences.ProcessData.RefPulses = StateMachine.ControlBoard.EtPulses(0); Sequences.ProcessData.RefPulses = StateMachine.ControlBoard.EtPulses(0);
Sequences.ProcessData.RefPulsesDelta = Sequences.ProcessData.RefPulses - oriRefPulses;
for (int i = 0; i < readersCount; i++) for (int i = 0; i < readersCount; i++)
{ {
@@ -55,7 +57,9 @@ namespace TBF.BenchControl.Operations
bool allDone = true; bool allDone = true;
bool anyError = false; bool anyError = false;
int oriRefPulses = Sequences.ProcessData.RefPulses;
Sequences.ProcessData.RefPulses = StateMachine.ControlBoard.EtPulses(0); Sequences.ProcessData.RefPulses = StateMachine.ControlBoard.EtPulses(0);
Sequences.ProcessData.RefPulsesDelta = Sequences.ProcessData.RefPulses - oriRefPulses;
for (int i = 0; i < readersCount; i++) for (int i = 0; i < readersCount; i++)
{ {
@@ -19,6 +19,7 @@ namespace TBF.BenchControl.Sequences
public static float LtrPerRefPulse; /// to calculate the ref.volume public static float LtrPerRefPulse; /// to calculate the ref.volume
public static int RefPulses; public static int RefPulses;
public static int RefPulsesDelta;
public static FloatBox RefFreq = new FloatBox() { Name = "RefFreq", Format = "F2" }; public static FloatBox RefFreq = new FloatBox() { Name = "RefFreq", Format = "F2" };
public static FloatBox RefFlow = new FloatBox() { Name = "RefFlow", Format = "F2" }; /// [m3/h] public static FloatBox RefFlow = new FloatBox() { Name = "RefFlow", Format = "F2" }; /// [m3/h]
@@ -68,15 +69,18 @@ namespace TBF.BenchControl.Sequences
/// ///
/// Statistics of 'continuous' variables (temperature, pressure, flow, etc.) /// Statistics of 'continuous' variables (temperature, pressure, flow, etc.)
/// ///
public static FloatStatistics AmbientTempStat = new FloatStatistics(); public static Statistics AmbientTempStat = new Statistics();
public static FloatStatistics AmbientPressureStat = new FloatStatistics(); public static Statistics AmbientPressureStat = new Statistics();
public static FloatStatistics AmbientHumidityStat = new FloatStatistics(); public static Statistics AmbientHumidityStat = new Statistics();
public static FloatStatistics TempInStat = new FloatStatistics(); public static Statistics TempInStat = new Statistics();
public static FloatStatistics TempOutStat = new FloatStatistics(); public static Statistics TempOutStat = new Statistics();
public static FloatStatistics TempDivStat = new FloatStatistics(); public static Statistics TempDivStat = new Statistics();
public static FloatStatistics PressureUpStat = new FloatStatistics(); public static Statistics PressureUpStat = new Statistics();
public static FloatStatistics PressureDownStat = new FloatStatistics(); public static Statistics PressureDownStat = new Statistics();
public static FloatStatistics RefFlowStat = new FloatStatistics(); public static Statistics RefFlowStat = new Statistics();
public static Statistics Energy = new Statistics();
public static int lastEnergyUpdateTime;
protected static void ClearAllStatistics() protected static void ClearAllStatistics()
{ {
@@ -89,6 +93,9 @@ namespace TBF.BenchControl.Sequences
PressureUpStat.Clear(); PressureUpStat.Clear();
PressureDownStat.Clear(); PressureDownStat.Clear();
RefFlowStat.Clear(); RefFlowStat.Clear();
Energy.Clear();
lastEnergyUpdateTime = 0;
} }
protected static void UpdateAllStatistics() protected static void UpdateAllStatistics()
@@ -2,24 +2,26 @@
namespace TBF.BenchControl.Sequences namespace TBF.BenchControl.Sequences
{ {
public class FloatStatistics public class Statistics
{ {
float first; double first;
float last; double last;
float min; double min;
float max; double max;
float sum; double sum;
UInt32 count; UInt32 count;
public float First { get { return first; } } public float First { get { return (float)first; } }
public float Last { get { return last; } } public float Last { get { return (float)last; } }
public float Min { get { return min; } } public float Min { get { return (float)min; } }
public float Max { get { return max; } } public float Max { get { return (float)max; } }
public float Average { get { if (Count > 0) return sum / (float)count; else return 0; } } public float Average { get { if (Count > 0) return (float)(sum / (double)count); else return 0; } }
public UInt32 Count { get { return count; } } public UInt32 Count { get { return count; } }
public double Sum { get { return sum; } }
public FloatStatistics()
public Statistics()
{ {
Clear(); Clear();
} }
@@ -41,7 +43,7 @@ namespace TBF.BenchControl.Sequences
/// Updates statistics /// Updates statistics
/// </summary> /// </summary>
/// <param name="value">New value</param> /// <param name="value">New value</param>
public void Update(float value) public void Update(double value)
{ {
if (count == 0) first = value; if (count == 0) first = value;
last = value; last = value;
@@ -51,6 +53,15 @@ namespace TBF.BenchControl.Sequences
count++; count++;
} }
/// <summary>
/// Updates statistics
/// </summary>
/// <param name="value">New boxed value</param>
public void Update(TBF.Boxes.DoubleBox box)
{
Update(box.Val);
}
/// <summary> /// <summary>
/// Updates statistics /// Updates statistics
/// </summary> /// </summary>
+1 -1
View File
@@ -516,7 +516,7 @@
<Compile Include="BenchControl\Output\FileWriters\Basic\WriterCfgCtrl.designer.cs"> <Compile Include="BenchControl\Output\FileWriters\Basic\WriterCfgCtrl.designer.cs">
<DependentUpon>WriterCfgCtrl.cs</DependentUpon> <DependentUpon>WriterCfgCtrl.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="BenchControl\Sequences\FloatStatistics.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">
<SubType>Form</SubType> <SubType>Form</SubType>