Beispiel #1
0
        public async Task <bool> GetSerieLEDSData()
        {
            try
            {
                EDSClass.Disconnect();
            }
            catch
            {
            }
            EDSClass.Connect();

            EDSReport    report       = new EDSReport(DateStart, DateEnd, EDSReportPeriod.sec5);
            EDSPointInfo pointInfoLvl = await EDSPointInfo.GetPointInfo(GG + "VT_PS00A-01.MCR@GRARM");

            EDSPointInfo pointInfoP = await EDSPointInfo.GetPointInfo(GG + "VT_LP01AO-03.MCR@GRARM");

            EDSReportRequestRecord recLvl = report.addRequestField(pointInfoLvl, EDSReportFunction.val);
            EDSReportRequestRecord recP   = report.addRequestField(pointInfoP, EDSReportFunction.val);
            bool ok = await report.ReadData();

            dataLvl = new SortedList <DateTime, double>();
            dataP   = new SortedList <DateTime, double>();
            foreach (DateTime dt in report.ResultData.Keys)
            {
                dataLvl.Add(dt, report.ResultData[dt][recLvl.Id]);
                dataP.Add(dt, report.ResultData[dt][recP.Id]);
            }
            return(true);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Settings.init("Data/Settings.xml");
            Logger.InitFileLogger(Settings.Single.LogPath, "pbrExport");
            //Logger.Info(string.Format("Считано аналоговых точек: {0}", EDSPointsClass.AllAnalogPoints.Count));

            /*uint cnt;
             * uint total;
             * if (!EDSClass.Connected)
             *      EDSClass.Connect();
             * ReportConfig[] reports = EDSClass.Client.getReportsConfigs(EDSClass.AuthStr, null, 0, 1000, out cnt, out total);
             * Console.WriteLine(reports.Count().ToString());
             * foreach (ReportConfig report in reports) {
             *      Console.WriteLine(report.reportDefinitionFile);
             *      Console.WriteLine(report.id);
             * }*/

            /*if (!EDSClass.Connected)
             *      EDSClass.Connect();
             * GlobalReportRequest req = new GlobalReportRequest();
             * req.reportConfigId = 16;
             * req.dtRef = new Timestamp() { second = EDSClass.toTS(DateTime.Now) };
             *
             * uint reqId=EDSClass.Client.requestGlobalReport(EDSClass.AuthStr, req);
             * bool ok=EDSClass.ProcessQuery(reqId);
             * Console.WriteLine(ok.ToString());*/

            MCSettings.init("Data/MCSettings.xml");
            MCServerReader reader = new MCServerReader(DateTime.Now.Date);

            EDSClass.Disconnect();
        }
        private async void btnCreatePP_Click(object sender, RoutedEventArgs e)
        {
            if (!EDSClass.Single.Ready)
            {
                MessageBox.Show("ЕДС сервер не готов");
                return;
            }
            EDSClass.Disconnect();
            EDSClass.Connect();
            CurrentDiagPP.GG = txtGG.Text;


            CurrentDiagPP.DateStart = _DateStart;



            CurrentDiagPP.DateEnd = _DateEnd;


            bool ok = await CurrentDiagPP.ReadData(CurrentDiagPP.GG);

            //win = new ReportResultWindow();
            reCalcPP();
            btnCreatePP.IsEnabled = false;
            btnRecalcPP.IsEnabled = true;
        }
        private async void  btnCreate_Click(object sender, RoutedEventArgs e)
        {
            if (!EDSClass.Single.Ready)
            {
                MessageBox.Show("ЕДС сервер не готов");
                return;
            }

            EDSClass.Disconnect();
            EDSClass.Connect();

            DateTime dt = clndDate.SelectedDate.Value;

            report = new AVRCHMReport();
            DateTime ds = dt.AddHours(0);
            DateTime de = dt.AddHours(24);

            if (de > DateTime.Now.AddMinutes(-5).AddHours(-2))
            {
                de = DateTime.Now.AddMinutes(-5).AddHours(-2);
            }
            int  winSize  = Int32.Parse(txtTWin.Text);
            int  tPlanMax = Int32.Parse(txtTPlan.Text);
            int  zvn      = Int32.Parse(txtZVN.Text);
            bool ok       = await report.ReadData(ds, de, zvn, tPlanMax, winSize);

            if (ok)
            {
                grdEvents.ItemsSource = report.Events.ToList();
                currentDate           = dt;
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            Settings.init("Data/Settings.xml");
            Logger.InitFileLogger(Settings.Single.LogPath, "aisImport");



            bool min = false;

            if (args.Length > 0)
            {
                min = args[0].ToLower().Contains("min");
            }

            DateTime date    = DateTime.Now.Date.AddHours(DateTime.Now.Hour - 2 - (min?1:12));
            DateTime dateEnd = !min?DateTime.Now.Date.AddHours(DateTime.Now.Hour) : DateTime.Now.AddHours(-2);

            if (args.Length == 3)
            {
                date    = GetDate(args[1], min);
                dateEnd = GetDate(args[2], min);
            }

            Logger.Info(String.Format("{0} {1} min:{2}", date, dateEnd, min));

            if (min)
            {
                AIS_1MIN ais = new AIS_1MIN();
                ais.readPoints();
                while (date < dateEnd)
                {
                    DateTime de = date.AddMinutes(10);
                    de = de > dateEnd ? dateEnd : de;
                    ais.readDataFromDB(date, de);
                    date = de.AddHours(0);
                }
            }
            else
            {
                AIS_NEW ais = new AIS_NEW();
                ais.readPoints();
                while (date < dateEnd)
                {
                    DateTime de = date.AddHours(24);
                    de = de > dateEnd ? dateEnd : de;
                    ais.readDataFromDB(date, de);
                    date = de.AddHours(0);
                }
            }
            EDSClass.Disconnect();
        }
Beispiel #6
0
        public async static void run()
        {
            uint cnt;
            uint total;

            if (!EDSClass.Connected)
            {
                EDSClass.Connect();
            }

            /*TimeDuration zone;
             * TimeDuration offset = new TimeDuration();
             * Timestamp s= EDSClass.Client.getServerTime(EDSClass.AuthStr, out zone, out offset);
             *
             * Console.WriteLine(EDSClass.fromTS(zone.seconds));
             * Console.WriteLine(EDSClass.fromTS(offset.seconds));
             * Console.Write(EDSClass.fromTS(s.second));
             * return;*/

            Dictionary <DateTime, int> data = new Dictionary <DateTime, int>();

            DateTime dateStart = DateTime.Parse("01.06.2018 00:00:00");
            DateTime dateEnd   = DateTime.Parse("01.09.2018 00:00:00");
            DateTime date      = dateStart.AddHours(0);
            DateTime dateSet   = DateTime.MinValue;
            bool     prevVal   = false;

            while (date <= dateEnd)
            {
                EDSClass.Connect();
                TabularRequest            req   = new TabularRequest();
                List <TabularRequestItem> items = new List <TabularRequestItem>();
                items.Add(new TabularRequestItem()
                {
                    function = "VALUE",
                    pointId  = new PointId()
                    {
                        iess = "04VT_AM01P-47.MCR@GRARM"
                    }
                });



                req.items = items.ToArray();

                req.period = new TimePeriod()
                {
                    from = new Timestamp()
                    {
                        second = EDSClass.toTS(date)
                    },
                    till = new Timestamp()
                    {
                        second = EDSClass.toTS(date.AddHours(24))
                    }
                };

                req.step = new TimeDuration()
                {
                    seconds = 1
                };

                uint id = EDSClass.Client.requestTabular(EDSClass.AuthStr, req);

                EDSClass.ProcessQuery(id);

                TabularRow[] rows;

                getTabularRequest request = new getTabularRequest()
                {
                    authString = EDSClass.AuthStr,
                    requestId  = id
                };

                getTabularResponse resp = await EDSClass.Client.getTabularAsync(request);

                foreach (TabularRow row in resp.rows)
                {
                    DateTime dt = EDSClass.fromTS(row.ts.second);

                    TabularValue tv = row.values[0];
                    if (tv.quality != Quality.QUALITYGOOD)
                    {
                        continue;
                    }

                    int val = 0;
                    if (tv.value.ipvSpecified)
                    {
                        val = (int)tv.value.ipv.Value;
                    }
                    if (tv.value.pvSpecified)
                    {
                        val = (int)tv.value.pv.Value;
                    }

                    string bin = Convert.ToString(val, 2);
                    bool   on  = false;
                    if (bin.Length >= 3 && bin[bin.Length - 3] == '1')
                    {
                        on = true;
                    }

                    if (!prevVal && on)
                    {
                        dateSet = dt.AddHours(0);
                        data.Add(dt, 0);
                    }
                    if (on)
                    {
                        data[dateSet]++;
                    }
                    prevVal = on;

                    /*string str = string.Format("{0}: {1} {2}", date, bin, on);
                     * Console.WriteLine(str);*/
                }

                date = date.AddHours(24);
                Console.WriteLine(date);
                EDSClass.Disconnect();
            }

            foreach (KeyValuePair <DateTime, int> de in data)
            {
                Console.WriteLine(string.Format("{0}:\t{1}:{2}", de.Key, de.Value / 60, de.Value % 60));
            }
        }
Beispiel #7
0
        public static async Task <bool> FillAnalogData(DateTime DateStart, DateTime DateEnd, List <string> Types)
        {
            DiagDBEntities diagDB = new DiagDBEntities();

            for (int gg = 1; gg <= 10; gg++)
            {
                if (gg == 8)
                {
                    continue;
                }
                try
                {
                    EDSClass.Disconnect();
                }
                catch { }
                EDSClass.Connect();

                Logger.Info(string.Format("GG{0}", gg));
                List <PuskStopPoint> points = (from p in diagDB.PuskStopPoints
                                               where p.gg == gg && p.analog == true && Types.Contains(p.pointType)
                                               select p).ToList();
                List <AnalogData> existData = (from a in diagDB.AnalogDatas
                                               where
                                               a.gg == gg && Types.Contains(a.pointType) &&
                                               a.Date >= DateStart && a.Date <= DateEnd
                                               select a).ToList();
                Dictionary <string, string> pointsDict = new Dictionary <string, string>();
                foreach (String type in Types)
                {
                    try
                    {
                        PuskStopPoint pt = (from p in diagDB.PuskStopPoints where p.gg == gg && p.pointType == type select p).First();
                        pointsDict.Add(type, pt.point);
                    }
                    catch
                    {
                        pointsDict.Add(type, "");
                    }
                }

                List <PuskStopInfo> data = (
                    from d in diagDB.PuskStopInfoes
                    where d.TimeOn <= DateEnd && d.TimeOff >= DateStart &&
                    d.GG == gg && d.TypeData.Contains("GG_RUN")
                    select d).ToList();


                foreach (PuskStopInfo ggRec in data)
                {
                    Logger.Info(String.Format("GG {0} {1} -{2}", gg, ggRec.TimeOn, ggRec.TimeOff));
                    foreach (string type in Types)
                    {
                        if (string.IsNullOrEmpty(pointsDict[type]))
                        {
                            continue;
                        }
                        foreach (DateTime dt in new DateTime[] { ggRec.TimeOn, ggRec.TimeOff })
                        {
                            IEnumerable <AnalogData> datas = (from a in existData where a.Date == dt && a.pointType == type select a);
                            AnalogData dat = null;
                            if (datas.Count() == 0)
                            {
                                dat = new AnalogData();
                                diagDB.AnalogDatas.Add(dat);
                                dat.pointType = type;
                                dat.gg        = gg;
                                dat.Date      = dt;
                                dat.value     = await EDSClass.getValFromServer(pointsDict[type], dt);
                            }
                            else
                            {
                                dat = datas.First();
                            }
                        }
                    }
                    diagDB.SaveChanges();
                }


                DateTime date = DateTime.Parse(DateStart.ToString("dd.MM.yyyy HH:00"));
                while (date <= DateEnd)
                {
                    Logger.Info(String.Format("GG {0} {1} ", gg, date));
                    if (gg == 5 && date < DateTime.Parse("01.06.2019"))
                    {
                        date = DateTime.Parse("01.06.2019");
                        continue;
                    }
                    if (gg == 3 && date < DateTime.Parse("07.05.2020"))
                    {
                        date = DateTime.Parse("07.05.2020");
                        continue;
                    }
                    if (gg == 1 && date < DateTime.Parse("21.04.2021"))
                    {
                        date = DateTime.Parse("21.04.2020");
                        continue;
                    }
                    foreach (string type in Types)
                    {
                        if (string.IsNullOrEmpty(pointsDict[type]))
                        {
                            continue;
                        }

                        IEnumerable <AnalogData> datas = (from a in existData where a.Date == date && a.pointType == type select a);
                        AnalogData dat = null;
                        if (datas.Count() == 0)
                        {
                            dat = new AnalogData();
                            diagDB.AnalogDatas.Add(dat);
                            dat.pointType = type;
                            dat.gg        = gg;
                            dat.Date      = date;
                            dat.value     = await EDSClass.getValFromServer(pointsDict[type], date);
                        }
                        else
                        {
                            dat = datas.First();
                        }
                    }
                    date = date.AddHours(3);
                }
            }
            return(true);
        }
Beispiel #8
0
        public async static Task <bool> FillPuskStopData(List <PuskStopReaderRecord> reqList, DateTime dateStart, DateTime dateEnd)
        {
            try
            {
                EDSClass.Disconnect();
            }
            catch { }
            EDSClass.Connect();
            if (!EDSClass.Connected)
            {
                return(false);
            }

            /*bool ok = await RefreshLevelsMNU(reqList, dateStart, dateEnd);
             * return ok;*/

            SortedList <int, List <PuskStopData> > FullResult = await AnalizePuskStopDataFull(reqList, dateStart, dateEnd);


            for (int index = 0; index < reqList.Count; index++)
            {
                List <PuskStopData>  data      = FullResult[index];
                PuskStopReaderRecord reqRecord = reqList[index];
                int    gg       = reqRecord.gg;
                string typeData = reqRecord.DBRecord;

                if (data.Count > 0)
                {
                    DiagDBEntities diagDB = new DiagDBEntities();

                    PuskStopData first = data.First();
                    PuskStopData last  = data.Last();
                    IQueryable <PuskStopInfo> reqFirst = from pi in diagDB.PuskStopInfoes where pi.GG == gg && pi.TypeData == typeData && pi.TimeOff == first.TimeOn select pi;

                    if (reqFirst.Count() > 0)
                    {
                        PuskStopInfo firstDB = reqFirst.First();
                        firstDB.TimeOff  = first.TimeOff;
                        firstDB.Length   = (firstDB.TimeOff - firstDB.TimeOn).TotalSeconds;
                        firstDB.ValueEnd = first.ValueEnd;

                        diagDB.SaveChanges();

                        if (data.Count > 1)
                        {
                            data.RemoveAt(0);
                        }
                        else
                        {
                            continue;
                        }
                    }

                    IQueryable <PuskStopInfo> reqLast = from pi in diagDB.PuskStopInfoes where pi.GG == gg && pi.TypeData == typeData && pi.TimeOn == last.TimeOff select pi;
                    if (reqLast.Count() > 0)
                    {
                        PuskStopInfo lastDB = reqLast.First();
                        lastDB.TimeOn     = last.TimeOn;
                        lastDB.Length     = (lastDB.TimeOff - lastDB.TimeOn).TotalSeconds;
                        lastDB.ValueStart = last.ValueStart;
                        diagDB.SaveChanges();
                        if (data.Count > 0)
                        {
                            data.Remove(last);
                        }
                        else
                        {
                            continue;
                        }
                    }



                    IQueryable <PuskStopInfo>           req    = from pi in diagDB.PuskStopInfoes where pi.GG == gg && pi.TypeData == typeData && pi.TimeOn > dateStart && pi.TimeOn <= dateEnd select pi;
                    SortedList <DateTime, PuskStopInfo> dataDB = new SortedList <DateTime, PuskStopInfo>();
                    foreach (PuskStopInfo pi in req)
                    {
                        if (!dataDB.ContainsKey(pi.TimeOn))
                        {
                            dataDB.Add(pi.TimeOn, pi);
                        }
                    }

                    foreach (PuskStopData rec in data)
                    {
                        PuskStopInfo recDB = new PuskStopInfo();
                        if (dataDB.ContainsKey(rec.TimeOn))
                        {
                            recDB = dataDB[rec.TimeOn];
                        }

                        recDB.GG         = gg;
                        recDB.TypeData   = typeData;
                        recDB.TimeOn     = rec.TimeOn;
                        recDB.TimeOff    = rec.TimeOff;
                        recDB.Length     = rec.Length;
                        recDB.ValueEnd   = rec.ValueEnd;
                        recDB.ValueStart = rec.ValueStart;
                        recDB.Comment    = "";

                        if (!dataDB.ContainsKey(rec.TimeOn))
                        {
                            diagDB.PuskStopInfoes.Add(recDB);
                        }
                    }
                    diagDB.SaveChanges();
                }
            }

            return(true);
        }
Beispiel #9
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();
        }
        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());
            }
        }
Beispiel #11
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);
        }