private CalcAirConditioningDto MakeAirConditioning([NotNull] TemperatureProfile temperatureProfile,
                                                           [NotNull] HouseType houseType,
                                                           [NotNull] HouseholdKey householdKey,
                                                           [CanBeNull] out CalcLocationDto airConditioningLocation)
        {
            var coolingParameter = MakeCoolingParameters(temperatureProfile, houseType);

            if (coolingParameter == null)
            {
                airConditioningLocation = null;
                return(null);
            }

            var degreeHourDict = new List <CalcDegreeHourDto>();

            foreach (var degreeHour in coolingParameter.DegreeHours)
            {
                var cdd = new CalcDegreeHourDto(degreeHour.Date.Year,
                                                degreeHour.Date.Month,
                                                degreeHour.Date.Day,
                                                degreeHour.Date.Hour,
                                                degreeHour.CoolingAmount);
                degreeHourDict.Add(cdd);
            }

            CalcLoadTypeDto lt  = _ltDict.GetLoadtypeDtoByLoadType(coolingParameter.CoolingLoadType);
            var             cdl = new CalcDeviceLoadDto(coolingParameter.CoolingLoadType.Name,
                                                        -1,
                                                        lt.Name,
                                                        lt.Guid,
                                                        coolingParameter.YearlyConsumption,
                                                        0,
                                                        Guid.NewGuid().ToStrGuid(),
                                                        1);
            var cdls = new List <CalcDeviceLoadDto> {
                cdl
            };

            airConditioningLocation = new CalcLocationDto("Air Conditioning", -100, Guid.NewGuid().ToStrGuid());
            var csh = new CalcAirConditioningDto("Air Conditioning",
                                                 -1,
                                                 cdls,
                                                 degreeHourDict,
                                                 householdKey,
                                                 airConditioningLocation.Name,
                                                 airConditioningLocation.Guid,
                                                 Guid.NewGuid().ToStrGuid());

            return(csh);
        }
        private static CalcSpaceHeatingDto MakeSpaceHeatingDto([NotNull] HeatingParameter heatingparameter,
                                                               [NotNull] CalcLoadTypeDtoDictionary ltDict,
                                                               [NotNull] HouseholdKey householdKey,
                                                               [CanBeNull] out CalcLocationDto heatingLocation)
        //, List<CalcDeviceTaggingSet> taggingSets)
        {
            if (!ltDict.SimulateLoadtype(heatingparameter.HeatingLoadType))
            {
                heatingLocation = null;
                return(null);
            }

            var degreeDayDict = new List <CalcDegreeDayDto>();

            foreach (var degreeDay in heatingparameter.DegreeDays)
            {
                var cdd = new CalcDegreeDayDto(degreeDay.Date.Year, degreeDay.Date.Month, degreeDay.Date.Day, degreeDay.HeatingAmount);
                degreeDayDict.Add(cdd);
            }

            var lt  = ltDict.GetLoadtypeDtoByLoadType(heatingparameter.HeatingLoadType);
            var cdl = new CalcDeviceLoadDto(heatingparameter.HeatingLoadType.Name,
                                            -1,
                                            lt.Name,
                                            lt.Guid,
                                            heatingparameter.YearlyConsumption,
                                            0,
                                            Guid.NewGuid().ToStrGuid(),
                                            1);
            var cdls = new List <CalcDeviceLoadDto> {
                cdl
            };

            heatingLocation = new CalcLocationDto("Space Heating Location", -102, Guid.NewGuid().ToStrGuid());
            var csh = new CalcSpaceHeatingDto("Space Heating",
                                              -1,
                                              cdls,
                                              degreeDayDict,
                                              householdKey,
                                              heatingLocation.Name,
                                              heatingLocation.Guid,
                                              Guid.NewGuid().ToStrGuid());

            //foreach (var calcDeviceTaggingSet in taggingSets) {
            //calcDeviceTaggingSet.AddTag("Space Heating","House Device");
            //}
            return(csh);
        }
Ejemplo n.º 3
0
        private List <CalcTransportationDeviceDto> MakeTransportationDevices([NotNull][ItemNotNull] List <TransportationDevice> transportationDevices,
                                                                             [NotNull] Dictionary <TransportationDeviceCategory, CalcTransportationDeviceCategoryDto> categoriesDict, [NotNull] HouseholdKey key)
        {
            List <CalcTransportationDeviceDto> transportationDeviceDtos = new List <CalcTransportationDeviceDto>();

            foreach (var transportationDevice in transportationDevices)
            {
                var loads = new List <CalcDeviceLoadDto>();
                foreach (TransportationDeviceLoad load in transportationDevice.Loads)
                {
                    VLoadType lt = load.LoadType;
                    if (lt == null)
                    {
                        throw new LPGException("Loadtype was null. This should never happen. Please report");
                    }

                    if (_loadTypeDict.SimulateLoadtype(lt))
                    {
                        CalcLoadTypeDto loadType = _loadTypeDict.GetLoadtypeDtoByLoadType(lt);
                        loads.Add(new CalcDeviceLoadDto(transportationDevice.Name + " - " + lt.Name,
                                                        transportationDevice.IntID, loadType.Name, loadType.Guid,
                                                        0, 0, Guid.NewGuid().ToStrGuid(), load.MaxPower));
                    }
                }

                double          distanceToEnergyFactor = 0;
                CalcLoadTypeDto chargingLoadType       = null;
                if (transportationDevice.ChargingDistanceAmount > 0 && transportationDevice.ChargingLoadType != null)
                {
                    distanceToEnergyFactor = DistanceToPowerFactor(transportationDevice.ChargingDistanceAmount, transportationDevice.ChargingEnergyAmount, transportationDevice.ChargingLoadType.ConversionFaktorPowerToSum);
                    chargingLoadType       = _loadTypeDict.Ltdtodict[transportationDevice.ChargingLoadType];
                }

                if (transportationDevice.TransportationDeviceCategory == null)
                {
                    throw new LPGException("Transportation device category was null");
                }
                CalcTransportationDeviceDto cd = new CalcTransportationDeviceDto(transportationDevice.Name,
                                                                                 transportationDevice.IntID, categoriesDict[transportationDevice.TransportationDeviceCategory],
                                                                                 transportationDevice.SpeedInMPerSecond, loads, key, transportationDevice.TotalRangeInMeters,
                                                                                 distanceToEnergyFactor, transportationDevice.ChargingPower, chargingLoadType?.Name, chargingLoadType?.Guid, Guid.NewGuid().ToStrGuid(),
                                                                                 transportationDevice.TransportationDeviceCategory.IsLimitedToSingleLocation);
                transportationDeviceDtos.Add(cd);
            }

            return(transportationDeviceDtos);
        }
        private static List <CalcEnergyStorageDto> CreateEnergyStorageDtos([NotNull][ItemNotNull] List <EnergyStorage> energyStorages,
                                                                           [NotNull] CalcLoadTypeDtoDictionary ltdict,
                                                                           [NotNull] HouseholdKey householdKey, CalcVariableDtoFactory calcVariableDtoFactory)
        {
            var calcEnergyStorages = new List <CalcEnergyStorageDto>();

            foreach (var es in energyStorages)
            {
                if (es.LoadType == null)
                {
                    throw new LPGException("Energy storage load type was null");
                }

                if (ltdict.SimulateLoadtype(es.LoadType))
                {
                    List <CalcEnergyStorageSignalDto> signals = new List <CalcEnergyStorageSignalDto>();
                    foreach (var signal in es.Signals)
                    {
                        if (signal.Variable == null)
                        {
                            throw new DataIntegrityException("Signal variable was null");
                        }

                        var cvdto = calcVariableDtoFactory.RegisterVariableIfNotRegistered(signal.Variable, "House",
                                                                                           Constants.HouseLocationGuid, Constants.HouseKey);
                        var cessig = new CalcEnergyStorageSignalDto(signal.Name,
                                                                    signal.IntID,
                                                                    signal.TriggerLevelOff,
                                                                    signal.TriggerLevelOn,
                                                                    signal.Value,
                                                                    cvdto,
                                                                    Guid.NewGuid().ToStrGuid());
                        signals.Add(cessig);
                    }

                    //foreach (DeviceTaggingSet set in deviceTaggingSets) {
                    //set.AddTag(es.Name,"House Device");
                    //}
                    var lt  = ltdict.GetLoadtypeDtoByLoadType(es.LoadType);
                    var ces = new CalcEnergyStorageDto(es.Name,
                                                       es.IntID,
                                                       lt,
                                                       es.MaximumStorageRate,
                                                       es.MaximumWithdrawRate,
                                                       es.MinimumStorageRate,
                                                       es.MinimumWithdrawRate,
                                                       es.InitialFill,
                                                       es.StorageCapacity,
                                                       householdKey,
                                                       Guid.NewGuid().ToStrGuid(),
                                                       signals);
                    calcEnergyStorages.Add(ces);
                    if (es.Signals.Count != ces.Signals.Count)
                    {
                        throw new LPGException("Signals for energy storage were not correctly initialized");
                    }
                }
                else
                {
                    throw new DataIntegrityException("You are trying to run a calculation with a house type that uses an energy storage, " +
                                                     " that references an load type you excluded. This will not work. Please enable the load type " +
                                                     es.LoadType + " by for example chosing All Loadtypes");
                }
            }

            return(calcEnergyStorages);
        }