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

1521 lines
73 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.Windows.Forms;
using System.Drawing.Printing;
using ZedGraph;
using System.Text.RegularExpressions;
using System.Globalization;
namespace GenesisDisplayTool
{
public partial class GENESIS_DISPLAY_TOOL : Form
{
#region Definitions and initializations
private Int32[] GraphIndexOfLists = new Int32[Constants.NumberOfPaths] { 0, 0, 0 };
public void SetGraphIndexOfLists(Int32 value, Int32 path)
{
GraphIndexOfLists[path] = value;
}
private Int64[] GraphNumberOfElements = new Int64[Constants.NumberOfPaths] { 0, 0, 0 };
public void SetGraphNumberOfElements(Int64 value, Int32 path)
{
GraphNumberOfElements[path] = value;
}
Double[] data = new Double[Constants.NumberOfPaths];
#endregion
public Boolean GetTabStatus()
{
Boolean Refresh = false;
if ((tab_Maintab.SelectedTab == tab_Graph) ||((tab_Maintab.SelectedTab == tab_Report) && (cB_ReportMainGraph.Checked)))
Refresh = true;
return Refresh;
}
public Boolean[] GetSelectedPath()
{
Boolean[] ret = new Boolean[Constants.NumberOfPaths];
ret[Constants.PATH0] = cB_GraphOptionEnPath0.Checked;
ret[Constants.PATH1] = cB_GraphOptionEnPath1.Checked;
ret[Constants.PATH2] = cB_GraphOptionEnPath2.Checked;
return ret;
}
public void SetCbGraphResetCheckStatus(Boolean value)
{
cB_GraphReset.Checked = value;
}
public Double GetNudmaingraphNomVal()
{
return (Double)nUD_MaingraphNomVal.Value;
}
private void MainGraphSetTitle(String selectedOption, Int32 numberOfStdDeviationValues, Int32 numberOfMeanValues, Boolean avg38en)
{
try
{
#region Definitions and initializations
String TitleOfGraph = String.Empty;
#endregion
#region Set title
if (selectedOption.Contains("Mean"))
TitleOfGraph = $"{ selectedOption}\n(Mean over {numberOfMeanValues.ToString(globalCulture)} values)";
else
TitleOfGraph = selectedOption;
if (selectedOption.Contains("deviation"))
{
TitleOfGraph = $"{selectedOption}\n(Std deviation over {numberOfStdDeviationValues.ToString(globalCulture)} values";
if (avg38en)
TitleOfGraph = $"{TitleOfGraph}, Mean over {numberOfMeanValues.ToString(globalCulture)} values)";
else
TitleOfGraph = $"{TitleOfGraph})";
}
ParamsMainGraph.Title = TitleOfGraph;
CreateMainGraphs(zGC_MainGraph, ParamsMainGraph, true);
#endregion
}
catch (Exception ex)
{
ErrorLog.Log(LogErrReason.Exception(), "MainGraphSetTitle() failed", $"0x{ex.HResult.ToString("X")}", String.Empty);
}
}
private void InitMainGraph(String selectedOption, Double xRange, Int32 numberOfStdDeviationValues, Int32 numberOfMeanValues, Boolean avg38en)
{
String Where = "Start";
try
{
#region Definitions and initializations
String TitleOfGraph = String.Empty;
#endregion
#region Set title
if (selectedOption.Contains("Mean"))
TitleOfGraph = $"{selectedOption}\n(Mean over {numberOfMeanValues.ToString(globalCulture)} values)";
else
TitleOfGraph = selectedOption;
if (selectedOption.Contains("deviation"))
{
TitleOfGraph = $"{selectedOption}\n(Std deviation over {numberOfStdDeviationValues.ToString(globalCulture)} values";
if (avg38en)
TitleOfGraph = $"{TitleOfGraph}, Mean over {numberOfMeanValues.ToString(globalCulture)} values)";
else
TitleOfGraph = $"{TitleOfGraph})";
}
ParamsMainGraph.Title = TitleOfGraph;
#endregion
#region Time of flight
if
(
(selectedOption.Contains("deviation")) ||
(selectedOption.Contains("DIF TOF")) ||
(selectedOption.Contains("TOF")))
{
Where = "TOF";
ParamsMainGraph.xAxis = "Values";
zGC_MainGraph.GraphPane.XAxis.Scale.Min = 0;
zGC_MainGraph.GraphPane.XAxis.Scale.Max = xRange;
zGC_MainGraph.GraphPane.YAxis.Scale.MinAuto = true;
zGC_MainGraph.GraphPane.YAxis.Scale.MaxAuto = true;
ParamsMainGraph.yAxis = "t/ps";
CreateMainGraphs(zGC_MainGraph, ParamsMainGraph, true);
return;
}
#endregion
#region Pulsewidth
if (selectedOption.Contains("Pulsewidth"))
{
Where = "Pulsewidth";
ParamsMainGraph.xAxis = "Values";
ParamsMainGraph.yAxis = "Ratio";
zGC_MainGraph.GraphPane.XAxis.Scale.Min = 0;
zGC_MainGraph.GraphPane.XAxis.Scale.Max = xRange;
zGC_MainGraph.GraphPane.YAxis.Scale.Min = 0;
zGC_MainGraph.GraphPane.YAxis.Scale.Max = 2.1;
CreateMainGraphs(zGC_MainGraph, ParamsMainGraph, true);
return;
}
#endregion
#region Temperature
if (selectedOption.Contains("Temperature (H-Protocol)"))
{
Where = "Temp";
ParamsMainGraph.xAxis = "Values";
ParamsMainGraph.yAxis = "°C";
zGC_MainGraph.GraphPane.XAxis.Scale.Min = 0;
zGC_MainGraph.GraphPane.XAxis.Scale.Max = xRange;
zGC_MainGraph.GraphPane.YAxis.Scale.Min = -5;
zGC_MainGraph.GraphPane.YAxis.Scale.Max = 70;
CreateMainGraphs(zGC_MainGraph, ParamsMainGraph, true);
return;
}
#endregion
#region Amplitude
if (selectedOption.Contains("Amplitude"))
{
Where = "Amplitude";
ParamsMainGraph.xAxis = "Values";
ParamsMainGraph.yAxis = "mV";
zGC_MainGraph.GraphPane.XAxis.Scale.Min = 0;
zGC_MainGraph.GraphPane.XAxis.Scale.Max = xRange;
zGC_MainGraph.GraphPane.YAxis.Scale.Min = 0;
zGC_MainGraph.GraphPane.YAxis.Scale.Max = 600;
CreateMainGraphs(zGC_MainGraph, ParamsMainGraph, true);
return;
}
#endregion
#region Amplitude
if (selectedOption.Contains("Volume"))
{
Where = "Volume";
ParamsMainGraph.xAxis = "Value";
ParamsMainGraph.yAxis = "Units as in Display";
zGC_MainGraph.GraphPane.XAxis.Scale.Min = 0;
zGC_MainGraph.GraphPane.XAxis.Scale.Max = xRange;
zGC_MainGraph.GraphPane.YAxis.Scale.Min = 0;
CreateMainGraphs(zGC_MainGraph, ParamsMainGraph, true);
return;
}
#endregion
}
catch (Exception ex)
{
ErrorLog.Log(LogErrReason.Exception(), "InitMainGraph() failed", $"0x{ex.HResult.ToString("X")}", Where);
}
}
private void ResetMainGraph()
{
try
{
// Reset graph pane
zGC_MainGraph.ZoomOutAll(zGC_MainGraph.GraphPane);
zGC_MainGraph.GraphPane.GraphObjList.Clear();
zGC_MainGraph.GraphPane.CurveList.Clear();
// Reset counters
for (UInt16 Path = Constants.PATH0; Path < Constants.NumberOfPaths; Path++)
{
GraphCounterDataMainTotal[Path] = 0;
GraphIndexOfLists[Path] = 0;
GraphNumberOfElements[Path] = 0;
}
// Reset range
zGC_MainGraph.GraphPane.XAxis.Scale.Max = (Double)nUD_SettingsXMainGraph.Value;
// Clear graphs
for (UInt16 Path = Constants.PATH0; Path < Constants.NumberOfPaths; Path++)
{
GraphListMainWindow[Path].Clear();
GraphListMainTotal[Path].Clear();
GraphListMainTotal[Path].Add(new PointPairList());
}
// Refresh
// db_Maingraph.flushData();
zGC_MainGraph.Refresh();
}
catch (Exception ex)
{
ErrorLog.Log(LogErrReason.Exception(), $"ResetMainGraph() failed", $"0x{ex.HResult.ToString("X")}", String.Empty);
}
}
private void AssignDataToMainGraph(DecodedData[] decodedValues, UInt16 path, ref List<PointPairList>[] graphListMainTotal, ref PointPairList[] graphListMainWindow, double xRange)
{
#region Definitions and initializations
String DifTofIndexString = String.Empty;
#endregion
#region Horizontal setup
zGC_MainGraph.SetAutoScrollMargin(100, 20);
zGC_MainGraph.IsAutoScrollRange = true;
zGC_MainGraph.ScrollGrace = Constants.DefaultScrollGrace;
zGC_MainGraph.HorizontalScroll.Enabled = true;
String SelectedOption = lB_Graph_SelectGraph.Text;
if ((zGC_MainGraph.GraphPane.XAxis.Scale.Max - xRange) >= 0)
{
if (zGC_MainGraph.GraphPane.XAxis.Scale.Max != xRange)
zGC_MainGraph.GraphPane.XAxis.Scale.Min = zGC_MainGraph.GraphPane.XAxis.Scale.Max - xRange + 1;
else
zGC_MainGraph.GraphPane.XAxis.Scale.Min = zGC_MainGraph.GraphPane.XAxis.Scale.Max - xRange; //
}
else
{
zGC_MainGraph.GraphPane.XAxis.Scale.Min = 0;
zGC_MainGraph.GraphPane.XAxis.Scale.Max = xRange;
}
/*
if (zGC_MainGraph.GraphPane.XAxis.Scale.Max != xRange)
zGC_MainGraph.GraphPane.XAxis.Scale.Min = zGC_MainGraph.GraphPane.XAxis.Scale.Max - xRange + 1;
else
zGC_MainGraph.GraphPane.XAxis.Scale.Min = zGC_MainGraph.GraphPane.XAxis.Scale.Max - xRange; // for the very first element eg. when max = 200 and min = 0
*/
#endregion
#region Set lists for backup whole data
#region Amplitude up (H-Protocol)
if (String.Equals(SelectedOption, "Amplitude Up (H-Protocol)") && (String.Equals(decodedValues[path].ProtocolVersion, "@h")))
{
#region Set graph
GraphListMainWindow[path].Add(GraphCounterDataMainTotal[path], decodedValues[path].HProt_AmplitudeUp);
#endregion
#region Backup data
data[path] = decodedValues[path].HProt_AmplitudeUp;
Graphs.BackupData(path, data, ref graphListMainTotal, ref GraphIndexOfLists, GraphCounterDataMainTotal);
FinalizeAssigning(path, xRange, graphListMainTotal);
return;
#endregion
}
#endregion
#region Amplitude down (H-Protocol)
if (String.Equals(SelectedOption, "Amplitude Down (H-Protocol)") && (String.Equals(decodedValues[path].ProtocolVersion, "@h")))
{
#region Set graph
GraphListMainWindow[path].Add(GraphCounterDataMainTotal[path], decodedValues[path].HProt_AmplitudeDown);
#endregion
#region Backup data
data[path] = decodedValues[path].HProt_AmplitudeDown;
Graphs.BackupData(path, data, ref graphListMainTotal, ref GraphIndexOfLists, GraphCounterDataMainTotal);
FinalizeAssigning(path, xRange, graphListMainTotal);
return;
#endregion
}
#endregion
#region Temperature (H-Protocol)
if (String.Equals(SelectedOption, "Temperature (H-Protocol)") && (String.Equals(decodedValues[path].ProtocolVersion, "@h")))
{
#region Set graph
GraphListMainWindow[path].Add(GraphCounterDataMainTotal[path], decodedValues[path].HProt_CalculatedTemperature);
#endregion
#region Backup data
data[path] = decodedValues[path].HProt_CalculatedTemperature;
Graphs.BackupData(path, data, ref graphListMainTotal, ref GraphIndexOfLists, GraphCounterDataMainTotal);
FinalizeAssigning(path, xRange, graphListMainTotal);
return;
#endregion
}
#endregion
#region Total TOF average (H-Protocol)
if (String.Equals(SelectedOption, "Total TOF AVG (H-Protocol)")&& (String.Equals(decodedValues[path].ProtocolVersion, "@h")))
{
#region Set graph
GraphListMainWindow[path].Add(GraphCounterDataMainTotal[path], decodedValues[path].HProt_TotalTimeOfFlightAvg);
#endregion
#region Backup data
data[path] = decodedValues[path].HProt_TotalTimeOfFlightAvg;
Graphs.BackupData(path, data, ref graphListMainTotal, ref GraphIndexOfLists, GraphCounterDataMainTotal);
FinalizeAssigning(path, xRange, graphListMainTotal);
return;
#endregion
}
#endregion
#region Delta TOF (H-Protocol)
if (String.Equals(SelectedOption, "Delta TOF (H-Protocol)") && (String.Equals(decodedValues[path].ProtocolVersion, "@h")))
{
#region Set graph
GraphListMainWindow[path].Add(GraphCounterDataMainTotal[path], decodedValues[path].HProt_DeltaTimeOfFlight);
#endregion
#region Backup data
data[path] = decodedValues[path].HProt_DeltaTimeOfFlight;
Graphs.BackupData(path, data, ref graphListMainTotal, ref GraphIndexOfLists, GraphCounterDataMainTotal);
FinalizeAssigning(path, xRange, graphListMainTotal);
return;
#endregion
}
#endregion
#region Amplitude up (I-Protocol)
if (String.Equals(SelectedOption, "Amplitude Up (I-Protocol)") && (String.Equals(decodedValues[path].ProtocolVersion, "@i")))
{
#region Set graph
GraphListMainWindow[path].Add(GraphCounterDataMainTotal[path], decodedValues[path].IProt_AmpUpCalculated);
#endregion
#region Backup data
data[path] = decodedValues[path].IProt_AmpUpCalculated;
Graphs.BackupData(path, data, ref graphListMainTotal, ref GraphIndexOfLists, GraphCounterDataMainTotal);
FinalizeAssigning(path, xRange, graphListMainTotal);
return;
#endregion
}
#endregion
#region Amplitude down (I-Protocol)
if (String.Equals(SelectedOption, "Amplitude Down (I-Protocol)") && (String.Equals(decodedValues[path].ProtocolVersion, "@i")))
{
#region Set graph
GraphListMainWindow[path].Add(GraphCounterDataMainTotal[path], decodedValues[path].IProt_AmpDownCalculated);
#endregion
#region Backup data
data[path] = decodedValues[path].IProt_AmpDownCalculated;
Graphs.BackupData(path, data, ref graphListMainTotal, ref GraphIndexOfLists, GraphCounterDataMainTotal);
FinalizeAssigning(path, xRange, graphListMainTotal);
return;
#endregion
}
#endregion
#region Pulsewidth up (I-Protocol)
if (String.Equals(SelectedOption, "Pulsewidth Up (I-Protocol)") && (String.Equals(decodedValues[path].ProtocolVersion, "@i")))
{
#region Set graph
GraphListMainWindow[path].Add(GraphCounterDataMainTotal[path], decodedValues[path].IProt_PwUp);
#endregion
#region Backup data
data[path] = decodedValues[path].IProt_PwUp;
Graphs.BackupData(path, data, ref graphListMainTotal, ref GraphIndexOfLists, GraphCounterDataMainTotal);
FinalizeAssigning(path, xRange, graphListMainTotal);
return;
#endregion
}
#endregion
#region Pulsewidth down (I-Protocol)
if (String.Equals(SelectedOption, "Pulsewidth Down (I-Protocol)") && (String.Equals(decodedValues[path].ProtocolVersion, "@i")))
{
#region Set graph
GraphListMainWindow[path].Add(GraphCounterDataMainTotal[path], decodedValues[path].IProt_PwDown);
#endregion
#region Backup data
data[path] = decodedValues[path].IProt_PwDown;
Graphs.BackupData(path, data, ref graphListMainTotal, ref GraphIndexOfLists, GraphCounterDataMainTotal);
FinalizeAssigning(path, xRange, graphListMainTotal);
return;
#endregion
}
#endregion
#region TOF sum of all up (I-Protocol)
if (String.Equals(SelectedOption, "TOF Sum of all up (I-Protocol)") && (String.Equals(decodedValues[path].ProtocolVersion, "@i")))
{
#region Set graph
GraphListMainWindow[path].Add(GraphCounterDataMainTotal[path], decodedValues[path].IProt_SumOfAllUp);
#endregion
#region Backup data
data[path] = decodedValues[path].IProt_SumOfAllUp;
Graphs.BackupData(path, data, ref graphListMainTotal, ref GraphIndexOfLists, GraphCounterDataMainTotal);
FinalizeAssigning(path, xRange, graphListMainTotal);
return;
#endregion
}
#endregion
#region TOF sum of all down (I-Protocol)
if (String.Equals(SelectedOption, "TOF Sum of all down (I-Protocol)") && (String.Equals(decodedValues[path].ProtocolVersion, "@i")))
{
#region Set graph
GraphListMainWindow[path].Add(GraphCounterDataMainTotal[path], decodedValues[path].IProt_SumOfAllDown);
#endregion
#region Backup data
data[path] = decodedValues[path].IProt_SumOfAllDown;
Graphs.BackupData(path, data, ref graphListMainTotal, ref GraphIndexOfLists, GraphCounterDataMainTotal);
FinalizeAssigning(path, xRange, graphListMainTotal);
return;
#endregion
}
#endregion
#region Flow (F-Protocol)
if (String.Equals(SelectedOption, "Display Volume (F-Protocol)") && (String.Equals(decodedValues[Constants.PATH0].ProtocolVersion, "@f")))
{
#region Set graph
for (UInt16 FlowPath = Constants.PATH0; FlowPath < Constants.NumberOfPaths; FlowPath++)
{
GraphListMainWindow[FlowPath].Add(GraphCounterDataMainTotal[FlowPath], (Double)decodedValues[FlowPath].FProt_DisplayVol);
#endregion
#region Backup data
data[FlowPath] = decodedValues[FlowPath].FProt_DisplayVol;
Graphs.BackupData(FlowPath, data, ref graphListMainTotal, ref GraphIndexOfLists, GraphCounterDataMainTotal);
FinalizeAssigning(FlowPath, xRange, graphListMainTotal);
}
return;
#endregion
}
#endregion
#endregion
}
private void FinalizeAssigning(UInt16 path, Double xRange, List<PointPairList>[] graphListMainTotal)
{
#region Create graph
GraphNumberOfElements[path] = (long)graphListMainTotal[path][GraphIndexOfLists[path]].Count();
CreateMainGraphs(zGC_MainGraph, ParamsMainGraph, false);
#endregion
#region X-Axis control
if (GraphCounterDataMainTotal[path] > UInt32.MaxValue - 2)
{
#region Counter overflow stop calculation
cB_GraphReset.Checked = false;
MessageBox.Show("Counter overflow, Maingraph stopped", "Form closing", MessageBoxButtons.OK, MessageBoxIcon.Error);
#endregion
}
else
GraphCounterDataMainTotal[path]++;
#endregion
#region Reset zedgraph data lists and counters
// if ((UInt32)GraphCounterDataMainTotal[path] % xRange == 0)
// if (UInt32.Equals(((UInt32)GraphCounterDataMainTotal[path] % xRange), 0))
// funzt if(((UInt32)GraphCounterDataMainTotal[path] % (UInt32)xRange) == 0)
var temp = (UInt32)GraphCounterDataMainTotal[path] % (UInt32)xRange;
//if(UInt32.Equals(temp, 0))
if(temp == 0)
//if (UInt32.Equals(((UInt32)GraphCounterDataMainTotal[path] % (UInt32)xRange), 0))
//if(UInt32.Equals((GraphCounterDataMainTotal[path] % (UInt32)xRange), 0))
{
cB_GraphReset.Enabled = false; // to avoid strange effects on deselecting in the wrong moment
GraphListMainWindow[path].Clear();
if (UInt16.Equals(path, Constants.PATH2))
zGC_MainGraph.GraphPane.XAxis.Scale.Max = zGC_MainGraph.GraphPane.XAxis.Scale.Max + xRange;
zGC_MainGraph.PerformAutoScale();
CreateMainGraphs(zGC_MainGraph, GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GetParamsMainGraph(), false);
cB_GraphReset.Enabled = true;
}
#endregion
}
private void CreateMainGraphs(ZedGraphControl zgc, zedGraphParameters graphParams, Boolean init)
{
#region Settings for the entire graph
GraphPane myPane = zgc.GraphPane;
myPane.Title.Text = graphParams.Title;
MainGraphTitle = graphParams.Title;
zgc.IsAutoScrollRange = true;
// 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 = graphParams.xAxis;
myPane.YAxis.Title.Text = graphParams.yAxis;
myPane.Fill.Color = Color.AliceBlue;
myPane.Chart.Fill.Color = Color.Cornsilk;
myPane.Legend.Fill.Color = Color.Cornsilk;
}
/*
// X-Axis decimal point
if (GraphsListDataMainTotal[Constants.PATH2].Count > 100000 - nUD_SettingsXMainGraph.Value)
myPane.XAxis.Scale.Format = "0.0000";
else
{
if (GraphsListDataMainTotal[Constants.PATH2].Count > 10000 - nUD_SettingsXMainGraph.Value)
myPane.XAxis.Scale.Format = "0.00";
else
myPane.XAxis.Scale.Format = "0";
}*/
#endregion
#region Reset curve lists
//Needed for redrawing the chart, to remove old curves
myPane.CurveList.Clear();
#endregion
#region Settings PATH0
#region Add Data
LineItem myMainCurvePath0;
myMainCurvePath0 = myPane.AddCurve("PATH1", GraphListMainWindow[Constants.PATH0], Color.Red);
#endregion
#region Customize graph
#region Enable/ disable curves and legend items
if (cB_GraphOptionEnPath0.Checked)
{
myMainCurvePath0.IsVisible = true;
myMainCurvePath0.Label.IsVisible = true;
}
else
{
myMainCurvePath0.IsVisible = false;
myMainCurvePath0.Label.IsVisible = false;
}
#endregion
#region Other settings
myMainCurvePath0.Line.IsVisible = true; //Hide line-connections
myMainCurvePath0.Symbol.Type = SymbolType.Circle;
myMainCurvePath0.Symbol.Size = 2f;
myMainCurvePath0.Symbol.Fill.Type = FillType.Solid;
myMainCurvePath0.Symbol.IsAntiAlias = true; //Makes the circles smoother
myMainCurvePath0.IsSelected = false;
#endregion
#endregion
#endregion
#region Settings PATH1
#region Add Data
LineItem myMainCurvePath1 = myPane.AddCurve("PATH2", GraphListMainWindow[Constants.PATH1], Color.Blue);
#endregion
#region Customize graph
#region Enable/ disable curves and legend items
if (cB_GraphOptionEnPath1.Checked)
{
myMainCurvePath1.IsVisible = true;
myMainCurvePath1.Label.IsVisible = true;
}
else
{
myMainCurvePath1.IsVisible = false;
myMainCurvePath1.Label.IsVisible = false;
}
#endregion
#region Other settings
myMainCurvePath1.Line.IsVisible = true; //Hide line-connections
myMainCurvePath1.Symbol.Type = SymbolType.Circle;
myMainCurvePath1.Symbol.Size = 2f;
myMainCurvePath1.Symbol.Fill.Type = FillType.Solid;
myMainCurvePath1.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#endregion
#region Settings PATH2
#region Add data
LineItem myMainCurvePath2 = myPane.AddCurve("PATH3", GraphListMainWindow[Constants.PATH2], Color.Green);
#endregion
#region Customize graph
#region Enable/ disable curves and legend items
if (cB_GraphOptionEnPath2.Checked)
{
myMainCurvePath2.IsVisible = true;
myMainCurvePath2.Label.IsVisible = true;
}
else
{
myMainCurvePath2.IsVisible = false;
myMainCurvePath2.Label.IsVisible = false;
}
#endregion
#region Other settings
myMainCurvePath2.Line.IsVisible = true; //Hide line-connections
myMainCurvePath2.Symbol.Type = SymbolType.Circle;
myMainCurvePath2.Symbol.Size = 2f;
myMainCurvePath2.Symbol.Fill.Type = FillType.Solid;
myMainCurvePath2.Symbol.IsAntiAlias = true; //Makes the circles smoother
#endregion
#endregion
#endregion
#region Refresh the graph in order to show the new data
zgc.AxisChange();
// If tab "Graph" selected of tab "Report" selected and Option "Maingraph" checked
if ((TabControl.Equals(tab_Maintab.SelectedTab, tab_Graph)) ||
((TabControl.Equals(tab_Maintab.SelectedTab, tab_Report)) && (cB_ReportMainGraph.Checked)))
{
zgc.Invalidate();
zgc.Refresh();
}
#endregion
}
}
//public class Maingraph
//{
// public String SelectedOption { get; set; }
// public CultureInfo Culture { get; set; }
// //public ZedGraphControl Zgc_Maingraph { get; set; }
// public Double Xrange { get; set; }
// public Boolean Avg38En { get; set; }
// public Int32 NumberOfStdDeviationValues { get; set; }
// public Int32 NumberOfMeanValues { get; set; }
// public ZedGraphParameters ParamsMainGraph { get; set; }
// //public PointPairList[] GraphListMainWindow { get; set; }
// //public List<PointPairList>[] GraphListMainTotal { get; set; }
// private Boolean GetTabStatus()
// {
// return GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GetTabStatus();
// }
// private Boolean[] GetSelectedPath()
// {
// return GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GetSelectedPath();
// }
// public Double InitXrange(Double xRange)
// {
// this.Xrange = xRange;
// return Xrange;
// }
// public void InitParameters(Double xRange, String selectedOption, Boolean avg38en, Int32 numberOfStdDeviationValues, Int32 numberOfMeanValues)
// {
// //this.Zgc_Maingraph = zBC_Maingraph;
// this.Xrange = xRange;
// this.SelectedOption = selectedOption;
// this.Avg38En = avg38en;
// this.NumberOfMeanValues = numberOfMeanValues;
// this.NumberOfStdDeviationValues = numberOfStdDeviationValues;
// //this.GraphListMainWindow = graphListMainWindow;
// //this.GraphListMainTotal = graphListMainTotal;
// }
// public void SetTitle(Int32 numberOfMeanValues)
// {
// try
// {
// #region Definitions and initializations
// String TitleOfGraph = String.Empty;
// #endregion
// #region Set title
// if (this.SelectedOption.Contains("Mean"))
// TitleOfGraph = this.SelectedOption + "\n(Mean over " + numberOfMeanValues.ToString(this.Culture) + " values)";
// else
// TitleOfGraph = this.SelectedOption;
// if (this.SelectedOption.Contains("deviation"))
// {
// TitleOfGraph = this.SelectedOption + "\n(Std deviation over " + this.NumberOfStdDeviationValues.ToString(this.Culture) + " values";
// if (this.Avg38En)
// TitleOfGraph = TitleOfGraph + ", Mean over " + numberOfMeanValues.ToString(this.Culture) + " values)";
// else
// TitleOfGraph = TitleOfGraph + ")";
// }
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.SetTitleMainGraph(TitleOfGraph);
// TitleOfGraph = this.SelectedOption;
// CreateGraphs(true, GetTabStatus(), GetSelectedPath());
// #endregion
// }
// catch (Exception ex)
// {
// ErrorLog.Log(LogErrReason.Exception(), "MainGraphSetTitle() failed", "0x" + ex.HResult.ToString("X", this.Culture), String.Empty);
// }
// }
// // public void InitGraph(PointPairList[] graphListMainWindow)
// public void InitGraph()
// {
// try
// {
// #region Definitions and initializations
// String TitleOfGraph = String.Empty;
// #endregion
// #region Set title
// if (this.SelectedOption.Contains("Mean"))
// TitleOfGraph = this.SelectedOption + "\n(Mean over " + this.NumberOfMeanValues.ToString(this.Culture) + " values)";
// else
// TitleOfGraph = this.SelectedOption;
// if (this.SelectedOption.Contains("deviation"))
// {
// TitleOfGraph = this.SelectedOption + "\n(Std deviation over " + this.NumberOfStdDeviationValues.ToString(this.Culture) + " values";
// if (this.Avg38En)
// TitleOfGraph = TitleOfGraph + ", Mean over " + this.NumberOfMeanValues.ToString(this.Culture) + " values)";
// else
// TitleOfGraph = TitleOfGraph + ")";
// }
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.SetTitleMainGraph(TitleOfGraph);
// #endregion
// #region Amplitude
// if (this.SelectedOption.Contains("Amplitude"))
// {
// ParamsMainGraph.xAxis = "Values";
// ParamsMainGraph.yAxis = "mV";
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Min = 0;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Max = this.Xrange;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.YAxis.Scale.Min = 0;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.YAxis.Scale.Max = 600;
// CreateGraphs(true, GetTabStatus(), GetSelectedPath());
// return;
// }
// #endregion
// #region Temperature
// if (this.SelectedOption.Contains("Temperature"))
// {
// ParamsMainGraph.xAxis = "Values";
// ParamsMainGraph.yAxis = "°C";
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Min = 0;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Max = Xrange;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.YAxis.Scale.Min = -5;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.YAxis.Scale.Max = 70;
// CreateGraphs(true, GetTabStatus(), GetSelectedPath());
// return;
// }
// #endregion
// /*
// #region Time of flight
// if
// (
// (this.SelectedOption.Contains("deviation")) ||
// (this.SelectedOption.Contains("DIF TOF")) ||
// (this.SelectedOption.Contains("TOF")))
// {
// ParamsMainGraph.xAxis = "Values";
// this.Zgc_Maingraph.GraphPane.XAxis.Scale.Min = 0;
// this.Zgc_Maingraph.GraphPane.XAxis.Scale.Max = this.Xrange;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.MinAuto = true;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.MaxAuto = true;
// ParamsMainGraph.yAxis = "t/ps";
// CreateGraphs(true, GetTabStatus(), GetSelectedPath());
// return;
// }
// #endregion
// #region Pulsewidth
// if (this.SelectedOption.Contains("Pulsewidth"))
// {
// ParamsMainGraph.xAxis = "Values";
// ParamsMainGraph.yAxis = "Ratio";
// this.Zgc_Maingraph.GraphPane.XAxis.Scale.Min = 0;
// this.Zgc_Maingraph.GraphPane.XAxis.Scale.Max = this.Xrange;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.Min = 0;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.Max = 2.1;
// CreateGraphs(true, GetTabStatus(), GetSelectedPath());
// return;
// }
// #endregion
// #region Temperature
// if (this.SelectedOption.Contains("Temperature"))
// {
// ParamsMainGraph.xAxis = "Values";
// ParamsMainGraph.yAxis = "°C";
// this.Zgc_Maingraph.GraphPane.XAxis.Scale.Min = 0;
// this.Zgc_Maingraph.GraphPane.XAxis.Scale.Max = Xrange;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.Min = -5;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.Max = 70;
// CreateGraphs(true, GetTabStatus(), GetSelectedPath());
// return;
// }
// #endregion
// #region Amplitude
// if (this.SelectedOption.Contains("Amplitude"))
// {
// ParamsMainGraph.xAxis = "Values";
// ParamsMainGraph.yAxis = "mV";
// this.Zgc_Maingraph.GraphPane.XAxis.Scale.Min = 0;
// this.Zgc_Maingraph.GraphPane.XAxis.Scale.Max = this.Xrange;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.Min = 0;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.Max = 600;
// CreateGraphs(true, GetTabStatus(), GetSelectedPath());
// return;
// }
// #endregion
// #region Flow (absolute)
// if (this.SelectedOption.Contains("Flow") && this.SelectedOption.Contains("absolute"))
// {
// ParamsMainGraph.xAxis = "Values";
// ParamsMainGraph.yAxis = "m³/h";
// this.Zgc_Maingraph.GraphPane.XAxis.Scale.Min = 0;
// this.Zgc_Maingraph.GraphPane.XAxis.Scale.Max = Xrange;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.Min = -100;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.Max = 100;
// CreateGraphs(true, GetTabStatus(), GetSelectedPath());
// return;
// }
// #endregion
// #region Flow (relative)
// if (this.SelectedOption.Contains("Flow") && this.SelectedOption.Contains("relative"))
// {
// ParamsMainGraph.xAxis = "Values";
// ParamsMainGraph.yAxis = "Δ% (deviation from nominal value)";
// this.Zgc_Maingraph.GraphPane.XAxis.Scale.Min = 0;
// this.Zgc_Maingraph.GraphPane.XAxis.Scale.Max = this.Xrange;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.Min = -100;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.Max = 100;
// CreateGraphs(true, GetTabStatus(), GetSelectedPath());
// return;
// }
// #endregion
// */
// }
// catch (Exception ex)
// {
// ErrorLog.Log(LogErrReason.Exception(), "Maingraph.InitGraph() failed", "0x" + ex.HResult.ToString("X", this.Culture), String.Empty);
// }
// }
// public void CreateGraphs(Boolean init, Boolean Refresh, Boolean[] selectedPath)
// {
// #region Settings for the entire graph
// GraphPane myPane = GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane;// zgc.GraphPane;
// myPane.Title.Text = this.ParamsMainGraph.Title;
// String MainGraphTitle = this.ParamsMainGraph.Title;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.IsAutoScrollRange = true;// zgc.IsAutoScrollRange = true;
// // 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 = this.ParamsMainGraph.xAxis;
// myPane.YAxis.Title.Text = this.ParamsMainGraph.yAxis;
// myPane.Fill.Color = Color.AliceBlue;
// myPane.Chart.Fill.Color = Color.Cornsilk;
// myPane.Legend.Fill.Color = Color.Cornsilk;
// }
// /*
// // X-Axis decimal point
// if (GraphsListDataMainTotal[Constants.PATH2].Count > 100000 - nUD_SettingsXMainGraph.Value)
// myPane.XAxis.Scale.Format = "0.0000";
// else
// {
// if (GraphsListDataMainTotal[Constants.PATH2].Count > 10000 - nUD_SettingsXMainGraph.Value)
// myPane.XAxis.Scale.Format = "0.00";
// else
// myPane.XAxis.Scale.Format = "0";
// }*/
// #endregion
// #region Reset curve lists
// //Needed for redrawing the chart, to remove old curves
// myPane.CurveList.Clear();
// #endregion
// #region Settings PATH0
// #region Add Data
// LineItem myMainCurvePath0;
// myMainCurvePath0 = myPane.AddCurve("PATH1", GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GraphListMainWindow[Constants.PATH0], Color.Red);
// #endregion
// #region Customize graph
// #region Enable/ disable curves and legend items
// //if (cB_GraphOptionEnPath0.Checked)
// if(selectedPath[Constants.PATH0])
// {
// myMainCurvePath0.IsVisible = true;
// myMainCurvePath0.Label.IsVisible = true;
// }
// else
// {
// myMainCurvePath0.IsVisible = false;
// myMainCurvePath0.Label.IsVisible = false;
// }
// #endregion
// #region Other settings
// myMainCurvePath0.Line.IsVisible = true; //Hide line-connections
// myMainCurvePath0.Symbol.Type = SymbolType.Circle;
// myMainCurvePath0.Symbol.Size = 2f;
// myMainCurvePath0.Symbol.Fill.Type = FillType.Solid;
// myMainCurvePath0.Symbol.IsAntiAlias = true; //Makes the circles smoother
// myMainCurvePath0.IsSelected = false;
// #endregion
// #endregion
// #endregion
// #region Settings PATH1
// #region Add Data
// LineItem myMainCurvePath1 = myPane.AddCurve("PATH2", GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GraphListMainWindow[Constants.PATH1], Color.Blue);
// #endregion
// #region Customize graph
// #region Enable/ disable curves and legend items
// // if (cB_GraphOptionEnPath1.Checked)
// if(selectedPath[Constants.PATH1])
// {
// myMainCurvePath1.IsVisible = true;
// myMainCurvePath1.Label.IsVisible = true;
// }
// else
// {
// myMainCurvePath1.IsVisible = false;
// myMainCurvePath1.Label.IsVisible = false;
// }
// #endregion
// #region Other settings
// myMainCurvePath1.Line.IsVisible = true; //Hide line-connections
// myMainCurvePath1.Symbol.Type = SymbolType.Circle;
// myMainCurvePath1.Symbol.Size = 2f;
// myMainCurvePath1.Symbol.Fill.Type = FillType.Solid;
// myMainCurvePath1.Symbol.IsAntiAlias = true; //Makes the circles smoother
// #endregion
// #endregion
// #endregion
// #region Settings PATH2
// #region Add data
// LineItem myMainCurvePath2 = myPane.AddCurve("PATH3", GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GraphListMainWindow[Constants.PATH2], Color.Green);
// #endregion
// #region Customize graph
// #region Enable/ disable curves and legend items
// //if (cB_GraphOptionEnPath2.Checked)
// if(selectedPath[Constants.PATH2])
// {
// myMainCurvePath2.IsVisible = true;
// myMainCurvePath2.Label.IsVisible = true;
// }
// else
// {
// myMainCurvePath2.IsVisible = false;
// myMainCurvePath2.Label.IsVisible = false;
// }
// #endregion
// #region Other settings
// myMainCurvePath2.Line.IsVisible = true; //Hide line-connections
// myMainCurvePath2.Symbol.Type = SymbolType.Circle;
// myMainCurvePath2.Symbol.Size = 2f;
// myMainCurvePath2.Symbol.Fill.Type = FillType.Solid;
// myMainCurvePath2.Symbol.IsAntiAlias = true; //Makes the circles smoother
// #endregion
// #endregion
// #endregion
// #region Refresh the graph in order to show the new data
// //zgc.AxisChange();
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.AxisChange();
// // If tab "Graph" selected of tab "Report" selected and Option "Maingraph" checked
// // if ((tabMaintab.SelectedTab == tab_Graph) ||
// // ((tabMaintab.SelectedTab == tabReport) && (cB_ReportMainGraph.Checked)))
// if(Refresh)
// {
// //zgc.Invalidate();
// //zgc.Refresh();
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.Invalidate();
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.Refresh();
// }
// #endregion
// }
// public void Reset(Double ScaleMax)
// {
// try
// {
// // Reset graph pane
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.ZoomOutAll(GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane);
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.GraphObjList.Clear();
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.CurveList.Clear();
// // Reset counters
// for (UInt16 Path = 0; Path < Constants.NumberOfPaths; Path++)
// {
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.SetGraphCounterDataMainTotal(0, Path);
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.SetGraphIndexOfLists(0, Path);
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.SetGraphNumberOfElements(0, Path);
// }
// // Reset range
// // zGC_MainGraph.GraphPane.XAxis.Scale.Max = (Double)nUD_SettingsXMainGraph.Value;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Max = ScaleMax;
// // Clear graphs
// for (UInt16 Path = 0; Path < Constants.NumberOfPaths; Path++)
// {
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GraphListMainWindow[Path].Clear();
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GraphListMainTotal[Path].Clear();
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GraphListMainTotal[Path].Add(new PointPairList());
// }
// // Refresh
// // db_Maingraph.flushData();
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.Refresh();
// }
// catch (Exception ex)
// {
// ErrorLog.Log(LogErrReason.Exception(), "Maingraph.Reset() failed", "0x" + ex.HResult.ToString("X", this.Culture), String.Empty);
// }
// }
// public void AssignData(DecodedData[] decodedValues, UInt16 path, ref UInt32[] graphCounterDataMainTotal, ref Int32[] graphIndexOfLists)
// {
// #region Definitions and initializations
// UInt32 DifTofIndex = 0;
// UInt32 TofIndex = 0;
// String DifTofIndexString = String.Empty;
// Double[] data = new Double[Constants.NumberOfPaths] { 0.0, 0.0, 0.0 };
// Double MaingraphNomVal = GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GetNudmaingraphNomVal();
// #endregion
// #region Horizontal setup
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.SetAutoScrollMargin(100, 20);
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.IsAutoScrollRange = true;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.ScrollGrace = Constants.DefaultScrollGrace;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.HorizontalScroll.Enabled = true;
// if ((GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Max - this.Xrange) >= 0)
// {
// if (GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Max != this.Xrange)
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Min = GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Max - this.Xrange + 1;
// else
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Min = GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Max - this.Xrange; //
// }
// else
// {
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Min = 0;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Max = this.Xrange;
// }
// /*
// if (zGC_MainGraph.GraphPane.XAxis.Scale.Max != xRange)
// zGC_MainGraph.GraphPane.XAxis.Scale.Min = zGC_MainGraph.GraphPane.XAxis.Scale.Max - xRange + 1;
// else
// zGC_MainGraph.GraphPane.XAxis.Scale.Min = zGC_MainGraph.GraphPane.XAxis.Scale.Max - xRange; // for the very first element eg. when max = 200 and min = 0
// */
// #endregion
// #region Set lists for backup whole data
// #region Amplitude up
// if (this.SelectedOption.Contains( "Amplitude Up (H-Protocol)"))
// {
// #region Set graph
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].HProt_AmplitudeUp);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].HProt_AmplitudeUp;
// Graphs.BackupData(path, data, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// //if(Path== Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].AmpUp, Decoded[Constants.PATH1].AmpUp, Decoded[Constants.PATH2].AmpUp);
// }
// #endregion
// #region Amplitude down
// if (this.SelectedOption.Contains("Amplitude Down (H-Protocol)"))
// {
// #region Set graph
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].HProt_AmplitudeDown);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].HProt_AmplitudeDown;
// Graphs.BackupData(path, data, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// //if(Path== Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].AmpUp, Decoded[Constants.PATH1].AmpUp, Decoded[Constants.PATH2].AmpUp);
// }
// #endregion
// #region Temperature
// if (this.SelectedOption.Contains("Temperature (H-Protocol)"))
// {
// #region Set graph
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].HProt_CalculatedTemperature);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].HProt_CalculatedTemperature;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GraphListMainTotal[path][graphIndexOfLists[path]].Add(graphCounterDataMainTotal[path], decodedValues[path].HProt_CalculatedTemperature);
// Graphs.BackupData(path, data, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// // if (Path == Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].TemperatureCold, Decoded[Constants.PATH1].TemperatureCold, Decoded[Constants.PATH2].TemperatureCold);
// }
// #endregion
// /*
// #region DIF TOF
// if (this.SelectedOption.Contains("DIF TOF") && (!this.SelectedOption.Contains("Mean")) && (!(this.SelectedOption.Contains("zero"))))
// {
// #region Prepare data
// DifTofIndex = UInt32.Parse(Regex.Match(this.SelectedOption, @"\d+").Value);
// //if (Path == Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].DifTof[DifTofIndex], Decoded[Constants.PATH1].DifTof[DifTofIndex], Decoded[Constants.PATH2].DifTof[DifTofIndex]);
// #endregion
// #region Set graph
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].DifTof[DifTofIndex]);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].DifTof[DifTofIndex];
// Graphs.BackupData(path, data, this.GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// }
// #endregion
// #region DIF TOF, mean
// if (this.SelectedOption.Contains("Mean DIF TOF") && (!(this.SelectedOption.Contains("zero"))))
// {
// #region Prepare data
// DifTofIndex = UInt32.Parse(Regex.Match(this.SelectedOption, @"\d+").Value);
// #endregion
// #region Set graph
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].DifTofMean[DifTofIndex]);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].DifTofMean[DifTofIndex];
// Graphs.BackupData(path, data, this.GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// }
// #endregion
// #region Standard deviation (8 zero crossings)
// if (this.SelectedOption == "Standard deviation (Mean over 8 zero crossings)")
// {
// #region Set graph
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].DifTof8HitsStdDeviation);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].DifTof8HitsStdDeviation;
// Graphs.BackupData(path, data, this.GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// // if (Path == Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].StdDev8Hits, Decoded[Constants.PATH1].StdDev8Hits, Decoded[Constants.PATH2].StdDev8Hits);
// }
// #endregion
// #region Standard deviation (3 zero crossings)
// if (this.SelectedOption == "Standard deviation (Mean over 3 zero crossings)")
// {
// #region Set graph
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].DifTof3HitsStdDeviation);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].DifTof3HitsStdDeviation;
// Graphs.BackupData(path, data, this.GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// }
// #endregion
// #region TOF, mean
// if (this.SelectedOption.Contains("Mean TOF") && (!(this.SelectedOption.Contains("zero"))))
// {
// #region Prepare data
// TofIndex = UInt32.Parse(Regex.Match(this.SelectedOption, @"\d+").Value);
// #endregion
// #region Set graph
// if (this.SelectedOption.Contains("up"))
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].TofUpMean[TofIndex]);
// if (this.SelectedOption.Contains("down"))
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].TofDownMean[TofIndex]);
// #endregion
// #region Backup data
// if (this.SelectedOption.Contains("up"))
// {
// data[path] = decodedValues[path].TofUpMean[TofIndex];
// Graphs.BackupData(path, data, GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// }
// if (this.SelectedOption.Contains("down"))
// {
// data[path] = decodedValues[path].TofDownMean[TofIndex];
// Graphs.BackupData(path, data, this.GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// }
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// }
// #endregion
// #region Amplitude up
// if (this.SelectedOption == "Amplitude Up")
// {
// #region Set graph
// GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].AmpUpCalculated);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].AmpUpCalculated;
// Graphs.BackupData(path, data, GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// //if(Path== Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].AmpUp, Decoded[Constants.PATH1].AmpUp, Decoded[Constants.PATH2].AmpUp);
// }
// #endregion
// #region Amplitude down
// if (this.SelectedOption == "Amplitude Down")
// {
// #region Set graph
// GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].AmpDownCalculated);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].AmpDownCalculated;
// Graphs.BackupData(path, data, GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// // if (Path == Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].AmpDown, Decoded[Constants.PATH1].AmpDown, Decoded[Constants.PATH2].AmpDown);
// #endregion
// }
// #endregion
// #region Pulsewidth up
// if (this.SelectedOption == "Pulsewidth Up")
// {
// #region Set graph
// GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].PulsewidthUp);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].PulsewidthUp;
// Graphs.BackupData(path, data, GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// // if (Path == Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].PulsewidthUp, Decoded[Constants.PATH1].PulsewidthUp, Decoded[Constants.PATH2].PulsewidthUp);
// }
// #endregion
// #region Pulsewidth down
// if (this.SelectedOption == "Pulsewidth Down")
// {
// #region Set graph
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].PulsewidthDown);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].PulsewidthDown;
// Graphs.BackupData(path, data, GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// }
// #endregion
// #region Temperature
// if (this.SelectedOption == "Temperature Cold")
// {
// #region Set graph
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].TemperatureCold);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].TemperatureCold;
// GraphListMainTotal[path][graphIndexOfLists[path]].Add(graphCounterDataMainTotal[path], decodedValues[path].TemperatureCold);
// Graphs.BackupData(path, data, GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// // if (Path == Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].TemperatureCold, Decoded[Constants.PATH1].TemperatureCold, Decoded[Constants.PATH2].TemperatureCold);
// }
// #endregion
// #region Flow (absolute)
// if (this.SelectedOption == "Flow (absolute)")
// {
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.MaxAuto = true;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.MinAuto = true;
// #region Set graph
// if (!Double.IsNaN(decodedValues[path].Flow))
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].Flow);
// else
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], 0);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].Flow;
// Graphs.BackupData(path, data, GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// //if(Path== Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].AmpUp, Decoded[Constants.PATH1].AmpUp, Decoded[Constants.PATH2].AmpUp);
// }
// #endregion
// #region Flow (absolute, mean)
// if (this.SelectedOption == "Flow (absolute, Mean)")
// {
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.MaxAuto = true;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.MinAuto = true;
// #region Set graph
// if (!Double.IsNaN(decodedValues[path].FlowMean))
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], decodedValues[path].FlowMean);
// else
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], 0);
// #endregion
// #region Backup data
// data[path] = decodedValues[path].FlowMean;
// Graphs.BackupData(path, data, GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// //if(Path== Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].AmpUp, Decoded[Constants.PATH1].AmpUp, Decoded[Constants.PATH2].AmpUp);
// }
// #endregion
// #region Flow (relative)
// if (this.SelectedOption == "Flow (relative)")
// {
// #region Definitions and initializations
// Double[] FlowRelative = new Double[Constants.NumberOfPaths] { 0, 0, 0 };
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.MaxAuto = true;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.MinAuto = true;
// #endregion
// #region Calculate value
// if (MaingraphNomVal == 0)
// {
// MessageBox.Show("Setting value must not be zero\ndue to devision by zero\nGraph stopped\n", "Form closing", MessageBoxButtons.OK, MessageBoxIcon.Error);
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.SetCbGraphResetCheckStatus(false);
// return;
// }
// if (!Double.IsNaN(decodedValues[path].Flow))
// FlowRelative[path] = 100 - (100 * decodedValues[path].Flow / MaingraphNomVal);
// #endregion
// #region Set graph
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], FlowRelative[path]);
// #endregion
// #region Backup data
// if (!Double.IsNaN(decodedValues[path].Flow))
// data[path] = MaingraphNomVal - decodedValues[path].Flow;
// Graphs.BackupData(path, data, GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// //if(Path== Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].AmpUp, Decoded[Constants.PATH1].AmpUp, Decoded[Constants.PATH2].AmpUp);
// }
// #endregion
// #region Flow (relative, mean)
// if (this.SelectedOption == "Flow (relative, Mean)")
// {
// Double[] FlowRelative = new Double[Constants.NumberOfPaths] { 0, 0, 0 };
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.MaxAuto = true;
// this.Zgc_Maingraph.GraphPane.YAxis.Scale.MinAuto = true;
// #region Calculate value
// if (MaingraphNomVal == 0)
// {
// MessageBox.Show("Setting value must not be zero\ndue to devision by zero\nGraph stopped\n", "Form closing", MessageBoxButtons.OK, MessageBoxIcon.Error);
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.SetCbGraphResetCheckStatus(false);
// return;
// }
// if (!Double.IsNaN(decodedValues[path].FlowMean))
// FlowRelative[path] = 100 - (100 * decodedValues[path].FlowMean / MaingraphNomVal);
// #endregion
// #region Set graph
// this.GraphListMainWindow[path].Add(graphCounterDataMainTotal[path], FlowRelative[path]);
// #endregion
// #region Backup data
// if (!Double.IsNaN(decodedValues[path].FlowMean))
// data[path] = MaingraphNomVal - decodedValues[path].FlowMean;
// Graphs.BackupData(path, data, GraphListMainTotal, ref graphIndexOfLists, graphCounterDataMainTotal);
// FinalizeAssigning(path, ref graphCounterDataMainTotal, ref graphIndexOfLists);
// return;
// #endregion
// //if(Path== Constants.PATH2)
// // db_Maingraph.insertData((int)GraphCounterDataMainTotal[Path], Decoded[Constants.PATH0].AmpUp, Decoded[Constants.PATH1].AmpUp, Decoded[Constants.PATH2].AmpUp);
// }
// */
// #endregion
// //#endregion
// }
// public void FinalizeAssigning(Int32 path, ref UInt32[] graphCounterDataMainTotal, ref Int32[] graphIndexOfLists)
// {
// #region Create graph
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.SetGraphNumberOfElements(GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GraphListMainTotal[path][graphIndexOfLists[path]].Count(), path);
// CreateGraphs(false, GetTabStatus(), GetSelectedPath());
// #endregion
// #region X-Axis control
// if (graphCounterDataMainTotal[path] > UInt32.MaxValue - 2)
// {
// #region Counter overflow stop calculation
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.SetCbGraphResetCheckStatus(false);
// MessageBox.Show("Counter overflow, Maingraph stopped", "Form closing", MessageBoxButtons.OK, MessageBoxIcon.Error);
// #endregion
// }
// else
// graphCounterDataMainTotal[path]++;
// #endregion
// #region Reset zedgraph data lists and counters
// if ((UInt32)graphCounterDataMainTotal[path] % this.Xrange == 0)
// {
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.SetCbGraphResetCheckStatus(false);
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.GraphListMainWindow[path].Clear();
// if (path == Constants.PATH2)
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Max = GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.GraphPane.XAxis.Scale.Max + this.Xrange;
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.zGC_MainGraph.PerformAutoScale();
// CreateGraphs(false, GetTabStatus(), GetSelectedPath());
// GENESIS_DISPLAY_TOOL._GENESIS_DISPLAY_TOOL.SetCbGraphResetCheckStatus(true);
// }
// #endregion
// }
//}
public static class Graphs
{
public static void BackupData(UInt16 path, Double[] data, ref List<PointPairList>[] graphListMainTotal, ref Int32[] graphIndexOfLists, UInt32[] graphCounterDataMainTotal)
{
if (!Double.IsNaN(data[path]))
graphListMainTotal[path][graphIndexOfLists[path]].Add(graphCounterDataMainTotal[path], data[path]);
else
graphListMainTotal[path][graphIndexOfLists[path]].Add(graphCounterDataMainTotal[path], 0);
if (graphListMainTotal[path][graphIndexOfLists[path]].Count > Constants.MainGraphListMaxElements - 1)
{
graphListMainTotal[path].Add(new PointPairList());
graphIndexOfLists[path]++;
}
return;
}
public static void GetFromBackup(UInt16 path, Int32 index, List<PointPairList>[] graphListMainTotal, ref PointPairList[] graphListMainWindow)
{
#region Get index
Int32 DataIndex = (index) / (Constants.MainGraphListMaxElements);
Int32 PosIndex = (index) % (Constants.MainGraphListMaxElements);
#endregion
#region Copy list
//if ((DataIndex <= GraphListMainTotal[Path].Count() - 1) && (PosIndex <= GraphListMainTotal[Path][DataIndex].Count() - 1))
if ((DataIndex <= graphListMainTotal[path].Count()) && (PosIndex <= graphListMainTotal[path][DataIndex].Count()))
graphListMainWindow[path].Add(graphListMainTotal[path][(Int32)DataIndex].ElementAt((Int32)PosIndex));
#endregion
}
}
}