コード例 #1
0
ファイル: AVRCHMReport.cs プロジェクト: rj128x/EDSProject2019
        public async Task <Dictionary <string, SortedList <DateTime, double> > > getGaData(DateTime dateStart, DateTime dateEnd)
        {
            Dictionary <string, SortedList <DateTime, double> > result = new Dictionary <string, SortedList <DateTime, double> >();
            EDSReportPeriod period = EDSReportPeriod.sec;
            EDSReport       report = new EDSReport(dateStart, dateEnd, period, true);

            for (int gg = 1; gg <= 10; gg++)
            {
                string name = String.Format("11VT_GG{0}{1}AP-031.MCR@GRARM", gg < 10 ? "0" : "", gg);
                report.addRequestField(AllPoints[name], EDSReportFunction.val);
                name = String.Format("11VT_GG{0}{1}AP-ZVM.MCR@GRARM", gg < 10 ? "0" : "", gg);
                report.addRequestField(AllPoints[name], EDSReportFunction.val);

                name = String.Format("11VT_GG{0}{1}AP-PDG.MCR@GRARM", gg < 10 ? "0" : "", gg);
                report.addRequestField(AllPoints[name], EDSReportFunction.val);

                /*name = String.Format("11VT_GG{0}{1}AP-502.MCR@GRARM", gg < 10 ? "0" : "", gg);
                 * report.addRequestField(AllPoints[name], EDSReportFunction.val);
                 * name = String.Format("11VT_GG{0}{1}AP-501.MCR@GRARM", gg < 10 ? "0" : "", gg);
                 * report.addRequestField(AllPoints[name], EDSReportFunction.val);*/

                name = String.Format("11VT_BS{0}{1}D-001.MCR@GRARM", gg < 10 ? "0" : "", gg);
                report.addRequestField(AllPoints[name], EDSReportFunction.val);
            }

            bool ok = await report.ReadData();

            if (!ok)
            {
                return(new Dictionary <string, SortedList <DateTime, double> >());
            }

            int indexVG = 0;

            foreach (string key in report.RequestData.Keys)
            {
                bool isVG = report.RequestData[key].Desc.Contains("ВГ");
                if (isVG)
                {
                    indexVG++;
                }
                SortedList <DateTime, double> data = new SortedList <DateTime, double>();
                foreach (DateTime date in report.ResultData.Keys)
                {
                    if (isVG)
                    {
                        data.Add(date.AddHours(-2), report.ResultData[date][key] + (indexVG));
                    }
                    else
                    {
                        data.Add(date.AddHours(-2), report.ResultData[date][key]);
                    }
                }

                result.Add(report.RequestData[key].Desc, data);
            }
            return(result);
        }
コード例 #2
0
        public static long getPeriodSeconds(EDSReportPeriod period)
        {
            long res = 3600;

            switch (period)
            {
            case EDSReportPeriod.sec:
                res = 1;
                break;

            case EDSReportPeriod.sec5:
                res = 5;
                break;

            case EDSReportPeriod.sec10:
                res = 10;
                break;

            case EDSReportPeriod.sec15:
                res = 15;
                break;

            case EDSReportPeriod.sec30:
                res = 30;
                break;

            case EDSReportPeriod.minute:
                res = 60;
                break;

            case EDSReportPeriod.minute5:
                res = 60 * 5;
                break;

            case EDSReportPeriod.minute10:
                res = 60 * 10;
                break;

            case EDSReportPeriod.minute15:
                res = 60 * 15;
                break;

            case EDSReportPeriod.minute30:
                res = 60 * 30;
                break;

            case EDSReportPeriod.hour:
                res = 3600;
                break;

            case EDSReportPeriod.day:
                res = 3600 * 24;
                break;
            }
            return(res);
        }
コード例 #3
0
 public EDSReport(DateTime dateStart, DateTime dateEnd, EDSReportPeriod period, bool MSK = false)
 {
     DateStart = dateStart;
     DateEnd   = dateEnd;
     Period    = period;
     this.MSK  = MSK;
     if (MSK)
     {
         DateStart = DateStart.AddHours(2);
         DateEnd   = DateEnd.AddHours(2);
     }
 }
コード例 #4
0
ファイル: AVRCHMReport.cs プロジェクト: rj128x/EDSProject2019
        public async Task <bool> ReadData(DateTime dateStart, DateTime dateEnd, int zvnMax, int tPlanMax, int winSize)
        {
            DateStart = dateStart;
            DateEnd   = dateEnd;
            EDSReportPeriod period = EDSReportPeriod.sec;

            EDSReport report = new EDSReport(dateStart.AddMinutes(-2), dateEnd.AddMinutes(2), period, true);

            Dictionary <string, EDSReportRequestRecord> records = new Dictionary <string, EDSReportRequestRecord>();

            foreach (KeyValuePair <string, EDSPointInfo> de in PointsRef)
            {
                EDSReportRequestRecord rec = report.addRequestField(de.Value, EDSReportFunction.val);
                records.Add(de.Key, rec);
            }

            bool ok = await report.ReadData();

            if (!ok)
            {
                return(false);
            }

            Data = new Dictionary <DateTime, AVRCHMRecord>();

            report.ResultData.Remove(report.ResultData.Keys.Last());
            DateTime dtMSK = report.ResultData.Keys.First().AddHours(-2);

            foreach (DateTime date in report.ResultData.Keys)
            {
                dtMSK = date.AddHours(-2);
                AVRCHMRecord rec = new AVRCHMRecord();
                Data.Add(dtMSK, rec);

                Dictionary <string, double> dataRec = report.ResultData[date];
                rec.PFakt       = dataRec[records["PFakt"].Id];
                rec.PPlan       = dataRec[records["PPlan"].Id];
                rec.PZVN        = dataRec[records["PZVN"].Id];
                rec.PPerv       = dataRec[records["PPerv"].Id];
                rec.GGCount     = (int)dataRec[records["GGCount"].Id];
                rec.SumGroupZad = dataRec[records["PZad"].Id] - rec.PZVN;
                rec.ResursZagr  = dataRec[records["ResursZagr"].Id];
                rec.ResursRazgr = dataRec[records["ResursRazgr"].Id];
                rec.PMinMaket   = dataRec[records["PMinMaket"].Id];
                rec.PMaxMaket   = dataRec[records["PMaxMaket"].Id];
            }
            checkErrors(zvnMax, tPlanMax, winSize);
            return(true);
        }
コード例 #5
0
        public static long getPeriodSeconds(EDSReportPeriod period)
        {
            long res = 3600;

            switch (period)
            {
            case EDSReportPeriod.sec:
                res = 1;
                break;

            case EDSReportPeriod.minute:
                res = 60;
                break;

            case EDSReportPeriod.hour:
                res = 3600;
                break;

            case EDSReportPeriod.day:
                res = 3600 * 24;
                break;
            }
            return(res);
        }
コード例 #6
0
        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();
        }