laatzen/GenesisDisplayTool/StandardDeviation.cs
2021-10-01 11:10:17 +02:00

1816 lines
87 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;
using System.Drawing.Printing;
using ZedGraph;
namespace GenesisDisplayTool
{
public partial class GENESIS_DISPLAY_TOOL : Form
{
#region Definitions and initializations
Int32[,] GraphIndexOfStdDevLists = new Int32[3, 10];
#endregion
#region Graphs
private void InitStdDevGraph(double xRange, bool enablePath0, bool enablePath1, bool enablePath2, int numberOfStdDeviationValues, int numberOfMeanValues, bool avg38en)
{
#region Definitions and initializations
string TitlePath0 = "Standard Deviation PATH1 (" + numberOfStdDeviationValues.ToString() + "values)";
string TitlePath1 = "Standard Deviation PATH2 (" + numberOfStdDeviationValues.ToString() + "values)";
string TitlePath2 = "Standard Deviation PATH3 (" + numberOfStdDeviationValues.ToString() + "values)";
if(avg38en)
{
TitlePath0 = TitlePath0 + "\n(Mean over " + numberOfMeanValues.ToString() + " values)";
TitlePath1 = TitlePath1 + "\n(Mean over " + numberOfMeanValues.ToString() + " values)";
TitlePath2 = TitlePath2 + "\n(Mean over " + numberOfMeanValues.ToString() + " values)";
}
#endregion
#region Init all graphs
#region PATH0
ParamsStdDev[Constants.PATH0].Title = TitlePath0;
ParamsStdDev[Constants.PATH0].xAxis = "Values";
ParamsStdDev[Constants.PATH0].yAxis = "time/ps";
//zGC_StdDevPath0.IsShowHScrollBar = true;
zGC_StdDevPath0.IsAutoScrollRange = true;
zGC_StdDevPath0.ScrollGrace = Constants.DefaultScrollGrace;
zGC_StdDevPath0.HorizontalScroll.Enabled = true;
zGC_StdDevPath0.GraphPane.XAxis.Scale.Min = 0;
zGC_StdDevPath0.GraphPane.XAxis.Scale.Max = xRange;
zGC_StdDevPath0.GraphPane.YAxis.Scale.MinAuto = true;
zGC_StdDevPath0.GraphPane.YAxis.Scale.MaxAuto = true;
zGC_StdDevPath0.GraphPane.XAxis.MinorGrid.IsVisible = true;
zGC_StdDevPath0.GraphPane.YAxis.MinorGrid.IsVisible = true;
zGC_StdDevPath0.GraphPane.XAxis.MajorGrid.IsVisible = true;
zGC_StdDevPath0.GraphPane.YAxis.MajorGrid.IsVisible = true;
CreateStdDevGraphPath0(zGC_StdDevPath0, ParamsStdDev[Constants.PATH0], true, tab_Maintab, enablePath0, (UInt32)nUD_SettingsXrangeStdDevGraph.Value);
#endregion
#region PATH1
ParamsStdDev[Constants.PATH1].Title = TitlePath1;
ParamsStdDev[Constants.PATH1].xAxis = "Values";
ParamsStdDev[Constants.PATH1].yAxis = "time/ps";
//zGC_StdDevPath1.IsShowHScrollBar = true;
zGC_StdDevPath1.IsAutoScrollRange = true;
zGC_StdDevPath1.ScrollGrace = Constants.DefaultScrollGrace;
zGC_StdDevPath1.HorizontalScroll.Enabled = true;
zGC_StdDevPath1.GraphPane.XAxis.Scale.Min = 0;
zGC_StdDevPath1.GraphPane.XAxis.Scale.Max = xRange;
zGC_StdDevPath1.GraphPane.YAxis.Scale.MinAuto = true;
zGC_StdDevPath1.GraphPane.YAxis.Scale.MaxAuto = true;
zGC_StdDevPath1.GraphPane.XAxis.MinorGrid.IsVisible = true;
zGC_StdDevPath1.GraphPane.YAxis.MinorGrid.IsVisible = true;
zGC_StdDevPath1.GraphPane.XAxis.MajorGrid.IsVisible = true;
zGC_StdDevPath1.GraphPane.YAxis.MajorGrid.IsVisible = true;
CreateStdDevGraphPath1(zGC_StdDevPath1, ParamsStdDev[Constants.PATH1], true, tab_Maintab, enablePath1, (UInt32)nUD_SettingsXrangeStdDevGraph.Value);
#endregion
#region PATH2
ParamsStdDev[Constants.PATH2].Title = TitlePath2;
ParamsStdDev[Constants.PATH2].xAxis = "Values";
ParamsStdDev[Constants.PATH2].yAxis = "time/ps";
//zGC_StdDevPath2.IsShowHScrollBar = true;
zGC_StdDevPath2.IsAutoScrollRange = true;
zGC_StdDevPath2.ScrollGrace = Constants.DefaultScrollGrace;
zGC_StdDevPath2.HorizontalScroll.Enabled = true;
zGC_StdDevPath2.GraphPane.XAxis.Scale.Min = 0;
zGC_StdDevPath2.GraphPane.XAxis.Scale.Max = xRange;
zGC_StdDevPath2.GraphPane.YAxis.Scale.MinAuto = true;
zGC_StdDevPath2.GraphPane.YAxis.Scale.MaxAuto = true;
zGC_StdDevPath2.GraphPane.XAxis.MinorGrid.IsVisible = true;
zGC_StdDevPath2.GraphPane.YAxis.MinorGrid.IsVisible = true;
zGC_StdDevPath2.GraphPane.XAxis.MajorGrid.IsVisible = true;
zGC_StdDevPath2.GraphPane.YAxis.MajorGrid.IsVisible = true;
CreateStdDevGraphPath2(zGC_StdDevPath2, ParamsStdDev[Constants.PATH2], true, tab_Maintab, enablePath2, (UInt32)nUD_SettingsXrangeStdDevGraph.Value);
#endregion
#endregion
}
private void ResetStdDevGraph(double xRange)
{
try
{
// Reset graph panes
zGC_StdDevPath0.ZoomOutAll(zGC_StdDevPath0.GraphPane);
zGC_StdDevPath1.ZoomOutAll(zGC_StdDevPath1.GraphPane);
zGC_StdDevPath2.ZoomOutAll(zGC_StdDevPath2.GraphPane);
zGC_StdDevPath0.GraphPane.CurveList.Clear();
zGC_StdDevPath1.GraphPane.CurveList.Clear();
zGC_StdDevPath2.GraphPane.CurveList.Clear();
zGC_StdDevPath0.GraphPane.GraphObjList.Clear();
zGC_StdDevPath1.GraphPane.GraphObjList.Clear();
zGC_StdDevPath2.GraphPane.GraphObjList.Clear();
// Reset counters
for (UInt16 Path = 0; Path < 3; Path++)
{
TelegramCounterStdDeviationMultihit[Path] = 0;
TelegramCounterStdDeviationSingle[Path] = 0;//For DifTofStdDeviationCalculator() to switch beetween buffer fill and living average mode eg. after values
GraphCounterDataStdDevTotal[Path] = 0; //Total number of graph values
for (UInt16 Hit = 0; Hit < 10; Hit++)
GraphIndexOfStdDevLists[Path, Hit] = 0;
}
// Reset range
zGC_StdDevPath0.GraphPane.XAxis.Scale.Max = xRange;
zGC_StdDevPath1.GraphPane.XAxis.Scale.Max = xRange;
zGC_StdDevPath2.GraphPane.XAxis.Scale.Max = xRange;
// Clear graphs
for (UInt16 Path = 0; Path < 3; Path++)
{
for (UInt16 Hit = 0; Hit < 10; Hit++)
{
GraphListStdDevWindow[Path, Hit].Clear();
GraphListStdDevTotal[Path, Hit].Clear();
GraphListStdDevTotal[Path, Hit].Add(new PointPairList());
}
}
// Refresh
zGC_StdDevPath0.Refresh();
zGC_StdDevPath1.Refresh();
zGC_StdDevPath2.Refresh();
}
catch(Exception ex)
{
ErrorLog.Log(LogErrReason.Exception(), "InitStdDevGraph() failed", "0x"+ex.HResult.ToString("X"), string.Empty);
}
}
private void AssignDataToStdDevGraph(DecodedData[] Decoded, UInt16 Path, UInt32 xRange, bool enablePath0, bool enablePath1, bool enablePath2)
{
#region Definitions and initializations
#endregion
try
{
#region Horizontal setup
zGC_StdDevPath0.IsAutoScrollRange = true;
zGC_StdDevPath1.IsAutoScrollRange = true;
zGC_StdDevPath2.IsAutoScrollRange = true;
zGC_StdDevPath0.ScrollGrace = Constants.DefaultScrollGrace;
zGC_StdDevPath1.ScrollGrace = Constants.DefaultScrollGrace;
zGC_StdDevPath2.ScrollGrace = Constants.DefaultScrollGrace;
zGC_StdDevPath0.HorizontalScroll.Enabled = true;
zGC_StdDevPath1.HorizontalScroll.Enabled = true;
zGC_StdDevPath2.HorizontalScroll.Enabled = true;
if (zGC_StdDevPath0.GraphPane.XAxis.Scale.Max != (double)xRange)
zGC_StdDevPath0.GraphPane.XAxis.Scale.Min = zGC_StdDevPath0.GraphPane.XAxis.Scale.Max - (double)xRange + 1;
else
zGC_StdDevPath0.GraphPane.XAxis.Scale.Min = zGC_StdDevPath0.GraphPane.XAxis.Scale.Max - (double)xRange;
if (zGC_StdDevPath1.GraphPane.XAxis.Scale.Max != (double)xRange)
zGC_StdDevPath1.GraphPane.XAxis.Scale.Min = zGC_StdDevPath1.GraphPane.XAxis.Scale.Max - (double)xRange + 1;
else
zGC_StdDevPath1.GraphPane.XAxis.Scale.Min = zGC_StdDevPath1.GraphPane.XAxis.Scale.Max - (double)xRange;
if (zGC_StdDevPath2.GraphPane.XAxis.Scale.Max != (double)xRange)
zGC_StdDevPath2.GraphPane.XAxis.Scale.Min = zGC_StdDevPath2.GraphPane.XAxis.Scale.Max - (double)xRange + 1;
else
zGC_StdDevPath2.GraphPane.XAxis.Scale.Min = zGC_StdDevPath2.GraphPane.XAxis.Scale.Max - (double)xRange;
#endregion
#region Set lists for backup whole data
for (UInt16 Hit = 0; Hit < 8; Hit++)
GraphListStdDevTotal[Path, Hit][GraphIndexOfStdDevLists[Path, Hit]].Add(GraphCounterDataStdDevTotal[Path], Decoded[Path].StdDeviation[Hit]);
GraphListStdDevTotal[Path, 8][GraphIndexOfStdDevLists[Path, 8]].Add(GraphCounterDataStdDevTotal[Path], Decoded[Path].DifTof3HitsStdDeviation);
GraphListStdDevTotal[Path, 9][GraphIndexOfStdDevLists[Path, 9]].Add(GraphCounterDataStdDevTotal[Path], Decoded[Path].DifTof8HitsStdDeviation);
for (UInt16 Hit = 0; Hit < 10; Hit++)
{
if (GraphListStdDevTotal[Path, Hit][GraphIndexOfStdDevLists[Path, Hit]].Count > Constants.StdDevGraphListMaxElements - 1)
{
GraphListStdDevTotal[Path, Hit].Add(new PointPairList());
GraphIndexOfStdDevLists[Path, Hit]++;
}
}
#endregion
#region Generate window values
for (UInt16 Hit = 0; Hit < 8; Hit++)
GraphListStdDevWindow[Path, Hit].Add(GraphCounterDataStdDevTotal[Path], Decoded[Path].StdDeviation[Hit]);
GraphListStdDevWindow[Path, 8].Add(GraphCounterDataStdDevTotal[Path], Decoded[Path].DifTof3HitsStdDeviation);
GraphListStdDevWindow[Path, 9].Add(GraphCounterDataStdDevTotal[Path], Decoded[Path].DifTof8HitsStdDeviation);
#endregion
#region Create graphs
switch (Path)
{
case Constants.PATH0:
CreateStdDevGraphPath0(zGC_StdDevPath0, ParamsStdDev[Path], false, tab_Maintab, enablePath0, (UInt32)nUD_SettingsXrangeStdDevGraph.Value);
break;
case Constants.PATH1:
CreateStdDevGraphPath1(zGC_StdDevPath1, ParamsStdDev[Path], false, tab_Maintab, enablePath1, (UInt32)nUD_SettingsXrangeStdDevGraph.Value);
break;
case Constants.PATH2:
CreateStdDevGraphPath2(zGC_StdDevPath2, ParamsStdDev[Path], false, tab_Maintab, enablePath2, (UInt32)nUD_SettingsXrangeStdDevGraph.Value);
break;
default: break;
}
#endregion
#region X-Axis control
if (GraphCounterDataStdDevTotal[Path] > UInt32.MaxValue - 2)
{
#region Counter overflow stop calculation
cB_StdDevEnable.Checked = false;
MessageBox.Show("Counter overflow, Std-Dev-Graphs stopped", "Form closing", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
#endregion
}
else
GraphCounterDataStdDevTotal[Path]++;
#endregion
#region Reset zedgraph data lists
if ((UInt32)GraphCounterDataStdDevTotal[Path] % xRange == 0)
{
cB_StdDevEnable.Enabled = false; // to avoid strange effects on deselecting hook in the wrong moment
for (UInt16 Hit = 0; Hit < 10; Hit++)
GraphListStdDevWindow[Path, Hit].Clear();
switch (Path)
{
case Constants.PATH0:
zGC_StdDevPath0.GraphPane.XAxis.Scale.Max = zGC_StdDevPath0.GraphPane.XAxis.Scale.Max + (double)xRange;
zGC_StdDevPath0.PerformAutoScale();
CreateStdDevGraphPath0(zGC_StdDevPath0, ParamsStdDev[Path], false, tab_Maintab, cB_ReportStdDevPath0.Checked, (UInt32)nUD_SettingsXrangeStdDevGraph.Value);
break;
case Constants.PATH1:
zGC_StdDevPath1.GraphPane.XAxis.Scale.Max = zGC_StdDevPath1.GraphPane.XAxis.Scale.Max + (double)xRange;
zGC_StdDevPath1.PerformAutoScale();
CreateStdDevGraphPath1(zGC_StdDevPath1, ParamsStdDev[Path], false, tab_Maintab, cB_ReportStdDevPath1.Checked, (UInt32)nUD_SettingsXrangeStdDevGraph.Value);
break;
case Constants.PATH2:
zGC_StdDevPath2.GraphPane.XAxis.Scale.Max = zGC_StdDevPath2.GraphPane.XAxis.Scale.Max + (double)xRange;
zGC_StdDevPath2.PerformAutoScale();
CreateStdDevGraphPath2(zGC_StdDevPath2, ParamsStdDev[Path], false, tab_Maintab, cB_ReportStdDevPath2.Checked, (UInt32)nUD_SettingsXrangeStdDevGraph.Value);
break;
default: break;
}
cB_StdDevEnable.Enabled = true;
}
#endregion
}
catch(Exception ex)
{
ErrorLog.Log(LogErrReason.Exception(), "AssignDataToStdDevGraph() failed", "0x"+ex.HResult.ToString("X"), string.Empty);
}
}
private void CreateStdDevGraphPath0(ZedGraphControl zgc, zedGraphParameters parameters, bool init, TabControl tab, bool enable, UInt32 xRange)
{
try
{
#region Settings for the entire graph
GraphPane myPane = zgc.GraphPane;
myPane.Title.Text = parameters.Title;
// First time initializations
if (init)
{
myPane.XAxis.MinorGrid.IsVisible = true;
myPane.YAxis.MinorGrid.IsVisible = true;
myPane.XAxis.MajorGrid.IsVisible = true;
myPane.YAxis.MajorGrid.IsVisible = true;
myPane.XAxis.Title.Text = parameters.xAxis;
myPane.YAxis.Title.Text = parameters.yAxis;
myPane.Fill.Color = Color.AliceBlue;
myPane.Chart.Fill.Color = Color.Cornsilk;
myPane.Legend.Fill.Color = Color.Cornsilk;
}
// X-Axis decimal point
// if (GraphListStdDevTotal[Constants.PATH0][Constants.HIT0].Count > (100000 - nUD_SettingsXStdDevGraph.Value)) // tab "Settings
if (GraphCounterDataStdDevTotal[Constants.PATH0] > (100000 - xRange))
myPane.XAxis.Scale.Format = "0.0000";
else
{
//if (GraphListStdDevTotal[Constants.PATH0][Constants.HIT0].Count > (10000 - nUD_SettingsXStdDevGraph.Value))
if (GraphCounterDataStdDevTotal[Constants.PATH0] > (10000 - xRange))
myPane.XAxis.Scale.Format = "0.00";
else
myPane.XAxis.Scale.Format = "0";
}
//Needed for redrawing the chart, to remove old curves
myPane.CurveList.Clear();
#endregion
#region Set data
#region HIT0
#region Add Data
LineItem myCurveHit0 = myPane.AddCurve("HIT0", GraphListStdDevWindow[Constants.PATH0, Constants.HIT0], Color.Red);
#endregion
#region Customize the graph
myCurveHit0.Line.IsVisible = true; //Hide line-connections
myCurveHit0.Symbol.Type = SymbolType.Circle;
myCurveHit0.Symbol.Size = 2f;
myCurveHit0.Symbol.Fill.Type = FillType.Solid;
myCurveHit0.Symbol.IsAntiAlias = true; //Makes the circles smoother
myCurveHit0.IsSelected = false;
#endregion
#endregion
#region HIT1
#region Add data
LineItem myCurveHit1 = myPane.AddCurve("HIT1", GraphListStdDevWindow[Constants.PATH0, Constants.HIT1], Color.Blue);
#endregion
#region Customize the graph
myCurveHit1.Line.IsVisible = true; //Hide line-connections
myCurveHit1.Symbol.Type = SymbolType.Circle;
myCurveHit1.Symbol.Size = 2f;
myCurveHit1.Symbol.Fill.Type = FillType.Solid;
myCurveHit1.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT2
#region Add the data
LineItem myCurveHit2 = myPane.AddCurve("HIT2", GraphListStdDevWindow[Constants.PATH0, Constants.HIT2], Color.Green);
#endregion
#region Customize the graph
myCurveHit2.Line.IsVisible = true; //Hide line-connections
myCurveHit2.Symbol.Type = SymbolType.Circle;
myCurveHit2.Symbol.Size = 2f;
myCurveHit2.Symbol.Fill.Type = FillType.Solid;
myCurveHit2.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT3
#region Add the data
LineItem myCurveHit3 = myPane.AddCurve("HIT3", GraphListStdDevWindow[Constants.PATH0, Constants.HIT3], Color.Cyan);
#endregion
#region Customize the graph
myCurveHit3.Line.IsVisible = true; //Hide line-connections
myCurveHit3.Symbol.Type = SymbolType.Circle;
myCurveHit3.Symbol.Size = 2f;
myCurveHit3.Symbol.Fill.Type = FillType.Solid;
myCurveHit3.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT4
#region Add the data
LineItem myCurveHit4 = myPane.AddCurve("HIT4", GraphListStdDevWindow[Constants.PATH0, Constants.HIT4], Color.Brown);
#endregion
#region Customize the graph
myCurveHit4.Line.IsVisible = true; //Hide line-connections
myCurveHit4.Symbol.Type = SymbolType.Circle;
myCurveHit4.Symbol.Size = 2f;
myCurveHit4.Symbol.Fill.Type = FillType.Solid;
myCurveHit4.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT5
#region Add the data
LineItem myCurveHit5 = myPane.AddCurve("HIT5", GraphListStdDevWindow[Constants.PATH0, Constants.HIT5], Color.BlueViolet);
#endregion
#region Customize the graph
myCurveHit5.Line.IsVisible = true; //Hide line-connections
myCurveHit5.Symbol.Type = SymbolType.Circle;
myCurveHit5.Symbol.Size = 2f;
myCurveHit5.Symbol.Fill.Type = FillType.Solid;
myCurveHit5.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT6
#region Add the data
LineItem myCurveHit6 = myPane.AddCurve("HIT6", GraphListStdDevWindow[Constants.PATH0, Constants.HIT6], Color.DarkGreen);
#endregion
#region Customize the graph
myCurveHit6.Line.IsVisible = true; //Hide line-connections
myCurveHit6.Symbol.Type = SymbolType.Circle;
myCurveHit6.Symbol.Size = 2f;
myCurveHit6.Symbol.Fill.Type = FillType.Solid;
myCurveHit6.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT7
#region Add the data
LineItem myCurveHit7 = myPane.AddCurve("HIT7", GraphListStdDevWindow[Constants.PATH0, Constants.HIT7], Color.Orange);
#endregion
#region Customize the graph
myCurveHit7.Line.IsVisible = true; //Hide line-connections
myCurveHit7.Symbol.Type = SymbolType.Circle;
myCurveHit7.Symbol.Size = 2f;
myCurveHit7.Symbol.Fill.Type = FillType.Solid;
myCurveHit7.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region 3 HITS
#region Add the data
LineItem myCurve3Hits = myPane.AddCurve("3 HITS", GraphListStdDevWindow[Constants.PATH0, 8], Color.DarkCyan);
#endregion
#region Customize the graph
myCurve3Hits.Line.IsVisible = true; //Hide line-connections
myCurve3Hits.Symbol.Type = SymbolType.Circle;
myCurve3Hits.Symbol.Size = 2f;
myCurve3Hits.Symbol.Fill.Type = FillType.Solid;
myCurve3Hits.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region 8 HITS
#region Add the data
LineItem myCurve8Hits = myPane.AddCurve("8 HITS", GraphListStdDevWindow[Constants.PATH0, 9], Color.DarkOrange);
#endregion
#region Customize the graph
myCurve8Hits.Line.IsVisible = true; //Hide line-connections
myCurve8Hits.Symbol.Type = SymbolType.Circle;
myCurve8Hits.Symbol.Size = 2f;
myCurve8Hits.Symbol.Fill.Type = FillType.Solid;
myCurve8Hits.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#endregion
#region Enable/ disable curves
#region HIT0
if (cB_StdDev0path0.Checked)
{
myCurveHit0.IsVisible = true; // curve
myCurveHit0.Label.IsVisible = true; // legend item
}
else
{
myCurveHit0.IsVisible = false; // curve
myCurveHit0.Label.IsVisible = false; // legend item
}
#endregion
#region HIT1
if (cB_StdDev1path0.Checked)
{
myCurveHit1.IsVisible = true; // curve
myCurveHit1.Label.IsVisible = true; // legend item
}
else
{
myCurveHit1.IsVisible = false; // curve
myCurveHit1.Label.IsVisible = false; // legend item
}
#endregion
#region HIT2
if (cB_StdDev2path0.Checked)
{
myCurveHit2.IsVisible = true;
myCurveHit2.Label.IsVisible = true;
}
else
{
myCurveHit2.IsVisible = false;
myCurveHit2.Label.IsVisible = false;
}
#endregion
#region HIT3
if (cB_StdDev3path0.Checked)
{
myCurveHit3.IsVisible = true;
myCurveHit3.Label.IsVisible = true;
}
else
{
myCurveHit3.IsVisible = false;
myCurveHit3.Label.IsVisible = false;
}
#endregion
#region HIT4
if (cB_StdDev4path0.Checked)
{
myCurveHit4.IsVisible = true;
myCurveHit4.Label.IsVisible = true;
}
else
{
myCurveHit4.IsVisible = false;
myCurveHit4.Label.IsVisible = false;
}
#endregion
#region HIT5
if (cB_StdDev5path0.Checked)
{
myCurveHit5.IsVisible = true;
myCurveHit5.Label.IsVisible = true;
}
else
{
myCurveHit5.IsVisible = false;
myCurveHit5.Label.IsVisible = false;
}
#endregion
#region HIT6
if (cB_StdDev6path0.Checked)
{
myCurveHit6.IsVisible = true;
myCurveHit6.Label.IsVisible = true;
}
else
{
myCurveHit6.IsVisible = false;
myCurveHit6.Label.IsVisible = false;
}
#endregion
#region HIT7
if (cB_StdDev7path0.Checked)
{
myCurveHit7.IsVisible = true;
myCurveHit7.Label.IsVisible = true;
}
else
{
myCurveHit7.IsVisible = false;
myCurveHit7.Label.IsVisible = false;
}
#endregion
#region 3HITS
if (cB_StdDev3CrossingsPath0.Checked)
{
myCurve3Hits.IsVisible = true;
myCurve3Hits.Label.IsVisible = true;
}
else
{
myCurve3Hits.IsVisible = false;
myCurve3Hits.Label.IsVisible = false;
}
#endregion
#region 8HITS
if (cB_StdDev8CrossingsPath0.Checked)
{
myCurve8Hits.IsVisible = true;
myCurve8Hits.Label.IsVisible = true;
}
else
{
myCurve8Hits.IsVisible = false;
myCurve8Hits.Label.IsVisible = false;
}
#endregion
#endregion
#region Refresh the graph in order to show the new data
zgc.AxisChange();
if ((tab.SelectedTab == tab_StdDev) ||
((tab.SelectedTab == tab_Report) && (enable)))
{
zgc.Invalidate();
zgc.Refresh();
}
#endregion
}
catch(Exception ex)
{
#region Error: exception
ErrorLog.Log(LogErrReason.Exception(), "CreateStdDevGraphPath0() failed", "0x"+ex.HResult.ToString("X"), string.Empty);
#endregion
}
}
private void CreateStdDevGraphPath1(ZedGraphControl zgc, zedGraphParameters parameters, bool init, TabControl tab, bool enable, UInt32 xRange)
{
try
{
#region Settings for the entire graph
GraphPane myPane = zgc.GraphPane;
myPane.Title.Text = parameters.Title;
// First time initializations
if (init)
{
myPane.XAxis.MinorGrid.IsVisible = true;
myPane.YAxis.MinorGrid.IsVisible = true;
myPane.XAxis.MajorGrid.IsVisible = true;
myPane.YAxis.MajorGrid.IsVisible = true;
myPane.XAxis.Title.Text = parameters.xAxis;
myPane.YAxis.Title.Text = parameters.yAxis;
myPane.Fill.Color = Color.AliceBlue;
myPane.Chart.Fill.Color = Color.Cornsilk;
myPane.Legend.Fill.Color = Color.Cornsilk;
}
// X-Axis decimal point
//if (GraphListStdDevTotal[Constants.PATH1][Constants.HIT0].Count > (100000 - nUD_SettingsXStdDevGraph.Value)) // tab "Settings
if (GraphCounterDataStdDevTotal[Constants.PATH0] > (100000 - xRange))
myPane.XAxis.Scale.Format = "0.0000";
else
{
if (GraphCounterDataStdDevTotal[Constants.PATH0] > (10000 - xRange))
myPane.XAxis.Scale.Format = "0.00";
else
myPane.XAxis.Scale.Format = "0";
}
//Needed for redrawing the chart, to remove old curves
myPane.CurveList.Clear();
#endregion
#region Set data
#region HIT0
#region Add data
LineItem myCurveHit0 = myPane.AddCurve("HIT0", GraphListStdDevWindow[Constants.PATH1, Constants.HIT0], Color.Red);
#endregion
#region Customize the graph
myCurveHit0.Line.IsVisible = true; //Hide line-connections
myCurveHit0.Symbol.Type = SymbolType.Circle;
myCurveHit0.Symbol.Size = 2f;
myCurveHit0.Symbol.Fill.Type = FillType.Solid;
myCurveHit0.Symbol.IsAntiAlias = true; //Makes the circles smoother
myCurveHit0.IsSelected = false;
#endregion
#endregion
#region HIT1
#region Add data
LineItem myCurveHit1 = myPane.AddCurve("HIT1", GraphListStdDevWindow[Constants.PATH1, Constants.HIT1], Color.Blue);
#endregion
#region customize the graph
myCurveHit1.Line.IsVisible = true; //Hide line-connections
myCurveHit1.Symbol.Type = SymbolType.Circle;
myCurveHit1.Symbol.Size = 2f;
myCurveHit1.Symbol.Fill.Type = FillType.Solid;
myCurveHit1.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT2
#region Add data
LineItem myCurveHit2 = myPane.AddCurve("HIT2", GraphListStdDevWindow[Constants.PATH1, Constants.HIT2], Color.Green);
#endregion
#region Customize the graph
myCurveHit2.Line.IsVisible = true; //Hide line-connections
myCurveHit2.Symbol.Type = SymbolType.Circle;
myCurveHit2.Symbol.Size = 2f;
myCurveHit2.Symbol.Fill.Type = FillType.Solid;
myCurveHit2.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT3
#region Add data
LineItem myCurveHit3 = myPane.AddCurve("HIT3", GraphListStdDevWindow[Constants.PATH1, Constants.HIT3], Color.Cyan);
#endregion
#region Customize the graph
myCurveHit3.Line.IsVisible = true; //Hide line-connections
myCurveHit3.Symbol.Type = SymbolType.Circle;
myCurveHit3.Symbol.Size = 2f;
myCurveHit3.Symbol.Fill.Type = FillType.Solid;
myCurveHit3.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT4
#region Add data
LineItem myCurveHit4 = myPane.AddCurve("HIT4", GraphListStdDevWindow[Constants.PATH1, Constants.HIT4], Color.Brown);
#endregion
#region Customize the graph
myCurveHit4.Line.IsVisible = true; //Hide line-connections
myCurveHit4.Symbol.Type = SymbolType.Circle;
myCurveHit4.Symbol.Size = 2f;
myCurveHit4.Symbol.Fill.Type = FillType.Solid;
myCurveHit4.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT5
#region Add data
LineItem myCurveHit5 = myPane.AddCurve("HIT5", GraphListStdDevWindow[Constants.PATH1, Constants.HIT5], Color.BlueViolet);
#endregion
#region Customize the graph
myCurveHit5.Line.IsVisible = true; //Hide line-connections
myCurveHit5.Symbol.Type = SymbolType.Circle;
myCurveHit5.Symbol.Size = 2f;
myCurveHit5.Symbol.Fill.Type = FillType.Solid;
myCurveHit5.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT6
#region Add data
LineItem myCurveHit6 = myPane.AddCurve("HIT6", GraphListStdDevWindow[Constants.PATH1, Constants.HIT6], Color.DarkGreen);
#endregion
#region Customize the graph
myCurveHit6.Line.IsVisible = true; //Hide line-connections
myCurveHit6.Symbol.Type = SymbolType.Circle;
myCurveHit6.Symbol.Size = 2f;
myCurveHit6.Symbol.Fill.Type = FillType.Solid;
myCurveHit6.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT7
#region Add data
LineItem myCurveHit7 = myPane.AddCurve("HIT7", GraphListStdDevWindow[Constants.PATH1, Constants.HIT7], Color.Orange);
#endregion
#region Customize the graph
myCurveHit7.Line.IsVisible = true; //Hide line-connections
myCurveHit7.Symbol.Type = SymbolType.Circle;
myCurveHit7.Symbol.Size = 2f;
myCurveHit7.Symbol.Fill.Type = FillType.Solid;
myCurveHit7.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region 3 HITS
#region Add data
LineItem myCurve3Hits = myPane.AddCurve("3 HITS", GraphListStdDevWindow[Constants.PATH1, 8], Color.DarkCyan);
#endregion
#region Customize the graph
myCurve3Hits.Line.IsVisible = true; //Hide line-connections
myCurve3Hits.Symbol.Type = SymbolType.Circle;
myCurve3Hits.Symbol.Size = 2f;
myCurve3Hits.Symbol.Fill.Type = FillType.Solid;
myCurve3Hits.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region 8 HITS
#region Add data
LineItem myCurve8Hits = myPane.AddCurve("8 HITS", GraphListStdDevWindow[Constants.PATH1, 9], Color.DarkOrange);
#endregion
#region Customize the graph
myCurve8Hits.Line.IsVisible = true; //Hide line-connections
myCurve8Hits.Symbol.Type = SymbolType.Circle;
myCurve8Hits.Symbol.Size = 2f;
myCurve8Hits.Symbol.Fill.Type = FillType.Solid;
myCurve8Hits.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#endregion
#region Enable/ disable curves
#region HIT0
if (cB_StdDev0path1.Checked)
{
myCurveHit0.IsVisible = true;
myCurveHit0.Label.IsVisible = true;
}
else
{
myCurveHit0.IsVisible = false;
myCurveHit0.Label.IsVisible = false;
}
#endregion
#region HIT1
if (cB_StdDev1path1.Checked)
{
myCurveHit1.IsVisible = true;
myCurveHit1.Label.IsVisible = true;
}
else
{
myCurveHit1.IsVisible = false;
myCurveHit1.Label.IsVisible = false;
}
#endregion
#region HIT2
if (cB_StdDev2path1.Checked)
{
myCurveHit2.IsVisible = true;
myCurveHit2.Label.IsVisible = true;
}
else
{
myCurveHit2.IsVisible = false;
myCurveHit2.Label.IsVisible = false;
}
#endregion
#region HIT3
if (cB_StdDev3path1.Checked)
{
myCurveHit3.IsVisible = true;
myCurveHit3.Label.IsVisible = true;
}
else
{
myCurveHit3.IsVisible = false;
myCurveHit3.Label.IsVisible = false;
}
#endregion
#region HIT4
if (cB_StdDev4path1.Checked)
{
myCurveHit4.IsVisible = true;
myCurveHit4.Label.IsVisible = true;
}
else
{
myCurveHit4.IsVisible = false;
myCurveHit4.Label.IsVisible = false;
}
#endregion
#region HIT5
if (cB_StdDev5path1.Checked)
{
myCurveHit5.IsVisible = true;
myCurveHit5.Label.IsVisible = true;
}
else
{
myCurveHit5.IsVisible = false;
myCurveHit5.Label.IsVisible = false;
}
#endregion
#region HIT6
if (cB_StdDev6path1.Checked)
{
myCurveHit6.IsVisible = true;
myCurveHit6.Label.IsVisible = true;
}
else
{
myCurveHit6.IsVisible = false;
myCurveHit6.Label.IsVisible = false;
}
#endregion
#region HIT7
if (cB_StdDev7path1.Checked)
{
myCurveHit7.IsVisible = true;
myCurveHit7.Label.IsVisible = true;
}
else
{
myCurveHit7.IsVisible = false;
myCurveHit7.Label.IsVisible = false;
}
#endregion
#region 3HITS
if (cB_StdDev3CrossingsPath1.Checked)
{
myCurve3Hits.IsVisible = true;
myCurve3Hits.Label.IsVisible = true;
}
else
{
myCurve3Hits.IsVisible = false;
myCurve3Hits.Label.IsVisible = false;
}
#endregion
#region 8HITS
if (cB_StdDev8CrossingsPath1.Checked)
{
myCurve8Hits.IsVisible = true;
myCurve8Hits.Label.IsVisible = true;
}
else
{
myCurve8Hits.IsVisible = false;
myCurve8Hits.Label.IsVisible = false;
}
#endregion
#endregion
#region Refresh the graph in order to show the new data
zgc.AxisChange();
if ((tab.SelectedTab == tab_StdDev) ||
((tab.SelectedTab == tab_Report) && (enable)))
{
zgc.Invalidate();
zgc.Refresh();
}
#endregion
}
catch(Exception ex)
{
#region Error: exception
ErrorLog.Log(LogErrReason.Exception(), "CreateStdDevGraphPath1() failed", "0x"+ex.HResult.ToString("X"), string.Empty);
#endregion
}
}
private void CreateStdDevGraphPath2(ZedGraphControl zgc, zedGraphParameters parameters, bool init, TabControl tab, bool enable, UInt32 xRange)
{
try
{
#region Settings for the entire graph
GraphPane myPane = zgc.GraphPane;
myPane.Title.Text = parameters.Title;
// First time initializations
if (init)
{
myPane.XAxis.MinorGrid.IsVisible = true;
myPane.YAxis.MinorGrid.IsVisible = true;
myPane.XAxis.MajorGrid.IsVisible = true;
myPane.YAxis.MajorGrid.IsVisible = true;
myPane.XAxis.Title.Text = parameters.xAxis;
myPane.YAxis.Title.Text = parameters.yAxis;
myPane.Fill.Color = Color.AliceBlue;
myPane.Chart.Fill.Color = Color.Cornsilk;
myPane.Legend.Fill.Color = Color.Cornsilk;
}
// X-Axis decimal point
if (GraphCounterDataStdDevTotal[Constants.PATH0] > (100000 - xRange))
//if (GraphListStdDevTotal[Constants.PATH2][Constants.HIT0].Count > (100000 - nUD_SettingsXStdDevGraph.Value)) // tab "Settings
myPane.XAxis.Scale.Format = "0.0000";
else
{
if (GraphCounterDataStdDevTotal[Constants.PATH0] > (10000 - xRange))
myPane.XAxis.Scale.Format = "0.00";
else
myPane.XAxis.Scale.Format = "0";
}
//Needed for redrawing the chart, to remove old curves
myPane.CurveList.Clear();
#endregion
#region Set data
#region HIT0
#region Add data
LineItem myCurveHit0 = myPane.AddCurve("HIT0", GraphListStdDevWindow[Constants.PATH2, Constants.HIT0], Color.Red);
#endregion
#region Customize the graph
myCurveHit0.Line.IsVisible = true; //Hide line-connections
myCurveHit0.Symbol.Type = SymbolType.Circle;
myCurveHit0.Symbol.Size = 2f;
myCurveHit0.Symbol.Fill.Type = FillType.Solid;
myCurveHit0.Symbol.IsAntiAlias = true; //Makes the circles smoother
myCurveHit0.IsSelected = false;
#endregion
#endregion
#region HIT1
#region Add data
LineItem myCurveHit1 = myPane.AddCurve("HIT1", GraphListStdDevWindow[Constants.PATH2, Constants.HIT1], Color.Blue);
#endregion
#region customize the graph
myCurveHit1.Line.IsVisible = true; //Hide line-connections
myCurveHit1.Symbol.Type = SymbolType.Circle;
myCurveHit1.Symbol.Size = 2f;
myCurveHit1.Symbol.Fill.Type = FillType.Solid;
myCurveHit1.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT2
#region Add data
LineItem myCurveHit2 = myPane.AddCurve("HIT2", GraphListStdDevWindow[Constants.PATH2, Constants.HIT2], Color.Green);
#endregion
#region Customize the graph
myCurveHit2.Line.IsVisible = true; //Hide line-connections
myCurveHit2.Symbol.Type = SymbolType.Circle;
myCurveHit2.Symbol.Size = 2f;
myCurveHit2.Symbol.Fill.Type = FillType.Solid;
myCurveHit2.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT3
#region Add data
LineItem myCurveHit3 = myPane.AddCurve("HIT3", GraphListStdDevWindow[Constants.PATH2, Constants.HIT3], Color.Cyan);
#endregion
#region Customize the graph
myCurveHit3.Line.IsVisible = true; //Hide line-connections
myCurveHit3.Symbol.Type = SymbolType.Circle;
myCurveHit3.Symbol.Size = 2f;
myCurveHit3.Symbol.Fill.Type = FillType.Solid;
myCurveHit3.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT4
#region Add data
LineItem myCurveHit4 = myPane.AddCurve("HIT4", GraphListStdDevWindow[Constants.PATH2, Constants.HIT4], Color.Brown);
#endregion
#region Customize the graph
myCurveHit4.Line.IsVisible = true; //Hide line-connections
myCurveHit4.Symbol.Type = SymbolType.Circle;
myCurveHit4.Symbol.Size = 2f;
myCurveHit4.Symbol.Fill.Type = FillType.Solid;
myCurveHit4.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT5
#region Add data
LineItem myCurveHit5 = myPane.AddCurve("HIT5", GraphListStdDevWindow[Constants.PATH2, Constants.HIT5], Color.BlueViolet);
#endregion
#region Customize the graph
myCurveHit5.Line.IsVisible = true; //Hide line-connections
myCurveHit5.Symbol.Type = SymbolType.Circle;
myCurveHit5.Symbol.Size = 2f;
myCurveHit5.Symbol.Fill.Type = FillType.Solid;
myCurveHit5.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT6
#region Add data
LineItem myCurveHit6 = myPane.AddCurve("HIT6", GraphListStdDevWindow[Constants.PATH2, Constants.HIT6], Color.DarkGreen);
#endregion
#region Customize the graph
myCurveHit6.Line.IsVisible = true; //Hide line-connections
myCurveHit6.Symbol.Type = SymbolType.Circle;
myCurveHit6.Symbol.Size = 2f;
myCurveHit6.Symbol.Fill.Type = FillType.Solid;
myCurveHit6.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region HIT7
#region Add data
LineItem myCurveHit7 = myPane.AddCurve("HIT7", GraphListStdDevWindow[Constants.PATH2, Constants.HIT7], Color.Orange);
#endregion
#region Customize the graph
myCurveHit7.Line.IsVisible = true; //Hide line-connections
myCurveHit7.Symbol.Type = SymbolType.Circle;
myCurveHit7.Symbol.Size = 2f;
myCurveHit7.Symbol.Fill.Type = FillType.Solid;
myCurveHit7.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region 3 HITS
#region Add data
LineItem myCurve3Hits = myPane.AddCurve("3 HITS", GraphListStdDevWindow[Constants.PATH2, 8], Color.DarkCyan);
#endregion
#region Customize the graph
myCurve3Hits.Line.IsVisible = true; //Hide line-connections
myCurve3Hits.Symbol.Type = SymbolType.Circle;
myCurve3Hits.Symbol.Size = 2f;
myCurve3Hits.Symbol.Fill.Type = FillType.Solid;
myCurve3Hits.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#region 8 HITS
#region Add data
LineItem myCurve8Hits = myPane.AddCurve("8 HITS", GraphListStdDevWindow[Constants.PATH2, 9], Color.DarkOrange);
#endregion
#region Customize the graph
myCurve8Hits.Line.IsVisible = true; //Hide line-connections
myCurve8Hits.Symbol.Type = SymbolType.Circle;
myCurve8Hits.Symbol.Size = 2f;
myCurve8Hits.Symbol.Fill.Type = FillType.Solid;
myCurve8Hits.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#endregion
#region Enable/ disable curves
#region HIT0
if (cB_StdDev0path2.Checked)
{
myCurveHit0.IsVisible = true;
myCurveHit0.Label.IsVisible = true;
}
else
{
myCurveHit0.IsVisible = false;
myCurveHit0.Label.IsVisible = false;
}
#endregion
#region HIT1
if (cB_StdDev1path2.Checked)
{
myCurveHit1.IsVisible = true;
myCurveHit1.Label.IsVisible = true;
}
else
{
myCurveHit1.IsVisible = false;
myCurveHit1.Label.IsVisible = false;
}
#endregion
#region HIT2
if (cB_StdDev2path2.Checked)
{
myCurveHit2.IsVisible = true;
myCurveHit2.Label.IsVisible = true;
}
else
{
myCurveHit2.IsVisible = false;
myCurveHit2.Label.IsVisible = false;
}
#endregion
#region HIT3
if (cB_StdDev3path2.Checked)
{
myCurveHit3.IsVisible = true;
myCurveHit3.Label.IsVisible = true;
}
else
{
myCurveHit3.IsVisible = false;
myCurveHit3.Label.IsVisible = false;
}
#endregion
#region HIT4
if (cB_StdDev4path2.Checked)
{
myCurveHit4.IsVisible = true;
myCurveHit4.Label.IsVisible = true;
}
else
{
myCurveHit4.IsVisible = false;
myCurveHit4.Label.IsVisible = false;
}
#endregion
#region HIT5
if (cB_StdDev5path2.Checked)
{
myCurveHit5.IsVisible = true;
myCurveHit5.Label.IsVisible = true;
}
else
{
myCurveHit5.IsVisible = false;
myCurveHit5.Label.IsVisible = false;
}
#endregion
#region HIT6
if (cB_StdDev6path2.Checked)
{
myCurveHit6.IsVisible = true;
myCurveHit6.Label.IsVisible = true;
}
else
{
myCurveHit6.IsVisible = false;
myCurveHit6.Label.IsVisible = false;
}
#endregion
#region HIT7
if (cB_StdDev7path2.Checked)
{
myCurveHit7.IsVisible = true;
myCurveHit7.Label.IsVisible = true;
}
else
{
myCurveHit7.IsVisible = false;
myCurveHit7.Label.IsVisible = false;
}
#endregion
#region 3HITS
if (cB_StdDev3CrossingsPath2.Checked)
{
myCurve3Hits.IsVisible = true;
myCurve3Hits.Label.IsVisible = true;
}
else
{
myCurve3Hits.IsVisible = false;
myCurve3Hits.Label.IsVisible = false;
}
#endregion
#region 8HITS
if (cB_StdDev8CrossingsPath2.Checked)
{
myCurve8Hits.IsVisible = true;
myCurve8Hits.Label.IsVisible = true;
}
else
{
myCurve8Hits.IsVisible = false;
myCurve8Hits.Label.IsVisible = false;
}
#endregion
#endregion
#region Refresh the graph in order to show the new data
zgc.AxisChange();
if ((tab.SelectedTab == tab_StdDev) ||
((tab.SelectedTab == tab_Report) && (enable)))
{
zgc.Invalidate();
zgc.Refresh();
}
#endregion
}
catch(Exception ex)
{
#region Error: exception
ErrorLog.Log(LogErrReason.Exception(), "CreateStdDevGraphPath2() failed", "0x"+ex.HResult.ToString("X"), string.Empty);
#endregion
}
}
#endregion
#region Calculations
#region Start background workers
private UInt16 StartBackgroundWorkerStdDeviationPath0(string messageType, UInt16 inputElapsedCounterStdDevCycles, bool enable)
{
if ((enable) && (messageType == Message.Data))
{
#region Start workers
if (!backgroundStdDev.IsBusy)
{
backgroundStdDev.RunWorkerAsync();
}
else
{
if (!backgroundStdDev2.IsBusy)
{
backgroundStdDev2.RunWorkerAsync();
}
else
{
inputElapsedCounterStdDevCycles++;
}
}
#endregion
}
#region Return data
return inputElapsedCounterStdDevCycles;
#endregion
}
private UInt16 StartBackgroundWorkerStdDeviationPath1(string messageType, UInt16 inputElapsedCounterStdDevCycles, bool enable)
{
if ((enable) && (messageType == Message.Data))
{
#region Start workers
if (!backgroundStdDev3.IsBusy)
{
backgroundStdDev3.RunWorkerAsync();
}
else
{
if (!backgroundStdDev4.IsBusy)
{
backgroundStdDev4.RunWorkerAsync();
}
else
{
inputElapsedCounterStdDevCycles++;
}
}
#endregion
}
#region Return data
return inputElapsedCounterStdDevCycles;
#endregion
}
private UInt16 StartBackgroundWorkerStdDeviationPath2(string messageType, UInt16 inputElapsedCounterStdDevCycles, bool enable)
{
if ((enable) && (messageType == Message.Data))
{
#region Start workers
if (!backgroundStdDev5.IsBusy)
{
backgroundStdDev5.RunWorkerAsync();
}
else
{
if (!backgroundStdDev6.IsBusy)
{
backgroundStdDev6.RunWorkerAsync();
}
else
{
inputElapsedCounterStdDevCycles++;
}
}
#endregion
}
#region Return data
return inputElapsedCounterStdDevCycles;
#endregion
}
#endregion
#region Background worker do work
private void backgroundStdDev_DoWork(object sender, DoWorkEventArgs e)
{
Decoded = StdDeviationCalculate.CalcSingle(Constants.PATH0, Decoded, ref TelegramCounterStdDeviationSingle, ref ProcessingStdDeviation, (UInt16)nUD_SettingsStdDev.Value);
// Start calculation when 'Mean' calculation ready
//if ((TelegramCounterMultiHitMean[Constants.PATH0]>=(UInt16)nUD_SettingsMean.Value))
Decoded = StdDeviationCalculate.CalcMulti(Constants.PATH0, Decoded, ref TelegramCounterStdDeviationMultihit, ref Processing3HitsStdDeviation, ref Processing8HitsStdDeviation, (UInt16)nUD_SettingsStdDev.Value);
}
private void backgroundStdDev2_DoWork(object sender, DoWorkEventArgs e)
{
Decoded = StdDeviationCalculate.CalcSingle(Constants.PATH0, Decoded, ref TelegramCounterStdDeviationSingle, ref ProcessingStdDeviation, (UInt16)nUD_SettingsStdDev.Value);
// Start calculation when 'Mean' calculation ready
//if ((TelegramCounterMultiHitMean[Constants.PATH0] >= (UInt16)nUD_SettingsMean.Value))
Decoded = StdDeviationCalculate.CalcMulti(Constants.PATH0, Decoded, ref TelegramCounterStdDeviationMultihit, ref Processing3HitsStdDeviation, ref Processing8HitsStdDeviation, (UInt16)nUD_SettingsStdDev.Value);
}
private void backgroundStdDev3_DoWork(object sender, DoWorkEventArgs e)
{
Decoded = StdDeviationCalculate.CalcSingle(Constants.PATH1, Decoded, ref TelegramCounterStdDeviationSingle, ref ProcessingStdDeviation, (UInt16)nUD_SettingsStdDev.Value);
// Start calculation when 'Mean' calculation ready
//if ((TelegramCounterMultiHitMean[Constants.PATH1] >= (UInt16)nUD_SettingsMean.Value))
Decoded = StdDeviationCalculate.CalcMulti(Constants.PATH1, Decoded, ref TelegramCounterStdDeviationMultihit, ref Processing3HitsStdDeviation, ref Processing8HitsStdDeviation, (UInt16)nUD_SettingsStdDev.Value);
}
private void backgroundStdDev4_DoWork(object sender, DoWorkEventArgs e)
{
Decoded = StdDeviationCalculate.CalcSingle(Constants.PATH1, Decoded, ref TelegramCounterStdDeviationSingle, ref ProcessingStdDeviation, (UInt16)nUD_SettingsStdDev.Value);
// Start calculation when 'Mean' calculation ready
//if ((TelegramCounterMultiHitMean[Constants.PATH1] >= (UInt16)nUD_SettingsMean.Value))
Decoded = StdDeviationCalculate.CalcMulti(Constants.PATH1, Decoded, ref TelegramCounterStdDeviationMultihit, ref Processing3HitsStdDeviation, ref Processing8HitsStdDeviation, (UInt16)nUD_SettingsStdDev.Value);
}
private void backgroundStdDev5_DoWork(object sender, DoWorkEventArgs e)
{
Decoded = StdDeviationCalculate.CalcSingle(Constants.PATH2, Decoded, ref TelegramCounterStdDeviationSingle, ref ProcessingStdDeviation, (UInt16)nUD_SettingsStdDev.Value);
// Start calculation when 'Mean' calculation ready
//if ((TelegramCounterMultiHitMean[Constants.PATH2] >= (UInt16)nUD_SettingsMean.Value))
Decoded = StdDeviationCalculate.CalcMulti(Constants.PATH2, Decoded, ref TelegramCounterStdDeviationMultihit, ref Processing3HitsStdDeviation, ref Processing8HitsStdDeviation, (UInt16)nUD_SettingsStdDev.Value);
}
private void backgroundStdDev6_DoWork(object sender, DoWorkEventArgs e)
{
Decoded = StdDeviationCalculate.CalcSingle(Constants.PATH2, Decoded, ref TelegramCounterStdDeviationSingle, ref ProcessingStdDeviation, (UInt16)nUD_SettingsStdDev.Value);
// Start calculation when 'Mean' calculation ready
//if ((TelegramCounterMultiHitMean[Constants.PATH2] >= (UInt16)nUD_SettingsMean.Value))
Decoded = StdDeviationCalculate.CalcMulti(Constants.PATH2, Decoded, ref TelegramCounterStdDeviationMultihit, ref Processing3HitsStdDeviation, ref Processing8HitsStdDeviation, (UInt16)nUD_SettingsStdDev.Value);
}
#endregion
#region Background workers completed
private void backgroundStdDev_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
#region Progress bar
if (TelegramCounterStdDeviationMultihit[Constants.PATH0] <= (UInt16)nUD_SettingsStdDev.Value)
{
#region Progress bar on tab "Maingraph"
if ((cB_GraphReset.Checked) && (lB_Graph_SelectGraph.Text.Contains("deviation")))
{
pB_MainGraphPrepareData.Maximum = (int)nUD_SettingsStdDev.Value;
pB_MainGraphPrepareData.Value = (int)TelegramCounterStdDeviationMultihit[Constants.PATH0];
}
#endregion
}
#endregion
#region Progress bar
pB_StdDeviation.Value = (int)TelegramCounterStdDeviationSingle[Constants.PATH0];
#endregion
#region Assign to graphs/ labels
#region Assign to graphs
if (TelegramCounterStdDeviationMultihit[Constants.PATH0] >= (UInt32)nUD_SettingsStdDev.Value)
AssignDataToStdDevGraph(Decoded, Constants.PATH0, (UInt32)nUD_SettingsXrangeStdDevGraph.Value, cB_ReportStdDevPath0.Checked, cB_ReportStdDevPath1.Checked, cB_ReportStdDevPath2.Checked);
#endregion
#region Assign to labels
if (TelegramCounterStdDeviationSingle[Constants.PATH0] >= (UInt32)nUD_SettingsStdDev.Value)
AssignToLabelStdDeviation(Decoded, Constants.PATH0, tab_Maintab);
#endregion
#endregion
}
catch(Exception ex)
{
#region Error
ErrorLog.Log(LogErrReason.Exception(), "backgroundStdDev_RunWorkerCompleted() failed", "0x" + ex.HResult.ToString("X"),string.Empty);
#endregion
}
}
private void backgroundStdDev2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
#region Progress bar
if (TelegramCounterStdDeviationMultihit[Constants.PATH0] <= (UInt16)nUD_SettingsStdDev.Value)
{
#region Progress bar on tab "Maingraph"
if ((cB_GraphReset.Checked) && (lB_Graph_SelectGraph.Text.Contains("deviation")))
{
pB_MainGraphPrepareData.Maximum = (int)nUD_SettingsStdDev.Value;
pB_MainGraphPrepareData.Value = (int)TelegramCounterStdDeviationMultihit[Constants.PATH0];
}
#endregion
}
#endregion
#region Progress bar
pB_StdDeviation.Value = (int)TelegramCounterStdDeviationSingle[Constants.PATH0];
#endregion
#region Assign to graphs/ labels
#region Assign to graphs
if (TelegramCounterStdDeviationMultihit[Constants.PATH0] >= (UInt32)nUD_SettingsStdDev.Value)
AssignDataToStdDevGraph(Decoded, Constants.PATH0, (UInt32)nUD_SettingsXrangeStdDevGraph.Value, cB_ReportStdDevPath0.Checked, cB_ReportStdDevPath1.Checked, cB_ReportStdDevPath2.Checked);
#endregion
#region Assign to labels
if (TelegramCounterStdDeviationSingle[Constants.PATH0] >= (UInt32)nUD_SettingsStdDev.Value)
AssignToLabelStdDeviation(Decoded, Constants.PATH0, tab_Maintab);
#endregion
#endregion
}
catch (Exception ex)
{
#region Error
ErrorLog.Log(LogErrReason.Exception(), "backgroundStdDev2_RunWorkerCompleted() failed", "0x" + ex.HResult.ToString("X"), string.Empty);
#endregion
}
}
private void backgroundStdDev3_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
#region Progress bar
if (TelegramCounterStdDeviationMultihit[Constants.PATH1] <= (UInt16)nUD_SettingsStdDev.Value)
{
#region Progress bar on tab "Maingraph"
if ((cB_GraphReset.Checked) && (lB_Graph_SelectGraph.Text.Contains("deviation")))
{
pB_MainGraphPrepareData.Maximum = (int)nUD_SettingsStdDev.Value;
pB_MainGraphPrepareData.Value = (int)TelegramCounterStdDeviationMultihit[Constants.PATH1];
}
#endregion
}
#endregion
#region Progress bar
pB_StdDeviation.Value = (int)TelegramCounterStdDeviationSingle[Constants.PATH1];
#endregion
#region Assign to graphs/ labels
#region Assign to graphs
if (TelegramCounterStdDeviationMultihit[Constants.PATH1] >= (UInt32)nUD_SettingsStdDev.Value)
AssignDataToStdDevGraph(Decoded, Constants.PATH1, (UInt32)nUD_SettingsXrangeStdDevGraph.Value, cB_ReportStdDevPath0.Checked, cB_ReportStdDevPath1.Checked, cB_ReportStdDevPath2.Checked);
#endregion
#region Assign to labels
if (TelegramCounterStdDeviationSingle[Constants.PATH1] >= (UInt32)nUD_SettingsStdDev.Value)
AssignToLabelStdDeviation(Decoded, Constants.PATH1, tab_Maintab);
#endregion
#endregion
}
catch (Exception ex)
{
#region Error
ErrorLog.Log(LogErrReason.Exception(), "backgroundStdDev3_RunWorkerCompleted() failed", "0x" + ex.HResult.ToString("X"), string.Empty);
#endregion
}
}
private void backgroundStdDev4_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
#region Progress bar
pB_StdDeviation.Value = (int)TelegramCounterStdDeviationSingle[Constants.PATH1];
#endregion
#region Progress bar
if (TelegramCounterStdDeviationMultihit[Constants.PATH1] <= (UInt16)nUD_SettingsStdDev.Value)
{
#region Progress bar on tab "Maingraph"
if ((cB_GraphReset.Checked) && (lB_Graph_SelectGraph.Text.Contains("deviation")))
{
pB_MainGraphPrepareData.Maximum = (int)nUD_SettingsStdDev.Value;
pB_MainGraphPrepareData.Value = (int)TelegramCounterStdDeviationMultihit[Constants.PATH1];
}
#endregion
}
#endregion
#region Assign to graphs/ labels
#region Assign to graphs
if (TelegramCounterStdDeviationMultihit[Constants.PATH1] >= (UInt32)nUD_SettingsStdDev.Value)
AssignDataToStdDevGraph(Decoded, Constants.PATH1, (UInt32)nUD_SettingsXrangeStdDevGraph.Value, cB_ReportStdDevPath0.Checked, cB_ReportStdDevPath1.Checked, cB_ReportStdDevPath2.Checked);
#endregion
#region Assign to labels
if (TelegramCounterStdDeviationSingle[Constants.PATH1] >= (UInt32)nUD_SettingsStdDev.Value)
AssignToLabelStdDeviation(Decoded, Constants.PATH1, tab_Maintab);
#endregion
#endregion
}
catch (Exception ex)
{
#region Error
ErrorLog.Log(LogErrReason.Exception(), "backgroundStdDev4_RunWorkerCompleted() failed", "0x" + ex.HResult.ToString("X"), string.Empty);
#endregion
}
}
private void backgroundStdDev5_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
#region Progress bar
if (TelegramCounterStdDeviationMultihit[Constants.PATH2] <= (UInt16)nUD_SettingsStdDev.Value)
{
#region Progress bar on tab "Maingraph"
if ((cB_GraphReset.Checked) && (lB_Graph_SelectGraph.Text.Contains("deviation")))
{
pB_MainGraphPrepareData.Maximum = (int)nUD_SettingsStdDev.Value;
pB_MainGraphPrepareData.Value = (int)TelegramCounterStdDeviationMultihit[Constants.PATH2];
}
#endregion
}
#endregion
#region Progress bar
pB_StdDeviation.Value = (int)TelegramCounterStdDeviationSingle[Constants.PATH2];
#endregion
#region Assign to graphs/ labels
#region Assign to graphs
if (TelegramCounterStdDeviationMultihit[Constants.PATH2] >= (UInt32)nUD_SettingsStdDev.Value)
AssignDataToStdDevGraph(Decoded, Constants.PATH2, (UInt32)nUD_SettingsXrangeStdDevGraph.Value, cB_ReportStdDevPath0.Checked, cB_ReportStdDevPath1.Checked, cB_ReportStdDevPath2.Checked);
#endregion
#region Assign to labels
if (TelegramCounterStdDeviationSingle[Constants.PATH2] >= (UInt32)nUD_SettingsStdDev.Value)
AssignToLabelStdDeviation(Decoded, Constants.PATH2, tab_Maintab);
#endregion
#endregion
}
catch (Exception ex)
{
#region Error
ErrorLog.Log(LogErrReason.Exception(), "backgroundStdDev5_RunWorkerCompleted() failed", "0x" + ex.HResult.ToString("X"), string.Empty);
#endregion
}
}
private void backgroundStdDev6_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
#region Progress bar
if (TelegramCounterStdDeviationMultihit[Constants.PATH2] <= (UInt16)nUD_SettingsStdDev.Value)
{
#region Progress bar on tab "Maingraph"
if ((cB_GraphReset.Checked) && (lB_Graph_SelectGraph.Text.Contains("deviation")))
{
pB_MainGraphPrepareData.Maximum = (int)nUD_SettingsStdDev.Value;
pB_MainGraphPrepareData.Value = (int)TelegramCounterStdDeviationMultihit[Constants.PATH2];
}
#endregion
}
#endregion
#region Progress bar
pB_StdDeviation.Value = (int)TelegramCounterStdDeviationSingle[Constants.PATH2];
#endregion
#region Assign to graphs/ labels
#region Assign to graphs
if (TelegramCounterStdDeviationMultihit[Constants.PATH2] >= (UInt32)nUD_SettingsStdDev.Value)
AssignDataToStdDevGraph(Decoded, Constants.PATH2, (UInt32)nUD_SettingsXrangeStdDevGraph.Value, cB_ReportStdDevPath0.Checked, cB_ReportStdDevPath1.Checked, cB_ReportStdDevPath2.Checked);
#endregion
#region Assign to labels
if (TelegramCounterStdDeviationSingle[Constants.PATH2] >= (UInt32)nUD_SettingsStdDev.Value)
AssignToLabelStdDeviation(Decoded, Constants.PATH2, tab_Maintab);
#endregion
#endregion
}
catch (Exception ex)
{
#region Error
ErrorLog.Log(LogErrReason.Exception(), "backgroundStdDev6_RunWorkerCompleted() failed", "0x" + ex.HResult.ToString("X"), string.Empty);
#endregion
}
}
#endregion
#region Labels
private void AssignToLabelStdDeviation(DecodedData[] inputData, UInt16 inputPath, TabControl tab)
{
try
{
if ((tab.SelectedTab == tab_StdDev) || (tab.SelectedTab == tab_Report))
{
switch (inputPath)
{
#region PATH0
case Constants.PATH0:
l_StdDev0DispPATH0.Text = inputData[inputPath].StdDeviation[Constants.HIT0].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev1DispPATH0.Text = inputData[inputPath].StdDeviation[Constants.HIT1].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev2DispPATH0.Text = inputData[inputPath].StdDeviation[Constants.HIT2].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev3DispPATH0.Text = inputData[inputPath].StdDeviation[Constants.HIT3].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev4DispPATH0.Text = inputData[inputPath].StdDeviation[Constants.HIT4].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev5DispPATH0.Text = inputData[inputPath].StdDeviation[Constants.HIT5].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev6DispPATH0.Text = inputData[inputPath].StdDeviation[Constants.HIT6].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev7DispPATH0.Text = inputData[inputPath].StdDeviation[Constants.HIT7].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
if (((cB_MeanValuesEnable.Checked) && (TelegramCounterStdDeviationMultihit[inputPath] >= (UInt16)nUD_SettingsMean.Value)))
{
l_StdDev3ZeroCrossingsDispPath0.Text = inputData[inputPath].DifTof3HitsStdDeviation.ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev8ZeroCrossingsDispPath0.Text = inputData[inputPath].DifTof8HitsStdDeviation.ToString(Formats.StdDevDispString) + Units.StdDevDispString;
}
break;
#endregion
#region PATH1
case Constants.PATH1:
l_StdDev0DispPATH1.Text = inputData[inputPath].StdDeviation[Constants.HIT0].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev1DispPATH1.Text = inputData[inputPath].StdDeviation[Constants.HIT1].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev2DispPATH1.Text = inputData[inputPath].StdDeviation[Constants.HIT2].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev3DispPATH1.Text = inputData[inputPath].StdDeviation[Constants.HIT3].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev4DispPATH1.Text = inputData[inputPath].StdDeviation[Constants.HIT4].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev5DispPATH1.Text = inputData[inputPath].StdDeviation[Constants.HIT5].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev6DispPATH1.Text = inputData[inputPath].StdDeviation[Constants.HIT6].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev7DispPATH1.Text = inputData[inputPath].StdDeviation[Constants.HIT7].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
if (((cB_MeanValuesEnable.Checked) && (TelegramCounterStdDeviationMultihit[inputPath] >= (UInt16)nUD_SettingsMean.Value)))
{
l_StdDev3ZeroCrossingsDispPath1.Text = inputData[inputPath].DifTof3HitsStdDeviation.ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev8ZeroCrossingsDispPath1.Text = inputData[inputPath].DifTof8HitsStdDeviation.ToString(Formats.StdDevDispString) + Units.StdDevDispString;
}
break;
#endregion
#region PATH2
case Constants.PATH2:
l_StdDev0DispPATH2.Text = inputData[inputPath].StdDeviation[Constants.HIT0].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev1DispPATH2.Text = inputData[inputPath].StdDeviation[Constants.HIT1].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev2DispPATH2.Text = inputData[inputPath].StdDeviation[Constants.HIT2].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev3DispPATH2.Text = inputData[inputPath].StdDeviation[Constants.HIT3].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev4DispPATH2.Text = inputData[inputPath].StdDeviation[Constants.HIT4].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev5DispPATH2.Text = inputData[inputPath].StdDeviation[Constants.HIT5].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev6DispPATH2.Text = inputData[inputPath].StdDeviation[Constants.HIT6].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev7DispPATH2.Text = inputData[inputPath].StdDeviation[Constants.HIT7].ToString(Formats.StdDevDispString) + Units.StdDevDispString;
if (((cB_MeanValuesEnable.Checked) && (TelegramCounterStdDeviationMultihit[inputPath] >= (UInt16)nUD_SettingsMean.Value)))
{
l_StdDev3ZeroCrossingsDispPath2.Text = inputData[inputPath].DifTof3HitsStdDeviation.ToString(Formats.StdDevDispString) + Units.StdDevDispString;
l_StdDev8ZeroCrossingsDispPath2.Text = inputData[inputPath].DifTof8HitsStdDeviation.ToString(Formats.StdDevDispString) + Units.StdDevDispString;
}
break;
#endregion
#region Default
default: break;
#endregion
}
}
}
catch (Exception ex)
{
#region Error
ErrorLog.Log(LogErrReason.Exception(), "AssignDataToStdDevLabels() failed", "0x" + ex.HResult.ToString("X"), string.Empty);
#endregion
}
}
private void ResetLabelsStdDeviation()
{
#region PATH0
l_StdDev0DispPATH0.Text = "---";
l_StdDev1DispPATH0.Text = "---";
l_StdDev2DispPATH0.Text = "---";
l_StdDev3DispPATH0.Text = "---";
l_StdDev4DispPATH0.Text = "---";
l_StdDev5DispPATH0.Text = "---";
l_StdDev6DispPATH0.Text = "---";
l_StdDev7DispPATH0.Text = "---";
l_StdDev8ZeroCrossingsDispPath0.Text = "---";
l_StdDev3ZeroCrossingsDispPath0.Text = "---";
#endregion
#region PATH1
l_StdDev0DispPATH1.Text = "---";
l_StdDev1DispPATH1.Text = "---";
l_StdDev2DispPATH1.Text = "---";
l_StdDev3DispPATH1.Text = "---";
l_StdDev4DispPATH1.Text = "---";
l_StdDev5DispPATH1.Text = "---";
l_StdDev6DispPATH1.Text = "---";
l_StdDev7DispPATH1.Text = "---";
l_StdDev8ZeroCrossingsDispPath1.Text = "---";
l_StdDev3ZeroCrossingsDispPath1.Text = "---";
#endregion
#region PATH2
l_StdDev0DispPATH2.Text = "---";
l_StdDev1DispPATH2.Text = "---";
l_StdDev2DispPATH2.Text = "---";
l_StdDev3DispPATH2.Text = "---";
l_StdDev4DispPATH2.Text = "---";
l_StdDev5DispPATH2.Text = "---";
l_StdDev6DispPATH2.Text = "---";
l_StdDev7DispPATH2.Text = "---";
l_StdDev8ZeroCrossingsDispPath2.Text = "---";
l_StdDev3ZeroCrossingsDispPath2.Text = "---";
#endregion
}
#endregion
#endregion
}
public class StdDeviationCalculate
{
public static DecodedData[] CalcSingle(UInt16 inputPath, DecodedData[] inputData, ref UInt16[] telegramCounterStdDeviation, ref List<List<double>>[] processingStdDeviation, UInt16 numberOfValues)
{
#region Initial fill
if (telegramCounterStdDeviation[inputPath] < numberOfValues)
{
#region Copy data to list
for (UInt16 Hit = 0; Hit < 8; Hit++)
processingStdDeviation[inputPath][Hit].Add(inputData[inputPath].DifTof[Hit]);
#endregion
#region Counter
telegramCounterStdDeviation[inputPath]++;
#endregion
}
#endregion
#region Moving average
else
{
#region Contineous filling and removing of values
for (UInt16 Hit = 0; Hit < 8; Hit++)
{
#region Remove first element
processingStdDeviation[inputPath][Hit].RemoveAt(0);
#endregion
#region Add last element
processingStdDeviation[inputPath][Hit].Add(inputData[inputPath].DifTof[Hit]);
#endregion
}
#endregion
#region Calculate value
for (UInt16 Hit = 0; Hit < 8; Hit++)
inputData[inputPath].StdDeviation[Hit] = processingStdDeviation[inputPath][Hit].StandardDeviation();
#endregion
}
#endregion
#region Return
return inputData;
#endregion
}
public static DecodedData[] CalcMulti(UInt16 inputPath, DecodedData[] inputData, ref UInt16[] telegramCounterStdDeviation, ref List<double>[] processing3HitsStdDeviation, ref List<double>[] processing8HitsStdDeviation, UInt16 numberOfValues)
{
#region Initial fill
if (telegramCounterStdDeviation[inputPath] < numberOfValues)
{
#region Copy data to list
// This must be very wrong
//Processing3HitsStdDeviation[inputPath].Add(inputData[inputPath].DifTof3HitsStdDeviation);
//Processing8HitsStdDeviation[inputPath].Add(inputData[inputPath].DifTof8HitsStdDeviation);
processing3HitsStdDeviation[inputPath].Add(inputData[inputPath].DifTof3HitsMean);
processing8HitsStdDeviation[inputPath].Add(inputData[inputPath].DifTof8HitsMean);
#endregion
#region Counter
telegramCounterStdDeviation[inputPath]++;
#endregion
}
#endregion
#region Moving average
else
{
#region Contineous filling and removing of values
processing3HitsStdDeviation[inputPath].RemoveAt(0);
processing8HitsStdDeviation[inputPath].RemoveAt(0);
processing3HitsStdDeviation[inputPath].Add(inputData[inputPath].DifTof3HitsMean);
processing8HitsStdDeviation[inputPath].Add(inputData[inputPath].DifTof8HitsMean);
#endregion
#region Calculate value
inputData[inputPath].DifTof3HitsStdDeviation = processing3HitsStdDeviation[inputPath].StandardDeviation();
inputData[inputPath].DifTof8HitsStdDeviation = processing8HitsStdDeviation[inputPath].StandardDeviation();
#endregion
}
#endregion
#region Return
return inputData;
#endregion
}
/*
public static DecodedData[] Calc(UInt16 inputPath, DecodedData[] inputData, ref UInt16[] telegramCounterStdDeviation, ref List<List<double>>[] ProcessingStdDeviation, ref List<double>[] Processing3HitsStdDeviation, ref List<double>[] Processing8HitsStdDeviation, UInt16 numberOfValues, bool enableMultihit)
{
#region Initial fill
if (telegramCounterStdDeviation[inputPath] < numberOfValues)
{
#region Copy data to list
for (UInt16 Hit = 0; Hit < 8; Hit++)
ProcessingStdDeviation[inputPath][Hit].Add(inputData[inputPath].DifTof[Hit]);
Processing3HitsStdDeviation[inputPath].Add(inputData[inputPath].DifTof3HitsStdDeviation);
Processing8HitsStdDeviation[inputPath].Add(inputData[inputPath].DifTof8HitsStdDeviation);
#endregion
#region Counter
telegramCounterStdDeviation[inputPath]++;
#endregion
}
#endregion
#region Moving average
else
{
#region Contineous filling and removing of values
for (UInt16 Hit = 0; Hit < 8; Hit++)
{
#region Remove first element
ProcessingStdDeviation[inputPath][Hit].RemoveAt(0);
#endregion
#region Add last element
ProcessingStdDeviation[inputPath][Hit].Add(inputData[inputPath].DifTof[Hit]);
#endregion
}
Processing3HitsStdDeviation[inputPath].RemoveAt(0);
Processing8HitsStdDeviation[inputPath].RemoveAt(0);
Processing3HitsStdDeviation[inputPath].Add(inputData[inputPath].DifTof3HitsMean);
Processing8HitsStdDeviation[inputPath].Add(inputData[inputPath].DifTof8HitsMean);
#endregion
#region Calculate value
for (UInt16 Hit = 0; Hit < 8; Hit++)
inputData[inputPath].StdDeviation[Hit] = ProcessingStdDeviation[inputPath][Hit].StandardDeviation();
inputData[inputPath].DifTof3HitsStdDeviation = Processing3HitsStdDeviation[inputPath].StandardDeviation();
inputData[inputPath].DifTof8HitsStdDeviation = Processing8HitsStdDeviation[inputPath].StandardDeviation();
#endregion
}
#endregion
#region Return
return inputData;
#endregion
}
*/
public static void Reset(ref UInt16[] telegramCounterStdDeviationMultihit, ref UInt16[] telegramCounterStdDeviationSingle, ref List<List<double>>[] ProcessingStdDeviation, ref List<double>[] Processing3HitsStdDeviation, ref List<double>[] Processing8HitsStdDeviation)
{
for (UInt16 Path = 0; Path < 3; Path++)
{
Processing3HitsStdDeviation[Path].Clear();
Processing8HitsStdDeviation[Path].Clear();
for (UInt16 Hit = 0; Hit < 8; Hit++)
{
ProcessingStdDeviation[Path][Hit].Clear();
}
telegramCounterStdDeviationMultihit[Path] = 0;
telegramCounterStdDeviationSingle[Path] = 0;
}
}
}
}