예제 #1
0
        private void MakeTransportationDevice([NotNull] CalcHousehold chh,
                                              [NotNull][ItemNotNull]
                                              List <CalcTransportationDeviceDto> transportationDevices)
        {
            foreach (var transportationDevice in transportationDevices)
            {
                var loads = new List <CalcDeviceLoad>();
                foreach (var load in transportationDevice.Loads)
                {
                    CalcLoadType clt = _loadTypeDict.GetLoadtypeByGuid(load.LoadTypeGuid);
                    loads.Add(new CalcDeviceLoad(load.Name, load.MaxPower, clt, 0, 0));
                }

                double distanceToEnergyFactor = transportationDevice.EnergyToDistanceFactor;

                CalcLoadType chargingLoadType = null;
                if (transportationDevice.ChargingCalcLoadTypeGuid.HasValue)
                {
                    chargingLoadType = _loadTypeDict.GetLoadtypeByGuid(transportationDevice.ChargingCalcLoadTypeGuid.Value);
                }
                if (chh.TransportationHandler == null)
                {
                    throw new LPGException("no transportation handler");
                }

                CalcDeviceDto cdd = new CalcDeviceDto(transportationDevice.Name,
                                                      transportationDevice.Category.Guid,
                                                      chh.HouseholdKey,
                                                      OefcDeviceType.Transportation, transportationDevice.Category.Name,
                                                      string.Empty, transportationDevice.Guid, StrGuid.Empty, string.Empty);
                var category = chh.TransportationHandler.GetCategory(transportationDevice.Category);
                CalcTransportationDevice cd = new CalcTransportationDevice(
                    category,
                    transportationDevice.AverageSpeedInMPerS, loads,
                    transportationDevice.FullRangeInMeters,
                    distanceToEnergyFactor, transportationDevice.MaxChargingPower, chargingLoadType,
                    chh.TransportationHandler.CalcSites,
                    cdd, _calcRepo);
                if (category.IsLimitedToSingleLocation)
                {
                    chh.TransportationHandler.AddVehicleDepotDevice(cd);
                }
                else
                {
                    chh.TransportationHandler.LocationUnlimitedDevices.Add(cd);
                }
            }
        }
예제 #2
0
        private List <CalcSite> MakeCalcSites([NotNull] CalcHouseholdDto household, [NotNull]
                                              DtoCalcLocationDict locDict, [NotNull] CalcLoadTypeDictionary ltDict,
                                              [NotNull] TransportationHandler th
                                              )
        {
            List <CalcSite> sites = new List <CalcSite>();

            //Dictionary<string, CalcSite> siteDictByGuid = new Dictionary<string, CalcSite>();
            if (household.CalcSites == null)
            {
                throw new LPGException("CalcSites was null"); //for the bug in the null checking
            }

            foreach (var siteDto in household.CalcSites)
            {
                var calcSite = new CalcSite(siteDto.Name, siteDto.Guid, household.HouseholdKey);
                sites.Add(calcSite);
                //siteDictByGuid.Add(siteDto.Guid, calcSite);
                foreach (var locGuid in siteDto.LocationGuid)
                {
                    CalcLocation calcLoc = locDict.GetCalcLocationByGuid(locGuid);
                    calcLoc.CalcSite = calcSite;
                    calcSite.Locations.Add(calcLoc);
                }

                foreach (var chargingStation in siteDto.ChargingStations)
                {
                    var gridLt = ltDict.GetLoadtypeByGuid(chargingStation.GridChargingLoadType.Guid);
                    var carLt  = ltDict.GetLoadtypeByGuid(chargingStation.CarChargingLoadType.Guid);
                    var cat    = th.GetCategory(chargingStation.DeviceCategory);
                    calcSite.AddChargingStation(gridLt, cat, chargingStation.MaxChargingPower,
                                                carLt, _calcRepo);
                }
            }
            return(sites);
        }
        private void MakeAllTransformationDevices([NotNull] CalcHouseDto house,
                                                  [NotNull] CalcHouse calchouse,
                                                  [NotNull] HouseholdKey householdKey) //List<CalcDeviceTaggingSet> taggingSets,
        {
            var ctds            = new List <CalcTransformationDevice>();
            var devcategoryGuid = Guid.NewGuid().ToStrGuid();
            var trafolocGuid    = Guid.NewGuid().ToStrGuid();

            foreach (var trafo in house.TransformationDevices)
            {
                foreach (var set in _calcDeviceTaggingSets.AllCalcDeviceTaggingSets)
                {
                    set.AddTag(trafo.Name, "House Device");
                }
                CalcDeviceDto cdd = new CalcDeviceDto(trafo.Name, devcategoryGuid, householdKey,
                                                      OefcDeviceType.Transformation, "Transformation Devices", "", trafo.Guid, trafolocGuid, "Transformation Devices");
                var ctd = new CalcTransformationDevice(_calcRepo.Odap,
                                                       trafo.MinValue,
                                                       trafo.MaxValue,
                                                       trafo.MinPower,
                                                       trafo.MaxPower,
                                                       cdd, _ltDict.GetLoadtypeByGuid(trafo.InputLoadType.Guid));
                foreach (var outlt in trafo.OutputLoadTypes)
                {
                    ctd.AddOutputLoadType(_ltDict.GetLoadtypeByGuid(outlt.LoadType.Guid), outlt.ValueScalingFactor, outlt.FactorType);
                }

                if (ctd.OutputLoadTypes.Count > 0)
                {
                    if (trafo.Datapoints != null)
                    {
                        foreach (var datapoint in trafo.Datapoints)
                        {
                            ctd.AddDatapoint(datapoint.Ref, datapoint.Val);
                        }
                    }

                    foreach (var condition in trafo.Conditions)
                    {
                        var variable = _variableRepository.GetVariableByGuid(condition.CalcVariableDto.Guid);
                        ctd.AddCondition(condition.Name, variable, condition.MinValue, condition.MaxValue, condition.Guid);
                    }

                    ctds.Add(ctd);
                }
            }

            calchouse.SetTransformationDevices(ctds);
        }
예제 #4
0
        private List <CalcAffordance.DeviceEnergyProfileTuple> MakeDeviceEnergyProfileTuples([ItemNotNull][NotNull] List <CalcDevice> devices,
                                                                                             [NotNull] CalcAffordanceDto affordancedto)
        {
            List <CalcAffordance.DeviceEnergyProfileTuple> deviceEnergyProfiles =
                new List <CalcAffordance.DeviceEnergyProfileTuple>();

            foreach (DeviceEnergyProfileTupleDto dto in affordancedto.Energyprofiles)
            {
                StrGuid      devguid = dto.CalcDeviceGuid;
                CalcDevice   device  = devices.Single(x => x.Guid == devguid);
                CalcProfile  cp      = CalcDeviceFactory.MakeCalcProfile(dto.TimeProfile, _calcRepo.CalcParameters);
                CalcLoadType clt     = _loadTypeDictionary.GetLoadtypeByGuid(dto.CalcLoadTypeGuid);
                CalcAffordance.DeviceEnergyProfileTuple dep = new CalcAffordance.DeviceEnergyProfileTuple(device,
                                                                                                          cp, clt, dto.TimeOffset, _calcRepo.CalcParameters.InternalStepsize, dto.Multiplier, dto.Probability);
                deviceEnergyProfiles.Add(dep);
            }

            return(deviceEnergyProfiles);
        }
        public static List <CalcDeviceLoad> MakeCalcDeviceLoads([NotNull] CalcDeviceDto device,
                                                                [NotNull] CalcLoadTypeDictionary calcLoadTypeDictionary)
        {
            var deviceLoads = new List <CalcDeviceLoad>();

            foreach (var ltdto in device.Loads)
            {
                if (calcLoadTypeDictionary.SimulateLoadtype(ltdto.LoadTypeGuid))
                {
                    var lt  = calcLoadTypeDictionary.GetLoadtypeByGuid(ltdto.LoadTypeGuid);
                    var cdl = new CalcDeviceLoad(ltdto.Name,
                                                 ltdto.MaxPower, lt,
                                                 ltdto.AverageYearlyConsumption, ltdto.PowerStandardDeviation);
                    deviceLoads.Add(cdl);
                }
            }

            return(deviceLoads);
        }
        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);
        }