Exemplo n.º 1
0
 public void RunTest()
 {
     using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
     {
         SqlResultLoggingService srls      = new SqlResultLoggingService(wd.WorkingDirectory);
         var calcParameters                = CalcParametersFactory.MakeGoodDefaults();
         CalcLoadTypeDtoDictionary   cltd  = new CalcLoadTypeDtoDictionary(new Dictionary <VLoadType, CalcLoadTypeDto>());
         CalcDeviceTaggingSetFactory cdtsf = new CalcDeviceTaggingSetFactory(calcParameters, cltd);
         using (DatabaseSetup ds = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
         {
             Simulator                          sim = new Simulator(ds.ConnectionString);
             CalcDeviceTaggingSets              devicetaggingset = cdtsf.GetDeviceTaggingSets(sim, 2);
             DeviceTaggingSetLogger             dtsl             = new DeviceTaggingSetLogger(srls);
             List <DeviceTaggingSetInformation> cdts             = new List <DeviceTaggingSetInformation>();
             cdts.AddRange(devicetaggingset.AllCalcDeviceTaggingSets);
             dtsl.Run(Constants.GeneralHouseholdKey, cdts);
             wd.CleanUp();
             ds.Cleanup();
         }
     }
 }
        private void RegisterEverything([NotNull] Simulator sim, [NotNull] string resultpath, [NotNull] CalcStartParameterSet csps, [NotNull] ICalcObject hh,
                                        [NotNull] ContainerBuilder builder, [NotNull] string sqlFileName, [NotNull] CalcParameters calcParameters,
                                        [CanBeNull] DeviceSelection ds)
        {
            builder.Register(c => new SqlResultLoggingService(sqlFileName)).As <SqlResultLoggingService>()
            .SingleInstance();
            builder.Register(c => calcParameters).As <CalcParameters>().SingleInstance();
            Random rnd = new Random(calcParameters.ActualRandomSeed);

            builder.Register(c => rnd).As <Random>().SingleInstance();
            builder.Register(c => csps.CalculationProfiler).As <CalculationProfiler>().SingleInstance();
            builder.Register(c => new NormalRandom(0, 0.1, rnd)).As <NormalRandom>().SingleInstance();
            builder.RegisterType <OnlineDeviceActivationProcessor>().As <IOnlineDeviceActivationProcessor>()
            .SingleInstance();
            builder.RegisterType <CalcHouseFactory>().As <CalcHouseFactory>().SingleInstance();
            builder.RegisterType <CalcManager>().As <CalcManager>().SingleInstance();
            builder.RegisterType <AffordanceTaggingSetFactory>().As <AffordanceTaggingSetFactory>().SingleInstance();
            builder.Register(x =>
                             CalcLoadTypeDtoFactory.MakeLoadTypes(sim.LoadTypes.It, calcParameters.InternalStepsize,
                                                                  csps.LoadTypePriority))
            .As <CalcLoadTypeDtoDictionary>().SingleInstance();
            builder.Register(x => CalcLoadTypeFactory.MakeLoadTypes(x.Resolve <CalcLoadTypeDtoDictionary>()))
            .As <CalcLoadTypeDictionary>().SingleInstance();
            //builder.Register(x =>ds).As<DeviceSelection>().SingleInstance();
            builder.Register(x => {
                CalcDeviceTaggingSetFactory ctsf =
                    new CalcDeviceTaggingSetFactory(x.Resolve <CalcParameters>(), x.Resolve <CalcLoadTypeDtoDictionary>());
                return(ctsf.GetDeviceTaggingSets(sim, hh.CalculatePersonCount()));
            }).As <CalcDeviceTaggingSets>().SingleInstance();
            builder.Register(x => new DeviceCategoryPicker(rnd, ds)).As <IDeviceCategoryPicker>().SingleInstance();
            builder.RegisterType <CalcModularHouseholdFactory>().As <CalcModularHouseholdFactory>().SingleInstance();
            builder.RegisterType <CalcHouseFactory>().As <CalcHouseFactory>().SingleInstance();
            builder.RegisterType <CalcLocationFactory>().As <CalcLocationFactory>().SingleInstance();
            builder.RegisterType <CalcPersonFactory>().As <CalcPersonFactory>().SingleInstance();
            builder.RegisterType <CalcDeviceFactory>().As <CalcDeviceFactory>().SingleInstance();
            builder.RegisterType <CalcRepo>().As <CalcRepo>().SingleInstance();
            builder.RegisterType <CalcAffordanceFactory>().As <CalcAffordanceFactory>().SingleInstance();
            builder.RegisterType <CalcTransportationFactory>().As <CalcTransportationFactory>().SingleInstance();

            builder.RegisterType <CalcVariableDtoFactory>().As <CalcVariableDtoFactory>().SingleInstance();

            builder.RegisterType <VacationDtoFactory>().As <VacationDtoFactory>().SingleInstance();
            builder.RegisterType <CalcVariableRepository>().As <CalcVariableRepository>().SingleInstance();
            builder.RegisterType <TemperatureDataLogger>().As <TemperatureDataLogger>().SingleInstance();
            builder.Register(x => new FileFactoryAndTracker(resultpath, hh.Name, x.Resolve <IInputDataLogger>()))
            .As <FileFactoryAndTracker>().SingleInstance();
            builder.Register(_ => new SqlResultLoggingService(resultpath)).As <SqlResultLoggingService>().SingleInstance();
            builder.Register(x => new DateStampCreator(x.Resolve <CalcParameters>())).As <DateStampCreator>().SingleInstance();
            builder.Register(c => new OnlineLoggingData(c.Resolve <DateStampCreator>(), c.Resolve <IInputDataLogger>(),
                                                        c.Resolve <CalcParameters>()))
            .As <OnlineLoggingData>().As <IOnlineLoggingData>().SingleInstance();
            builder.Register(x => new LogFile(calcParameters, x.Resolve <FileFactoryAndTracker>())).As <ILogFile>().SingleInstance();
            builder.RegisterType <AffordanceTaggingSetFactory>().As <AffordanceTaggingSetFactory>();
            builder.RegisterType <CalcPersonDtoFactory>().As <CalcPersonDtoFactory>();
            builder.RegisterType <CalcDeviceDtoFactory>().As <CalcDeviceDtoFactory>();
            builder.RegisterType <CalcLocationDtoFactory>().As <CalcLocationDtoFactory>();
            builder.RegisterType <CalcAffordanceDtoFactory>().As <CalcAffordanceDtoFactory>();
            builder.RegisterType <CalcHouseDtoFactory>().As <CalcHouseDtoFactory>();
            builder.RegisterType <CalcModularHouseholdDtoFactory>().As <CalcModularHouseholdDtoFactory>();
            builder.RegisterType <AvailabilityDtoRepository>().As <AvailabilityDtoRepository>().SingleInstance();
            builder.RegisterType <CalcTransportationDtoFactory>().As <CalcTransportationDtoFactory>();
            //data save loggers + input data loggers
            builder.RegisterType <InputDataLogger>().As <IInputDataLogger>().SingleInstance();
            builder.RegisterType <CalcParameterLogger>().As <IDataSaverBase>();
            builder.RegisterType <DeviceTaggingSetLogger>().As <IDataSaverBase>();
            builder.RegisterType <HouseholdDtoLogger>().As <IDataSaverBase>();
            builder.RegisterType <DaylightTimesLogger>().As <IDataSaverBase>();
            builder.RegisterType <TemperatureDataLogger>().As <IDataSaverBase>();
            builder.RegisterType <CalcStartParameterSetLogger>().As <IDataSaverBase>();
            builder.RegisterType <CalcLoadTypeDtoLogger>().As <IDataSaverBase>();
            builder.RegisterType <ActionEntryLogger>().As <IDataSaverBase>();
            builder.RegisterType <CalcPersonDtoLogger>().As <IDataSaverBase>();
            builder.RegisterType <CalcDeviceDtoLogger>().As <IDataSaverBase>();
            builder.RegisterType <CalcAutoDevDtoLogger>().As <IDataSaverBase>();
            builder.RegisterType <CalcVariableDtoLogger>().As <IDataSaverBase>();
            builder.RegisterType <HouseholdKeyLogger>().As <IDataSaverBase>();
            builder.RegisterType <CalcObjectInformationLogger>().As <IDataSaverBase>();
            builder.RegisterType <BodilyActivityLevelStatisticsLogger>().As <IDataSaverBase>();
            builder.RegisterType <ResultFileEntryLogger>().As <IDataSaverBase>();
            builder.RegisterType <CalcAffordanceDtoLogger>().As <IDataSaverBase>();
            builder.RegisterType <CalcAffordanceTaggingSetDtoLogger>().As <IDataSaverBase>();
            builder.RegisterType <DeviceActivationEntryLogger>().As <IDataSaverBase>();
            builder.RegisterType <ColumnEntryLogger>().As <IDataSaverBase>();
            builder.RegisterType <BridgeDayEntryLogger>().As <IDataSaverBase>();
            builder.RegisterType <HouseDtoLogger>().As <IDataSaverBase>();
            builder.RegisterType <LocationEntryLogger>().As <IDataSaverBase>();
            builder.RegisterType <CalcSiteDtoLogger>().As <IDataSaverBase>();
            builder.RegisterType <CalcTransportationDeviceDtoLogger>().As <IDataSaverBase>();
            builder.RegisterType <CalcTravelRouteDtoLogger>().As <IDataSaverBase>();
            builder.RegisterType <TransportationEventLogger>().As <IDataSaverBase>();
            builder.RegisterType <TransportationStatusLogger>().As <IDataSaverBase>();
            builder.RegisterType <PersonStatusLogger>().As <IDataSaverBase>();
            builder.RegisterType <TransportationStateEntryLogger>().As <IDataSaverBase>();
            builder.RegisterType <ChargingStationStateLogger>().As <IDataSaverBase>();
            builder.RegisterType <VariableEntryLogger>().As <IDataSaverBase>();
            builder.RegisterType <TransportationDeviceStatisticsLogger>().As <IDataSaverBase>();

            builder.RegisterType <AffordanceEnergyUseLogger>().As <IDataSaverBase>();
            //builder.Register(x=> x.Resolve<CalcVariableDtoFactory>().GetRepository()).As<CalcVariableRepository>().SingleInstance();
            builder.Register(x => MakeLightNeededArray(csps.GeographicLocation, csps.TemperatureProfile,
                                                       rnd,
                                                       new List <VacationTimeframe>(), hh.Name, calcParameters)).As <DayLightStatus>().SingleInstance();
        }