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