public void TestGetGenerationMixAndSystemWideEmissionsResults()
        {
            // Arrange
            var regionAbbreviation = "PJM";
            EmissionsApiInteraction emissionsApiInteraction = new EmissionsApiInteraction(selfThrottlingMethod, maxNumberOfCallsPerMinute);

            // Act
            var pointsReturned = emissionsApiInteraction.GetGenerationMixAndSystemWideEmissionsResults(this.wattTimeApiUrl, regionAbbreviation, DateTime.Now.AddDays(-25), DateTime.Now.AddDays(20), null, wattTimeApiKey);

            // Assert
            Assert.IsTrue(pointsReturned.Count > 0);
        }
Пример #2
0
        public void TestGetGenerationMixAndSystemWideEmissionsResults()
        {
            // Arrange
            var regionAbbreviation = "PJM";
            EmissionsApiInteraction emissionsApiInteraction = new EmissionsApiInteraction(selfThrottlingMethod, maxNumberOfCallsPerMinute);

            emissionsApiInteraction.RegisterWithWattTime(this.wattTimeApiV2Url, WattTimeUsername, WattTimePassword, WattTimeEmail, WattTimeOrganization);

            // Act
            var pointsReturned = emissionsApiInteraction.GetGenerationMixAndSystemWideEmissionsResults(this.wattTimeApiUrl, regionAbbreviation, DateTime.Now.AddDays(-15), DateTime.Now.AddDays(2), null, wattTimeApiKey);

            // Assert
            Assert.IsTrue(pointsReturned.Count > 0);
        }
        public void TestMineHistoricCarbonResults()
        {
            // Arrange
            var startDateTime = DateTime.Now.AddDays(-10);
            var endDateTime   = DateTime.Now.AddDays(-1);

            var    wattTimeApiUrl            = CloudConfigurationManager.GetSetting("WattTimeApiUrl");
            var    wattTimeApiKey            = CloudConfigurationManager.GetSetting("WattTimeApiKey");
            string wattTimeApiV2Url          = CloudConfigurationManager.GetSetting("WattTimeApiV2Url");
            string WattTimeUsername          = CloudConfigurationManager.GetSetting("WattTimeUsername");
            string WattTimePassword          = CloudConfigurationManager.GetSetting("WattTimePassword");
            string WattTimeEmail             = CloudConfigurationManager.GetSetting("WattTimeEmail");
            string WattTimeOrganization      = CloudConfigurationManager.GetSetting("WattTimeOrganization");
            var    selfThrottlingMethod      = "AzureTableStorageCallRecollection";
            var    maxNumberOfCallsPerMinute = 200;


            List <WattTimeBalancingAuthorityInformation> regionsToMine = new List <WattTimeBalancingAuthorityInformation>();

            regionsToMine.Add(new WattTimeBalancingAuthorityInformation("PJM", "US_PJM", "Eastern Standard Time", 40.348444276169, -74.6428556442261));

            //regionsToMine.Add(new WattTimeBalancingAuthorityInformation("PSEI", "US_PugetSoundEnergy", "Pacific Standard Time", 47.68009593341535, -122.11638450372567));

            //regionsToMine.Add(new WattTimeBalancingAuthorityInformation("BPA", "US_BPA", "Pacific Standard Time", 40.348444276169, -74.6428556442261));
            //regionsToMine.Add(new WattTimeBalancingAuthorityInformation("CAISO", "US_CAISO", "Pacific Standard Time", 41.7324, -123.409423));
            //regionsToMine.Add(new WattTimeBalancingAuthorityInformation("ERCOT", "US_ERCOT", "Central Standard Time", 32.79878236662912, -96.77856445062508));
            //regionsToMine.Add(new WattTimeBalancingAuthorityInformation("ISONE", "US_ISONewEngland", "Eastern Standard Time", 42.70864591994315, -72.16918945062508));
            //regionsToMine.Add(new WattTimeBalancingAuthorityInformation("MISO", "US_UpperMidwestISO", "Central Standard Time", 41.91853269857261, -93.55193137872567));
            //regionsToMine.Add(new WattTimeBalancingAuthorityInformation("PJM", "US_PJM", "Eastern Standard Time", 40.348444276169, -74.6428556442261));
            //regionsToMine.Add(new WattTimeBalancingAuthorityInformation("SPP", "US_SouthwesternPublicServiceISO", "Eastern Standard Time", 34.41133502036136, -103.19243430841317));

            foreach (var region in regionsToMine)
            {
                int regionId;
                using (var _objectModel = new SmartEnergyOM(databaseConnectionString))
                {
                    regionId =
                        _objectModel.AddEmissionsRegion(region.smartGridRegionName, region.timeZone, region.regionLat, region.regionLong)
                        .EmissionsRegionID;

                    _objectModel.AddMarketWeatherEmissionsRegionMapping(
                        region.smartGridRegionName,
                        null,
                        null,
                        regionId);
                }


                var wattTimeInteraction = new EmissionsApiInteraction(selfThrottlingMethod, maxNumberOfCallsPerMinute);

                CarbonEmissionsMiner carbonEmissionsMiner = new CarbonEmissionsMiner(
                    wattTimeApiUrl,
                    wattTimeApiKey,
                    wattTimeApiV2Url,
                    WattTimeUsername,
                    WattTimePassword,
                    WattTimeEmail,
                    WattTimeOrganization,
                    selfThrottlingMethod,
                    databaseConnectionString,
                    maxNumberOfCallsPerMinute,
                    wattTimeInteraction);

                // Act
                carbonEmissionsMiner.MineHistoricCarbonResults(
                    startDateTime,
                    endDateTime,
                    region.regionWattTimeName,
                    regionId);

                // Assert
                // Verify that each data point has been recorded in the database
                var marginalCarbonResults = wattTimeInteraction.GetObservedMarginalCarbonResults(
                    wattTimeApiV2Url,
                    region.regionWattTimeName,
                    WattTimeUsername,
                    WattTimePassword,
                    startDateTime,
                    endDateTime,
                    null);

                using (var _objectModel = new SmartEnergyOM(databaseConnectionString))
                {
                    foreach (var result in marginalCarbonResults)
                    {
                        var dataPoint = _objectModel.FindCarbonEmissionsDataPoint(regionId, result.point_time);
                        Assert.IsNotNull(dataPoint);
                    }
                }

                var systemWideResults = wattTimeInteraction.GetGenerationMixAndSystemWideEmissionsResults(
                    wattTimeApiUrl,
                    region.regionWattTimeName,
                    startDateTime,
                    endDateTime,
                    null,
                    wattTimeApiKey);

                using (var _objectModel = new SmartEnergyOM(databaseConnectionString))
                {
                    foreach (var result in systemWideResults)
                    {
                        var dataPoint = _objectModel.FindCarbonEmissionsDataPoint(regionId, result.timestamp);
                        Assert.IsNotNull(dataPoint);
                    }
                }
            }
        }
        public void TestMineHistoricCarbonResults()
        {
            // Arrange

            var startDateTime = DateTime.Now.AddDays(-10);
            var endDateTime   = DateTime.Now.AddDays(-9);

            var wattTimeApiUrl            = CloudConfigurationManager.GetSetting("WattTimeApiUrl");
            var wattTimeApiKey            = CloudConfigurationManager.GetSetting("WattTimeApiKey");
            var selfThrottlingMethod      = "AzureTableStorageCallRecollection";
            var maxNumberOfCallsPerMinute = 20;

            List <WattTimeBalancingAuthorityInformation> regionsToMine =
                new List <WattTimeBalancingAuthorityInformation>
            {
                new WattTimeBalancingAuthorityInformation(
                    "PJM",
                    "US_PJM",
                    "Eastern Standard Time",
                    40.348444276169,
                    -74.6428556442261)
            };

            foreach (var region in regionsToMine)
            {
                int regionId;
                using (var _objectModel = new SmartEnergyOM(databaseConnectionString))
                {
                    regionId =
                        _objectModel.AddEmissionsRegion(region.smartGridRegionName, region.timeZone, region.regionLat, region.regionLong)
                        .EmissionsRegionID;

                    _objectModel.AddMarketWeatherEmissionsRegionMapping(
                        region.smartGridRegionName,
                        null,
                        null,
                        regionId);
                }


                var wattTimeInteraction = new EmissionsApiInteraction(selfThrottlingMethod, maxNumberOfCallsPerMinute);

                CarbonEmissionsMiner carbonEmissionsMiner = new CarbonEmissionsMiner(
                    wattTimeApiUrl,
                    wattTimeApiKey,
                    selfThrottlingMethod,
                    databaseConnectionString,
                    maxNumberOfCallsPerMinute,
                    wattTimeInteraction);

                // Act
                carbonEmissionsMiner.MineHistoricCarbonResults(
                    startDateTime,
                    endDateTime,
                    region.regionWattTimeName,
                    regionId);

                // Assert
                // Verify that each data point has been recorded in the database
                var marginalCarbonResults = wattTimeInteraction.GetObservedMarginalCarbonResults(
                    wattTimeApiUrl,
                    region.regionWattTimeName,
                    startDateTime,
                    endDateTime,
                    null,
                    wattTimeApiKey);

                using (var _objectModel = new SmartEnergyOM(databaseConnectionString))
                {
                    foreach (var result in marginalCarbonResults)
                    {
                        var dataPoint = _objectModel.FindCarbonEmissionsDataPoints(regionId, result.timestamp);
                        Assert.IsNotNull(dataPoint);
                    }
                }

                var systemWideResults = wattTimeInteraction.GetGenerationMixAndSystemWideEmissionsResults(
                    wattTimeApiUrl,
                    region.regionWattTimeName,
                    startDateTime,
                    endDateTime,
                    null,
                    wattTimeApiKey);

                using (var _objectModel = new SmartEnergyOM(databaseConnectionString))
                {
                    foreach (var result in systemWideResults)
                    {
                        var dataPoint = _objectModel.FindCarbonEmissionsDataPoints(regionId, result.timestamp);
                        Assert.IsNotNull(dataPoint);
                    }
                }
            }
        }
        public void TestMineHistoricSystemWideCarbonResults()
        {
            // Arrange
            var startDateTime = DateTime.Now.AddDays(-10);
            var endDateTime   = DateTime.Now.AddDays(-1);

            var    wattTimeApiUrl            = CloudConfigurationManager.GetSetting("WattTimeApiUrl");
            var    wattTimeApiKey            = CloudConfigurationManager.GetSetting("WattTimeApiKey");
            string wattTimeApiV2Url          = CloudConfigurationManager.GetSetting("WattTimeApiV2Url");
            string WattTimeUsername          = CloudConfigurationManager.GetSetting("WattTimeUsername");
            string WattTimePassword          = CloudConfigurationManager.GetSetting("WattTimePassword");
            string WattTimeEmail             = CloudConfigurationManager.GetSetting("WattTimeEmail");
            string WattTimeOrganization      = CloudConfigurationManager.GetSetting("WattTimeOrganization");
            var    selfThrottlingMethod      = "AzureTableStorageCallRecollection";
            var    maxNumberOfCallsPerMinute = 9;

            List <WattTimeBalancingAuthorityInformation> regionsToMine = new List <WattTimeBalancingAuthorityInformation>();

            regionsToMine.Add(new WattTimeBalancingAuthorityInformation("ERCOT", "US_ERCOT", "Central Standard Time", 32.79878236662912, -96.77856445062508));

            foreach (var region in regionsToMine)
            {
                int regionId;
                using (var _objectModel = new SmartEnergyOM(databaseConnectionString))
                {
                    regionId =
                        _objectModel.AddEmissionsRegion(region.smartGridRegionName, region.timeZone, region.regionLat, region.regionLong)
                        .EmissionsRegionID;

                    _objectModel.AddMarketWeatherEmissionsRegionMapping(
                        region.smartGridRegionName,
                        null,
                        null,
                        regionId);
                }


                var wattTimeInteraction = new EmissionsApiInteraction(selfThrottlingMethod, maxNumberOfCallsPerMinute);

                CarbonEmissionsMiner carbonEmissionsMiner = new CarbonEmissionsMiner(
                    wattTimeApiUrl,
                    wattTimeApiKey,
                    wattTimeApiV2Url,
                    WattTimeUsername,
                    WattTimePassword,
                    WattTimeEmail,
                    WattTimeOrganization,
                    selfThrottlingMethod,
                    databaseConnectionString,
                    maxNumberOfCallsPerMinute,
                    wattTimeInteraction);

                // Act
                carbonEmissionsMiner.MineHistoricSystemWideCarbonResults(
                    startDateTime,
                    endDateTime,
                    region.regionWattTimeName,
                    regionId);

                // Assert
                // Verify that each data point has been recorded in the database
                var results = wattTimeInteraction.GetGenerationMixAndSystemWideEmissionsResults(
                    wattTimeApiUrl,
                    region.regionWattTimeName,
                    startDateTime,
                    endDateTime,
                    null,
                    wattTimeApiKey);

                using (var _objectModel = new SmartEnergyOM(databaseConnectionString))
                {
                    foreach (var result in results)
                    {
                        var dataPoint = _objectModel.FindCarbonEmissionsDataPoint(regionId, result.timestamp);
                        Assert.IsNotNull(dataPoint);
                    }
                }
            }
        }