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

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

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

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

            dataLvl = new SortedList <DateTime, double>();
            dataP   = new SortedList <DateTime, double>();
            foreach (DateTime dt in report.ResultData.Keys)
            {
                dataLvl.Add(dt, report.ResultData[dt][recLvl.Id]);
                dataP.Add(dt, report.ResultData[dt][recP.Id]);
            }
            return(true);
        }
Ejemplo n.º 2
0
        public async Task <bool> ReadData(string GG)
        {
            report   = new EDSReport(DateStart.AddSeconds(0), DateEnd, EDSReportPeriod.minute);
            recF     = report.addRequestField(AllPoints[GG + "VT_GC01A-16.MCR@GRARM"], EDSReportFunction.val);
            recL_OGA = report.addRequestField(AllPoints[GG + "VT_PS00A-03.MCR@GRARM"], EDSReportFunction.val);
            recL_AGA = report.addRequestField(AllPoints[GG + "VT_PS00A-11.MCR@GRARM"], EDSReportFunction.val);
            recL_SB  = report.addRequestField(AllPoints[GG + "VT_PS00A-05.MCR@GRARM"], EDSReportFunction.val);
            recL_LB  = report.addRequestField(AllPoints[GG + "VT_PS00AI-07.MCR@GRARM"], EDSReportFunction.val);
            recL_NA  = report.addRequestField(AllPoints[GG + "VT_GC02A-86.MCR@GRARM"], EDSReportFunction.val);
            recL_RK  = report.addRequestField(AllPoints[GG + "VT_GC02A-68.MCR@GRARM"], EDSReportFunction.val);

            recD_MNU1 = report.addRequestField(AllPoints[GG + "VT_PS01DI-01.MCR@GRARM"], EDSReportFunction.max);
            recD_MNU2 = report.addRequestField(AllPoints[GG + "VT_PS02DI-01.MCR@GRARM"], EDSReportFunction.max);
            recD_MNU3 = report.addRequestField(AllPoints[GG + "VT_PS03DI-01.MCR@GRARM"], EDSReportFunction.max);

            recD_LA1 = report.addRequestField(AllPoints[GG + "VT_PS04DI-01.MCR@GRARM"], EDSReportFunction.max);
            recD_LA2 = report.addRequestField(AllPoints[GG + "VT_PS05DI-01.MCR@GRARM"], EDSReportFunction.max);

            recT_SB = report.addRequestField(AllPoints[GG + "VT_PS00A-21.MCR@GRARM"], EDSReportFunction.val);



            bool ok = await report.ReadData();

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


            return(ok);
        }
Ejemplo n.º 3
0
        public async Task <Dictionary <string, SortedList <DateTime, double> > > getGaData(DateTime dateStart, DateTime dateEnd)
        {
            Dictionary <string, SortedList <DateTime, double> > result = new Dictionary <string, SortedList <DateTime, double> >();
            EDSReportPeriod period = EDSReportPeriod.sec;
            EDSReport       report = new EDSReport(dateStart, dateEnd, period, true);

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

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

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

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

            bool ok = await report.ReadData();

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

            int indexVG = 0;

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

                result.Add(report.RequestData[key].Desc, data);
            }
            return(result);
        }
Ejemplo n.º 4
0
        protected static DateTime readDateFromGRARM(EDSReport rep, DateTime dtRep,
                                                    EDSReportRequestRecord rYear, EDSReportRequestRecord rMonth, EDSReportRequestRecord rDay,
                                                    EDSReportRequestRecord rHour, EDSReportRequestRecord rMin)
        {
            int      year   = (int)rep.ResultData[dtRep][rYear.Id];
            int      month  = (int)rep.ResultData[dtRep][rMonth.Id];
            int      day    = (int)rep.ResultData[dtRep][rDay.Id];
            int      hour   = (int)rep.ResultData[dtRep][rHour.Id];
            int      min    = (int)rep.ResultData[dtRep][rMin.Id];
            DateTime result = new DateTime(2000 + year, month, day, hour, min, 0);

            return(result);
        }
Ejemplo n.º 5
0
        public async Task <bool> ReadData(DateTime dateStart, DateTime dateEnd, int zvnMax, int tPlanMax, int winSize)
        {
            DateStart = dateStart;
            DateEnd   = dateEnd;
            EDSReportPeriod period = EDSReportPeriod.sec;

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

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

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

            bool ok = await report.ReadData();

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

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

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

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

                Dictionary <string, double> dataRec = report.ResultData[date];
                rec.PFakt       = dataRec[records["PFakt"].Id];
                rec.PPlan       = dataRec[records["PPlan"].Id];
                rec.PZVN        = dataRec[records["PZVN"].Id];
                rec.PPerv       = dataRec[records["PPerv"].Id];
                rec.GGCount     = (int)dataRec[records["GGCount"].Id];
                rec.SumGroupZad = dataRec[records["PZad"].Id] - rec.PZVN;
                rec.ResursZagr  = dataRec[records["ResursZagr"].Id];
                rec.ResursRazgr = dataRec[records["ResursRazgr"].Id];
                rec.PMinMaket   = dataRec[records["PMinMaket"].Id];
                rec.PMaxMaket   = dataRec[records["PMaxMaket"].Id];
            }
            checkErrors(zvnMax, tPlanMax, winSize);
            return(true);
        }
Ejemplo n.º 6
0
        public override async Task <bool> ReadData(string GG)
        {
            report = new EDSReport(DateStart.AddSeconds(0), DateEnd, EDSReportPeriod.minute);

            recTUp  = report.addRequestField(AllPoints[GG + "VT_BG01RI-25.MCR@GRARM"], EDSReportFunction.val);
            recTDn  = report.addRequestField(AllPoints[GG + "VT_BG01RI-26.MCR@GRARM"], EDSReportFunction.val);
            recLvl1 = report.addRequestField(AllPoints[GG + "VT_BG01AI-01.MCR@GRARM"], EDSReportFunction.val);
            recLvl2 = report.addRequestField(AllPoints[GG + "VT_BG01AI-02.MCR@GRARM"], EDSReportFunction.val);
            recF    = report.addRequestField(AllPoints[GG + "VT_GC01A-16.MCR@GRARM"], EDSReportFunction.val);

            bool ok = await report.ReadData();

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


            return(ok);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        protected async Task <Dictionary <DateTime, SDPMDKRecord> > ReadDataGOU(DateTime dateStart, DateTime dateEnd, string GOU, bool accept, Dictionary <string, EDSPointInfo> PointsRef)
        {
            EDSReport report = new EDSReport(dateStart, dateEnd.AddMinutes(1), EDSReportPeriod.sec);
            EDSReportRequestRecord recDKCRC        = null;
            EDSReportRequestRecord recDKManTrigger = null;
            EDSReportRequestRecord recDKIDAuto     = null;
            EDSReportRequestRecord recDKIDMan      = null;

            if (accept)
            {
                recDKIDAuto = report.addRequestField(PointsRef["DKIDAuto"], EDSReportFunction.val);
                recDKIDMan  = report.addRequestField(PointsRef["DKIDMan"], EDSReportFunction.val);
            }
            else
            {
                recDKCRC        = report.addRequestField(PointsRef["DKCRC"], EDSReportFunction.val);
                recDKManTrigger = report.addRequestField(PointsRef["DKManTrigger"], EDSReportFunction.val);
            }
            bool ok = await report.ReadData();

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

            SortedList <DateTime, bool> DKDates = new SortedList <DateTime, bool>();
            double prevID           = -1;
            double prevIDMan        = -1;
            double prevIDAuto       = -1;
            double prevDKManTrigger = -1;

            foreach (DateTime date in dates)
            {
                DateTime dt = date;
                if (date > dateEnd)
                {
                    break;
                }
                if (accept)
                {
                    double idMan  = report.ResultData[date][recDKIDMan.Id];
                    double idAuto = report.ResultData[date][recDKIDAuto.Id];
                    bool   man    = false;
                    if (idMan != prevIDMan && prevIDMan != -1 && idMan != 0)
                    {
                        while (DKDates.ContainsKey(dt))
                        {
                            dt = dt.AddMilliseconds(1);
                        }
                        DKDates.Add(dt, false);
                        man = true;
                    }

                    if (idAuto != prevIDAuto && prevIDAuto != -1 && idAuto != 0 && !man)
                    {
                        while (DKDates.ContainsKey(dt))
                        {
                            dt = dt.AddMilliseconds(1);
                        }
                        DKDates.Add(dt, true);
                    }
                    prevIDMan  = idMan;
                    prevIDAuto = idAuto;
                }
                else
                {
                    double id           = report.ResultData[date][recDKCRC.Id];
                    double dkManTrigger = report.ResultData[date][recDKManTrigger.Id];

                    if (id != prevID && prevID != -1 && id != 0)
                    {
                        while (DKDates.ContainsKey(dt))
                        {
                            dt = dt.AddMilliseconds(1);
                        }
                        DKDates.Add(dt, true);
                    }

                    if (dkManTrigger > 0.9 && prevDKManTrigger < 0.9)
                    {
                        while (DKDates.ContainsKey(dt))
                        {
                            dt = dt.AddMilliseconds(1);
                        }
                        DKDates.Add(dt, false);
                    }

                    prevID           = id;
                    prevDKManTrigger = dkManTrigger;
                }
            }

            Dictionary <DateTime, SDPMDKRecord> ResultData = new Dictionary <DateTime, SDPMDKRecord>();

            foreach (KeyValuePair <DateTime, bool> dd in DKDates)
            {
                DateTime  date  = dd.Key.AddMilliseconds(-dd.Key.Millisecond);
                EDSReport repDK = new EDSReport(date, date.AddSeconds(5), EDSReportPeriod.sec);
                Dictionary <string, EDSReportRequestRecord> repRecords = new Dictionary <string, EDSReportRequestRecord>();
                foreach (KeyValuePair <string, EDSPointInfo> de in PointsRef)
                {
                    EDSReportRequestRecord rec = repDK.addRequestField(PointsRef[de.Key], EDSReportFunction.val);
                    repRecords.Add(de.Key, rec);
                }
                ok = await repDK.ReadData();

                SDPMDKRecord DKRecord = new SDPMDKRecord();
                DKRecord.DKTrigger = date;
                DKRecord.DKTime    = readDateFromGRARM(repDK, date.AddSeconds(4),
                                                       repRecords["DKYear"], repRecords["DKMonth"], repRecords["DKDay"],
                                                       repRecords["DKHour"], repRecords["DKMin"]);
                DKRecord.DKStartTime = readDateFromGRARM(repDK, date.AddSeconds(4),
                                                         repRecords["DKStartYear"], repRecords["DKStartMonth"], repRecords["DKStartDay"],
                                                         repRecords["DKStartHour"], repRecords["DKStartMin"]);
                DKRecord.DKEndTime = readDateFromGRARM(repDK, date.AddSeconds(4),
                                                       repRecords["DKEndYear"], repRecords["DKEndMonth"], repRecords["DKEndDay"],
                                                       repRecords["DKEndHour"], repRecords["DKEndMin"]);
                DKRecord.DKVal     = repDK.ResultData[date.AddSeconds(4)][repRecords["DKVal"].Id];
                DKRecord.DKNum     = (int)repDK.ResultData[date.AddSeconds(4)][repRecords["DKNum"].Id];
                DKRecord.GOU       = GOU;
                DKRecord.AutoDK    = dd.Value;
                DKRecord.DKAutoStr = dd.Value ? "A" : "M";
                while (ResultData.ContainsKey(date))
                {
                    date = date.AddMilliseconds(1);
                }
                ResultData.Add(date, DKRecord);

                switch (DKRecord.DKNum)
                {
                case 1:
                    DKRecord.DK = "Работать по ПДГ";
                    break;

                case 2:
                    DKRecord.DK = String.Format("На {0:0.0} МВт выше ПДГ", DKRecord.DKVal);
                    break;

                case 3:
                    DKRecord.DK = String.Format("На {0:0.0} МВт ниже ПДГ", DKRecord.DKVal);
                    break;

                case 4:
                    DKRecord.DK = String.Format("Генерация {0:0.0} МВт ", DKRecord.DKVal);
                    break;
                }
            }
            return(ResultData);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
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();
        }
Ejemplo n.º 12
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);
        }