コード例 #1
0
        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;
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: rj128x/EDSProjNew
        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();
        }
コード例 #4
0
ファイル: DiagNasos.cs プロジェクト: rj128x/EDSProject2019
        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);
        }
コード例 #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();
        }
コード例 #6
0
        protected static async Task <bool> UpdateValue(PuskStopData dataRecord, PuskStopReaderRecord readerRecord)
        {
            if (String.IsNullOrEmpty(readerRecord.ValueIess))
            {
                return(false);
            }
            double val0 = await EDSClass.getValFromServer(readerRecord.ValueIess, dataRecord.TimeOn);

            double val1 = await EDSClass.getValFromServer(readerRecord.ValueIess, dataRecord.TimeOff);

            dataRecord.ValueStart = val0;
            dataRecord.ValueEnd   = val1;
            return(true);
        }
コード例 #7
0
ファイル: RecordClass.cs プロジェクト: rj128x/EDSProject2019
        public static async Task <bool> initEDS()
        {
            try
            {
                EDSPoints = new SortedList <string, EDSPointInfo>();
                EDSClass.Connect();
                bool ok = await EDSPointsClass.getPointsArr("MC_NPRCH_GG.*EDS@CALC", EDSPoints);

                return(true);
            }
            catch
            {
                MessageBox.Show("Не удалось подключиться к ЕДС");
                return(false);
            }
        }
コード例 #8
0
        public async Task <bool> init()
        {
            SelectedPoints = new List <EDSReportRequestRecord>();
            Dictionary <int, TechGroupInfo> grs = await EDSClass.GetTechGroups();

            TechGroups = grs.Values.ToList();
            AllPoints  = await EDSPointsClass.GetAllAnalogPoints();

            FilteredPoints = AllPoints.Values.ToList();

            //lbPoints.ItemsSource = FilteredPoints;
            grdPoints.ItemsSource   = FilteredPoints;
            lbSelPoints.ItemsSource = SelectedPoints;
            lbGroups.ItemsSource    = TechGroups;
            RefreshSelection("");
            return(true);
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: rj128x/EDSProject2019
        public static void runReports(DateTime date)
        {
            Logger.Info("статистика за " + date);
            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());
            List <int> idsForRun = new List <int>();

            foreach (ReportConfig report in reports)
            {
                /*Console.WriteLine(report.id);
                 *              Console.WriteLine(report.reportDefinitionFile);
                 *              Console.WriteLine(report.inputValues);*/
                string file = report.reportDefinitionFile.ToLower();
                if (file.Contains("ou17"))
                {
                    idsForRun.Add((int)report.id);
                }
            }

            foreach (int id in idsForRun)
            {
                Logger.Info(String.Format("Выполнение {0}", id));
                GlobalReportRequest req = new GlobalReportRequest();
                req.reportConfigId = (uint)id;
                req.dtRef          = new Timestamp()
                {
                    second = EDSClass.toTS(date)
                };

                uint reqId = EDSClass.Client.requestGlobalReport(EDSClass.AuthStr, req);
                bool ok    = EDSClass.ProcessQuery(reqId);
                Logger.Info(ok.ToString());
            }
        }
コード例 #10
0
        public void readDataFromDB(DateTime dateStart, DateTime dateEnd)
        {
            List <ShadeSelector> sel    = new List <ShadeSelector>();
            List <Shade>         shades = new List <Shade>();
            List <ShadeValue>    vals   = new List <ShadeValue>();

            List <DateTime> dates = new List <DateTime>();
            DateTime        dt    = dateStart.AddMinutes(30);

            while (dt <= dateEnd)
            {
                dates.Add(dt);
                dt = dt.AddMinutes(30);
            }

            try {
                foreach (AISPointInfo point in AISPoints)
                {
                    SqlConnection con = getConnection(point.DBName);
                    con.Open();
                    string comSTR = "";
                    comSTR = String.Format("SELECT DATA_DATE,VALUE0 FROM DATA WHERE OBJECT={0} AND OBJTYPE={1} AND ITEM={2} AND PARNUMBER=12 AND DATA_DATE>'{3}' AND DATA_DATE<='{4}'",
                                           point.Obj, point.ObjType, point.Item, dateStart.ToString(DateFormat), dateEnd.ToString(DateFormat));
                    SqlCommand    command = new SqlCommand(comSTR, con);
                    SqlDataReader reader  = command.ExecuteReader();


                    List <DateTime> fillDates = new List <DateTime>();
                    while (reader.Read())
                    {
                        DateTime date = reader.GetDateTime(0);
                        double   val  = reader.GetDouble(1);

                        try {
                            vals.Add(new ShadeValue()
                            {
                                period = new TimePeriod()
                                {
                                    from = new Timestamp()
                                    {
                                        second = EDSClass.toTS(date.AddHours(2).AddMinutes(-30))
                                    },
                                    till = new Timestamp()
                                    {
                                        second = EDSClass.toTS(date.AddHours(2))
                                    }
                                },
                                quality = Quality.QUALITYGOOD,
                                value   = new PointValue()
                                {
                                    av = (float)val, avSpecified = true
                                }
                            });
                            fillDates.Add(date);
                        } catch { }
                    }

                    foreach (DateTime emptyDT in dates)
                    {
                        if (!fillDates.Contains(emptyDT))
                        {
                            try {
                                vals.Add(new ShadeValue()
                                {
                                    period = new TimePeriod()
                                    {
                                        from = new Timestamp()
                                        {
                                            second = EDSClass.toTS(emptyDT.AddHours(2).AddMinutes(-30))
                                        },
                                        till = new Timestamp()
                                        {
                                            second = EDSClass.toTS(emptyDT.AddHours(2))
                                        }
                                    },
                                    quality = Quality.QUALITYBAD,
                                    value   = new PointValue()
                                    {
                                        av = (float)0, avSpecified = true
                                    }
                                });
                            } catch { }
                        }
                    }

                    reader.Close();
                    con.Close();

                    if (vals.Count == 0)
                    {
                        continue;
                    }


                    sel.Add(new ShadeSelector()
                    {
                        period = new TimePeriod()
                        {
                            from = new Timestamp()
                            {
                                second = EDSClass.toTS(dateStart.AddHours(2).AddMinutes(30))
                            },
                            till = new Timestamp()
                            {
                                second = EDSClass.toTS(dateEnd.AddHours(2).AddMinutes(-30))
                            }
                        },
                        pointId = new PointId()
                        {
                            iess = point.EDSPoint
                        }
                    });


                    shades.Add(new Shade()
                    {
                        pointId = new PointId()
                        {
                            iess = point.EDSPoint
                        },
                        values = vals.ToArray()
                    });
                }

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

                Logger.Info(String.Format("Удаление записей по точке {0} - {1} ", dateStart.ToString("dd.MM.yyyy HH:mm"), dateEnd.ToString("dd.MM.yyyy HH:mm")));
                uint id = EDSClass.Client.requestShadesClear(EDSClass.AuthStr, sel.ToArray());
                bool ok = EDSClass.ProcessQuery(id);
                Logger.Info(String.Format("Записьданных по точке {0} - {1} ", dateStart.ToString("dd.MM.yyyy HH:mm"), dateEnd.ToString("dd.MM.yyyy HH:mm")));
                id = EDSClass.Client.requestShadesWrite(EDSClass.AuthStr, shades.ToArray());
                ok = EDSClass.ProcessQuery(id);
            }catch (Exception e) {
                Logger.Info("ошибка обработки: " + e.ToString());
            }
        }
コード例 #11
0
        public static async Task <List <PuskStopData> > AnalizePuskStopData(string pointName, DateTime dateStart, DateTime dateEnd, bool inverted)
        {
            List <PuskStopData> result = new List <PuskStopData>();

            try
            {
                DateTime ds = dateStart.AddSeconds(0);
                DateTime de = dateEnd.AddSeconds(0);

                double val0 = await EDSClass.getValFromServer(pointName, ds);

                if ((inverted && val0 < 0.5) || (!inverted && val0 > 0.9))
                {
                    PuskStopData record = new PuskStopData();
                    DateTime     dt     = await EDSClass.getValNextDate(pointName, ds, de, inverted? "F_INTOOVER_DT" : "F_INTOUNDER_DT", 0.5);

                    if (dt > ds && dt < de)
                    {
                        ds             = dt;
                        record.TimeOn  = dateStart;
                        record.TimeOff = dt;
                        result.Add(record);
                    }
                    else
                    {
                        record.TimeOn  = dateStart;
                        record.TimeOff = dateEnd;
                        result.Add(record);
                        return(result);
                    }
                }
                while (ds < de)
                {
                    PuskStopData record = new PuskStopData();
                    DateTime     dt     = await EDSClass.getValNextDate(pointName, ds.AddSeconds(1), de, inverted? "F_INTOUNDER_DT" : "F_INTOOVER_DT", 0.5);

                    Logger.Info(String.Format("Pusk {0}", dt));
                    if (dt > ds && dt < de)
                    {
                        record.TimeOn = dt;
                        DateTime dt1 = await EDSClass.getValNextDate(pointName, dt.AddSeconds(1), de, inverted? "F_INTOOVER_DT" : "F_INTOUNDER_DT", 0.5);

                        Logger.Info(String.Format("Stop {0}", dt1));
                        if (dt1 > dt && dt1 < de)
                        {
                            record.TimeOff = dt1;
                            record.Length  = (int)(record.TimeOff - record.TimeOn).TotalSeconds;
                            result.Add(record);
                            record = new PuskStopData();
                            ds     = dt1.AddSeconds(1);
                        }
                        else
                        {
                            record.TimeOff = dateEnd;
                            record.Length  = (int)(record.TimeOff - record.TimeOn).TotalSeconds;
                            result.Add(record);
                            return(result);
                        }
                    }
                    else
                    {
                        return(result);
                    }
                }
                return(result);
            }
            catch
            {
                return(result);
            }
        }
コード例 #12
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);
        }
コード例 #13
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);
        }
コード例 #14
0
        public static async Task <SortedList <int, List <PuskStopData> > > AnalizePuskStopDataFull(List <PuskStopReaderRecord> req, DateTime dateStart, DateTime dateEnd)
        {
            EDSReport report = new EDSReport(dateStart, dateEnd, EDSReportPeriod.sec);
            Dictionary <string, EDSReportRequestRecord> records = new Dictionary <string, EDSReportRequestRecord>();

            foreach (PuskStopReaderRecord de in req)
            {
                EDSReportRequestRecord pointRec = null;
                if (!records.ContainsKey(de.iess))
                {
                    EDSPointInfo point = await EDSPointInfo.GetPointInfo(de.iess);

                    pointRec = report.addRequestField(point, EDSReportFunction.val);
                    records.Add(de.iess, pointRec);
                }
                else
                {
                    pointRec = records[de.iess];
                }
                de.rec = pointRec;

                if (!String.IsNullOrEmpty(de.ValueIess) && !records.ContainsKey(de.ValueIess))
                {
                    EDSPointInfo point = await EDSPointInfo.GetPointInfo(de.ValueIess);

                    pointRec = report.addRequestField(point, EDSReportFunction.val);
                    records.Add(de.ValueIess, pointRec);
                }
            }
            bool ok = await report.ReadData();

            List <DateTime> keys = report.ResultData.Keys.ToList();

            SortedList <int, List <PuskStopData> > FullResult = new SortedList <int, List <PuskStopData> >();

            foreach (PuskStopReaderRecord readField in req)
            {
                bool inverted = readField.inverted;
                List <PuskStopData> result = new List <PuskStopData>();
                FullResult.Add(FullResult.Count, result);
                SortedList <DateTime, double> data = new SortedList <DateTime, double>();
                foreach (DateTime dt in keys)
                {
                    data.Add(dt, report.ResultData[dt][readField.rec.Id]);
                }
                double val0 = data.Values.First();

                PuskStopData record = new PuskStopData();

                DateTime ds = dateStart.AddSeconds(0);
                if ((inverted && val0 < 0.5) || (!inverted && val0 > 0.9))
                {
                    try
                    {
                        DateTime dt = inverted ? data.First(de => de.Value > 0.5).Key : data.First(de => de.Value < 0.5).Key;
                        record.TimeOff = dt;
                        record.TimeOn  = dateStart;
                        record.Length  = (dt - dateStart).TotalSeconds;
                        ds             = dt.AddSeconds(0);
                        result.Add(record);
                    }
                    catch
                    {
                        record.TimeOn  = dateStart;
                        record.TimeOff = dateEnd;
                        record.Length  = (dateEnd - dateStart).TotalSeconds;
                        result.Add(record);
                        continue;
                    }
                }

                while (ds <= dateEnd)
                {
                    try
                    {
                        DateTime dt = inverted ? data.First(de => de.Key > ds && de.Value < 0.5).Key :
                                      data.First(de => de.Key > ds && de.Value > 0.5).Key;
                        record        = new PuskStopData();
                        record.TimeOn = dt;
                        try
                        {
                            DateTime dt1 = inverted ? data.First(de => de.Key > dt && de.Value > 0.5).Key :
                                           data.First(de => de.Key > dt && de.Value < 0.5).Key;
                            record.TimeOff = dt1;
                            record.Length  = (record.TimeOff - record.TimeOn).TotalSeconds;
                            result.Add(record);
                            ds = dt1.AddSeconds(0);
                        }
                        catch
                        {
                            record.TimeOff = dateEnd;
                            record.Length  = (record.TimeOff - record.TimeOn).TotalSeconds;
                            result.Add(record);
                            break;
                        }
                    }
                    catch
                    {
                        break;
                    }
                }
            }
            for (int i = 0; i < FullResult.Keys.Count; i++)
            {
                List <PuskStopData>  data   = FullResult[i];
                PuskStopReaderRecord reqRec = req[i];
                if (String.IsNullOrEmpty(reqRec.ValueIess))
                {
                    continue;
                }
                EDSReportRequestRecord requestRecord = records[reqRec.ValueIess];
                foreach (PuskStopData pi in data)
                {
                    if (report.ResultData.Keys.Contains(pi.TimeOn))
                    {
                        pi.ValueStart = report.ResultData[pi.TimeOn][requestRecord.Id];
                    }
                    else
                    {
                        pi.ValueStart = await EDSClass.getValFromServer(reqRec.ValueIess, pi.TimeOn);
                    }

                    if (report.ResultData.Keys.Contains(pi.TimeOff))
                    {
                        pi.ValueEnd = report.ResultData[pi.TimeOff][requestRecord.Id];
                    }
                    else
                    {
                        pi.ValueEnd = await EDSClass.getValFromServer(reqRec.ValueIess, pi.TimeOff);
                    }
                }
            }

            return(FullResult);
        }
コード例 #15
0
ファイル: MCPBRData.cs プロジェクト: rj128x/EDSProjNew
        public bool writeToEDS(string pointName, SortedList <DateTime, double> data, bool data15, bool datamin)
        {
            bool ok = false;

            try {
                //SortedList<DateTime, double> data15 = createHH15Data();
                if (!EDSClass.Connected)
                {
                    EDSClass.Connect();
                }

                List <ShadeSelector> sel = new List <ShadeSelector>();
                sel.Add(new ShadeSelector()
                {
                    period = new TimePeriod()
                    {
                        from = new Timestamp()
                        {
                            second = EDSClass.toTS(data.Keys.First().AddHours(2))
                        },
                        till = new Timestamp()
                        {
                            second = EDSClass.toTS(data.Keys.Last().AddHours(2))
                        }
                    },
                    pointId = new PointId()
                    {
                        iess = pointName
                    }
                });

                Logger.Info("Удаление записей");
                uint id = EDSClass.Client.requestShadesClear(EDSClass.AuthStr, sel.ToArray());
                ok = EDSClass.ProcessQuery(id);

                if (ok)
                {
                    List <Shade>      shades = new List <Shade>();
                    List <ShadeValue> vals   = new List <ShadeValue>();

                    if (data15)
                    {
                        foreach (KeyValuePair <DateTime, double> de in data)
                        {
                            DateTime d    = de.Key.AddMinutes(0);
                            DateTime dEnd = de.Key.AddMinutes(30);
                            //dEnd = dEnd > data.Last().Key ? data.Last().Key : dEnd;
                            while (d < dEnd)
                            {
                                vals.Add(new ShadeValue()
                                {
                                    period = new TimePeriod()
                                    {
                                        from = new Timestamp()
                                        {
                                            second = EDSClass.toTS(d.AddHours(2))
                                        },
                                        till = new Timestamp()
                                        {
                                            second = EDSClass.toTS(d.AddHours(2).AddMinutes(1))
                                        }
                                    },
                                    quality = Quality.QUALITYGOOD,
                                    value   = new PointValue()
                                    {
                                        av = (float)de.Value, avSpecified = true
                                    }
                                });
                                d = d.AddMinutes(1);
                            }
                        }
                        ;
                    }
                    else if (datamin)
                    {
                        foreach (KeyValuePair <DateTime, double> de in data)
                        {
                            vals.Add(new ShadeValue()
                            {
                                period = new TimePeriod()
                                {
                                    from = new Timestamp()
                                    {
                                        second = EDSClass.toTS(de.Key.AddHours(2))
                                    },
                                    till = new Timestamp()
                                    {
                                        second = EDSClass.toTS(de.Key.AddHours(2).AddMinutes(1))
                                    }
                                },
                                quality = Quality.QUALITYGOOD,
                                value   = new PointValue()
                                {
                                    av = (float)de.Value, avSpecified = true
                                }
                            });
                        }
                        ;
                    }
                    else
                    {
                        double sum = 0;
                        foreach (KeyValuePair <DateTime, double> de in data)
                        {
                            DateTime d = de.Key.AddMinutes(0);
                            sum += de.Value / 60;
                            vals.Add(new ShadeValue()
                            {
                                period = new TimePeriod()
                                {
                                    from = new Timestamp()
                                    {
                                        second = EDSClass.toTS(d.AddHours(2))
                                    },
                                    till = new Timestamp()
                                    {
                                        second = EDSClass.toTS(d.AddHours(2).AddMinutes(1)) - 1
                                    }
                                },
                                quality = Quality.QUALITYGOOD,
                                value   = new PointValue()
                                {
                                    av = (float)sum, avSpecified = true
                                }
                            });
                            d = d.AddMinutes(1);
                        }
                        ;
                    }
                    shades.Add(new Shade()
                    {
                        pointId = new PointId()
                        {
                            iess = pointName
                        },
                        values = vals.ToArray()
                    });

                    Logger.Info("Запись данных");
                    id = EDSClass.Client.requestShadesWrite(EDSClass.AuthStr, shades.ToArray());
                    ok = EDSClass.ProcessQuery(id);
                }
            } catch (Exception e) {
                Logger.Info("Ошибка при записи ПБР в EDS " + e.ToString());
                ok = false;
            }
            return(ok);
        }
コード例 #16
0
        public async Task <bool> ReadData()
        {
            ResultData = new Dictionary <DateTime, Dictionary <string, double> >();
            DateTime date = DateStart.AddHours(0);

            while (date < DateEnd)
            {
                DateTime de = date.AddHours(0);
                switch (Period)
                {
                case EDSReportPeriod.sec:
                    de = date.AddSeconds(1);
                    break;

                case EDSReportPeriod.minute:
                    de = date.AddMinutes(1);
                    break;

                case EDSReportPeriod.hour:
                    de = date.AddHours(1);
                    break;

                case EDSReportPeriod.day:
                    de = date.AddDays(1);
                    break;

                case EDSReportPeriod.month:
                    de = date.AddMonths(1);
                    break;
                }
                ResultData.Add(date, new Dictionary <string, double>());
                foreach (string id in RequestData.Keys)
                {
                    ResultData[date].Add(id, 0);
                }
                date = de.AddHours(0);
            }


            List <TabularRequestItem> list = new List <TabularRequestItem>();

            foreach (EDSReportRequestRecord rec in RequestData.Values)
            {
                list.Add(new TabularRequestItem()
                {
                    function = EDSClass.getReportFunctionName(rec.Function),
                    pointId  = new PointId()
                    {
                        iess = rec.Point.IESS
                    },
                    shadePriority = rec.Point.IsShade ? ShadePriority.SHADEOVERREGULAR : ShadePriority.REGULAROVERSHADE
                });
            }



            if (!EDSClass.Connected)
            {
                EDSClass.Connect();
            }
            if (EDSClass.Connected)
            {
                if (Period != EDSReportPeriod.month)
                {
                    List <DateTime> dates = ResultData.Keys.ToList();
                    DateTime        ds    = DateStart.AddHours(0);
                    DateTime        de    = DateStart.AddHours(1);
                    while (ds < DateEnd)
                    {
                        if (Period == EDSReportPeriod.minute || Period == EDSReportPeriod.sec)
                        {
                            int i0 = dates.IndexOf(ds);
                            int i1 = i0 + 1000;
                            de = i1 < dates.Count ? dates[i1] : DateEnd;
                        }
                        else
                        {
                            de = de.AddDays(5);
                            try {
                                de = dates.First(d => d >= de);
                            } catch {
                                de = DateEnd;
                            }
                        }

                        EDSClass.Single.GlobalInfo = String.Format("{0}-{1}", ds.ToString("dd.MM.yyyy HH:mm:ss"), de.ToString("dd.MM.yyyy HH:mm:ss"));

                        TabularRequest req = new TabularRequest();
                        req.period = new TimePeriod()
                        {
                            from = new Timestamp()
                            {
                                second = EDSClass.toTS(ds)
                            },
                            till = new Timestamp()
                            {
                                second = EDSClass.toTS(de)
                            }
                        };

                        req.step = new TimeDuration()
                        {
                            seconds = EDSClass.getPeriodSeconds(Period)
                        };
                        req.items = list.ToArray();
                        uint         id = EDSClass.Client.requestTabular(EDSClass.AuthStr, req);
                        TabularRow[] rows;
                        bool         ok = await EDSClass.ProcessQueryAsync(id);

                        if (!ok)
                        {
                            break;
                        }
                        PointId[]     points = EDSClass.Client.getTabular(EDSClass.AuthStr, id, out rows);
                        List <string> keys   = RequestData.Keys.ToList();

                        foreach (TabularRow row in rows)
                        {
                            DateTime dt = EDSClass.fromTS(row.ts.second);
                            for (int i = 0; i < row.values.Count(); i++)
                            {
                                double  val   = EDSClass.getVal(row.values[i].value);
                                PointId point = points[i];
                                string  resId = keys[i];
                                EDSReportRequestRecord request = RequestData[resId];
                                if (request.Function == EDSReportFunction.vyrab && Period == EDSReportPeriod.day)
                                {
                                    val *= 24;
                                }
                                ResultData[dt][resId] = val;
                            }
                        }

                        ds = de.AddHours(0);
                    }
                }
                else
                {
                    DateTime ds = DateStart.AddHours(0);
                    while (ds < DateEnd)
                    {
                        EDSClass.Single.GlobalInfo = String.Format("{0}-{1}", ds.ToString("dd.MM.yyyy"), ds.AddMonths(1).ToString("dd.MM.yyyy"));
                        DateTime       de  = ds.AddMonths(1);
                        TabularRequest req = new TabularRequest();
                        req.period = new TimePeriod()
                        {
                            from = new Timestamp()
                            {
                                second = EDSClass.toTS(ds)
                            },
                            till = new Timestamp()
                            {
                                second = EDSClass.toTS(de)
                            }
                        };


                        int seconds = (int)(EDSClass.toTS(de) - EDSClass.toTS(ds));
                        req.step = new TimeDuration()
                        {
                            seconds = seconds
                        };
                        req.items = list.ToArray();
                        uint         id = EDSClass.Client.requestTabular(EDSClass.AuthStr, req);
                        TabularRow[] rows;
                        bool         ok = await EDSClass.ProcessQueryAsync(id);

                        if (!ok)
                        {
                            break;
                        }
                        PointId[]     points = EDSClass.Client.getTabular(EDSClass.AuthStr, id, out rows);
                        List <string> keys   = RequestData.Keys.ToList();

                        TabularRow row = rows.First();
                        DateTime   dt  = EDSClass.fromTS(row.ts.second);
                        for (int i = 0; i < row.values.Count(); i++)
                        {
                            double  val   = EDSClass.getVal(row.values[i].value);
                            PointId point = points[i];
                            string  resId = keys[i];
                            EDSReportRequestRecord request = RequestData[resId];
                            if (request.Function == EDSReportFunction.vyrab)
                            {
                                val *= seconds / 3600.0;
                            }
                            ResultData[dt][resId] = val;
                        }

                        ds = de.AddHours(0);
                    }
                }
            }

            return(true);
        }
コード例 #17
0
        public MCServerReader(DateTime date, bool writeNPBR = true)
        {
            Logger.Info("Чтение ПБР за " + date.ToString());
            Date         = date;
            AutooperData = new List <string>();
            Logger.Info("Connect MC");
            ProcessedPBRS = new Dictionary <int, MCPBRData>();

            try {
                modesConnect();
                SyncZone zone = SyncZone.First;

                IModesTimeSlice ts = null;
                ts = api.GetModesTimeSlice(date.Date.LocalHqToSystemEx(), zone
                                           , TreeContent.PGObjects              /*только оборудование, по которому СО публикует ПГ(включая родителей)*/
                                           , false);


                bool ok = true;
                foreach (IGenObject obj in ts.GenTree)
                {
                    ok = ok && getPlan(obj);
                }

                if (ok)
                {
                    if (ProcessedPBRS.Count != 7)
                    {
                        Logger.Info("Количество ПБР !=7. Отправка в автооператор не производится");
                    }
                    else
                    {
                        foreach (MCPBRData pbr in ProcessedPBRS.Values)
                        {
                            pbr.CreateData();
                            pbr.addAutooperData(AutooperData);
                        }
                        Logger.Info("АО кол.строк " + AutooperData.Count);
                        if (AutooperData.Count == 100)
                        {
                            Logger.Info("Отправка в АО кол.строк ");
                            try {
                                sendAutooperData();
                                Logger.Info("Данный отправлены  в АО");
                            } catch (Exception e) {
                                Logger.Info("Ошибка при отправке данных в АО");
                                Logger.Info(e.ToString());
                            }
                        }
                        else
                        {
                            Logger.Info("Неверное количество данных в АО");
                        }
                    }
                }
                //return;

                if (ok)
                {
                    Logger.Info("Зaпись ПБР в Базу");
                    foreach (MCPBRData pbr in ProcessedPBRS.Values)
                    {
                        try {
                            pbr.CreateData();
                            bool okWrite = false;
                            int  i       = 0;
                            while (!okWrite && i < 3)
                            {
                                Logger.Info(String.Format("Запись {0} ПБР. Попытка {1}", pbr.Item, i));
                                okWrite = pbr.ProcessData();
                                i++;
                            }
                        } catch {
                            Logger.Info("Ошибка при записи ПБР в базу");
                        }
                    }
                    Logger.Info("Запись номера ПБР");

                    DateTime             ds  = DateTime.Now;
                    DateTime             de  = this.Date.AddDays(1);
                    List <ShadeSelector> sel = new List <ShadeSelector>();
                    sel.Add(new ShadeSelector()
                    {
                        period = new TimePeriod()
                        {
                            from = new Timestamp()
                            {
                                second = EDSClass.toTS(ds)
                            },
                            till = new Timestamp()
                            {
                                second = EDSClass.toTS(de)
                            }
                        },
                        pointId = new PointId()
                        {
                            iess = "NPBR.EDS@CALC"
                        }
                    });

                    Logger.Info("Удаление номера ПБР");
                    uint id = EDSClass.Client.requestShadesClear(EDSClass.AuthStr, sel.ToArray());
                    ok = EDSClass.ProcessQuery(id);

                    if (ok)
                    {
                        List <Shade>      shades = new List <Shade>();
                        List <ShadeValue> vals   = new List <ShadeValue>();
                        vals.Add(new ShadeValue()
                        {
                            period = new TimePeriod()
                            {
                                from = new Timestamp()
                                {
                                    second = EDSClass.toTS(ds)
                                },
                                till = new Timestamp()
                                {
                                    second = EDSClass.toTS(de)
                                }
                            },
                            quality = Quality.QUALITYGOOD,
                            value   = new PointValue()
                            {
                                av = NPBR, avSpecified = true
                            }
                        });
                        shades.Add(new Shade()
                        {
                            pointId = new PointId()
                            {
                                iess = "NPBR.EDS@CALC"
                            },
                            values = vals.ToArray()
                        });
                        Logger.Info("Запись данных");
                        id = EDSClass.Client.requestShadesWrite(EDSClass.AuthStr, shades.ToArray());
                        ok = EDSClass.ProcessQuery(id);
                    }
                }
            } catch (Exception e) {
                Logger.Info("Ошибка при получении ПБР с сервера MC " + e);
            } finally {
                ModesApiFactory.CloseConnection();
            }
        }
コード例 #18
0
        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());
            }
        }
コード例 #19
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();
        }
コード例 #20
0
        public static async Task <bool> PBRExport()
        {
            Settings.init("Data/Settings.xml");
            Logger.InitFileLogger(Settings.Single.LogPath, "pbrExport");

            string        folderName = @"C:\EDSPBRReports";
            DirectoryInfo di         = new DirectoryInfo(folderName);

            FileInfo[] filesArr = di.GetFiles();
            SortedList <DateTime, FileInfo> files = new SortedList <DateTime, FileInfo>();

            foreach (FileInfo fi in filesArr)
            {
                files.Add(fi.CreationTime, fi);
            }
            foreach (FileInfo fi in files.Values)
            {
                GRARMPBRData PBR_gtp1 = new GRARMPBRData("PBR_GTP1.EDS@CALC", "GRARM_PBR_GTP1_SMOOTH.EDS@CALC", false);
                GRARMPBRData PBR_gtp2 = new GRARMPBRData("PBR_GTP2.EDS@CALC", "GRARM_PBR_GTP2_SMOOTH.EDS@CALC", false);
                GRARMPBRData PBR_ges  = new GRARMPBRData("PBR_GES.EDS@CALC", "GRARM_PBR_GES_SMOOTH.EDS@CALC", true);
                PBR_ges.IntegratedEDSPoint = "GRARM_PBR_GES_VYR_PLAN.EDS@CALC";
                StreamReader sr    = new StreamReader(fi.FullName);
                String       text  = sr.ReadToEnd();
                string[]     lines = text.Split(new char[] { '\n' });
                foreach (string line in lines)
                {
                    try
                    {
                        string[] vals    = line.Split(';');
                        DateTime dt      = DateTime.Parse(vals[0]);
                        double   valGTP1 = double.Parse(vals[2]);
                        double   valGTP2 = double.Parse(vals[4]);
                        double   valGES  = double.Parse(vals[6]);
                        PBR_ges.AddValue(dt, valGES);
                        PBR_gtp1.AddValue(dt, valGTP1);
                        PBR_gtp2.AddValue(dt, valGTP2);
                        Console.WriteLine(String.Format("{0} {1} {2} {3}", dt, valGTP1, valGTP2, valGES));
                    }
                    catch
                    {
                        Logger.Info("Ошибка в формате");
                    }
                }
                bool ok = true;
                PBR_ges.CreateData();
                ok = ok && PBR_ges.ProcessData();

                PBR_gtp1.CreateData();
                ok = ok && PBR_gtp1.ProcessData();

                PBR_gtp2.CreateData();
                ok = ok && PBR_gtp2.ProcessData();

                if (ok)
                {
                    Logger.Info("Запись номера ПБР");

                    DateTime             ds  = DateTime.Now;
                    DateTime             de  = ds.Date.AddDays(1);
                    List <ShadeSelector> sel = new List <ShadeSelector>();
                    sel.Add(new ShadeSelector()
                    {
                        period = new TimePeriod()
                        {
                            from = new Timestamp()
                            {
                                second = EDSClass.toTS(ds)
                            },
                            till = new Timestamp()
                            {
                                second = EDSClass.toTS(de)
                            }
                        },
                        pointId = new PointId()
                        {
                            iess = "GRARM_PBR_IND.EDS@CALC"
                        }
                    });

                    Logger.Info("Удаление номера ПБР");
                    uint id = EDSClass.Client.requestShadesClear(EDSClass.AuthStr, sel.ToArray());
                    ok = EDSClass.ProcessQuery(id);

                    string dt   = ds.ToString("HHmm");
                    long   NPBR = long.Parse(dt);
                    if (ok)
                    {
                        List <Shade>      shades = new List <Shade>();
                        List <ShadeValue> vals   = new List <ShadeValue>();
                        vals.Add(new ShadeValue()
                        {
                            period = new TimePeriod()
                            {
                                from = new Timestamp()
                                {
                                    second = EDSClass.toTS(ds)
                                },
                                till = new Timestamp()
                                {
                                    second = EDSClass.toTS(de)
                                }
                            },
                            quality = Quality.QUALITYGOOD,
                            value   = new PointValue()
                            {
                                av = NPBR, avSpecified = true
                            }
                        });
                        shades.Add(new Shade()
                        {
                            pointId = new PointId()
                            {
                                iess = "GRARM_PBR_IND.EDS@CALC"
                            },
                            values = vals.ToArray()
                        });
                        Logger.Info("Запись данных");
                        id = EDSClass.Client.requestShadesWrite(EDSClass.AuthStr, shades.ToArray());
                        ok = EDSClass.ProcessQuery(id);
                    }
                }

                try
                {
                    sr.Close();
                    fi.Delete();
                }
                catch { }
            }
            return(true);
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: rj128x/EDSProject2019
        public static async Task <bool> readDataHHT()
        {
            Logger.Info("Start");
            EDSClass.Connect();
            AllPoints = new SortedList <string, EDSPointInfo>();

            bool ok = true;

            ok &= await EDSPointsClass.getPointsArr(".*VT.*MCR@GRARM", AllPoints);

            Logger.Info(String.Format("Points {0}", AllPoints.Count));

            DateTime DateStart = new DateTime(2019, 1, 1);
            DateTime DateEnd   = new DateTime(2021, 5, 17);

            Dictionary <int, EDSPointInfo> pointsH  = new Dictionary <int, EDSPointInfo>();
            Dictionary <int, EDSPointInfo> pointsNA = new Dictionary <int, EDSPointInfo>();
            Dictionary <int, EDSPointInfo> pointsP  = new Dictionary <int, EDSPointInfo>();
            Dictionary <int, EDSPointInfo> pointsF  = new Dictionary <int, EDSPointInfo>();
            Dictionary <int, EDSPointInfo> pointsR  = new Dictionary <int, EDSPointInfo>();
            Dictionary <int, string>       iessP    = new Dictionary <int, string>();
            Dictionary <int, string>       iessNA   = new Dictionary <int, string>();
            Dictionary <int, string>       iessH    = new Dictionary <int, string>();
            Dictionary <int, string>       iessF    = new Dictionary <int, string>();
            Dictionary <int, string>       iessR    = new Dictionary <int, string>();


            Dictionary <int, EDSReportRequestRecord> recPmax  = new Dictionary <int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recH     = new Dictionary <int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recNAmin = new Dictionary <int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recNAavg = new Dictionary <int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recNAmax = new Dictionary <int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recF     = new Dictionary <int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recRmin  = new Dictionary <int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recRmax  = new Dictionary <int, EDSReportRequestRecord>();


            EDSReportRequestRecord recHAvg;
            EDSPointInfo           pointHAvg;

            pointHAvg = await EDSPointInfo.GetPointInfo("11VT_ST00A-034.MCR@GRARM");

            Dictionary <int, List <int> > napors = new Dictionary <int, List <int> >();;

            foreach (int gg in new int[] { 2, 6, 8, 9, 10 })
            {
                Logger.Info("Get points " + gg);
                OutputData.InitOutput(String.Format("hht_gg_{0}", gg));
                //OutputData.InitOutput(String.Format("gg_{0}_{1}", gg,napor));
                napors.Add(gg, new List <int>());
                string ggS = gg < 10 ? "0" + gg.ToString() : gg.ToString();
                if ((new int[] { 3, 4, 5, 7 }).Contains(gg))
                {
                    iessP.Add(gg, String.Format("0{0}VT_LP01AO-03.MCR@GRARM", gg));
                    iessH.Add(gg, String.Format("0{0}VT_TC01A-11.MCR@GRARM", gg));
                    iessNA.Add(gg, String.Format("0{0}VT_GC01A-08.MCR@GRARM", gg));
                    iessF.Add(gg, String.Format("0{0}VT_GC01A-16.MCR@GRARM", gg));
                    iessR.Add(gg, String.Format("0{0}VT_AM03P-01.MCR@GRARM", gg));
                }
                else
                {
                    string suf = "";
                    if (gg <= 2)
                    {
                        suf = ".UNIT01@BLOCK1";
                    }
                    else if (gg <= 6)
                    {
                        suf = ".UNIT05@BLOCK3";
                    }
                    else if (gg <= 8)
                    {
                        suf = ".UNIT07@BLOCK4";
                    }
                    else if (gg <= 10)
                    {
                        suf = ".UNIT09@BLOCK5";
                    }

                    iessP.Add(gg, String.Format("{0}VT_LP02AO-03", ggS) + suf);
                    iessH.Add(gg, String.Format("{0}VT_GC00A-111", ggS) + suf);
                    iessNA.Add(gg, String.Format("{0}VT_GC03AI-04", ggS) + suf);
                    iessF.Add(gg, String.Format("{0}VT_GC00A-105", ggS) + suf);
                    iessR.Add(gg, String.Format("{0}VT_AM00P-60", ggS) + suf);
                }

                EDSPointInfo p = await EDSPointInfo.GetPointInfo(iessP[gg]);

                pointsP.Add(gg, p);

                p = await EDSPointInfo.GetPointInfo(iessH[gg]);

                pointsH.Add(gg, p);

                p = await EDSPointInfo.GetPointInfo(iessNA[gg]);

                pointsNA.Add(gg, p);

                p = await EDSPointInfo.GetPointInfo(iessF[gg]);

                pointsF.Add(gg, p);

                p = await EDSPointInfo.GetPointInfo(iessR[gg]);

                pointsR.Add(gg, p);
            }


            DateTime date = DateStart.AddMinutes(0);

            while (date < DateEnd)
            {
                DateTime ds = date.AddMinutes(0);
                DateTime de = date.AddHours(24);
                Logger.Info(string.Format("{0}-{1}", ds, de));

                recPmax.Clear();
                recH.Clear();
                recNAavg.Clear();
                recNAmin.Clear();
                recNAmax.Clear();
                recF.Clear();
                recRmin.Clear();
                recRmax.Clear();

                EDSReport report = new EDSReport(ds, de, EDSReportPeriod.sec30);
                foreach (int gg in new int[] { 2, 6, 8, 9, 10 })
                {
                    recPmax.Add(gg, report.addRequestField(pointsP[gg], EDSReportFunction.max));
                    recH.Add(gg, report.addRequestField(pointsH[gg], EDSReportFunction.avg));
                    recNAmin.Add(gg, report.addRequestField(pointsNA[gg], EDSReportFunction.min));
                    recNAmax.Add(gg, report.addRequestField(pointsNA[gg], EDSReportFunction.max));
                    recNAavg.Add(gg, report.addRequestField(pointsNA[gg], EDSReportFunction.avg));
                    recF.Add(gg, report.addRequestField(pointsF[gg], EDSReportFunction.avg));
                    recRmin.Add(gg, report.addRequestField(pointsR[gg], EDSReportFunction.min));
                    recRmax.Add(gg, report.addRequestField(pointsR[gg], EDSReportFunction.max));
                }
                recHAvg = report.addRequestField(pointHAvg, EDSReportFunction.avg);
                await report.ReadData();

                List <DateTime> resultDates = report.ResultData.Keys.ToList();
                foreach (DateTime dt in resultDates)
                {
                    foreach (int gg in new int[] { 2, 6, 8, 9, 10 })
                    {
                        double pMax  = report.ResultData[dt][recPmax[gg].Id];
                        double naAvg = report.ResultData[dt][recNAavg[gg].Id];
                        double naMin = report.ResultData[dt][recNAmin[gg].Id];
                        double naMax = report.ResultData[dt][recNAmax[gg].Id];
                        double f     = report.ResultData[dt][recF[gg].Id];
                        double h     = report.ResultData[dt][recH[gg].Id];
                        double hAvg  = report.ResultData[dt][recHAvg.Id];

                        double rMin = report.ResultData[dt][recRmin[gg].Id];
                        double rMax = report.ResultData[dt][recRmax[gg].Id];

                        long mask = (new int[] { 3, 4, 5, 7 }).Contains(gg) ? (long)Math.Pow(2, 4) : (long)Math.Pow(2, 15);

                        long rAbsMax = (long)rMax;
                        long maskMax = rAbsMax & mask;

                        long rAbsMin = (long)rMin;
                        long maskMin = rAbsMin & mask;



                        if (naMax - naMin > 1 || rAbsMin != rAbsMax || maskMin == 0 || naAvg < 6 || naAvg > 16)
                        {
                            continue;
                        }


                        OutputData.writeToOutput(String.Format("hht_gg_{0}", gg), string.Format("{0};{1};{2};{3}", dt, h, hAvg, naAvg));
                    }
                }
                date = de.AddMinutes(0);
            }
            return(true);
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: rj128x/EDSProject2019
        public static async Task <bool> readData()
        {
            Logger.Info("Start");
            EDSClass.Connect();
            AllPoints = new SortedList <string, EDSPointInfo>();

            bool ok = true;

            ok &= await EDSPointsClass.getPointsArr(".*VT.*", AllPoints);

            Logger.Info(String.Format("Points {0}", AllPoints.Count));

            DateTime DateStart = new DateTime(2019, 1, 1);
            DateTime DateEnd   = new DateTime(2021, 5, 17);

            Dictionary <int, EDSPointInfo> pointsH  = new Dictionary <int, EDSPointInfo>();
            Dictionary <int, EDSPointInfo> pointsNA = new Dictionary <int, EDSPointInfo>();
            Dictionary <int, EDSPointInfo> pointsP  = new Dictionary <int, EDSPointInfo>();

            Dictionary <int, string> iessP  = new Dictionary <int, string>();
            Dictionary <int, string> iessNA = new Dictionary <int, string>();
            Dictionary <int, string> iessH  = new Dictionary <int, string>();

            Dictionary <int, EDSReportRequestRecord> recPavg = new Dictionary <int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recPmin = new Dictionary <int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recPmax = new Dictionary <int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recH    = new Dictionary <int, EDSReportRequestRecord>();
            //Dictionary<int, EDSReportRequestRecord> recNA = new Dictionary<int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recNAavg = new Dictionary <int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recNAmin = new Dictionary <int, EDSReportRequestRecord>();
            Dictionary <int, EDSReportRequestRecord> recNAmax = new Dictionary <int, EDSReportRequestRecord>();


            Dictionary <int, List <int> > napors = new Dictionary <int, List <int> >();;

            EDSReportRequestRecord recHAvg;
            EDSPointInfo           pointHAvg;

            pointHAvg = await EDSPointInfo.GetPointInfo("11VT_ST00A-034.MCR@GRARM");


            foreach (int gg in new int[] { 2, 6, 8, 9, 10 })
            {
                Logger.Info("Get points " + gg);

                //OutputData.InitOutput(String.Format("gg_{0}_{1}", gg,napor));
                napors.Add(gg, new List <int>());
                string ggS = gg < 10 ? "0" + gg.ToString() : gg.ToString();

                if ((new int[] { 3, 4, 5, 7 }).Contains(gg))
                {
                    iessP.Add(gg, String.Format("0{0}VT_LP01AO-03.MCR@GRARM", gg));
                    iessH.Add(gg, String.Format("0{0}VT_TC01A-11.MCR@GRARM", gg));
                    iessNA.Add(gg, String.Format("0{0}VT_GC01A-08.MCR@GRARM", gg));
                }
                else
                {
                    string suf = "";
                    if (gg <= 2)
                    {
                        suf = ".UNIT01@BLOCK1";
                    }
                    else if (gg <= 6)
                    {
                        suf = ".UNIT05@BLOCK3";
                    }
                    else if (gg <= 8)
                    {
                        suf = ".UNIT07@BLOCK4";
                    }
                    else if (gg <= 10)
                    {
                        suf = ".UNIT09@BLOCK5";
                    }
                    iessP.Add(gg, String.Format("{0}VT_LP02AO-03", ggS) + suf);
                    iessH.Add(gg, String.Format("{0}VT_GC00A-111", ggS) + suf);
                    //iessH.Add(gg, "11VT_ST00A - 034.MCR@GRARM");

                    iessNA.Add(gg, String.Format("{0}VT_GC03AI-04", ggS) + suf);
                }
                EDSPointInfo p = await EDSPointInfo.GetPointInfo(iessP[gg]);

                pointsP.Add(gg, p);

                p = await EDSPointInfo.GetPointInfo(iessH[gg]);

                pointsH.Add(gg, p);

                p = await EDSPointInfo.GetPointInfo(iessNA[gg]);

                pointsNA.Add(gg, p);
            }


            DateTime date = DateStart.AddMinutes(0);

            while (date < DateEnd)
            {
                DateTime ds = date.AddMinutes(0);
                DateTime de = date.AddHours(24);
                Logger.Info(string.Format("{0}-{1}", ds, de));
                recPavg.Clear();
                recPmin.Clear();
                recPmax.Clear();
                recH.Clear();
                //recNA.Clear();
                recNAavg.Clear();
                recNAmin.Clear();
                recNAmax.Clear();


                EDSReport report = new EDSReport(ds, de, EDSReportPeriod.minute5);
                foreach (int gg in new int[] { 2, 6, 8, 9, 10 })
                {
                    recPavg.Add(gg, report.addRequestField(pointsP[gg], EDSReportFunction.avg));
                    recPmin.Add(gg, report.addRequestField(pointsP[gg], EDSReportFunction.min));
                    recPmax.Add(gg, report.addRequestField(pointsP[gg], EDSReportFunction.max));
                    recH.Add(gg, report.addRequestField(pointsH[gg], EDSReportFunction.avg));
                    //recNA.Add(gg, report.addRequestField(pointsNA[gg], EDSReportFunction.avg));

                    recNAavg.Add(gg, report.addRequestField(pointsNA[gg], EDSReportFunction.avg));
                    recNAmin.Add(gg, report.addRequestField(pointsNA[gg], EDSReportFunction.min));
                    recNAmax.Add(gg, report.addRequestField(pointsNA[gg], EDSReportFunction.max));
                }
                recHAvg = report.addRequestField(pointHAvg, EDSReportFunction.avg);


                await report.ReadData();

                List <DateTime> resultDates = report.ResultData.Keys.ToList();
                foreach (DateTime dt in resultDates)
                {
                    foreach (int gg in new int[] { 2, 6, 8, 9, 10 })
                    {
                        double pAvg = report.ResultData[dt][recPavg[gg].Id];
                        double pMin = report.ResultData[dt][recPmin[gg].Id];
                        double pMax = report.ResultData[dt][recPmax[gg].Id];
                        double h    = report.ResultData[dt][recH[gg].Id];
                        double hAvg = report.ResultData[dt][recHAvg.Id];
                        //double na = report.ResultData[dt][recNA[gg].Id];

                        double naAvg = report.ResultData[dt][recNAavg[gg].Id];
                        double naMin = report.ResultData[dt][recNAmin[gg].Id];
                        double naMax = report.ResultData[dt][recNAmax[gg].Id];
                        if ((pMax - pMin > 2) || pMin < 5 || (naMax - naMin > 2))
                        {
                            continue;
                        }

                        int napor = 140;
                        while (napor < 240)
                        {
                            if (Math.Abs(napor / 10.0 - h) < 0.1)
                            {
                                if (!napors[gg].Contains(napor))
                                {
                                    napors[gg].Add(napor);
                                    OutputData.InitOutput(String.Format("gg_{0}_{1}", gg, napor));
                                }

                                OutputData.writeToOutput(String.Format("gg_{0}_{1}", gg, napor), string.Format("{0};{1};{2};{3};{4}", dt, h, hAvg, pAvg, naAvg));
                            }
                            napor += 5;
                        }


                        napor = 140;
                        while (napor < 240)
                        {
                            if (Math.Abs(napor / 10.0 - hAvg) < 0.1)
                            {
                                if (!napors[gg].Contains(napor))
                                {
                                    napors[gg].Add(napor);
                                    OutputData.InitOutput(String.Format("gg_hAVG_{0}_{1}", gg, napor));
                                }

                                OutputData.writeToOutput(String.Format("gg_hAVG_{0}_{1}", gg, napor), string.Format("{0};{1};{2};{3};{4}", dt, h, hAvg, pAvg, naAvg));
                            }
                            napor += 5;
                        }
                    }
                }
                date = de.AddMinutes(0);
            }
            return(true);
        }
コード例 #23
0
ファイル: Program.cs プロジェクト: rj128x/EDSProject2019
        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));
            }
        }
コード例 #24
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);
        }