public async Task StartUpdateAsync() { List <Entry> temperatureEntries = new List <Entry>(); List <Entry> waterLevelEntries = new List <Entry>(); Entry initialWaterLevel = ClimateMetricService.GetWaterTankLevelEntry(_cooltainerId); waterLevelEntries.Add(initialWaterLevel); var temperatureChartView = FindViewById <ChartView>(Resource.Id.temperatureChartView1); var humidityChartView = FindViewById <ChartView>(Resource.Id.humidityChartView1); var co2ChartView = FindViewById <ChartView>(Resource.Id.co2ChartView1); var pressureChartView = FindViewById <ChartView>(Resource.Id.pressureChartView1); var waterLevelChartView = FindViewById <ChartView>(Resource.Id.waterLevelChartView1); while (true) { UpdateTemperature(temperatureEntries, temperatureChartView); UpdateHumidity(humidityChartView); UpdateCo2(co2ChartView); UpdatePressure(pressureChartView); UpdateWaterLevel(waterLevelEntries, waterLevelChartView); await Task.Delay(1000); } }
private void UpdatePressure(ChartView pressureChartView) { List <Entry> pressureEntries = ClimateMetricService.GetPressureEntryList(_cooltainerId); pressureChartView.Chart = new DonutChart() { Entries = pressureEntries }; }
private void UpdateCo2(ChartView co2ChartView) { List <Entry> co2Entries = ClimateMetricService.GetCo2LevelEntryList(_cooltainerId); co2ChartView.Chart = new DonutChart() { Entries = co2Entries }; }
private void UpdateHumidity(ChartView humidityChartView) { List <Entry> humidityEntries = ClimateMetricService.GetHumidityEntryList(_cooltainerId); humidityChartView.Chart = new DonutChart() { Entries = humidityEntries }; }
private void UpdateTemperature(List <Entry> temperatureEntries, ChartView temperatureChartView) { Entry latestTemp = ClimateMetricService.GetTemperatureEntry(_cooltainerId); temperatureEntries.Add(latestTemp); TrimGraphToTimespan(temperatureEntries); temperatureChartView.Chart = new LineChart() { Entries = temperatureEntries }; }
private void UpdateWaterLevel(List <Entry> waterLevelEntries, ChartView waterLevelChartView) { var latestWaterLevel = waterLevelEntries.Last().Value > 0 ? waterLevelEntries.Last().Value - 1 : 0; Entry latestWaterLevelEntry = ClimateMetricService.GetWaterTankLevelEntry(latestWaterLevel); waterLevelEntries.Add(latestWaterLevelEntry); TrimGraphToTimespan(waterLevelEntries); waterLevelChartView.Chart = new LineChart() { Entries = waterLevelEntries }; }