Beispiel #1
0
 public void RegisterDeviceActivationTest()
 {
     using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
     {
         wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService));
         wd.InputDataLogger.AddSaver(new DeviceActivationEntryLogger(wd.SqlResultLoggingService));
         wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService));
         CalcParameters cp = CalcParametersFactory.MakeGoodDefaults().EnableShowSettlingPeriod();
         using (var fft = new FileFactoryAndTracker(wd.WorkingDirectory, "hhname", wd.InputDataLogger))
         {
             var key = new HouseholdKey(" hh1");
             fft.HouseholdRegistry.RegisterHousehold(key, "hh key", HouseholdKeyType.Household, wd.InputDataLogger, "desc", null, null);
             fft.HouseholdRegistry.RegisterHousehold(Constants.GeneralHouseholdKey, "general", HouseholdKeyType.General, wd.InputDataLogger, "desc", null, null);
             DateStampCreator dsc = new DateStampCreator(cp);
             using OnlineLoggingData old = new OnlineLoggingData(dsc, wd.InputDataLogger, cp);
             fft.HouseholdRegistry.RegisterHousehold(key, "hh key", HouseholdKeyType.Household, wd.InputDataLogger, "desc", null, null);
             CalcLoadTypeDto clt = new CalcLoadTypeDto("lt", "unitofpower", "unitofsum", 1, true, "guid".ToStrGuid());
             TimeStep        ts  = new TimeStep(1, 1, true);
             CalcDeviceDto   cdd = new CalcDeviceDto("devname", "".ToStrGuid(), key,
                                                     OefcDeviceType.Device, "devcatname", "", Guid.NewGuid().ToStrGuid(), "locguid".ToStrGuid(), "locname");
             DeviceActivationEntry aeue = new DeviceActivationEntry("affname", clt, 1, "activatorname", 1, ts, cdd);
             old.RegisterDeviceActivation(aeue);
             old.FinalSaveToDatabase();
         }
         wd.CleanUp();
     }
 }
Beispiel #2
0
 public void TestLocationEntryBasics()
 {
     Config.IsInUnitTesting = true;
     using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
     {
         DateTime       startdate      = new DateTime(2018, 1, 1);
         DateTime       enddate        = startdate.AddMinutes(1000);
         CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults().SetStartDate(startdate).SetEndDate(enddate).SetSettlingDays(0).EnableShowSettlingPeriod();
         calcParameters.Options.Add(CalcOption.LocationsEntries);
         //FileFactoryAndTracker fft = new FileFactoryAndTracker(wd.WorkingDirectory,"blub",wd.InputDataLogger);
         //CalcLocation cl = new CalcLocation("blub", 1, Guid.NewGuid().ToStrGuid());
         //Mock<ILogFile> lf = new Mock<ILogFile>();
         //CalcPerson cp = MakeCalcPerson(cl,calcParameters,lf.Object);
         HouseholdKey  key = new HouseholdKey("hh1");
         TimeStep      ts  = new TimeStep(1, 0, false);
         LocationEntry le  = new LocationEntry(key, "personName", "personGuid".ToStrGuid(), ts, "locname",
                                               "locguid".ToStrGuid());
         DateStampCreator dsc = new DateStampCreator(calcParameters);
         using (OnlineLoggingData old = new OnlineLoggingData(dsc, wd.InputDataLogger, calcParameters))
         {
             wd.InputDataLogger.AddSaver(new LocationEntryLogger(wd.SqlResultLoggingService));
             old.AddLocationEntry(le);
             old.FinalSaveToDatabase();
         }
         var lel = new LocationEntryLogger(wd.SqlResultLoggingService);
         var e   = lel.Load(key);
         e.Count.Should().Be(1);
         wd.CleanUp();
     }
 }
        public void VariableLogfileTests1()
        {
            using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
            {
                wd.InputDataLogger.AddSaver(new VariableEntryLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService));
                CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults().EnableShowSettlingPeriod();
                using (var fft = new FileFactoryAndTracker(wd.WorkingDirectory, "blub", wd.InputDataLogger))
                {
                    HouseholdKey key = new HouseholdKey("hh1");
                    fft.RegisterGeneralHouse();
                    fft.RegisterHousehold(key, "householdname", HouseholdKeyType.Household, "desc", null, null);
                    DateStampCreator dsc = new DateStampCreator(calcParameters);
                    using (IOnlineLoggingData old = new OnlineLoggingData(dsc, wd.InputDataLogger, calcParameters))
                    {
                        CalcVariableRepository cvr = new CalcVariableRepository();
                        //using (LogFile lf = new LogFile(calcParameters,fft, old,wd.SqlResultLoggingService, true))
                        CalcLocation cloc = new CalcLocation("loc1", Guid.NewGuid().ToStrGuid());
                        CalcVariable cv   = new CalcVariable("mycalcvar", Guid.NewGuid().ToStrGuid(),
                                                             0, cloc.Name, cloc.Guid, key);
                        cvr.RegisterVariable(cv);
                        TimeStep ts = new TimeStep(0, calcParameters);
                        old.AddVariableStatus(new CalcVariableEntry(cv.Name, cv.Guid, 1, cv.LocationName, cv.LocationGuid,
                                                                    cv.HouseholdKey, ts));
                        old.AddVariableStatus(new CalcVariableEntry(cv.Name, cv.Guid, 2, cv.LocationName, cv.LocationGuid,
                                                                    cv.HouseholdKey, ts));
                        old.AddVariableStatus(new CalcVariableEntry(cv.Name, cv.Guid, 3, cv.LocationName, cv.LocationGuid,
                                                                    cv.HouseholdKey, ts));
                        old.FinalSaveToDatabase();
                    }
                    VariableEntryLogger vel = new VariableEntryLogger(wd.SqlResultLoggingService);
                    var varEntries          = vel.Read(key);
                    foreach (CalcVariableEntry entry in varEntries)
                    {
                        Logger.Info(entry.Value.ToString(CultureInfo.InvariantCulture));
                    }
                    varEntries[0].Value.Should().Be(1);
                    varEntries[1].Value.Should().Be(2);
                    varEntries[2].Value.Should().Be(3);
                }

                /*old.
                 * cloc.Add();
                 * cloc[0].Variables.Add("trig1", 1.0);
                 * tlf.WriteLine(0, cloc);
                 * cloc[0].Variables["trig1"] = 2.0;
                 * tlf.WriteLine(1, cloc);
                 * lf.Close(null);*/
                wd.CleanUp();
            }
        }
Beispiel #4
0
 public void TestLocationEntryBasicsWithFile()
 {
     Config.IsInUnitTesting = true;
     using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
     {
         wd.InputDataLogger.AddSaver(new LocationEntryLogger(wd.SqlResultLoggingService));
         DateTime       startdate      = new DateTime(2018, 1, 1);
         DateTime       enddate        = startdate.AddMinutes(1000);
         CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults().SetStartDate(startdate).SetEndDate(enddate).SetSettlingDays(0).EnableShowSettlingPeriod();
         calcParameters.Options.Add(CalcOption.LocationsEntries);
         //FileFactoryAndTracker fft = new FileFactoryAndTracker(wd.WorkingDirectory, "hhname", wd.InputDataLogger);
         //LocationsLogFile llf = new LocationsLogFile(true, fft, calcParameters);
         //CalcLocation cl = new CalcLocation("blub", 1, Guid.NewGuid().ToStrGuid());
         //Mock<ILogFile> lf = new Mock<ILogFile>();
         //CalcPerson cp = MakeCalcPerson(cl,calcParameters,lf.Object);
         //LocationEntry le = new LocationEntry(cp, 1, cl,calcParameters);
         //llf.WriteEntry(le, new HouseholdKey("HH1"));
         //llf.WriteEntry(le, new HouseholdKey("HH2"));
         //llf.WriteEntry(le, new HouseholdKey("HH3"));
         //llf.Close();
         HouseholdKey  key1 = new HouseholdKey("hh1");
         TimeStep      ts   = new TimeStep(1, 0, false);
         LocationEntry le1  = new LocationEntry(key1, "personName", "personGuid".ToStrGuid(), ts, "locname",
                                                "locguid".ToStrGuid());
         HouseholdKey  key2 = new HouseholdKey("hh2");
         LocationEntry le2  = new LocationEntry(key2, "personName", "personGuid".ToStrGuid(), ts, "locname",
                                                "locguid".ToStrGuid());
         HouseholdKey  key3 = new HouseholdKey("hh3");
         LocationEntry le3  = new LocationEntry(key3, "personName", "personGuid".ToStrGuid(), ts, "locname",
                                                "locguid".ToStrGuid());
         DateStampCreator dsc = new DateStampCreator(calcParameters);
         using (OnlineLoggingData old = new OnlineLoggingData(dsc, wd.InputDataLogger, calcParameters))
         {
             old.AddLocationEntry(le1);
             old.AddLocationEntry(le2);
             old.AddLocationEntry(le3);
             old.FinalSaveToDatabase();
         }
         LocationEntryLogger lel = new LocationEntryLogger(wd.SqlResultLoggingService);
         var le = lel.Load(key1);
         Logger.Info("count: " + le.Count);
         string prev   = JsonConvert.SerializeObject(le1, Formatting.Indented);
         string loaded = JsonConvert.SerializeObject(le[0], Formatting.Indented);
         loaded.Should().Be(prev);
         wd.CleanUp();
     }
 }
Beispiel #5
0
        public void PostProcessingTestTwoActivation()
        {
            var startdate      = new DateTime(2018, 1, 1);
            var enddate        = startdate.AddMinutes(100);
            var calcParameters = CalcParametersFactory.MakeGoodDefaults().SetStartDate(startdate).SetEndDate(enddate).EnableShowSettlingPeriod();
            //CalculationProfiler calculationProfiler = new CalculationProfiler();

            var rnd = new Random(1);
            var nr  = new NormalRandom(0, 1, rnd);

            using (var wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) {
                calcParameters.Enable(CalcOption.HouseSumProfilesFromDetailedDats);
                calcParameters.Enable(CalcOption.DeviceProfilesIndividualHouseholds);
                calcParameters.Enable(CalcOption.TotalsPerDevice);
                calcParameters.Enable(CalcOption.TotalsPerLoadtype);
                calcParameters.Enable(CalcOption.DeviceActivations);
                calcParameters.Enable(CalcOption.DetailedDatFiles);
                Config.IsInUnitTesting = true;
                wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new CalcParameterLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new CalcLoadTypeDtoLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new ColumnEntryLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new CalcObjectInformationLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new DeviceActivationEntryLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new CalcPersonDtoLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new DeviceTaggingSetLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.Save(calcParameters);
                using (var fft = new FileFactoryAndTracker(wd.WorkingDirectory, "hh1", wd.InputDataLogger)) {
                    fft.RegisterHousehold(Constants.GeneralHouseholdKey, "general", HouseholdKeyType.General, "desc", null, null);
                    //fft.RegisterHousehold(Constants.GeneralHouseholdKey, "general", HouseholdKeyType.General,"desc");
                    //SqlResultLoggingService srls =new SqlResultLoggingService(Path.Combine(wd.WorkingDirectory, "results.sqlite"));
                    var dsc = new DateStampCreator(calcParameters);
                    using (IOnlineLoggingData old = new OnlineLoggingData(dsc, wd.InputDataLogger, calcParameters)) {
                        var coi = new CalcObjectInformation(CalcObjectType.ModularHousehold, "objname", wd.WorkingDirectory);
                        wd.InputDataLogger.Save(coi);
                        using (var lf = new LogFile(calcParameters, fft)) {
                            var key = new HouseholdKey("hh1");
                            fft.RegisterHousehold(key, "hh1 key", HouseholdKeyType.Household, "Description", null, null);
                            var odap      = new OnlineDeviceActivationProcessor(old, calcParameters, fft);
                            var clt       = new CalcLoadType("lt1", "W", "kWh", 3, true, Guid.NewGuid().ToStrGuid());
                            var loadTypes = new List <CalcLoadTypeDto> {
                                clt.ConvertToDto()
                            };
                            wd.InputDataLogger.Save(loadTypes);
                            var cdl         = new CalcDeviceLoad("devload1", 10, clt, 666, 0);
                            var deviceLoads = new List <CalcDeviceLoad> {
                                cdl
                            };
                            var cloc            = new CalcLocation("locname", Guid.NewGuid().ToStrGuid());
                            var devguid         = Guid.NewGuid().ToStrGuid();
                            var devcategoryguid = Guid.NewGuid().ToStrGuid();
                            var cdto            = new CalcDeviceDto("devicename", devcategoryguid, key, OefcDeviceType.Device, "category", "", devguid,
                                                                    cloc.Guid, cloc.Name);
                            var devices = new List <IHouseholdKey> {
                                cdto
                            };
                            wd.InputDataLogger.SaveList(devices);
                            using (var calcRepo = new CalcRepo(odap, calcParameters: calcParameters, rnd: rnd, normalRandom: nr)) {
                                var device = new CalcDevice(deviceLoads, cloc, cdto, calcRepo);
                                //var devices = new List<CalcDevice> {device};
                                var cp = new CalcProfile("profile1", Guid.NewGuid().ToStrGuid(), new TimeSpan(0, 1, 0), ProfileType.Absolute,
                                                         "custom");
                                cp.AddNewTimepoint(new TimeSpan(0), 0);
                                cp.AddNewTimepoint(new TimeSpan(0, 1, 0), 10);
                                cp.AddNewTimepoint(new TimeSpan(0, 2, 0), 0);
                                cp.ConvertToTimesteps();
                                //var locations = new List<CalcLocation> {cloc};
                                var ts = new TimeStep(0, calcParameters);
                                device.SetTimeprofile(cp, ts, clt, "affordanceName", "activatorName", 1, false);
                                device.SetTimeprofile(cp, ts.AddSteps(5), clt, "affordanceName", "activatorName", 1, false);
                                device.SetTimeprofile(cp.CompressExpandDoubleArray(0.5), ts.AddSteps(8), clt, "affordanceName", "activatorName", 1,
                                                      false);
                                device.SetTimeprofile(cp.CompressExpandDoubleArray(2), ts.AddSteps(10), clt, "affordanceName", "activatorName", 1,
                                                      false);
                            }

                            for (var i = 0; i < 30; i++)
                            {
                                var ts1      = new TimeStep(i, calcParameters);
                                var filerows = odap.ProcessOneTimestep(ts1);
                                filerows.Count.Should().Be(1);
                                filerows[0].EnergyEntries.Count.Should().Be(1);
                                Logger.Info(filerows[0].EnergyEntries[0].ToString(CultureInfo.CurrentCulture));
                                foreach (var fileRow in filerows)
                                {
                                    fileRow.Save(odap.BinaryOutStreams[fileRow.LoadType]);
                                }
                            }

                            //var autoDevs = new List<CalcAutoDev>();
                            //var ps = new Postprocessor(lf.FileFactoryAndTracker, calculationProfiler,calcParameters);
                            //var householdKeys = new HashSet<string> {"1"};
                            //var calcAffordanceTaggingSets = new List<CalcAffordanceTaggingSet>();
                            var deviceTaggingSetInformation = new DeviceTaggingSetInformation("name");
                            var taggingsets = new List <DeviceTaggingSetInformation> {
                                deviceTaggingSetInformation
                            };

                            wd.InputDataLogger.Save(taggingsets);
                            //var householdPlans = new List<CalcHouseholdPlan>();
                            //var householdNamesByNumber = new Dictionary<string, string> {["HH1"] = "household"};
                            //var affordanceEnergyUseFile = new AffordanceEnergyUseFile(lf.FileFactoryAndTracker,calcParameters);
                            //lf.Close(null); // needed to free file access
                            //var results = new Dictionary<string, double>();
                            var persons = new List <CalcPersonDto>();
                            var dto     = new CalcPersonDto("name", Guid.NewGuid().ToStrGuid(), 18, PermittedGender.Female, key, new List <DateSpan>(),
                                                            new List <DateSpan>(), 1, "tag", "hhname");
                            persons.Add(dto);
                            wd.InputDataLogger.SaveList(persons.ConvertAll(x => (IHouseholdKey)x));
                            //var deviceNamesToCategory = new Dictionary<string, string>();
                            old.FinalSaveToDatabase();
                            lf.Dispose();
                            fft.Dispose();
                            var cprof = new CalculationProfiler();
                            var ppm   = new PostProcessingManager(cprof, fft);
                            ppm.Run(wd.WorkingDirectory);
                            var tel     = new TotalsPerLoadtypeEntryLogger(wd.SqlResultLoggingService);
                            var results = tel.Read(key);
                            results[0].Value.Should().Be(150);
                        }
                    }
                }

                Logger.Info(wd.WorkingDirectory);
                wd.CleanUp();
            }
        }
Beispiel #6
0
        public void PostProcessingTestSingleActivation()
        {
            using (var wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) {
                wd.InputDataLogger.AddSaver(new CalcParameterLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new ColumnEntryLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new DeviceActivationEntryLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new CalcLoadTypeDtoLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new CalcPersonDtoLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new DeviceTaggingSetLogger(wd.SqlResultLoggingService));
                var calculationProfiler = new CalculationProfiler();

                var startdate      = new DateTime(2018, 1, 1);
                var enddate        = startdate.AddMinutes(1000);
                var calcParameters = CalcParametersFactory.MakeGoodDefaults().SetStartDate(startdate).SetEndDate(enddate).EnableShowSettlingPeriod();

                var rnd = new Random(1);
                var nr  = new NormalRandom(0, 1, rnd);

                calcParameters.Enable(CalcOption.HouseSumProfilesFromDetailedDats);
                calcParameters.Enable(CalcOption.DeviceProfilesIndividualHouseholds);
                calcParameters.Enable(CalcOption.TotalsPerDevice);
                calcParameters.Enable(CalcOption.TotalsPerLoadtype);
                calcParameters.Enable(CalcOption.DetailedDatFiles);
                calcParameters.Enable(CalcOption.DeviceActivations);
                var key = new HouseholdKey("hh1");

                wd.InputDataLogger.Save(calcParameters);

                using (var fft = new FileFactoryAndTracker(wd.WorkingDirectory, "hhname", wd.InputDataLogger)) {
                    //wd.InputDataLogger.AddSaver(new CalcDeviceDtoLogger(wd.SqlResultLoggingService));
                    var dsc = new DateStampCreator(calcParameters);
                    using (IOnlineLoggingData old = new OnlineLoggingData(dsc, wd.InputDataLogger, calcParameters)) {
                        var calcPersonDto = new CalcPersonDto("blub", "personguid".ToStrGuid(), 1, PermittedGender.Male, key, new List <DateSpan>(),
                                                              new List <DateSpan>(), 1, "traittag", "householdname");
                        var persons = new List <CalcPersonDto> {
                            calcPersonDto
                        };
                        wd.InputDataLogger.SaveList(persons.ConvertAll(x => (IHouseholdKey)x));

                        using (var lf = new LogFile(calcParameters, fft)) {
                            fft.RegisterHousehold(key, "test hh", HouseholdKeyType.Household, "Description", null, null);
                            fft.RegisterHousehold(Constants.GeneralHouseholdKey, "General", HouseholdKeyType.General, "Description", null, null);
                            var odap         = new OnlineDeviceActivationProcessor(old, calcParameters, fft);
                            var clt          = new CalcLoadType("lt1", "W", "kWh", 3, true, Guid.NewGuid().ToStrGuid());
                            var loadTypeDtos = new List <CalcLoadTypeDto> {
                                clt.ConvertToDto()
                            };
                            wd.InputDataLogger.Save(loadTypeDtos);
                            //var loadTypes = new List<CalcLoadType> {clt};
                            var cdl         = new CalcDeviceLoad("devload1", 10, clt, 666, 0);
                            var deviceLoads = new List <CalcDeviceLoad> {
                                cdl
                            };
                            var cloc = new CalcLocation("locname", Guid.NewGuid().ToStrGuid());
                            var deviceCategoryGuid = Guid.NewGuid().ToStrGuid();
                            var calcDeviceDto      = new CalcDeviceDto("devicename", deviceCategoryGuid, key, OefcDeviceType.Device, "category",
                                                                       string.Empty, Guid.NewGuid().ToStrGuid(), cloc.Guid, cloc.Name);
                            var calcDeviceDtos = new List <CalcDeviceDto> {
                                calcDeviceDto
                            };
                            wd.InputDataLogger.SaveList(calcDeviceDtos.ConvertAll(x => (IHouseholdKey)x));
                            //device tagging set for the post processing
                            var cdts = new List <DeviceTaggingSetInformation>();
                            var dtsi = new DeviceTaggingSetInformation("myset");
                            dtsi.AddTag(calcDeviceDto.Name, "testTag ");
                            cdts.Add(dtsi);
                            wd.InputDataLogger.Save(cdts);
                            //device
                            using (var calcRepo = new CalcRepo(calcParameters: calcParameters, odap: odap, rnd: rnd, normalRandom: nr)) {
                                var device = new CalcDevice(deviceLoads, cloc, calcDeviceDto, calcRepo);
                                //var devices = new List<CalcDevice> {device};
                                double[] resultValues = { 0, 100.0, 0, 0, 0, 0, 0, 0, 0, 0 };
                                var      cp           = new CalcProfile("profile1", Guid.NewGuid().ToStrGuid(), new TimeSpan(0, 1, 0), ProfileType.Absolute,
                                                                        "custom");
                                cp.AddNewTimepoint(new TimeSpan(0), 0);
                                cp.AddNewTimepoint(new TimeSpan(0, 1, 0), 10);
                                cp.AddNewTimepoint(new TimeSpan(0, 2, 0), 0);
                                cp.ConvertToTimesteps();
                                //var locations = new List<CalcLocation> {cloc};
                                var ts1 = new TimeStep(0, calcParameters);
                                device.SetTimeprofile(cp, ts1, clt, "affordanceName", "activatorName", 10, false);
                                for (var i = 0; i < 10; i++)
                                {
                                    var ts       = new TimeStep(i, calcParameters);
                                    var filerows = odap.ProcessOneTimestep(ts);
                                    filerows.Count.Should().Be(1);
                                    filerows[0].EnergyEntries.Count.Should().Be(1);
                                    Logger.Info(filerows[0].EnergyEntries[0].ToString(CultureInfo.CurrentCulture));
                                    filerows[0].EnergyEntries[0].Should().Be(resultValues[i]);
                                    foreach (var fileRow in filerows)
                                    {
                                        fileRow.Save(odap.BinaryOutStreams[fileRow.LoadType]);
                                    }
                                }
                            }
                            old.FinalSaveToDatabase();
                            fft.Dispose();
                            lf.Dispose(); // needed to free the file access
                            //var autoDevs = new List<CalcAutoDev>();
                            //var ps = new Postprocessor(lf.FileFactoryAndTracker, calculationProfiler,calcParameters );
                            //var householdKeys = new HashSet<string> {"1"};
                            //var calcAffordanceTaggingSets = new List<CalcAffordanceTaggingSet>();
                            //var calcDeviceTaggingSets = new List<CalcDeviceTaggingSet>();
                            //var calcDeviceTaggingSets = new List<DeviceTaggingSetInformation>();
                            //var householdPlans = new List<CalcHouseholdPlan>();
                            //var householdNamesByNumber = new Dictionary<string, string> {["HH1"] = "household"};
                            //var affordanceEnergyUseFile = new AffordanceEnergyUseFile(lf.FileFactoryAndTracker,calcParameters);

                            //var results = new Dictionary<string, double>();
                            //BitArray isSick = new BitArray(calcParameters.InternalTimesteps);
                            //BitArray isOnVacation = new BitArray(calcParameters.InternalTimesteps);
                            //CalcPersonDto cpd = new CalcPersonDto("personname", Guid.NewGuid().ToStrGuid(),18,PermittedGender.Female,key,new List<DateSpan>(),new List<DateSpan>(),1,"traittag","hhname"  );
                            //var persons = new List<CalcPerson> {new CalcPerson(cpd, new Random(), lf,cloc,calcParameters,isSick,isOnVacation)};
                            //var deviceNamesToCategory = new Dictionary<string, string>();
                            //CalcDeviceTaggingSets calcDeviceTaggingSets = new CalcDeviceTaggingSets();
                            var cpp = new PostProcessingManager(calculationProfiler, fft);
                            cpp.Run(wd.WorkingDirectory);

                            /*ps.EndOfSimulationProcessing(devices, locations, autoDevs, loadTypes, odap.Oefc, householdKeys
                             *  ,calcAffordanceTaggingSets, calcDeviceTaggingSets, householdPlans, householdNamesByNumber
                             *  ,affordanceEnergyUseFile, results, CalcObjectType.ModularHousehold, persons, deviceNamesToCategory,10);*/
                            //var dstpath = Path.Combine(wd.WorkingDirectory,DirectoryNames.CalculateTargetdirectory(TargetDirectory.Reports),"DeviceSums." + clt.Name + ".csv");
                            lf.Dispose(); // needed to free the file access
                            var di  = new DirectoryInfo(wd.WorkingDirectory);
                            var fis = di.GetFiles("DeviceSums.*", SearchOption.AllDirectories);

                            if (fis.Length == 0)
                            {
                                throw new LPGException("No Sum File was generated");
                            }
                            fft.Dispose();
                            using (var sr = new StreamReader(fis[0].FullName)) {
                                sr.ReadLine();              //header
                                var result = sr.ReadLine(); //0
                                if (result == null)
                                {
                                    throw new LPGException("Result was null");
                                }

                                var arr = result.Split(';');
                                Assert.Equal("300", arr[1]);
                            }
                        }
                    }
                }

                Logger.Info(wd.WorkingDirectory);
                wd.CleanUp();
            }
        }