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); }
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 CalcAutoDevDto MakeAutoDevFromDevice(EnergyIntensityType energyIntensity, [NotNull] HouseholdKey householdKey, [ItemNotNull][NotNull] ObservableCollection <DeviceAction> deviceActions, [ItemNotNull][NotNull] List <DeviceCategoryDto> deviceCategoryDtos, [NotNull] HouseTypeDevice hhautodev, [ItemNotNull][NotNull] List <IAssignableDevice> allAutonomousDevices, [NotNull] CalcLocationDto calcLocation, [NotNull] AvailabilityDataReferenceDto timearray ) { if (hhautodev.LoadType == null) { throw new LPGException("Loadtype was null"); } if (hhautodev.TimeProfile == null) { throw new LPGException("TimeProfile was null"); } if (_ltDict.SimulateLoadtype(hhautodev.LoadType)) { var profile = CalcDeviceDtoFactory.GetCalcProfileDto(hhautodev.TimeProfile); if (hhautodev.Location == null) { throw new LPGException("Location was null"); } var rd = _picker.GetAutoDeviceDeviceFromDeviceCategoryOrDevice(hhautodev.Device, allAutonomousDevices, energyIntensity, deviceActions, hhautodev.Location.IntID); var cdl = CalcDeviceDtoFactory.MakeCalcDeviceLoads(rd, _ltDict); var lt = _ltDict.Ltdtodict[hhautodev.LoadType]; CalcVariableDto variable = null; if (hhautodev.Variable != null) { var v = hhautodev.Variable; variable = _calcVariableDtoFactory.RegisterVariableIfNotRegistered(v, calcLocation.Name, calcLocation.Guid, householdKey); } List <VariableRequirementDto> reqDtos = new List <VariableRequirementDto>(); if (variable?.Name != null) { VariableRequirementDto req = new VariableRequirementDto(variable.Name, hhautodev.VariableValue, calcLocation.Name, calcLocation.Guid, hhautodev.VariableCondition, variable.Guid); reqDtos.Add(req); } //TODO: xxx missing probability? if (rd.DeviceCategory == null) { throw new LPGException("Device category was null"); } DeviceCategoryDto deviceCategoryDto = deviceCategoryDtos.Single(x => x.FullCategoryName == rd.DeviceCategory.FullPath); var cautodev = new CalcAutoDevDto(rd.Name, profile, lt.Name, lt.Guid, cdl, (double)hhautodev.TimeStandardDeviation, deviceCategoryDto.Guid, householdKey, 1, calcLocation.Name, calcLocation.Guid, deviceCategoryDto.FullCategoryName, Guid.NewGuid().ToStrGuid(), timearray, reqDtos, deviceCategoryDto.FullCategoryName); //cautodev.ApplyBitArry(busyarr, _ltDict.LtDict[hhautodev.LoadType]); return(cautodev); } return(null); }
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); }