Exemple #1
0
        private void UpdatePVSystemInfo(PVSystemInfo systemInfo)
        {
            try
            {
                if (!Looper.MainLooper.IsCurrentThread)
                {
                    RunOnUiThread(delegate { UpdatePVSystemInfo(systemInfo); });
                    return;
                }

                TextView systemSizeText  = FindViewById <TextView>(Resource.Id.system_size_text);
                TextView moduleCountText = FindViewById <TextView>(Resource.Id.module_count_text);

                if (systemInfo != null)
                {
                    systemSizeText.Text  = $"{systemInfo.SystemSize} kW/h";
                    moduleCountText.Text = $"{systemInfo.PanelCount}";
                }
                else
                {
                    systemSizeText.Text  = "...";
                    moduleCountText.Text = "...";
                }
            }
            catch (Exception e)
            {
                Log.Error(ToString(), e.ToString());
            }
        }
Exemple #2
0
        private async Task UpdateSummaryAsync()
        {
            var estDaily   = FindViewById <TextView>(Resource.Id.estimated_daily);
            var estMonthly = FindViewById <TextView>(Resource.Id.estimated_monthly);
            var estAnnual  = FindViewById <TextView>(Resource.Id.estimated_annual);

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

            var panelSummary = await systemInfo.GetPanelSummaryAsync(
                panel, powerCalc, pvWattsApiClient,
                new GeoCoords(sn.Latitude, sn.Longtitude),
                GetZenith(), DateTime.Now, GetTimeZoneOffset(),
                tempCelsius : 25.0);

            estDaily.Text   = (panelSummary.TodayDCArrayOutput).ToString("0.00") + "kW";
            estMonthly.Text = (panelSummary.MonthlyDCArrayOutput).ToString("0.00") + "kW";
            estAnnual.Text  = (panelSummary.AnnualDCArrayOutput).ToString("0.00") + "kW";
        }
Exemple #3
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());
            }
        }
Exemple #4
0
        private async Task <SystemSummary> GetArraySummaryAsync(WeatherInfo weatherInfo)
        {
            GeoCoords coords = new GeoCoords
            {
                Latitude  = solarNetwork.Latitude,
                Longitude = solarNetwork.Longtitude
            };

            TimeZone timeZone            = TimeZone.CurrentTimeZone;
            TimeSpan timeZoneOffset      = timeZone.GetUtcOffset(DateTime.Now);
            double   timeZoneOffsetHours = timeZoneOffset.Hours + timeZoneOffset.Minutes / 30.0;

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

            return(await systemInfo.GetSystemSummaryAsync(
                       powerCalculator,
                       pvWattsApiClient,
                       coords,
                       DateTime.Now,
                       timeZoneOffsetHours,
                       tempCelsius : weatherInfo.Temperature.Value - 273.15
                       ));
        }