private async void GetData() { var yAxis = new DateTimeAxis(); byte c = 0; foreach (var address in AddressList) { var i = address.IndexOf('.'); var deviceAdress = address.Substring(0, i); var objectAdress = address.Substring(i + 1, address.Length - i - 1); string requestUrl = string.Format("{0}/{1}/{2}/history", HistoryUri, deviceAdress, objectAdress ); var a = await _dataTransport.GetRequestAsync <Dictionary <DateTime, string> >(requestUrl, true, 30000); if (a == null || a.Count == 0) { continue; } var model = new GraphModel { Address = address, Color = _graphColours[c % _graphColours.Count()], Name = UnitsList[c], Times = a.Keys.ToList(), Values = a.Values.Select(val => double.Parse(val.Replace('.', ','))).ToList() }; var xDs = new EnumerableDataSource <DateTime>(model.Times); var yDs = new EnumerableDataSource <double>(model.Values); model.MinValue = model.Values.Min() - 1; model.MaxValue = model.Values.Max() + 1; //set the mappings xDs.SetXMapping(x => yAxis.ConvertToDouble(x)); yDs.SetYMapping(y => y); model.PointDataSource = new CompositeDataSource(xDs, yDs); Graphs.Add(model); c++; } }
private async void GetData() { var yAxis = new DateTimeAxis(); byte c = 0; foreach (var address in AddressList) { var i = address.IndexOf('.'); var deviceAdress = address.Substring(0, i); var objectAdress = address.Substring(i + 1, address.Length - i - 1); string requestUrl = string.Format("{0}/{1}/{2}/history", HistoryUri, deviceAdress, objectAdress ); var a = await _dataTransport.GetRequestAsync<Dictionary<DateTime, string>>(requestUrl, true, 30000); if (a == null || a.Count == 0) continue; var model = new GraphModel { Address = address, Color = _graphColours[c%_graphColours.Count()], Name = UnitsList[c], Times = a.Keys.ToList(), Values = a.Values.Select(val => double.Parse(val.Replace('.', ','))).ToList() }; var xDs = new EnumerableDataSource<DateTime>(model.Times); var yDs = new EnumerableDataSource<double>(model.Values); model.MinValue = model.Values.Min() - 1; model.MaxValue = model.Values.Max() + 1; //set the mappings xDs.SetXMapping(x => yAxis.ConvertToDouble(x)); yDs.SetYMapping(y => y); model.PointDataSource = new CompositeDataSource(xDs, yDs); Graphs.Add(model); c++; } }
public void AppendValues(double L, double a, double b, double C, double H, double T) { DateTimeAxis axis = new DateTimeAxis(); double time = axis.ConvertToDouble(DateTime.Now); Point p1 = new Point(time, L); Point p2 = new Point(time, a); Point p3 = new Point(time, b); Point p4 = new Point(time, C); Point p5 = new Point(time, H); Point p6 = new Point(time, T); SourceL.AppendAsync(App.Current.Dispatcher, p1); SourceA.AppendAsync(App.Current.Dispatcher, p2); SourceB.AppendAsync(App.Current.Dispatcher, p3); SourceC.AppendAsync(App.Current.Dispatcher, p4); SourceH.AppendAsync(App.Current.Dispatcher, p5); SourceT.AppendAsync(App.Current.Dispatcher, p6); Thread.Sleep(10); }