public void RunPVProviderTestForAllEntries() { ServiceRepository services = new ServiceRepository(null, null, Logger, Config, new Random(1)); var slice = new ScenarioSliceParameters(Scenario.FromEnum(ScenarioEnum.Utopia), 2050, null); var dbHouse = services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Houses, slice); var pventries = dbHouse.Fetch <PvSystemEntry>(); var has = dbHouse.Fetch <Hausanschluss>(); var dbdto = new DBDto(null, has, null, null, null); PVProfileProvider pvp = new PVProfileProvider(services, slice, dbdto); foreach (var entry in pventries) { HouseComponentRo hcro = new HouseComponentRo("myname", "PV", 1, 1, "status", "isns", "standort", 0); ProviderParameterDto pp = new ProviderParameterDto(entry, null, hcro); pvp.PrepareLoadProfileIfNeeded(pp); var prosumer = pvp.ProvideProfile(pp); if (prosumer?.Profile == null) { throw new FlaException("No profile"); } if (Math.Abs(prosumer.Profile.EnergySum() - entry.EffectiveEnergyDemand) > 0.1) { throw new FlaException("Invalid profile: missing energy: should be " + entry.EffectiveEnergyDemand + " but was " + prosumer.Profile.EnergySum()); } Info("Profile generated correctly."); } }
public void RunPVProviderTest() { // ReSharper disable AssignNullToNotNullAttribute var dbdto = new DBDto(null, null, null, null, null); // ReSharper restore AssignNullToNotNullAttribute // ReSharper disable twice AssignNullToNotNullAttribute ServiceRepository services = new ServiceRepository(null, null, Logger, Config, new Random(1)); PVProfileProvider pvp = new PVProfileProvider(services, Constants.PresentSlice, dbdto); PvSystemEntry pve = new PvSystemEntry("houseguid", "pvguid", "haguid", "myname", "pv123", 2017); pve.PVAreas = new List <PVSystemArea> { new PVSystemArea(30, 30, 1000) }; HouseComponentRo hcro = new HouseComponentRo("myname", "PV", 1, 1, "status", "isns", "standort", 0); ProviderParameterDto pp = new ProviderParameterDto(pve, null, hcro); pvp.PrepareLoadProfileIfNeeded(pp); }
public void TestProfileCreation() { SqlConnectionPreparer ms = new SqlConnectionPreparer(Config); var dbHouses = ms.GetDatabaseConnection(Stage.Houses, Constants.PresentSlice); var pvEntries = dbHouses.Fetch <PvSystemEntry>(); if (pvEntries.Count == 0) { throw new FlaException("No PVEntries"); } var houseGuids = pvEntries.Select(x => x.HouseGuid).Distinct().Take(10).ToList(); // ReSharper disable AssignNullToNotNullAttribute ServiceRepository sp = new ServiceRepository(null, null, Logger, Config, new Random()); // ReSharper restore AssignNullToNotNullAttribute // ReSharper disable AssignNullToNotNullAttribute var dbdto = new DBDto(null, dbHouses.Fetch <Hausanschluss>(), null, null, null); // ReSharper restore AssignNullToNotNullAttribute PVProfileProvider pvp = new PVProfileProvider(sp, Constants.PresentSlice, dbdto); var hcrc = new HouseComponentRo("name", "type", 1, 1, "status", "", "standort", 0); foreach (string houseGuid in houseGuids) { var pse = pvEntries.Single(x => x.HouseGuid == houseGuid); ProviderParameterDto parameters = new ProviderParameterDto(pse, "dummydir", hcrc); pvp.PrepareLoadProfileIfNeeded(parameters); } foreach (string houseGuid in houseGuids) { var pse = pvEntries.Single(x => x.HouseGuid == houseGuid); ProviderParameterDto parameters = new ProviderParameterDto(pse, "dummydir", hcrc); var result = pvp.ProvideProfile(parameters); Info("Got a profile with " + result?.Profile?.EnergySum()); } }