Esempio n. 1
0
        private static void PrintList([NotNull] string connectionString, CalcObjectType type)
        {
            Logger.Info("Loading...");
            var sim = new Simulator(connectionString);

            Logger.Info("Loading finished.");
            var           i = 0;
            List <DBBase> items;

            switch (type)
            {
            case CalcObjectType.ModularHousehold:
                items = new List <DBBase>(sim.ModularHouseholds.It);
                break;

            case CalcObjectType.House:
                items = new List <DBBase>(sim.Houses.It);
                break;

            case CalcObjectType.Settlement:
                items = new List <DBBase>(sim.Settlements.It);
                break;

            default: throw new LPGException("Unknown type");
            }
            foreach (var household in items)
            {
                Logger.Info("[" + i++ + "] " + household.Name);
            }
        }
        private static ICalcAbleObject MakeCalcHouseObject([NotNull] Simulator sim,
                                                           [NotNull] CalcStartParameterSet csps, [NotNull] ICalcObject hh,
                                                           [NotNull] ILifetimeScope scope,
                                                           [NotNull] CalcVariableDtoFactory cvrdto, [NotNull] CalcVariableRepository variableRepository,
                                                           out CalcObjectType cot, [NotNull] CalcRepo calcRepo)
        {
            var house = (House)hh;

            calcRepo.FileFactoryAndTracker.RegisterHousehold(Constants.HouseKey, "House Infrastructure",
                                                             HouseholdKeyType.House, "House Infrastructure", house.Name, house.Description);
            var housedtoFac = scope.Resolve <CalcHouseDtoFactory>();
            var housedto    = housedtoFac.MakeHouseDto(sim, house, csps.TemperatureProfile,
                                                       csps.GeographicLocation, csps.EnergyIntensity);

            foreach (HouseholdKeyEntry entry in housedto.GetHouseholdKeyEntries())
            {
                calcRepo.InputDataLogger.Save(Constants.GeneralHouseholdKey, entry);
            }

            var convertedAutoDevList = housedto.AutoDevs.ConvertAll(x => (IHouseholdKey)x).ToList();

            if (calcRepo.CalcParameters.Options.Contains(CalcOption.HouseholdContents))
            {
                calcRepo.InputDataLogger.SaveList(convertedAutoDevList);
                calcRepo.InputDataLogger.Save(Constants.GeneralHouseholdKey, housedto);
            }

            var chf = scope.Resolve <CalcHouseFactory>();

            RegisterAllDtoVariables(cvrdto, variableRepository);
            ICalcAbleObject ch = chf.MakeCalcHouse(housedto, calcRepo);

            cot = CalcObjectType.House;
            return(ch);
        }
        private static ICalcAbleObject MakeCalcHouseholdObject([NotNull] Simulator sim, [NotNull] CalcStartParameterSet csps, [NotNull] ICalcObject hh,
                                                               [NotNull] ILifetimeScope scope,
                                                               [NotNull] CalcVariableDtoFactory cvrdto,
                                                               [NotNull] CalcVariableRepository variableRepository,
                                                               out CalcObjectType cot,
                                                               [NotNull] CalcRepo calcRepo)
        {
            var              cmhdf        = scope.Resolve <CalcModularHouseholdDtoFactory>();
            HouseholdKey     householdKey = new HouseholdKey("HH1");
            CalcHouseholdDto dto          = cmhdf.MakeCalcModularHouseholdDto(sim, (ModularHousehold)hh,
                                                                              csps.TemperatureProfile, householdKey, csps.GeographicLocation,
                                                                              out _, csps.TransportationDeviceSet, csps.TravelRouteSet,
                                                                              csps.EnergyIntensity, csps.ChargingStationSet);
            var cmhf = scope.Resolve <CalcModularHouseholdFactory>();

            /*foreach (var v in dto.CalcVariables)
             *              {
             *                  variableRepository.RegisterVariable(new CalcVariable(v.Name, v.Guid, v.Value, v.LocationName, v.LocationGuid, v.HouseholdKey));
             *              }*/
            foreach (HouseholdKeyEntry entry in dto.GetHouseholdKeyEntries())
            {
                calcRepo.InputDataLogger.Save(Constants.GeneralHouseholdKey, entry);
            }

            calcRepo.InputDataLogger.Save(Constants.GeneralHouseholdKey, dto);
            RegisterAllDtoVariables(cvrdto, variableRepository);
            ICalcAbleObject ch = cmhf.MakeCalcModularHousehold(dto, out _, null, null, calcRepo);

            cot = CalcObjectType.ModularHousehold;
            return(ch);
        }
 public CalcObjectInformation(CalcObjectType calcObjectType, [NotNull] string calcObjectName, [NotNull] string basePath)
 {
     CalcObjectType = calcObjectType;
     CalcObjectName = calcObjectName;
     BasePath       = basePath;
 }