Ejemplo n.º 1
0
 private static IEnumerable <GetPvPowerForecastsResponse> PowerForecasts(IEnumerable <Location> locations)
 {
     using (var client = new SolcastClient())
     {
         return(locations.Select(location => client.GetPvPowerForecasts(location)).ToList());
     }
 }
Ejemplo n.º 2
0
 private static async Task <GetPvPowerForecastsResponse> PowerForecastAsync(Location location)
 {
     using (var client = new SolcastClient())
     {
         return(await client.GetPvPowerForecastsAsync(location));
     }
 }
Ejemplo n.º 3
0
 private static GetPvPowerForecastsResponse PowerForecast(Location location)
 {
     using (var client = new SolcastClient())
     {
         client.RateLimitExceededFn = message =>
         {
             // Custom Action code to place if RateLimit has been exceeded
         };
         return(client.GetPvPowerForecasts(location));
     }
 }
Ejemplo n.º 4
0
        public void TestPowerLatestEstimatedActuals()
        {
            var location = Places.Sydney();

            Debug.WriteLine(location.Dump());
            using (var client = new SolcastClient())
            {
                var results = client.GetLatestPvPowerEstimatedActuals(location);
                Assert.NotNull(results);
                Assert.NotNull(results.EstimatedActuals);
            }
        }
Ejemplo n.º 5
0
        private static IEnumerable <GetPvPowerForecastsResponse> BatchedPowerForecasts(IEnumerable <Location> locations)
        {
            var results = new List <GetPvPowerForecastsResponse>();

            using (var client = new SolcastClient())
            {
                Parallel.ForEach(locations, location =>
                {
                    results.Add(client.GetPvPowerForecasts(location));
                });
            }
            return(results);
        }
Ejemplo n.º 6
0
        public void TestPowerForecast()
        {
            var location = Places.Sydney();

            Debug.WriteLine(location.Dump());

            using (var client = new SolcastClient())
            {
                var results = client.GetPvPowerForecasts(location);
                Assert.NotNull(results);
                Assert.NotNull(results.Forecasts);
                Assert.True(results.Forecasts.Count == ForecastDefault.Count);
            }
        }
Ejemplo n.º 7
0
        public void TestRadiationLatestEstimatedActuals()
        {
            var location = Places.Sydney();

            Debug.WriteLine(location.Dump());
            Task.Run(async() =>
            {
                using (var client = new SolcastClient())
                {
                    var results = await client.GetLatestRadiationEstimatedActualsAsync(location);
                    Assert.NotNull(results);
                    Assert.NotNull(results.EstimatedActuals);
                }
            }).Wait();
        }
Ejemplo n.º 8
0
        private static GetPvPowerForecastsResponse WaitRetryPowerForecast(Location location)
        {
            // Set a policy on WebServiceExceptions with StatusCode of 429 to wait and retry the request again in 5 seconds
            var policy = Policy
                         .Handle <WebServiceException>(z => z.StatusCode == 429)
                         .WaitAndRetry(new[] { TimeSpan.FromSeconds(5) });

            return(policy.Execute(() =>
            {
                using (var client = new SolcastClient())
                {
                    return client.GetPvPowerForecasts(location);
                }
            }));
        }
Ejemplo n.º 9
0
        public void TestRadiationForecast()
        {
            var location = Places.Sydney();

            Debug.WriteLine(location.Dump());
            Task.Run(async() =>
            {
                using (var client = new SolcastClient())
                {
                    var results = await client.GetRadiationForecastsAsync(location);
                    Assert.NotNull(results);
                    Assert.NotNull(results.Forecasts);
                    Assert.True(results.Forecasts.Count == ForecastDefault.Count);
                }
            }).Wait();
        }