コード例 #1
0
ファイル: NetworkActivity.cs プロジェクト: veselink1/SunRays
        private async void BeginInitialize()
        {
            // Setup the database.
            db = new DatabaseHelper(this);
            // Use the intent values to bind to a specific network ID.
            long networkID = Intent.GetLongExtra(EXTRA_NETWORK_ID, -1);

            if (networkID != -1)
            {
                solarNetwork = await db.SolarNetworks.SelectByIdAsync(networkID);

                SupportActionBar.Title = solarNetwork.Name;
            }
            else
            {
                throw new InvalidProgramException();
            }

            // Get the weather service.
            weatherProvider = ServiceManager.Resolve <IWeatherProvider>();
            // Get the calculator service.
            powerCalculator = ServiceManager.Resolve <IPowerCalculator>();
            // Initialize the PVWatts Client.
            pvWattsApiClient = new PVWattsV5ApiClient(apiKey: Secrets.PVWattsApiKey);

            // Setup the network card
            InitializeCards();
        }
コード例 #2
0
ファイル: PVSystemInfo.cs プロジェクト: veselink1/SunRays
        public async Task <SystemSummary> GetSystemSummaryAsync(IPowerCalculator powerCalculator, PVWattsV5ApiClient pvWattsApiClient, GeoCoords coords, DateTime dateTime, double timeZoneOffsetHours, double tempCelsius)
        {
            double azmuth          = powerCalculator.CalculateAizmuth(coords, dateTime, timeZoneOffsetHours);
            int    totalPanelCount = Panels.Count;

            IEnumerable <Task <SystemSummary> > summaryPerTypeTask =
                Panels.Select(x => GetPanelSummaryAsync(x, powerCalculator, pvWattsApiClient, coords, azmuth, dateTime, timeZoneOffsetHours, tempCelsius));

            return((await Task.WhenAll(summaryPerTypeTask)).Aggregate(new SystemSummary {
            }, (acc, x) =>
            {
                return new SystemSummary
                {
                    HourlyDCArrayOutput = acc.HourlyDCArrayOutput + x.HourlyDCArrayOutput,
                    TodayDCArrayOutput = acc.TodayDCArrayOutput + x.TodayDCArrayOutput,
                    MonthlyDCArrayOutput = acc.MonthlyDCArrayOutput + x.MonthlyDCArrayOutput,
                    AnnualDCArrayOutput = acc.AnnualDCArrayOutput + x.AnnualDCArrayOutput,
                };
            }));
        }
コード例 #3
0
ファイル: PVSystemInfo.cs プロジェクト: veselink1/SunRays
        public async Task <SystemSummary> GetPanelSummaryAsync(Panel panel, IPowerCalculator powerCalculator, PVWattsV5ApiClient pvWattsApiClient, GeoCoords coords, double azmuth, DateTime dateTime, double timeZoneOffsetHours, double tempCelsius)
        {
            int    count        = panel.Count;
            double powerLoss    = powerCalculator.CalculateModulePowerLoss(panel.ModuleType, tempCelsius);
            var    pvSystemInfo = await pvWattsApiClient.GetSystemInfoCachedAsync(
                ID,
                panel.PowerRating,
                panel.ModuleType,
                panel.ArrayType,
                systemLosses : powerLoss,
                tilt : panel.TiltAngle,
                azmuth : azmuth,
                coords : coords
                );

            double hourly                = pvSystemInfo.GetHourlyDCArrayOutput(dateTime);
            double hourlyWithLosses      = hourly - (hourly * powerLoss);
            double totalHourlyWithLosses = hourlyWithLosses * count;

            double today           = pvSystemInfo.GetDailyDCArrayOutput(dateTime);
            double todayWithLosses = today - (today * powerLoss);

            double monthly                = pvSystemInfo.GeMonthlyDCArrayOutput(dateTime);
            double monthlyWithLosses      = monthly - (monthly * powerLoss);
            double totalMonthlyWithLosses = monthlyWithLosses * count;

            double annual                = pvSystemInfo.AnnualDCArrayOutput;
            double annualWithLosses      = annual - (annual * powerLoss);
            double totalAnnualWithLosses = annualWithLosses * count;

            return(new SystemSummary
            {
                HourlyDCArrayOutput = totalHourlyWithLosses,
                TodayDCArrayOutput = todayWithLosses,
                MonthlyDCArrayOutput = totalMonthlyWithLosses,
                AnnualDCArrayOutput = totalAnnualWithLosses
            });
        }