示例#1
0
 public EDSReportRequestRecord(EDSPointInfo point, EDSReportFunction func)
 {
     this.Point    = point;
     this.Function = func;
     this.Id       = String.Format("{0} [{1}]", Point.IESS, Function);
     this.Desc     = String.Format("{0} [{1}]", Point.Desc, EDSClass.ReportFunctions[func]);
 }
示例#2
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);
        }
示例#3
0
 public void addRequestField(EDSPointInfo point, EDSReportFunction func)
 {
     try {
         EDSReportRequestRecord rec = new EDSReportRequestRecord(point, func);
         RequestData.Add(rec.Id, rec);
     } catch (Exception e) {
         Logger.Info(e.ToString());
     }
 }
        private void grdPoints_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try {
                EDSPointInfo           selPoint = grdPoints.SelectedItem as EDSPointInfo;
                EDSReportFunction      func     = (EDSReportFunction)cmbFunction.SelectedValue;
                EDSReportRequestRecord rec      = new EDSReportRequestRecord(selPoint, func);

                bool exists = SelectedPoints.Exists(req => req.Id == rec.Id);
                if (!exists)
                {
                    SelectedPoints.Add(rec);
                    lbSelPoints.Items.Refresh();
                }
            } catch { }
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
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);
        }