private void CreateChart(DeviceLogsInChartFormat chartData) { PlotModel plotModel = new PlotModel(); plotModel.Title = chartData.ChartName; LinearAxis xAxis = new LinearAxis(); xAxis.Position = AxisPosition.Bottom; xAxis.Title = chartData.AxesNames[0].ToLower(); plotModel.Axes.Add(xAxis); for (var y = 1; y < chartData.AxesNames.Length; y++) { var seria = new LineSeries(); var points = chartData.Logs.Select(log => { return(new DataPoint(log.Values[0], log.Values[y])); }); seria.Points.AddRange(points); seria.Title = chartData.AxesNames[y].ToLower(); plotModel.Series.Add(seria); } PlotModel = plotModel; PlotModel.InvalidatePlot(true); }
public DeviceLogsInChartFormat PrepareDataForUI(List <DeviceLog> serializedLogs) { DeviceLogsInChartFormat uiData = new DeviceLogsInChartFormat { ChartName = this.PluginPurpose, Logs = new List <Log>(), AxesNames = AxesNames }; DeserealizeLogsAndAddToChartsData(serializedLogs, uiData); return(uiData); }
public async Task <IActionResult> GetLogs(int?utcDate, bool isInitial, string deviceName = "SamsungDPlugin") { try { if (!isInitial) { _collectionOfLogs.resetEvent.WaitOne(); } var logs = await _devicesLogsService.GetDeviceLogsAsync(utcDate); DeviceLogsInChartFormat logsForUI = _devicesLogsService.PrepareLogsForUI(logs, deviceName); return(new JsonResult(new { StatusCode = StatusCodes.Status200OK, ChartData = logsForUI })); } catch (Exception ex) { //Debugger.Break(); Console.WriteLine(ex.Message); return(BadRequest(ex.Message)); } }
private void DeserealizeLogsAndAddToChartsData(List <DeviceLog> serializedLogs, DeviceLogsInChartFormat uiData) { List <XiomiLog> XiomiLogs = new List <XiomiLog>(); foreach (var log in serializedLogs) { DeviceData deviceData = ByteArrayToCharacteristics(log.Message); XiomiLogs.Add(new XiomiLog() { Hour = log.DateStamp.Hour, Preasure = deviceData.Preasure, }); } GroupLogsByHour(XiomiLogs, uiData.Logs); }
private void DeserealizeLogsAndAddToChartsData(List <DeviceLog> serializedLogs, DeviceLogsInChartFormat uiData) { List <SamsungLog> samsungLogs = new List <SamsungLog>(); foreach (var log in serializedLogs) { DeviceData deviceData = ByteArrayToCharacteristics(log.Message); samsungLogs.Add(new SamsungLog() { Hour = log.DateStamp.Hour, Temperature = deviceData.Temperature, Humidity = deviceData.Humidity }); } GroupLogsByHour(samsungLogs, uiData.Logs); }