public void createPumpPuskChart(ChartZedControl chart, PumpTypeEnum type, SortedList <DateTime, SvodDataRecord> Data, SortedList <DateTime, double> DataRun, bool time) { int ind = 0; chart.init(); List <int> powers = new List <int>(); if (Data.Count > 0) { SortedList <DateTime, double> data = new SortedList <DateTime, double>(); System.Drawing.Color color = ChartZedSerie.NextColor(); foreach (KeyValuePair <DateTime, SvodDataRecord> de in Data) { double val = 0; switch (type) { case PumpTypeEnum.Drenage: val = time ? de.Value.DN1Time + de.Value.DN2Time : de.Value.DN1Pusk + de.Value.DN2Pusk; break; case PumpTypeEnum.Leakage: val = time ? de.Value.LN1Time + de.Value.LN2Time : de.Value.LN1Pusk + de.Value.LN2Pusk; break; case PumpTypeEnum.MNU: val = time ? de.Value.MNU1Time + de.Value.MNU2Time + de.Value.MNU3Time : de.Value.MNU1Pusk + de.Value.MNU2Pusk + de.Value.MNU3Pusk; break; } data.Add(de.Key, val); } chart.AddSerie(String.Format("{0}", time ? "Работа (ceк)" : "Пусков"), data, color, true, true, 0); } if (DataRun.Count > 0) { System.Drawing.Color color = ChartZedSerie.NextColor(); chart.AddSerie(String.Format("Работа ГГ"), DataRun, color, true, true); } }
private async void btnCreate_Click(object sender, RoutedEventArgs e) { if (!EDSClass.Single.Ready) { MessageBox.Show("ЕДС сервер не готов"); return; } if (!clndFrom.SelectedDate.HasValue) { MessageBox.Show("Выберите дату начала"); return; } if (!clndFrom.SelectedDate.HasValue) { MessageBox.Show("Выберите дату конца"); return; } /*if (cmbFunction.SelectedItem == null) { * MessageBox.Show("Выберите функцию"); * return; * }*/ if (cmbPeriod.SelectedItem == null) { MessageBox.Show("Выберите период"); return; } if (cntrlSelectPoints.SelectedPoints.Count() == 0) { MessageBox.Show("Выберите точки"); return; } DateTime dtStart = clndFrom.SelectedDate.Value; DateTime dtEnd = clndTo.SelectedDate.Value; //EDSRdeportFunction func = (EDSReportFunction)cmbFunction.SelectedValue; EDSReportPeriod period = (EDSReportPeriod)cmbPeriod.SelectedValue; EDSReport report = new EDSReport(dtStart, dtEnd, period, chbMsk.IsChecked.Value); foreach (EDSReportRequestRecord rec in cntrlSelectPoints.SelectedPoints) { report.addRequestField(rec.Point, rec.Function); } //System.Windows.Application.Current.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Background, new System.Action(delegate { report.ReadData(); })); EDSClass.Disconnect(); EDSClass.Connect(); bool ready = await report.ReadData(); String header = ""; foreach (EDSReportRequestRecord rec in report.RequestData.Values) { header += String.Format("<th width='100'>{0}</th>", rec.Desc); } TextWriter tW = new StreamWriter("out.html"); String txt = string.Format(@"<html> <head> <meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8"" /> </head> <table border='1'><tr><th>точка</th>{0}</tr>" , header); tW.WriteLine(txt); foreach (KeyValuePair <DateTime, Dictionary <string, double> > de in report.ResultData) { DateTime dt = de.Key; string ValuesStr = ""; foreach (double val in de.Value.Values) { ValuesStr += String.Format("<td align='right'>{0:0.00}</td>", val); } tW.WriteLine(String.Format("<tr><th >{0}</th>{1}</tr>", dt.ToString("dd.MM.yyyy HH:mm:ss"), ValuesStr)); } tW.WriteLine("</table></html>"); tW.Close(); Process.Start("out.html"); ReportResultWindow win = new ReportResultWindow(); win.chart.init(); SortedList <DateTime, double> data = new SortedList <DateTime, double>(); int index = -1; foreach (KeyValuePair <string, EDSReportRequestRecord> de in report.RequestData) { string id = de.Key; EDSReportRequestRecord request = de.Value; data.Clear(); foreach (DateTime dt in report.ResultData.Keys) { data.Add(dt, report.ResultData[dt][id]); } win.chart.AddSerie(request.Desc, data, ChartZedSerie.NextColor(), true, true, index++); } win.Show(); }
private async void grdEvents_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (!EDSClass.Single.Ready) { MessageBox.Show("ЕДС сервер не готов"); return; } try { EDSClass.Disconnect(); EDSClass.Connect(); AVRCHMReportRecord ev = grdEvents.SelectedItem as AVRCHMReportRecord; ReportResultWindow win = new ReportResultWindow(); win.Title = ev.Date; win.chart.initControl(); win.chart.init(true, "HH:mm:ss"); win.chart.AllYAxisIsVisible = true; DateTime ds = ev.DateStart; DateTime de = ev.DateEnd; SortedList <String, SortedList <DateTime, double> > errors = report.getSeriesErrorsData("ErrorLimits15", ds, de); foreach (KeyValuePair <String, SortedList <DateTime, double> > rec in errors) { win.chart.AddSerie("План " + rec.Key, rec.Value, System.Drawing.Color.Red, true, false, false, 0, true); } bool HasErrorReserv = false; errors = report.getSeriesErrorsData("ErrorRezervGraph", ds, de); foreach (KeyValuePair <String, SortedList <DateTime, double> > rec in errors) { HasErrorReserv = true; win.chart.AddSerie("Резерв " + rec.Key, rec.Value, System.Drawing.Color.OrangeRed, true, false, false, 3, true); } win.chart.AddSerie("P план", report.getSerieData("PPlan", ds, de), System.Drawing.Color.Pink, true, false, true, 0, false); win.chart.AddSerie("P факт", report.getSerieData("PFakt", ds, de), System.Drawing.Color.Blue, true, false, false, 0, true); win.chart.AddSerie("P зад сум", report.getSerieData("PPlanFull", ds, de), System.Drawing.Color.Coral, true, false, false, 0, true); win.chart.AddSerie("P зад ГРАРМ", report.getSerieData("SumGroupZad", ds, de), System.Drawing.Color.Green, true, false, true, 0, false); win.chart.AddSerie("P нг", report.getSerieData("PMin", ds, de), System.Drawing.Color.Gray, true, false, false, 0, true); win.chart.AddSerie("P вг", report.getSerieData("PMax", ds, de), System.Drawing.Color.Gray, true, false, false, 0, true); win.chart.AddSerie("ГГ кол", report.getSerieData("GGCount", ds, de), System.Drawing.Color.LightBlue, true, false, false, 1, true, 0, 20); //win.chart.AddSerie("нарушение", report.getSerieData("ErrorLimits15", ds, de, false), System.Drawing.Color.Red, false, true, false, 0, true); win.chart.AddSerie("P перв", report.getSerieData("PPerv", ds, de), System.Drawing.Color.Purple, true, false, false, 2, false); win.chart.AddSerie("P звн", report.getSerieData("PZVN", ds, de), System.Drawing.Color.Orange, true, false, false, 2, false); win.chart.AddSerie("ресурс+", report.getSerieData("ResursZagr", ds, de), System.Drawing.Color.GreenYellow, true, false, false, 3, HasErrorReserv); win.chart.AddSerie("ресурс-", report.getSerieData("ResursRazgr", ds, de), System.Drawing.Color.YellowGreen, true, false, false, 3, HasErrorReserv); //win.chart.AddSerie("Нарушение рез", report.getSerieData("ErrorRezervGraph", ds, de, false), System.Drawing.Color.Red, false, true, false, 3, false); if (!ev.Date.ToLower().Contains("сутки")) { /*win.chart2.Visibility = Visibility.Visible; * win.mainGrid.RowDefinitions.Last().Height = new GridLength(1, GridUnitType.Star);*/ win.chart.init(true, "HH:mm:ss"); Dictionary <string, SortedList <DateTime, double> > series = await report.getGaData(ds, de); System.Drawing.Color color = ChartZedSerie.NextColor(); foreach (string key in series.Keys) { bool isVG = key.Contains("ВГ"); SortedList <DateTime, double> data = series[key]; if (!isVG && data.Values.Max() > 10 || isVG && data.Values.Min() != data.Values.Max()) { win.chart.AddSerie(key, data, color, true, false, key.Contains("Задание"), isVG ? 0 : 3, !isVG, isVG ? 0 : double.MinValue, isVG ? 20 : double.MaxValue); } color = isVG ? ChartZedSerie.NextColor() : color; } } win.Show(); } catch { Logger.Info(e.ToString()); } }
public void createPumpRunChart(ChartZedControl chart, PumpTypeEnum type, bool split, int splitPower) { int ind = 0; PumpDiagnostics report = new PumpDiagnostics(clndFrom.SelectedDate.Value, clndTo.SelectedDate.Value); SortedList <DateTime, PumpDataRecord> Data = new SortedList <DateTime, PumpDataRecord>(); chart.init(); List <int> powers = new List <int>(); if (split) { powers.Add(-1); int power = 35; while (power <= 115) { powers.Add(power); power += splitPower; } } else { splitPower = 200; powers.Add(-1); } SortedList <DateTime, double> dataLStart = new SortedList <DateTime, double>(); SortedList <DateTime, double> dataLStop = new SortedList <DateTime, double>(); foreach (int p in powers) { string header = ""; if (!split) { Data = report.ReadDataPump(type, -1, 200); header = "Время работы насосов"; } else { if (p == -1) { Data = report.ReadDataPump(type, -1, 0); header = "Простой"; } else { Data = report.ReadDataPump(type, p, p + splitPower); header = String.Format("Работа при P {0}-{1}", p, p + splitPower); } } if (Data.Count > 1) { System.Drawing.Color color = ChartZedSerie.NextColor(); SortedList <DateTime, double> data = new SortedList <DateTime, double>(); foreach (KeyValuePair <DateTime, PumpDataRecord> de in Data) { data.Add(de.Key, de.Value.RunTime); dataLStart.Add(de.Key, de.Value.LevelStart); dataLStop.Add(de.Key, de.Value.LevelStop); } chart.AddSerie(header, data, color, false, true); SortedList <DateTime, double> appr = report.Approx(data); ChartZedSerie ser = chart.AddSerie(header, appr, color, true, false, -1, false); } } chart.AddSerie("LStart", dataLStart, ChartZedSerie.NextColor(), true, false, 0); chart.AddSerie("LStop", dataLStop, ChartZedSerie.NextColor(), true, false, 0); }
public void createOilChart(ChartZedControl chart, bool gp, bool splitHot, bool splitCold, double step, bool isOhl) { int ind = 0; PumpDiagnostics report = new PumpDiagnostics(clndFrom.SelectedDate.Value, clndTo.SelectedDate.Value); Dictionary <DateTime, SvodDataRecord> Data = new Dictionary <DateTime, SvodDataRecord>(); chart.init(); string obj = gp ? "GP_" : "PP_"; string temp = splitHot ? "Hot" : "Cold"; obj = obj + temp; string isUstGroup = gp ? "IsUstGP" : "IsUstPP"; if (isOhl) { isUstGroup += "Ohl"; } bool split = splitHot || splitCold; if (isOhl) { split = false; } List <double> AllTemps = new List <double>(); if (split) { double t = 10; while (t <= 50) { AllTemps.Add(t); t += step; } } else { step = 50; AllTemps.Add(10); } foreach (double t in AllTemps) { string headerRun = ""; string headerStop = ""; if (!split) { if (!isOhl) { headerRun = "Уровень масла (ГГ в работе)"; headerStop = "Уровень масла (ГГ стоит)"; } else { headerRun = "Расход (ГГ в работе)"; headerStop = "Расход (ГГ стоит)"; } } else { headerRun = String.Format("Уровень при t {0:0.0}-{1:0.0} (ГГ в работе)", t, t + step); headerStop = String.Format("Уровень при t {0:0.0}-{1:0.0} (стоит)", t, t + step); } SortedList <DateTime, double> RunForApprox = new SortedList <DateTime, double>(); SortedList <DateTime, double> StopForApprox = new SortedList <DateTime, double>(); Data = report.ReadSvod(obj, t, t + step, isUstGroup); foreach (KeyValuePair <DateTime, SvodDataRecord> de in Data) { if (de.Value.PAvg == 0) { if (gp) { StopForApprox.Add(de.Key, isOhl ? de.Value.GPOhlRashod : de.Value.GPLevel); } else { StopForApprox.Add(de.Key, isOhl ? de.Value.PPOhlRashod : de.Value.PPLevel); } } else { if (gp) { RunForApprox.Add(de.Key, isOhl ? de.Value.GPOhlRashod : de.Value.GPLevel); } else { RunForApprox.Add(de.Key, isOhl ? de.Value.PPOhlRashod : de.Value.PPLevel); } } } System.Drawing.Color color = ChartZedSerie.NextColor(); if (RunForApprox.Count > 1) { chart.AddSerie(headerRun, RunForApprox, color, false, true); SortedList <DateTime, double> appr = report.Approx(RunForApprox); ChartZedSerie ser = chart.AddSerie(headerRun, appr, color, true, false, -1, false); } //line.Line.IsVisible = false; if (StopForApprox.Count > 1 && !isOhl) { chart.AddSerie(headerStop, StopForApprox, color, false, true); SortedList <DateTime, double> appr = report.Approx(StopForApprox); ChartZedSerie ser = chart.AddSerie(headerStop, appr, color, true, false, -1, false); } //line.Line.IsVisible = false; } if (!isOhl) { SortedList <DateTime, double> DataHot = new SortedList <DateTime, double>(); SortedList <DateTime, double> DataCold = new SortedList <DateTime, double>(); Data = report.ReadSvod(obj, -200, 200, isUstGroup); foreach (KeyValuePair <DateTime, SvodDataRecord> de in Data) { if (gp) { DataHot.Add(de.Key, de.Value.GPHot); DataCold.Add(de.Key, de.Value.GPCold); } else { DataHot.Add(de.Key, de.Value.PPHot); DataCold.Add(de.Key, de.Value.PPCold); } } chart.AddSerie("T_Hot", DataHot, ChartZedSerie.NextColor(), true, false, 0); chart.AddSerie("T_Cold", DataCold, ChartZedSerie.NextColor(), true, false, 0); } }