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); }
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); }