예제 #1
0
        private void UpdateArraySummary(SystemSummary systemInfo, ConsumerInfo consumerInfo = null)
        {
            try
            {
                View summaryCard = FindViewById <View>(Resource.Id.production_card_bg_root);

                TextView productionHourlyText  = FindViewById <TextView>(Resource.Id.production_per_hour);
                TextView productionTodayText   = FindViewById <TextView>(Resource.Id.production_daily);
                TextView productionMonthlyText = FindViewById <TextView>(Resource.Id.production_per_month);
                TextView productionAnnualText  = FindViewById <TextView>(Resource.Id.production_per_year);

                if (systemInfo != null)
                {
                    productionHourlyText.Text  = systemInfo.HourlyDCArrayOutput.ToString("0.00") + " kW";
                    productionTodayText.Text   = systemInfo.TodayDCArrayOutput.ToString("0.00") + " kW";
                    productionMonthlyText.Text = systemInfo.MonthlyDCArrayOutput.ToString("0.00") + " kW";
                    productionAnnualText.Text  = systemInfo.AnnualDCArrayOutput.ToString("0.00") + " kW";

                    if (consumerInfo != null)
                    {
                        if (consumerInfo.TotalUsage >= systemInfo.TodayDCArrayOutput)
                        {
                            summaryCard.SetBackgroundResource(Resource.Color.md_red_100);
                        }
                        else
                        {
                            summaryCard.SetBackgroundResource(Resource.Color.md_green_100);
                        }
                    }
                }
                else
                {
                    productionHourlyText.Text  = "...";
                    productionTodayText.Text   = "...";
                    productionMonthlyText.Text = "...";
                    productionAnnualText.Text  = "...";
                }
            }
            catch (Exception e)
            {
                Log.Error(ToString(), e.ToString());
            }
        }
예제 #2
0
        private async Task UpdateCardsAsync()
        {
            try
            {
                bool hasConnection = await CheckInternetConnectionAsync();

                if (!hasConnection)
                {
                    Snackbar.Make(FindViewById(Resource.Id.main_content), "No internet connection.", Snackbar.LengthShort).Show();
                    CallOnReconnect(async delegate { await UpdateCardsAsync(); });
                    return;
                }

                GeoCoords geoCoords = new GeoCoords {
                    Latitude = solarNetwork.Latitude, Longitude = solarNetwork.Longtitude
                };

                PVSystemInfo systemInfo = await PVSystemInfo.FromDBAsync(db, solarNetwork.ID);

                UpdatePVSystemInfo(systemInfo);

                WeatherInfo weatherInfo = await weatherProvider.GetWeatherInfoAsync(geoCoords);

                UpdateWeatherInfoView(weatherInfo);

                ConsumerInfo consumerInfo = await ConsumerInfo.FromDBAsync(db, solarNetwork.ID);

                UpdateConsumerInfo(consumerInfo);

                SystemSummary arraySummary = await GetArraySummaryAsync(weatherInfo);

                UpdateArraySummary(arraySummary, consumerInfo);
            }
            catch (Exception e)
            {
                Log.Error(ToString(), e.ToString());
            }
        }