예제 #1
0
        static EDSClass()
        {
            Single        = new EDSClass();
            ReportPeriods = new Dictionary <EDSReportPeriod, string>();
            ReportPeriods.Add(EDSReportPeriod.sec, "Секунда");
            ReportPeriods.Add(EDSReportPeriod.sec5, "5 Секунда");
            ReportPeriods.Add(EDSReportPeriod.sec10, "10 Секунда");
            ReportPeriods.Add(EDSReportPeriod.sec15, "15 Секунда");
            ReportPeriods.Add(EDSReportPeriod.sec30, "30 Секунда");
            ReportPeriods.Add(EDSReportPeriod.minute, "Минута");
            ReportPeriods.Add(EDSReportPeriod.hour, "Час");
            ReportPeriods.Add(EDSReportPeriod.day, "Сутки");
            ReportPeriods.Add(EDSReportPeriod.month, "Месяц");
            ReportPeriods.Add(EDSReportPeriod.minute5, "5 минут");
            ReportPeriods.Add(EDSReportPeriod.minute10, "10 минут");
            ReportPeriods.Add(EDSReportPeriod.minute15, "15 минут");
            ReportPeriods.Add(EDSReportPeriod.minute30, "30 минут");

            ReportFunctions = new Dictionary <EDSReportFunction, string>();
            ReportFunctions.Add(EDSReportFunction.avg, "Среднее");
            ReportFunctions.Add(EDSReportFunction.vyrab, "Выработка");
            ReportFunctions.Add(EDSReportFunction.min, "Минимум");
            ReportFunctions.Add(EDSReportFunction.max, "Максимум");
            ReportFunctions.Add(EDSReportFunction.val, "Значение");
        }
예제 #2
0
        public static async Task <DateTime> getValNextDate(string iess, DateTime dateStart, DateTime dateEnd, string func, double limitVal)
        {
            TabularRequest req = new TabularRequest();

            req.period = new TimePeriod()
            {
                from = new Timestamp()
                {
                    second = EDSClass.toTS(dateStart)
                },
                till = new Timestamp()
                {
                    second = EDSClass.toTS(dateEnd)
                }
            };

            req.step = new TimeDuration()
            {
                seconds = (long)(dateEnd - dateStart).TotalSeconds
            };

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

            list.Add(new TabularRequestItem()
            {
                function = func,
                pointId  = new PointId()
                {
                    iess = iess
                },
                @params = new double[] { limitVal }
            });

            req.items = list.ToArray();
            uint id = 0;

            try
            {
                id = EDSClass.Client.requestTabular(EDSClass.AuthStr, req);
            }
            catch (Exception e)
            {
                Logger.Info(e.ToString());
            }
            TabularRow[] rows;
            bool         ok = await EDSClass.ProcessQueryAsync(id);

            PointId[] points = EDSClass.Client.getTabular(EDSClass.AuthStr, id, out rows);
            if (rows.Length > 0)
            {
                TabularRow row = rows[0];
                double     ts  = getVal(row.values[0].value);
                return(EDSClass.fromTS((long)ts));
            }
            else
            {
                return(dateEnd);
            }
        }
예제 #3
0
        protected async static Task <bool> LoadAnalogPointsFromServer()
        {
            _allAnalogPoints = new SortedList <string, EDSPointInfo>();
            try {
                if (!EDSClass.Connected)
                {
                    EDSClass.Connect();
                }
                PointFilter      filter = new PointFilter();
                List <PointType> types  = new List <PointType>();
                types.Add(PointType.POINTTYPEANALOG);
                types.Add(PointType.POINTTYPEPACKED);
                types.Add(PointType.POINTTYPEDOUBLE);
                types.Add(PointType.POINTTYPEINT64);
                filter.rt = types.ToArray();



                bool             finish = false;
                uint             index  = 0;
                getPointsRequest req    = new getPointsRequest();
                req.authString = EDSClass.AuthStr;
                req.filter     = filter;
                req.order      = "";

                EDSClass.Single.GlobalInfo  = "Получение списка точек";
                EDSClass.Single.Ready       = false;
                EDSClass.Single.ProcessCalc = true;
                uint match = 0;
                while (!finish)
                {
                    req.maxCount = 1000;
                    req.startIdx = index;
                    EDSClass.Single.ProcessInfo = String.Format("Точки {0} - {1} из {2}", req.startIdx, req.startIdx + req.maxCount, (match == 0 ? "?" : match.ToString()));
                    getPointsResponse resp = await EDSClass.Client.getPointsAsync(req);

                    //Point[] points = EDSClass.Client.getPoints(EDSClass.AuthStr, filter, "", index, 1000, out cnt, out total);
                    foreach (Point point in resp.points)
                    {
                        try {
                            string tg = string.Join(";", point.tg);
                            _allAnalogPoints.Add(point.id.iess, new EDSPointInfo(point.id.iess, point.desc, tg));
                        } catch { }
                    }
                    index += (uint)resp.points.Count();
                    finish = index >= resp.matchCount;
                    match  = resp.matchCount;
                }
            } catch (Exception e) {
                Logger.Info(("Ошибка при получении списка точек: " + e.ToString()));
            } finally {
                EDSClass.Single.Ready       = true;
                EDSClass.Single.ProcessCalc = false;
            }
            return(true);
        }
예제 #4
0
        public static async Task <double> getValFromServer(string iess, DateTime date)
        {
            TabularRequest req = new TabularRequest();

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

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

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

            list.Add(new TabularRequestItem()
            {
                function = "VALUE",
                pointId  = new PointId()
                {
                    iess = iess
                },
                shadePriority = ShadePriority.REGULAROVERSHADE
            });

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

            TabularRow[] rows;
            bool         ok = await EDSClass.ProcessQueryAsync(id);

            PointId[]  points = EDSClass.Client.getTabular(EDSClass.AuthStr, id, out rows);
            double     val    = Double.MinValue;
            TabularRow row    = rows[0];

            {
                val = getVal(row.values[0].value);
            }
            return(val);
        }
예제 #5
0
        public bool writeToEDS(string pointName, SortedList <DateTime, double> data, bool data15, bool datamin, bool data60)
        {
            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 if (data60)
                    {
                        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(3))
                                    }
                                },
                                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);
                            if (d.Date != d.AddMinutes(1).Date)
                            {
                                sum = 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);
        }