public CalcHousehold MakeCalcModularHousehold([NotNull] CalcHouseholdDto householdDto, [NotNull] out DtoCalcLocationDict dtoCalcLocationDict, [CanBeNull] string houseName, [CanBeNull] string houseDescription, [NotNull] CalcRepo calcRepo) { CalcHousehold chh = null; _calcRepo.FileFactoryAndTracker.RegisterHousehold(householdDto.HouseholdKey, householdDto.Name, HouseholdKeyType.Household, householdDto.Description, houseName, houseDescription); string name = householdDto.Name + " " + householdDto.HouseholdKey; try { dtoCalcLocationDict = new DtoCalcLocationDict(); var calcLocations = _clf.MakeCalcLocations(householdDto.LocationDtos, dtoCalcLocationDict, calcRepo); if (calcLocations.Count == 0) { throw new LPGException("Not a single location could be created. Something in this household is wrong. Please fix."); } // devices var calcDevices = new List <CalcDevice>(); _cdf.MakeCalcDevices(calcLocations, householdDto.DeviceDtos, calcDevices, householdDto.HouseholdKey, _ltDict, calcRepo); var autodevs = _cdf.MakeCalcAutoDevs(householdDto.AutoDevices, dtoCalcLocationDict); //affordances /*if (householdDto.Vacation == null) * { * throw new LPGException("Vacation was null"); * }*/ //_cdf.MakeCalcDevices(calcLocations, householdDto.DeviceDtos, calcDevices,householdDto.HouseholdKey, _ltDict); var calcpersons = _cpf.MakeCalcPersons(householdDto.Persons, calcLocations[0], householdDto.Name); chh = new CalcHousehold(name, householdDto.GeographicLocationName, householdDto.TemperatureprofileName, householdDto.HouseholdKey, householdDto.Guid, _calcVariableRepository, calcLocations, calcpersons, householdDto.Description, _calcRepo); HashSet <StrGuid> deviceGuids = new HashSet <StrGuid>(); foreach (CalcDevice device in calcDevices) { if (!deviceGuids.Add(device.Guid)) { throw new LPGException("Tried to add the same device guid twice"); } } chh.SetDevices(calcDevices); chh.SetAutoDevs(autodevs); //chh.BridgeDays = householdDto.BridgeDays; _caf.SetAllAffordaces(householdDto.Affordances, dtoCalcLocationDict, _calcVariableRepository, calcDevices); CheckCalcAffordancesForExecutability(chh); if (householdDto.CalcTravelRoutes != null) { Logger.Info("Starting to initialize transportation for household " + householdDto.Name + "..."); _ctf.MakeTransportation(householdDto, dtoCalcLocationDict, chh); } else { Logger.Info("No travel route was set for for household " + householdDto.Name + ", skipping transportation"); } return(chh); } catch { chh?.Dispose(); throw; } }