568 lines
24 KiB
C#
568 lines
24 KiB
C#
|
|
using ScottPlot.WPF;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Windows;
|
|||
|
|
using System.Windows.Controls;
|
|||
|
|
using Newtonsoft.Json;
|
|||
|
|
using Xylem.Common.CommonCore.Consts;
|
|||
|
|
using Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol;
|
|||
|
|
using Xylem.Common.Logic.ProductionOrderCore.TestResults;
|
|||
|
|
using Xylem.Common.Logic.SoftwareAccessHelper;
|
|||
|
|
using Xylem.Common.Metrology.Measurements;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Runtime.Remoting.Messaging;
|
|||
|
|
using ScottPlot;
|
|||
|
|
|
|||
|
|
namespace CordoPlot
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Interaction logic for MainWindow.xaml
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class MainWindow : Window, INotifyPropertyChanged
|
|||
|
|
{
|
|||
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|||
|
|
|
|||
|
|
|
|||
|
|
public DataTable dspData { get; set; }
|
|||
|
|
|
|||
|
|
public DataTable chnData1 { get; set; }
|
|||
|
|
|
|||
|
|
public DataTable chnData2 { get; set; }
|
|||
|
|
public DataTable chnData3 { get; set; }
|
|||
|
|
|
|||
|
|
|
|||
|
|
public String CSerialnr { get { return _CSerialnr; } set { _CSerialnr = value; OnPropertyChanged("CSerialnr"); } }
|
|||
|
|
public String CTestRunNr { get { return _CTestRunNr; } set { _CTestRunNr = value; OnPropertyChanged("CTestRunNr"); } }
|
|||
|
|
public String CTestBenchNr { get { return _CTestBenchNr; } set { _CTestBenchNr = value; OnPropertyChanged("CTestBenchNr"); } }
|
|||
|
|
public String CDate { get { return _CDate; } set { _CDate = value; OnPropertyChanged("CDate"); } }
|
|||
|
|
public String CMeterSize { get { return _CMeterSize; } set { _CMeterSize = value; OnPropertyChanged("CMeterSize"); } }
|
|||
|
|
public String CAirTempC { get { return _CAirTempC; } set { _CAirTempC = value; OnPropertyChanged("CAirTempC"); } }
|
|||
|
|
public String CAirPressure { get { return _CAirPressure; } set { _CAirPressure = value; OnPropertyChanged("CAirPressure"); } }
|
|||
|
|
public String CAirHumanity { get { return _CAirHumanity; } set { _CAirHumanity = value; OnPropertyChanged("CAirHumanity"); } }
|
|||
|
|
public String CWaterTempC { get { return _CWaterTempC; } set { _CWaterTempC = value; OnPropertyChanged("CWaterTempC"); } }
|
|||
|
|
public String CTotalMeters { get { return _CTotalMeters; } set { _CTotalMeters = value; OnPropertyChanged("CTotalMeters"); } }
|
|||
|
|
public String CRemark { get { return _CRemark; } set { _CRemark = value; OnPropertyChanged("CRemark"); } }
|
|||
|
|
|
|||
|
|
private String _CSerialnr { get; set; }
|
|||
|
|
private String _CTestRunNr { get; set; }
|
|||
|
|
private String _CTestBenchNr { get; set; }
|
|||
|
|
private String _CDate { get; set; }
|
|||
|
|
private String _CMeterSize { get; set; }
|
|||
|
|
private String _CAirTempC { get; set; }
|
|||
|
|
private String _CAirPressure { get; set; }
|
|||
|
|
private String _CAirHumanity { get; set; }
|
|||
|
|
private String _CWaterTempC { get; set; }
|
|||
|
|
private String _CTotalMeters { get; set; }
|
|||
|
|
private String _CRemark { get; set; }
|
|||
|
|
|
|||
|
|
protected void OnPropertyChanged(string propertyName)
|
|||
|
|
{
|
|||
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private PlotableTestResults _testBenchresults;
|
|||
|
|
|
|||
|
|
public PlotableTestResults testBenchresults
|
|||
|
|
{
|
|||
|
|
get { return _testBenchresults; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
if (value != _testBenchresults)
|
|||
|
|
{
|
|||
|
|
_testBenchresults = value;
|
|||
|
|
OnPropertyChanged("testBenchresults");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
public MainWindow()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Button_Click(Object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
|
|||
|
|
var dialog = new Microsoft.Win32.OpenFileDialog();
|
|||
|
|
dialog.FileName = "led"; // Default file name
|
|||
|
|
dialog.DefaultExt = ".log"; // Default file extension
|
|||
|
|
dialog.Filter = "Text documents (.log)|*.log"; // Filter files by extension
|
|||
|
|
|
|||
|
|
// Show open file dialog box
|
|||
|
|
bool? result = dialog.ShowDialog();
|
|||
|
|
|
|||
|
|
// Process open file dialog box results
|
|||
|
|
if (result == true)
|
|||
|
|
{
|
|||
|
|
//lade testresult from webservise
|
|||
|
|
// Open document
|
|||
|
|
string filename = dialog.FileName;
|
|||
|
|
testBenchresults = new PlotableTestResults();
|
|||
|
|
var AllLines = File.ReadAllLines(filename);
|
|||
|
|
|
|||
|
|
//LedRawData__Slot_7_SN24712962_PG2016079130.log
|
|||
|
|
if (filename.Contains("_SN") && filename.Contains("_PG"))
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
|
|||
|
|
var sn = filename.Substring(filename.LastIndexOf("_SN") + 3, filename.LastIndexOf("_PG") - filename.LastIndexOf("_SN") - 3);
|
|||
|
|
var pg = filename.Substring(filename.LastIndexOf("_PG") + 3, filename.LastIndexOf(".log") - filename.LastIndexOf("_PG") - 3);
|
|||
|
|
testBenchresults = JsonConvert.DeserializeObject<PlotableTestResults>(LocalWebRequest.GetRequest($"http://localhost:50075/api/TestBench/GetTestResults?SerialNr={sn}&TestRunNr={pg}", 10000));
|
|||
|
|
testBenchresults.HasResults = true;
|
|||
|
|
|
|||
|
|
dataGridTestPoints.ItemsSource = testBenchresults.TestPointsMain;
|
|||
|
|
dataGridTestPoints.Items.Refresh();
|
|||
|
|
|
|||
|
|
|
|||
|
|
DataTable MainInfoDt = new DataTable("DisplayData");
|
|||
|
|
|
|||
|
|
|
|||
|
|
MainInfoDt.Columns.Add("Prop", typeof(string));
|
|||
|
|
MainInfoDt.Columns.Add("Val", typeof(string));
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
MainInfoDt.Rows.Add("Serialnr", testBenchresults.Serialnr.ToString());
|
|||
|
|
MainInfoDt.Rows.Add("TestRunNr", testBenchresults.TestRunNr.ToString());
|
|||
|
|
MainInfoDt.Rows.Add("TestBenchNr", testBenchresults.TestBenchNr.ToString());
|
|||
|
|
MainInfoDt.Rows.Add("Date", testBenchresults.Date.ToString());
|
|||
|
|
MainInfoDt.Rows.Add("MeterSize", testBenchresults.MeterSize.ToString());
|
|||
|
|
MainInfoDt.Rows.Add("AirTempC", testBenchresults.AirTempC.ToString());
|
|||
|
|
MainInfoDt.Rows.Add("AirPressure", testBenchresults.AirPressure.ToString());
|
|||
|
|
MainInfoDt.Rows.Add("AirHumanity", testBenchresults.AirHumanity.ToString());
|
|||
|
|
MainInfoDt.Rows.Add("WaterTempC", testBenchresults.WaterTempC.ToString());
|
|||
|
|
MainInfoDt.Rows.Add("TotalMeters", testBenchresults.TotalMeters.ToString());
|
|||
|
|
MainInfoDt.Rows.Add("Remark", testBenchresults.Remark.ToString());
|
|||
|
|
dataGridInfo.DataContext = MainInfoDt.DefaultView;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var listOfData = new List<List<IMeasurementRecord>>();
|
|||
|
|
listOfData.Add(new List<IMeasurementRecord>());
|
|||
|
|
listOfData.Add(new List<IMeasurementRecord>());
|
|||
|
|
listOfData.Add(new List<IMeasurementRecord>());
|
|||
|
|
listOfData.Add(new List<IMeasurementRecord>());
|
|||
|
|
var decoder = new StreamingDecoder();
|
|||
|
|
var currentSyncmark = SyncMarkRecord.DecodeEveryPackage;
|
|||
|
|
//DecodeMsg
|
|||
|
|
var linecounter = 0;
|
|||
|
|
foreach (var line in AllLines)
|
|||
|
|
{
|
|||
|
|
linecounter = linecounter + 1;
|
|||
|
|
decoder = new StreamingDecoder();
|
|||
|
|
|
|||
|
|
if (line.Contains("|"))
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
var t = line.Split('|');
|
|||
|
|
DateTime recived = DateTime.Now;
|
|||
|
|
DateTime.TryParse(t[0], out recived);
|
|||
|
|
if (t[1].Contains("@"))
|
|||
|
|
{
|
|||
|
|
decoder.DecodeMsg(t[1].Trim());
|
|||
|
|
IMeasurementRecord recordToAdd;
|
|||
|
|
if (decoder.DataBendDetectTest != null && decoder.DataBendDetectTest.IsValid)
|
|||
|
|
{
|
|||
|
|
decoder.DataBendDetectTest.ReceivedTime = recived;
|
|||
|
|
decoder.DataBendDetectTest.SyncMarkRecord = currentSyncmark;
|
|||
|
|
recordToAdd = decoder.DataBendDetectTest;
|
|||
|
|
}
|
|||
|
|
else if (decoder.DataCalib != null && decoder.DataCalib.IsValid)
|
|||
|
|
{
|
|||
|
|
decoder.DataCalib.ReceivedTime = recived;
|
|||
|
|
decoder.DataCalib.SyncMarkRecord = currentSyncmark;
|
|||
|
|
var n = new PlotCalibrationRecord(decoder.DataCalib, linecounter);
|
|||
|
|
|
|||
|
|
listOfData[n.GetChannel()].Add(n);
|
|||
|
|
}
|
|||
|
|
else if (decoder.DataFlowTest != null && decoder.DataFlowTest.IsValid)
|
|||
|
|
{
|
|||
|
|
decoder.DataFlowTest.ReceivedTime = recived;
|
|||
|
|
decoder.DataFlowTest.SyncMarkRecord = currentSyncmark;
|
|||
|
|
var n = new PlotFlowTestRecord(decoder.DataFlowTest, linecounter);
|
|||
|
|
listOfData[n.GetChannel()].Add(n);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//No valid data
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (line.Contains("Mark next incoming record as"))
|
|||
|
|
{
|
|||
|
|
if (line.Contains("Mark next incoming record as SyncStart"))
|
|||
|
|
{
|
|||
|
|
currentSyncmark = SyncMarkRecord.SyncStart;
|
|||
|
|
}
|
|||
|
|
else if (line.Contains("Mark next incoming record as DecodeIntermediate"))
|
|||
|
|
{
|
|||
|
|
currentSyncmark = SyncMarkRecord.DecodeIntermediate;
|
|||
|
|
}
|
|||
|
|
else if (line.Contains("Mark next incoming record as SkipDecoding"))
|
|||
|
|
{
|
|||
|
|
currentSyncmark = SyncMarkRecord.SkipDecoding;
|
|||
|
|
}
|
|||
|
|
else if (line.Contains("Mark next incoming record as SyncEnd"))
|
|||
|
|
{
|
|||
|
|
currentSyncmark = SyncMarkRecord.SyncEnd;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
currentSyncmark = SyncMarkRecord.DecodeEveryPackage;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//FlowTestRecord
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
testBenchresults.MapDataPoints(listOfData);
|
|||
|
|
StringBuilder sb;
|
|||
|
|
StringBuilder sbDetails;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
DataTable dspDataRef;
|
|||
|
|
|
|||
|
|
DataTable chnData1Ref;
|
|||
|
|
|
|||
|
|
DataTable chnData2Ref;
|
|||
|
|
DataTable chnData3Ref;
|
|||
|
|
|
|||
|
|
|
|||
|
|
testBenchresults.PrepExprtDataPoints();
|
|||
|
|
|
|||
|
|
//dspData = dspDataRef;
|
|||
|
|
//chnData1 = chnData1Ref;
|
|||
|
|
//chnData2 = chnData2Ref;
|
|||
|
|
//chnData3 = chnData3Ref;
|
|||
|
|
dataGridDispl.DataContext = dspData.DefaultView;
|
|||
|
|
dataGridchl1.DataContext = chnData1.DefaultView;
|
|||
|
|
dataGridchl2.DataContext = chnData2.DefaultView;
|
|||
|
|
dataGridchl3.DataContext = chnData3.DefaultView;
|
|||
|
|
|
|||
|
|
//File.WriteAllText(filename + "Display.csv", sb.ToString());
|
|||
|
|
//File.WriteAllText(filename + "Details.csv", sbDetails.ToString());
|
|||
|
|
|
|||
|
|
List<List<double>> Lines = new List<List<double>>();
|
|||
|
|
Lines.Add(new List<double>());
|
|||
|
|
Lines.Add(new List<double>());
|
|||
|
|
Lines.Add(new List<double>());
|
|||
|
|
Lines.Add(new List<double>());
|
|||
|
|
|
|||
|
|
|
|||
|
|
var ChnlHelper = new List<Tuple<int, WpfPlot, int?>>();
|
|||
|
|
ChnlHelper.Add(new Tuple<int, WpfPlot, int?>(0, WpfPlot1, null));
|
|||
|
|
ChnlHelper.Add(new Tuple<int, WpfPlot, int?>(1, WpfPlot1, null));
|
|||
|
|
ChnlHelper.Add(new Tuple<int, WpfPlot, int?>(2, WpfPlot1, null));
|
|||
|
|
ChnlHelper.Add(new Tuple<int, WpfPlot, int?>(3, WpfPlot1, null));
|
|||
|
|
Plot(ChnlHelper);
|
|||
|
|
//List<List<ushort>> Errors = new List<List<ushort>>();
|
|||
|
|
//Errors.Add(new List<ushort>());
|
|||
|
|
//Errors.Add(new List<ushort>());
|
|||
|
|
//Errors.Add(new List<ushort>());
|
|||
|
|
//Errors.Add(new List<ushort>());
|
|||
|
|
|
|||
|
|
|
|||
|
|
//List<double> Syncmarks = new List<double>();
|
|||
|
|
|
|||
|
|
//List<double> Linescale = new List<double>();
|
|||
|
|
//foreach (var dataItem in listOfData)
|
|||
|
|
//{
|
|||
|
|
// foreach (var item in dataItem)
|
|||
|
|
// {
|
|||
|
|
// if (item is FlowTestRecord flow)
|
|||
|
|
// {
|
|||
|
|
// Lines.First().Add(flow.GetVolumeCm());
|
|||
|
|
// Errors.First().Add(0);
|
|||
|
|
// Linescale.Add(flow.GetTimeS());
|
|||
|
|
// if (item.GetDataSyncMark() == SyncMarkRecord.SyncStart || item.GetDataSyncMark() == SyncMarkRecord.SyncEnd)
|
|||
|
|
// {
|
|||
|
|
// Syncmarks.Add(flow.GetTimeS());
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// if (item is CalibrationRecord cal)
|
|||
|
|
// {
|
|||
|
|
// if (Linescale.Any())
|
|||
|
|
// {
|
|||
|
|
// Lines[cal.Channel].Add(cal.GetVolumeCm());
|
|||
|
|
// Errors[cal.Channel].Add(cal.Validation);
|
|||
|
|
// if (item.GetDataSyncMark() == SyncMarkRecord.SyncStart || item.GetDataSyncMark() == SyncMarkRecord.SyncEnd)
|
|||
|
|
// {
|
|||
|
|
// Syncmarks.Add(cal.GetTimeS());
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//foreach (var syncm in Syncmarks)
|
|||
|
|
//{
|
|||
|
|
// WpfPlot1.Plot.Add.VerticalLine(syncm, 2, ScottPlot.Colors.DarkGray);
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//WpfPlot1.Plot.Axes.AutoScale();
|
|||
|
|
|
|||
|
|
//for (int i = 0; i <= 3; i++)
|
|||
|
|
//{
|
|||
|
|
|
|||
|
|
// WpfPlot1.Plot.Add.Scatter(Lines[i].ToArray(), Linescale.ToArray(), colors[i].Item1);
|
|||
|
|
// WpfPlot1.Plot.Add.Scatter(Errors[i].ToArray(), Linescale.ToArray(), colors[i].Item2);
|
|||
|
|
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//WpfPlot1.Refresh();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void Plot(List<Tuple<int, WpfPlot, int?>> ChnlHelper)
|
|||
|
|
{
|
|||
|
|
WpfPlot1.Reset();
|
|||
|
|
WpfPlot2.Reset();
|
|||
|
|
WpfPlot3.Reset();
|
|||
|
|
List<Tuple<ScottPlot.Color, ScottPlot.Color>> colors = new List<Tuple<ScottPlot.Color, ScottPlot.Color>>();
|
|||
|
|
|
|||
|
|
colors.Add(new Tuple<ScottPlot.Color, ScottPlot.Color>(ScottPlot.Colors.Blue, ScottPlot.Colors.DarkBlue));
|
|||
|
|
colors.Add(new Tuple<ScottPlot.Color, ScottPlot.Color>(ScottPlot.Colors.Brown, ScottPlot.Colors.DarkGoldenRod));
|
|||
|
|
colors.Add(new Tuple<ScottPlot.Color, ScottPlot.Color>(ScottPlot.Colors.Yellow, ScottPlot.Colors.DarkKhaki));
|
|||
|
|
colors.Add(new Tuple<ScottPlot.Color, ScottPlot.Color>(ScottPlot.Colors.Violet, ScottPlot.Colors.DarkViolet));
|
|||
|
|
|
|||
|
|
List<List<double>> FinLines = new List<List<double>>();
|
|||
|
|
FinLines.Add(new List<double>());
|
|||
|
|
FinLines.Add(new List<double>());
|
|||
|
|
FinLines.Add(new List<double>());
|
|||
|
|
FinLines.Add(new List<double>());
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
var Plotresults = new List<PlotResult>();
|
|||
|
|
foreach (var item in ChnlHelper)
|
|||
|
|
{
|
|||
|
|
var volLines = testBenchresults.Plot(item.Item1, item.Item3);
|
|||
|
|
volLines.Color = colors[item.Item1].Item1;
|
|||
|
|
Plotresults.Add(volLines);
|
|||
|
|
|
|||
|
|
//foreach (var item in Errors[i])
|
|||
|
|
//{
|
|||
|
|
|
|||
|
|
// if (item != 0)
|
|||
|
|
// {
|
|||
|
|
// WpfPlot1.Plot.Add.Marker(Linescale[cordHelp], FinLines[i][cordHelp], ScottPlot.MarkerShape.Cross, 10, colors[1].Item2);
|
|||
|
|
// }
|
|||
|
|
// cordHelp = cordHelp + 1;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var maxScale = Plotresults.Max(p => p.ScaleLine.Count);
|
|||
|
|
var AddScale = Plotresults.First(p => p.ScaleLine.Count == maxScale);
|
|||
|
|
var srtExport = new System.Text.StringBuilder();
|
|||
|
|
|
|||
|
|
foreach (var item in ChnlHelper)
|
|||
|
|
{
|
|||
|
|
// Plotresults[item.Item1].ScaleUp(AddScale.ScaleLine);
|
|||
|
|
WpfPlot1.Plot.Add.Scatter(Plotresults[item.Item1].ScaleLine.ToArray(), Plotresults[item.Item1].VolumeLine.ToArray(), Plotresults[item.Item1].Color);
|
|||
|
|
|
|||
|
|
if (Plotresults[item.Item1].TofLine.Any())
|
|||
|
|
{
|
|||
|
|
WpfPlot2.Plot.Add.Scatter(Plotresults[item.Item1].ScaleLine.ToArray(), Plotresults[item.Item1].TofLine.ToArray(), Plotresults[item.Item1].Color);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
if (Plotresults[item.Item1].AmplitudeDownVLine.Any())
|
|||
|
|
{
|
|||
|
|
WpfPlot3.Plot.Add.Scatter(Plotresults[item.Item1].ScaleLine.ToArray(), Plotresults[item.Item1].AmplitudeDownVLine.ToArray(), Plotresults[item.Item1].Color);
|
|||
|
|
WpfPlot3.Plot.Add.Scatter(Plotresults[item.Item1].ScaleLine.ToArray(), Plotresults[item.Item1].AmplitudeUpVLine.ToArray(), Plotresults[item.Item1].Color);
|
|||
|
|
}
|
|||
|
|
var exprLine = 0;
|
|||
|
|
srtExport.AppendLine($"Chnl {item.Item1} ;Scale; Vol;");
|
|||
|
|
foreach (var exprHelpLine in Plotresults[item.Item1].ScaleLine)
|
|||
|
|
{
|
|||
|
|
srtExport.AppendLine($"{exprHelpLine};{Plotresults[item.Item1].VolumeLine[exprLine]};");
|
|||
|
|
exprLine = exprLine + 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
WpfPlot1.Plot.Axes.AutoScale();
|
|||
|
|
WpfPlot1.Refresh();
|
|||
|
|
WpfPlot2.Plot.Axes.AutoScale();
|
|||
|
|
WpfPlot2.Refresh();
|
|||
|
|
WpfPlot3.Plot.Axes.AutoScale();
|
|||
|
|
WpfPlot3.Refresh();
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void DataGrid_SelectedCellsChanged(Object sender, System.Windows.Controls.SelectedCellsChangedEventArgs e)
|
|||
|
|
{
|
|||
|
|
DataGridCellInfo di = e.AddedCells.First();
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Cast the DataGridCellInfo.Item to the source object type
|
|||
|
|
//In this case the ItemsSource is a DataTable and individual items are DataRows
|
|||
|
|
|
|||
|
|
if (di.Item is TestPoint tp)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
dataGridDispl.DataContext = dspData.AsEnumerable()
|
|||
|
|
.Where(row => row.Field<int>("TestNr") == tp.TestPointNr)
|
|||
|
|
.CopyToDataTable();
|
|||
|
|
|
|||
|
|
|
|||
|
|
dataGridchl1.DataContext = chnData1.AsEnumerable()
|
|||
|
|
.Where(row => row.Field<int>("TestNr") == tp.TestPointNr)
|
|||
|
|
.CopyToDataTable();
|
|||
|
|
|
|||
|
|
dataGridchl2.DataContext = chnData2.AsEnumerable()
|
|||
|
|
.Where(row => row.Field<int>("TestNr") == tp.TestPointNr)
|
|||
|
|
.CopyToDataTable();
|
|||
|
|
|
|||
|
|
dataGridchl3.DataContext = chnData3.AsEnumerable()
|
|||
|
|
.Where(row => row.Field<int>("TestNr") == tp.TestPointNr)
|
|||
|
|
.CopyToDataTable();
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
var ChnlHelper = new List<Tuple<int, WpfPlot, int?>>();
|
|||
|
|
ChnlHelper.Add(new Tuple<int, WpfPlot, int?>(0, WpfPlot1, tp.TestPointNr - 1));
|
|||
|
|
ChnlHelper.Add(new Tuple<int, WpfPlot, int?>(1, WpfPlot1, tp.TestPointNr - 1));
|
|||
|
|
ChnlHelper.Add(new Tuple<int, WpfPlot, int?>(2, WpfPlot1, tp.TestPointNr - 1));
|
|||
|
|
ChnlHelper.Add(new Tuple<int, WpfPlot, int?>(3, WpfPlot1, tp.TestPointNr - 1));
|
|||
|
|
Plot(ChnlHelper);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
string lastTitle = "";
|
|||
|
|
List<int> lastListOfIndex = new List<int>();
|
|||
|
|
List<object> lastListOfValues = new List<object>();
|
|||
|
|
private void dataGridchl1_SelectedCellsChanged(Object sender, SelectedCellsChangedEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (sender is DataGrid dg)
|
|||
|
|
{
|
|||
|
|
if (dg.CurrentColumn == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
WpfPlot2.Reset();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
|
|||
|
|
var c = dg.CurrentColumn.DisplayIndex;
|
|||
|
|
|
|||
|
|
var currentIndex = dg.Items.IndexOf(dg.CurrentItem);
|
|||
|
|
|
|||
|
|
var listOfIndex = new List<int>();
|
|||
|
|
|
|||
|
|
var listOfValues = new List<object>();
|
|||
|
|
|
|||
|
|
Coordinates? mark = null;
|
|||
|
|
|
|||
|
|
var i = 0;
|
|||
|
|
foreach (var item in dg.Items)
|
|||
|
|
{
|
|||
|
|
if (item is DataRowView drw)
|
|||
|
|
{
|
|||
|
|
listOfIndex.Add(i);
|
|||
|
|
listOfValues.Add(drw[c]);
|
|||
|
|
if (i == currentIndex)
|
|||
|
|
{
|
|||
|
|
if (drw[c] is double d)
|
|||
|
|
{
|
|||
|
|
mark = new Coordinates(i, d);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
i = i + 1;
|
|||
|
|
}
|
|||
|
|
lastListOfValues = listOfValues;
|
|||
|
|
lastListOfIndex = listOfIndex;
|
|||
|
|
if (mark.HasValue)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
|
|||
|
|
var hs = WpfPlot2.Plot.Add.HorizontalSpan(mark.Value.X, mark.Value.X, ScottPlot.Colors.Gray);
|
|||
|
|
hs.LineStyle.Width = 1;
|
|||
|
|
hs.LineStyle.Pattern = LinePattern.Dashed;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WpfPlot2.Plot.Add.Scatter(listOfIndex.ToArray(), listOfValues.ToArray(), ScottPlot.Colors.Blue);
|
|||
|
|
|
|||
|
|
|
|||
|
|
WpfPlot2.Plot.Axes.AutoScale();
|
|||
|
|
lastTitle = dg.CurrentColumn.Header.ToString();
|
|||
|
|
WpfPlot2.Plot.Title(dg.CurrentColumn.Header.ToString());
|
|||
|
|
WpfPlot2.Refresh();
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void dataGridchl1_CurrentCellChanged(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Button_Click_1(Object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
var newWin = new GridCopy();
|
|||
|
|
newWin.ShowChart(lastListOfIndex, lastListOfValues, lastTitle);
|
|||
|
|
newWin.Show();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|