Example #1
0
        public void SetAllAffordaces([NotNull][ItemNotNull] List <CalcAffordanceDto> affordances,
                                     [NotNull] DtoCalcLocationDict locations,
                                     [NotNull] CalcVariableRepository variableRepository,
                                     [ItemNotNull][NotNull] List <CalcDevice> devices)
        {
            if (affordances.Count == 0)
            {
                throw new LPGException("No Affordances found.");
            }

            foreach (CalcAffordanceDto affordancedto in affordances)
            {
                CalcProfile  personProfile = CalcDeviceFactory.MakeCalcProfile(affordancedto.PersonProfile, _calcRepo.CalcParameters);
                CalcLocation calcLocation  = locations.GetCalcLocationByGuid(affordancedto.CalcLocationGuid);
                var          calcDesires   = MakeCalcDesires(affordancedto.Satisfactionvalues);
                var          color         = new ColorRGB(affordancedto.ColorR, affordancedto.ColorG, affordancedto.ColorB);
                var          variableOps   = MakeVariableOps(locations, affordancedto.VariableOps, variableRepository);
                List <VariableRequirement> requirements = new List <VariableRequirement>();
                foreach (VariableRequirementDto requirementDto in affordancedto.VariableRequirements)
                {
                    VariableRequirement vrq = new VariableRequirement(requirementDto.Name,
                                                                      requirementDto.Value, requirementDto.CalcLocationName, requirementDto.LocationGuid,
                                                                      requirementDto.VariableCondition, variableRepository, requirementDto.VariableGuid);
                    requirements.Add(vrq);
                }

                var deviceEnergyProfiles = MakeDeviceEnergyProfileTuples(devices, affordancedto);

                var            busyarr = _availabilityDtoRepository.GetByGuid(affordancedto.IsBusyArray.Guid);
                CalcAffordance caff    = new CalcAffordance(
                    affordancedto.Name,
                    personProfile, calcLocation,
                    affordancedto.RandomEffect,
                    calcDesires,
                    affordancedto.MiniumAge,
                    affordancedto.MaximumAge,
                    affordancedto.PermittedGender,
                    affordancedto.NeedsLight,
                    affordancedto.TimeStandardDeviation,
                    color,
                    affordancedto.AffCategory,
                    affordancedto.IsInterruptable,
                    affordancedto.IsInterrupting,
                    variableOps,
                    requirements,
                    affordancedto.ActionAfterInterruption,
                    affordancedto.TimeLimitName,
                    affordancedto.Weight,
                    affordancedto.RequireAllDesires,
                    affordancedto.SrcTrait,
                    affordancedto.Guid,
                    variableRepository, deviceEnergyProfiles,
                    busyarr, affordancedto.BodilyActivityLevel, _calcRepo);
                MakeSubAffordances(locations, variableRepository, affordancedto, caff);

                calcLocation.AddAffordance(caff);
            }
        }
        private List <CalcAutoDev> MakeCalcAutoDevsFromHouse([NotNull] CalcHouseDto house,
                                                             [NotNull][ItemNotNull] List <CalcLocation> houseLocations)
        {
            var autodevs = new List <CalcAutoDev>(house.AutoDevs.Count);

            // zur kategorien zuordnung
            foreach (var hhautodev in house.AutoDevs)
            {
                CalcProfile           calcProfile = CalcDeviceFactory.MakeCalcProfile(hhautodev.CalcProfile, _calcRepo.CalcParameters);
                CalcLoadType          clt         = _ltDict.GetLoadtypeByGuid(hhautodev.LoadtypeGuid);
                List <CalcDeviceLoad> loads       = new List <CalcDeviceLoad>();
                foreach (CalcDeviceLoadDto loadDto in hhautodev.Loads)
                {
                    CalcDeviceLoad load = new CalcDeviceLoad(loadDto.Name,
                                                             loadDto.MaxPower,
                                                             _ltDict.GetLoadtypeByGuid(loadDto.LoadTypeGuid),
                                                             loadDto.AverageYearlyConsumption,
                                                             loadDto.PowerStandardDeviation);
                    loads.Add(load);
                }

                List <VariableRequirement> requirements = new List <VariableRequirement>();
                foreach (var reqDto in hhautodev.Requirements)
                {
                    VariableRequirement rq = new VariableRequirement(reqDto.Name,
                                                                     reqDto.Value,
                                                                     reqDto.CalcLocationName,
                                                                     reqDto.LocationGuid,
                                                                     reqDto.VariableCondition,
                                                                     _variableRepository,
                                                                     reqDto.VariableGuid);
                    requirements.Add(rq);
                }

                CalcLocation houseLocation = houseLocations.Single(x => x.Guid == hhautodev.CalcLocationGuid);
                var          cautodev      = new CalcAutoDev(
                    calcProfile,
                    clt,
                    loads,
                    hhautodev.TimeStandardDeviation,
                    hhautodev.Multiplier,
                    houseLocation,
                    requirements, hhautodev, _calcRepo);
                var busyarr = _availabilityDtoRepository.GetByGuid(hhautodev.BusyArr.Guid);
                cautodev.ApplyBitArry(busyarr, _ltDict.GetLoadtypeByGuid(hhautodev.LoadtypeGuid));
                autodevs.Add(cautodev);
            }

            return(autodevs);
        }
        public List <CalcAutoDev> MakeCalcAutoDevs(
            [NotNull][ItemNotNull] List <CalcAutoDevDto> autoDevices,
            [NotNull] DtoCalcLocationDict locationDict)
        {
            var autodevs = new List <CalcAutoDev>(autoDevices.Count);

            foreach (var autoDevDto in autoDevices)
            {
                if (_loadTypeDictionary.SimulateLoadtype(autoDevDto.LoadtypeGuid))
                {
                    var         deviceLoads = MakeCalcDeviceLoads(autoDevDto, _loadTypeDictionary);
                    CalcProfile cp          = MakeCalcProfile(autoDevDto.CalcProfile, _calcRepo.CalcParameters);

                    var          loadtype     = _loadTypeDictionary.GetLoadtypeByGuid(autoDevDto.LoadtypeGuid);
                    CalcLocation calcLocation = locationDict.GetCalcLocationByGuid(autoDevDto.CalcLocationGuid);
                    List <VariableRequirement> requirements = new List <VariableRequirement>();
                    foreach (var req in  autoDevDto.Requirements)
                    {
                        VariableRequirement vreq = new VariableRequirement(req.Name,
                                                                           req.Value, req.CalcLocationName, req.LocationGuid,
                                                                           req.VariableCondition, _calcVariableRepository, req.VariableGuid);
                        requirements.Add(vreq);
                    }

                    autoDevDto.AdditionalName = " (autonomous)";
                    var cautodev = new CalcAutoDev(cp, loadtype,
                                                   deviceLoads, autoDevDto.TimeStandardDeviation,
                                                   1, calcLocation,
                                                   requirements, autoDevDto, _calcRepo);
                    var busyarr = _availabilityDtoRepository.GetByGuid(autoDevDto.BusyArr.Guid);
                    cautodev.ApplyBitArry(busyarr, loadtype);
                    autodevs.Add(cautodev);
                }
            }

            return(autodevs);
        }