Ejemplo n.º 1
0
        private void  loadDayData(DateTime date, string block)
        {
            /* try
             * {           */
            Dictionary <DateTime, Record> Data;

            RecordHour recHour = new RecordHour(SettingsNPRCH.BlocksDict[block]);

            recHour.processFile(date, DiffHour, true);
            txtFile.Text = recHour.getText();
            Data         = recHour.getData();

            SortedList <DateTime, double> list_P        = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_F        = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_Fmin     = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_Fmax     = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_FminReal = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_FmaxReal = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_Pmin     = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_Pmax     = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_Pzad     = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_Pperv    = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_Pzvn     = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_X        = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_Y        = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_Xdx      = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_Ydy      = new SortedList <DateTime, double>();
            SortedList <DateTime, double> list_NR       = new SortedList <DateTime, double>();

            list_Fmin.Add(date, 49.98);
            list_Fmin.Add(date.AddHours(1), 49.98);
            list_Fmax.Add(date, 50.02);
            list_Fmax.Add(date.AddHours(1), 50.02);
            list_FminReal.Add(date, 49.987);
            list_FminReal.Add(date.AddHours(1), 49.987);
            list_FmaxReal.Add(date, 50.013);
            list_FmaxReal.Add(date.AddHours(1), 50.013);

            foreach (Record rec in Data.Values)
            {
                list_P.Add(rec.Date, rec.P_fakt);
                list_Pmin.Add(rec.Date, rec.P_min);
                list_Pmax.Add(rec.Date, rec.P_max);
                list_Pzad.Add(rec.Date, rec.P_plan);
                list_F.Add(rec.Date, rec.F_gc);
                list_Pperv.Add(rec.Date, rec.P_planFull);
                list_Pzvn.Add(rec.Date, rec.P_zvn);
                list_X.Add(rec.Date, rec.X_avg);
                list_Y.Add(rec.Date, rec.Y_avg);
                list_Xdx.Add(rec.Date, rec.Xdx_avg);
                list_Ydy.Add(rec.Date, rec.Ydy_avg);
                list_NR.Add(rec.Date, rec.NoReact);
            }

            grdData.ItemsSource = Data.Values;

            chart.initControl();
            chart.init(true, "HH:mm:ss");
            //chart.ShowCrossHair = true;
            chart.AllYAxisIsVisible = true;

            //prepareChart(chart.chart);
            chart.AddSerie("P факт", list_P, System.Drawing.Color.Red, true, false, false, 0);
            chart.AddSerie("P плн", list_Pzad, System.Drawing.Color.Orange, true, false, false, 0);
            chart.AddSerie("P мин", list_Pmin, System.Drawing.Color.Pink, true, false, true, 0);
            chart.AddSerie("P макс", list_Pmax, System.Drawing.Color.Pink, true, false, true, 0);
            chart.AddSerie("F мин", list_Fmin, System.Drawing.Color.LightBlue, true, false, true, 1);
            chart.AddSerie("F макс", list_Fmax, System.Drawing.Color.LightBlue, true, false, true, 1);
            chart.AddSerie("F мин факт", list_FminReal, System.Drawing.Color.LightGreen, true, false, true, 1);
            chart.AddSerie("F макс факт", list_FmaxReal, System.Drawing.Color.LightGreen, true, false, true, 1);

            chart.AddSerie("F", list_F, System.Drawing.Color.Blue, true, false, false, 1);

            chart.AddSerie("P плн сум", list_Pperv, System.Drawing.Color.Purple, true, false, false, 0);

            chart.AddSerie("P звн", list_Pzvn, System.Drawing.Color.Orange, true, false, false, 2, true);

            chart.init(true, "HH:mm:ss");
            chart.AddSerie("X", list_X, System.Drawing.Color.LightGreen, true, false, true, 0, true);
            chart.AddSerie("Y", list_Y, System.Drawing.Color.LightYellow, true, false, true, 0, true);
            chart.AddSerie("Xdx", list_Xdx, System.Drawing.Color.Green, true, false, false, 1, true);
            chart.AddSerie("Ydy", list_Ydy, System.Drawing.Color.Yellow, true, false, false, 1, true);
            chart.AddSerie("NR", list_NR, System.Drawing.Color.IndianRed, true, false, false, 2, true);



            tabHour.IsSelected = true;



            tabHour.Header = string.Format("{0}-{1} [GMT {2}]", date.ToString("dd.MM HH:00"), date.AddHours(1).ToString("dd.MM HH:00"), DiffHour);

            /*}
             * catch (Exception e1)
             * {
             *  MessageBox.Show("Ошибка при загрузке данных");
             * }*/
        }
Ejemplo n.º 2
0
        private async Task <bool> LoadFiles()
        {
            DateTime date = clndDate.SelectedDate.Value;

            FTPData  = new Dictionary <string, DateTime>();
            DiffHour = Int32.Parse(txtDiffHour.Text);

            List <RecordHour> hoursData = new List <RecordHour>();

            RecordHour.DataSDay = new Dictionary <string, List <Record> >();
            RecordHour prev = null;
            SortedList <string, EDSReportRequestRecord> EDSData = new SortedList <string, EDSReportRequestRecord>();
            EDSReport report = null;

            if (chbNPRCHMaket.IsChecked.Value)
            {
                try
                {
                    EDSClass.Disconnect();
                }
                catch { }
                EDSClass.Connect();
                report = new EDSReport(date.AddHours(-DiffHour + 5), date.AddHours(-DiffHour + 5 + 24), EDSReportPeriod.hour);

                foreach (KeyValuePair <string, BlockData> de in SettingsNPRCH.BlocksDict)
                {
                    int    gg   = Int32.Parse(de.Key);
                    string iess = String.Format("MC_NPRCH_GG{0}.EDS@CALC", gg);
                    EDSReportRequestRecord rec = report.addRequestField(RecordHour.EDSPoints[iess], EDSReportFunction.val);
                    EDSData.Add(de.Key, rec);
                }
                bool ok = await report.ReadData();
            }
            for (int hour = 0; hour <= 23; hour++)
            {
                foreach (KeyValuePair <string, BlockData> de in SettingsNPRCH.BlocksDict)
                {
                    StatusText = "Загрузка " + hour.ToString();
                    DateTime dt     = date.AddHours(hour);
                    bool     ok     = FTPClass.CheckFile(dt.AddHours(-DiffHour), de.Key);
                    string   header = String.Format("ГГ{3} {0} [{1} UTC] {2}", dt.ToString("dd.MM HH"), dt.AddHours(-DiffHour).ToString("dd.MM HH"), ok, de.Key);
                    FTPData.Add(header, dt);
                    if (ok)
                    {
                        StatusText = "Обработка " + hour.ToString();
                        RecordHour rh = new RecordHour(de.Value);
                        rh.Header = header;
                        rh.processFile(dt, DiffHour, false);
                        if (chbNPRCHMaket.IsChecked.Value)
                        {
                            double val = report.ResultData[report.DateStart.AddHours(hour)][EDSData[de.Key].Id];
                            rh.NPRCHMaket = val > 0 ? "+" : " ";
                        }
                        hoursData.Add(rh);

                        prev = rh;
                    }
                }
                System.Threading.Thread.Sleep(10);
            }
            //hoursData.Last().NoReactComment = "";
            //hoursData.Last().calcReact(RecordHour.DataSDay["10"],false);
            //RecDay.calcRHO();
            // StatusText = RecDay.RHO.ToString();
            lbHours.ItemsSource       = FTPData;
            lbHours.DisplayMemberPath = "Key";
            grdDayData.ItemsSource    = hoursData;
            tabDay.IsSelected         = true;

            btnLoadFiles.IsEnabled = true;
            return(true);
        }