public GraphVyrabPage() { InitializeComponent(); CurrentAnswer = new GraphVyrabAnswer(); context = new GraphVyrabDomainContext(); pnlSettings.DataContext = CurrentAnswer; settings = new SettingsGraphVyab(); settings.Second = 30; settings.AutoRefresh = true; pnlRefresh.DataContext = settings; timer = new DispatcherTimer(); timer.Tick += new EventHandler(timer_Tick); timer.Interval = new TimeSpan(0, 0, 1); }
public static GraphVyrabAnswer getAnswer(DateTime date, bool calcTables = true, bool steppedPBR=true) { DateTime dateStart=date.Date; DateTime dateEnd=date.Date.AddHours(24); date = calcTables ? date : dateEnd; GraphVyrabAnswer answer=new GraphVyrabAnswer(); PBRData ges=new PBRData(dateStart, dateEnd, date, GTPEnum.ges); PBRData gtp1=new PBRData(dateStart, dateEnd, date, GTPEnum.gtp1); PBRData gtp2=new PBRData(dateStart, dateEnd, date, GTPEnum.gtp2); ges.IsSteppedPBR = steppedPBR; gtp1.IsSteppedPBR = steppedPBR; gtp2.IsSteppedPBR = steppedPBR; answer.Chart = new ChartAnswer(); answer.Chart.Properties = getChartProperties(steppedPBR); answer.Chart.Data = new ChartData(); gtp1.InitData(); gtp2.InitData(); ges.InitData(); answer.ActualDate = gtp1.Date < gtp2.Date ? gtp1.Date : gtp2.Date; answer.ActualDate = ges.Date < answer.ActualDate ? ges.Date : answer.ActualDate; DateTime lastDate=answer.ActualDate; answer.VyrabPlan = ges.IntegratedPBR[lastDate]; answer.VyrabFakt = ges.IntegratedP[lastDate]; answer.VyrabDiff = ges.IntegratedP[lastDate] - ges.IntegratedPBR[lastDate]; answer.VyrabDiffProc = PBRData.getDiffProc(ges.IntegratedP[lastDate], ges.IntegratedPBR[lastDate]); if (calcTables) { answer.TableCurrent.Add(new GraphVyrabTableRow("P план", Math.Round(gtp1.MinutesPBR[lastDate]), Math.Round(gtp2.MinutesPBR[lastDate]), Math.Round(ges.MinutesPBR[lastDate]))); answer.TableCurrent.Add(new GraphVyrabTableRow("P факт", Math.Round(gtp1.RealP[lastDate]), Math.Round(gtp2.RealP[lastDate]), Math.Round(ges.RealP[lastDate]))); answer.TableCurrent.Add(new GraphVyrabTableRow("P откл", gtp1.getDiff(lastDate), gtp2.getDiff(lastDate), ges.getDiff(lastDate))); answer.TableCurrent.Add(new GraphVyrabTableRow("P откл %", gtp1.getDiffProc(lastDate), gtp2.getDiffProc(lastDate), ges.getDiffProc(lastDate))); SortedList<string,double> gtp1Hour=gtp1.getHourVals(lastDate); SortedList<string,double> gtp2Hour=gtp2.getHourVals(lastDate); SortedList<string,double> gesHour=ges.getHourVals(lastDate); answer.TableHour.Add(new GraphVyrabTableRow("P план", Math.Round(gtp1Hour["plan"]), Math.Round(gtp2Hour["plan"]), Math.Round(gesHour["plan"]))); answer.TableHour.Add(new GraphVyrabTableRow("P факт", Math.Round(gtp1Hour["fakt"]), Math.Round(gtp2Hour["fakt"]), Math.Round(gesHour["fakt"]))); answer.TableHour.Add(new GraphVyrabTableRow("P откл", gtp1Hour["diff"], gtp2Hour["diff"], gesHour["diff"])); answer.TableHour.Add(new GraphVyrabTableRow("P откл %", gtp1Hour["diffProc"], gtp2Hour["diffProc"], gesHour["diffProc"])); answer.TableHour.Add(new GraphVyrabTableRow("P рек", Math.Round(gtp1Hour["recP"]), Math.Round(gtp2Hour["recP"]), Math.Round(gesHour["recP"]))); } answer.Chart.Data.addSerie(getDataSerie("gtp1Fakt", gtp1.RealP, -1)); answer.Chart.Data.addSerie(getDataSerie("gtp2Fakt", gtp2.RealP, -1)); answer.Chart.Data.addSerie(getDataSerie("gesFakt", ges.RealP, -1)); answer.Chart.Data.addSerie(getDataSerie("gtp1Plan", steppedPBR?gtp1.SteppedPBR:gtp1.RealPBR, 0)); answer.Chart.Data.addSerie(getDataSerie("gtp2Plan", steppedPBR?gtp2.SteppedPBR:gtp2.RealPBR, 0)); answer.Chart.Data.addSerie(getDataSerie("gesPlan", steppedPBR?ges.SteppedPBR:ges.RealPBR, 0)); answer.Chart.Data.addSerie(getDataSerie("vyrabPlan", ges.IntegratedPBR, -1)); answer.Chart.Data.addSerie(getDataSerie("vyrabFakt", ges.IntegratedP, -1)); return answer; }
partial void OnGTPChanging(GraphVyrabAnswer value);