public void UpdateCharts(double t, double temp, double hum, double press) { LineSeries TemperatureLineSeries = TemperaturePlotModel.Series[0] as LineSeries; LineSeries HumidityLineSeries = HumidityPlotModel.Series[0] as LineSeries; LineSeries PressureLineSeries = PressurePlotModel.Series[0] as LineSeries; TemperatureLineSeries.Points.Add(new DataPoint(t, temp)); HumidityLineSeries.Points.Add(new DataPoint(t, hum)); PressureLineSeries.Points.Add(new DataPoint(t, press)); if (TemperatureLineSeries.Points.Count > Config.MaxSamples || HumidityLineSeries.Points.Count > Config.MaxSamples || PressureLineSeries.Points.Count > Config.MaxSamples) { TemperatureLineSeries.Points.RemoveAt(0); HumidityLineSeries.Points.RemoveAt(0); PressureLineSeries.Points.RemoveAt(0); } if (t >= Config.XAxisMax) { TemperaturePlotModel.Axes[0].Minimum = (t - Config.XAxisMax); TemperaturePlotModel.Axes[0].Maximum = t + Config.SampleTime / 1000.0; HumidityPlotModel.Axes[0].Minimum = (t - Config.XAxisMax); HumidityPlotModel.Axes[0].Maximum = t + Config.SampleTime / 1000.0; PressurePlotModel.Axes[0].Minimum = (t - Config.XAxisMax); PressurePlotModel.Axes[0].Maximum = t + Config.SampleTime / 1000.0; } TemperaturePlotModel.InvalidatePlot(true); HumidityPlotModel.InvalidatePlot(true); PressurePlotModel.InvalidatePlot(true); }
private void StartTimer() { if (RequestTimer == null) { RequestTimer = new Timer(Config.SampleTime); RequestTimer.Elapsed += new ElapsedEventHandler(RequestTimerElapsed); RequestTimer.Enabled = true; TemperaturePlotModel.ResetAllAxes(); HumidityPlotModel.ResetAllAxes(); PressurePlotModel.ResetAllAxes(); } }