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); }
public List <CalcLocationDto> MakeCalcLocations([NotNull][ItemNotNull] List <Location> locations, [NotNull] HouseholdKey householdKey, EnergyIntensityType et, [NotNull] Dictionary <CalcLocationDto, List <IAssignableDevice> > deviceLocationDict, [NotNull][ItemNotNull] ObservableCollection <DeviceAction> deviceActions, [NotNull] LocationDtoDict locdict, [ItemNotNull][NotNull] List <DeviceCategoryDto> deviceCategoryDtos) { var locs = new List <CalcLocationDto>(); foreach (var t in locations) { // loc anlegen var cloc = new CalcLocationDto(t.Name, t.IntID, Guid.NewGuid().ToStrGuid()); foreach (var locdev in t.LocationDevices) { RealDevice rd; if (locdev.Device == null) { throw new LPGException("Device was null"); } if (locdev.Device.AssignableDeviceType == AssignableDeviceType.DeviceCategory) { rd = _picker.PickDeviceFromCategory((DeviceCategory)locdev.Device, et, deviceActions); } else { rd = (RealDevice)locdev.Device; } var deviceName = CalcAffordanceFactory.FixAffordanceName(rd.Name, _calcParameters.CSVCharacter); if (rd.DeviceCategory == null) { throw new LPGException("Device Category was null"); } var devcatdto = deviceCategoryDtos.Single(x => x.FullCategoryName == rd.DeviceCategory.FullPath); var clightdevice = new CalcDeviceDto(deviceName, devcatdto.Guid, householdKey, OefcDeviceType.Light, rd.DeviceCategory.FullPath, string.Empty, Guid.NewGuid().ToStrGuid(), cloc.Guid, cloc.Name); clightdevice.AddLoads(CalcDeviceDtoFactory.MakeCalcDeviceLoads(rd, _calcLoadTypeDict)); cloc.AddLightDevice(clightdevice); } deviceLocationDict.Add(cloc, new List <IAssignableDevice>()); locs.Add(cloc); locdict.LocationDict.Add(t, cloc); } return(locs); }
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 <CalcAffordanceVariableOpDto> MakeVariableOps([NotNull] CalcLocationDto calcloc, [NotNull] LocationDtoDict locDict, [NotNull] HouseholdKey householdKey, AffordanceWithTimeLimit aff) { var variableOps = new List <CalcAffordanceVariableOpDto>(); foreach (var affVariableOperation in aff.Affordance.ExecutedVariables) { CalcLocationDto loc = null; if (affVariableOperation.LocationMode == VariableLocationMode.OtherLocation) { if (affVariableOperation.Location == null) { throw new LPGException("Location was null"); } if (locDict.SimulateLocation(affVariableOperation.Location)) { loc = locDict.GetDtoForLocation(affVariableOperation.Location); } // if the Location does not exist, don't do anything. } else { loc = calcloc; } if (loc != null) { if (affVariableOperation.Location == null) { throw new LPGException("Location was null"); } var variable = _variableRepository.RegisterVariableIfNotRegistered( affVariableOperation.Variable, affVariableOperation.Location, householdKey, locDict); variableOps.Add(new CalcAffordanceVariableOpDto(affVariableOperation.Variable.Name, affVariableOperation.Value, loc.Name, loc.Guid, affVariableOperation.Action, affVariableOperation.ExecutionTime, variable.Guid)); } } return(variableOps); }
private List <VariableRequirementDto> MakeVariableRequirements([NotNull] CalcLocationDto calcloc, [NotNull] LocationDtoDict locDict, [NotNull] HouseholdKey householdKey, AffordanceWithTimeLimit aff) { var variableRequirements = new List <VariableRequirementDto>(); foreach (var affVariableRequirement in aff.Affordance.RequiredVariables) { CalcLocationDto loc = null; if (affVariableRequirement.LocationMode == VariableLocationMode.OtherLocation) { if (affVariableRequirement.Location == null) { throw new LPGException("Location was null"); } if (locDict.SimulateLocation(affVariableRequirement.Location)) { loc = locDict.GetDtoForLocation(affVariableRequirement.Location); } } else { loc = calcloc; } if (loc != null) { if (affVariableRequirement.Location == null) { throw new LPGException("Location was null"); } var variable = _variableRepository.RegisterVariableIfNotRegistered (affVariableRequirement.Variable, affVariableRequirement.Location, householdKey, locDict); variableRequirements.Add(new VariableRequirementDto(affVariableRequirement.Variable.Name, affVariableRequirement.Value, loc.Name, loc.Guid, affVariableRequirement.Condition, variable.Guid)); } } return(variableRequirements); }
public static CalcSpaceHeatingDto CreateSpaceHeatingObject([NotNull] House house, [NotNull] TemperatureProfile temperatureProfile, [NotNull] HouseholdKey householdKey, [CanBeNull] out CalcLocationDto heatingLocation, DateTime startTime, DateTime endTime, CalcLoadTypeDtoDictionary ltDict) //, List<CalcDeviceTaggingSet> deviceTaggingSets) { if (house.HouseType == null) { throw new LPGException("Housetype was null"); } if (house.HouseType.HeatingLoadType != null && Math.Abs(house.HouseType.HeatingYearlyTotal) > 0.0001 && !double.IsNaN(house.HouseType.HeatingYearlyTotal)) { var degreeDays = MakeDegreeDaysClass.MakeDegreeDays(temperatureProfile, startTime, endTime, house.HouseType.HeatingTemperature, house.HouseType.RoomTemperature, house.HouseType.HeatingYearlyTotal, house.HouseType.AdjustYearlyEnergy, house.HouseType.ReferenceDegreeDays); foreach (var degreeHour in degreeDays) { if (double.IsNaN(degreeHour.HeatingAmount)) { throw new LPGException("Heating Amount was NaN"); } } var heatingParameter = new HeatingParameter(degreeDays, house.HouseType.HeatingLoadType, house.HouseType.HeatingYearlyTotal); var spaceheating = MakeSpaceHeatingDto(heatingParameter, ltDict, householdKey, out heatingLocation); return(spaceheating); //,deviceTaggingSets } heatingLocation = null; return(null); }
private List <CalcAffordanceDto> GetCalcAffordancesAtLocation([NotNull] CalcLocationDto calcloc, [NotNull] List <AffordanceWithTimeLimit> affordancesAtLocation, TimeSpan internalStepSize, int timeStepsPerHour, [NotNull] TemperatureProfile temperatureProfile, [NotNull] CalcLoadTypeDtoDictionary ltdict, [NotNull] GeographicLocation geographicLocation, [NotNull] Random rnd, [NotNull][ItemNotNull] List <VacationTimeframe> vacationTimeframes, [NotNull] string holidayKey, [NotNull][ItemNotNull] ObservableCollection <DeviceAction> allDeviceActions, [NotNull] LocationDtoDict locDict, [NotNull] out List <DateTime> bridgeDays, [NotNull] HouseholdKey householdKey, [NotNull][ItemNotNull] List <CalcDeviceDto> deviceDtosAtLocation, [ItemNotNull][NotNull] List <DeviceCategoryDto> deviceCategoryDtos) { List <CalcAffordanceDto> createdAffordances = new List <CalcAffordanceDto>(); bridgeDays = new List <DateTime>(); foreach (AffordanceWithTimeLimit aff in affordancesAtLocation) { var affordanceName = CalcAffordanceFactory.FixAffordanceName(aff.Affordance.Name, _cp.CSVCharacter); if (aff.Affordance.PersonProfile == null) { throw new DataIntegrityException("Person profile on " + aff.Affordance.PrettyName + " was null. Please fix."); } var cp1 = CalcDeviceDtoFactory.GetCalcProfileDto(aff.Affordance.PersonProfile); List <CalcDesireDto> calcDesires = MakeCalcDesires(timeStepsPerHour, aff, affordanceName); List <CalcAffordanceVariableOpDto> variableOps = MakeVariableOps(calcloc, locDict, householdKey, aff); List <VariableRequirementDto> variableRequirements = MakeVariableRequirements(calcloc, locDict, householdKey, aff); MakeAffordanceTimelimit(temperatureProfile, geographicLocation, rnd, vacationTimeframes, holidayKey, bridgeDays, aff, out var availabilityDataReference); //make the affordance Logger.Debug("Converting the time limit to a bitarray for the affordance " + aff.Affordance.Name); //caff.IsBusyArray = tmparr; string timeLimitName = ""; if (aff.TimeLimit != null) { timeLimitName = aff.TimeLimit.Name; } var caff = new CalcAffordanceDto(affordanceName, aff.Affordance.IntID, cp1, calcloc.Name, calcloc.Guid, aff.Affordance.RandomDesireResults, calcDesires, aff.Affordance.MinimumAge, aff.Affordance.MaximumAge, aff.Affordance.PermittedGender, aff.Affordance.NeedsLight, (double)aff.Affordance.TimeStandardDeviation, aff.Affordance.CarpetPlotColor.R, aff.Affordance.CarpetPlotColor.G, aff.Affordance.CarpetPlotColor.B, aff.Affordance.AffCategory, aff.Affordance.IsInterruptable, aff.Affordance.IsInterrupting, variableOps, variableRequirements, aff.Affordance.ActionAfterInterruption, timeLimitName, aff.Weight, aff.Affordance.RequireAllDesires, aff.SrcTraitName, Guid.NewGuid().ToStrGuid(), availabilityDataReference, householdKey, aff.Affordance.BodilyActivityLevel); foreach (var devtup in aff.Affordance.AffordanceDevices) { MakeAffordanceDevices(calcloc, internalStepSize, ltdict, allDeviceActions, aff, caff, devtup, deviceDtosAtLocation, deviceCategoryDtos); } MakeSubAffordances(caff, aff.Affordance, timeStepsPerHour, internalStepSize, calcloc, locDict, _cp.CSVCharacter, aff.Weight, aff.SrcTraitName, householdKey); createdAffordances.Add(caff); } return(createdAffordances); }
private void MakeSubAffordances([NotNull] CalcAffordanceDto caff, [NotNull] Affordance aff, int timeStepsPerHour, TimeSpan internalStepSize, [NotNull] CalcLocationDto calcloc, [NotNull] LocationDtoDict locDict, [NotNull] string csvCharacter, int weight, [NotNull] string srcTrait, [NotNull] HouseholdKey householdKey) { // Subaffordanzen durchgehen foreach (var affsubaff in aff.SubAffordances) { var calcDesires = new List <CalcDesireDto>(); if (affsubaff.SubAffordance == null) { throw new LPGException("SubAffordance was null"); } var name = CalcAffordanceFactory.FixAffordanceName(affsubaff.SubAffordance.Name, csvCharacter); // f�r alle desires calcdesires anlegen foreach (var subaffDesire in affsubaff.SubAffordance.SubAffordanceDesires) { if (subaffDesire.Desire == null) { throw new LPGException("Desire was null"); } var cd = new CalcDesireDto(name + " - " + subaffDesire.Name, subaffDesire.Desire.IntID, 0, 0, subaffDesire.SatisfactionValue, 0, timeStepsPerHour, subaffDesire.Desire.CriticalThreshold, null, srcTrait, ""); calcDesires.Add(cd); } var minutesperstep = (decimal)internalStepSize.TotalMinutes; var delayTimeInSteps = (int)(affsubaff.DelayTime / minutesperstep); // variables var calcAffordanceVariableOps = new List <CalcAffordanceVariableOpDto>(); foreach (var affVariableOp in affsubaff.SubAffordance.SubAffordanceVariableOps) { CalcLocationDto loc = null; if (affVariableOp.LocationMode == VariableLocationMode.OtherLocation) { if (affVariableOp.Location != null && locDict.SimulateLocation(affVariableOp.Location)) { loc = locDict.GetDtoForLocation(affVariableOp.Location); } } else { loc = calcloc; } if (loc != null && affVariableOp.Variable != null) { if (affVariableOp.Location == null) { throw new LPGException("Variable Location was null"); } var variable = _variableRepository.RegisterVariableIfNotRegistered(affVariableOp.Variable, affVariableOp.Location, householdKey, locDict); calcAffordanceVariableOps.Add(new CalcAffordanceVariableOpDto(affVariableOp.Variable.Name, affVariableOp.Value, loc.Name, loc.Guid, affVariableOp.VariableAction, affVariableOp.ExecutionTime, variable.Guid)); } } // CalcSubaffordanz anlegen var affName = CalcAffordanceFactory.FixAffordanceName(aff.Name, csvCharacter); // ReSharper disable once ConditionIsAlwaysTrueOrFalse var csubaff = new CalcSubAffordanceDto(name + " (" + affName + ")", affsubaff.IntID, calcloc.Name, calcloc.Guid, calcDesires, affsubaff.SubAffordance.MinimumAge, affsubaff.SubAffordance.MaximumAge, delayTimeInSteps, affsubaff.SubAffordance.PermittedGender, aff.AffCategory, affsubaff.SubAffordance.IsInterruptable, affsubaff.SubAffordance.IsInterrupting, calcAffordanceVariableOps, weight, srcTrait, Guid.NewGuid().ToStrGuid()); caff.SubAffordance.Add(csubaff); } }
private void MakeAffordanceDevices([NotNull] CalcLocationDto calcloc, TimeSpan internalStepSize, [NotNull] CalcLoadTypeDtoDictionary ltdict, [NotNull][ItemNotNull] ObservableCollection <DeviceAction> allDeviceActions, AffordanceWithTimeLimit aff, [NotNull] CalcAffordanceDto caff, [NotNull] AffordanceDevice devtup, [NotNull][ItemNotNull] List <CalcDeviceDto> devicesAtLocation, [ItemNotNull][NotNull] List <DeviceCategoryDto> deviceCategoryDtos) { if (devtup.Device == null) { throw new LPGException("Device was null"); } // pick the device itself var pickedDevice = _picker.GetDeviceDtoForAffordance(devtup.Device, devicesAtLocation, calcloc.ID, allDeviceActions, deviceCategoryDtos); if (pickedDevice == null) { throw new DataIntegrityException( "Affordance " + aff.Affordance.Name + " has broken devices. Please fix", aff.Affordance); } // find the device in the calc devices var dev = devicesAtLocation.Single(calcDevice => calcDevice.Name == pickedDevice.Name); if (dev == null) { throw new DataIntegrityException( "Affordance " + aff.Affordance.Name + " has broken devices. Please fix", aff.Affordance); } if (devtup.Device == null) { throw new LPGException("Device was null"); } switch (devtup.Device.AssignableDeviceType) { case AssignableDeviceType.Device: case AssignableDeviceType.DeviceCategory: { if (devtup.LoadType == null) { throw new LPGException("No load type set"); } if (ltdict.SimulateLoadtype(devtup.LoadType)) { if (devtup.TimeProfile == null) { throw new DataIntegrityException( "Affordance " + aff.Affordance.Name + " has broken time profiles. Please fix.", aff.Affordance); } var newprof = CalcDeviceDtoFactory.GetCalcProfileDto(devtup.TimeProfile); CalcLoadTypeDto loadtype = ltdict.GetLoadtypeDtoByLoadType(devtup.LoadType); caff.AddDeviceTuple(dev.Name, dev.Guid, newprof, loadtype.Name, loadtype.Guid, devtup.TimeOffset, internalStepSize, 1, devtup.Probability); } } break; case AssignableDeviceType.DeviceAction: case AssignableDeviceType.DeviceActionGroup: { DeviceAction da; // if it's a device action group, then go back to the picker to select a specific // device action based on the available devices if (devtup.Device.AssignableDeviceType == AssignableDeviceType.DeviceActionGroup) { da = _picker.GetDeviceActionFromGroup(devtup.Device, devicesAtLocation, allDeviceActions); } else { da = (DeviceAction)devtup.Device; } if (da == null) { throw new LPGException("Device action was null"); } if (da.Profiles.Count == 0) { throw new DataIntegrityException( "The device action " + da.Name + " has no time profiles. Please fix", da); } foreach (var profile in da.Profiles) { if (profile.VLoadType == null) { throw new LPGException("Profile was null"); } if (ltdict.SimulateLoadtype(profile.VLoadType)) { if (profile.Timeprofile == null) { throw new DataIntegrityException( "The device action " + da.Name + " has broken time profiles. Please fix.", da); } if (profile.VLoadType == null) { throw new DataIntegrityException( "The device action " + da.Name + " has broken load types. Please fix.", da); } var newprof = CalcDeviceDtoFactory.GetCalcProfileDto(profile.Timeprofile); CalcLoadTypeDto loadType = ltdict.GetLoadtypeDtoByLoadType(profile.VLoadType); caff.AddDeviceTuple(dev.Name, dev.Guid, newprof, loadType.Name, loadType.Guid, profile.TimeOffset + devtup.TimeOffset, internalStepSize, profile.Multiplier, devtup.Probability); } } } break; default: throw new LPGException( "Missing an AssignableDeviceType at GetCalcAffordancesAtLocation! Please report to the programmer."); } }
private void MakeAutoDevFromDeviceAction(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 availref, List <CalcAutoDevDto> autodevs ) { if (hhautodev.Location == null) { throw new LPGException("Location was null"); } if (hhautodev.Device == null) { throw new LPGException("Device was null"); } var deviceAction = _picker.GetAutoDeviceActionFromGroup(hhautodev.Device, allAutonomousDevices, energyIntensity, deviceActions, hhautodev.Location.IntID); foreach (var actionProfile in deviceAction.Profiles) { if (actionProfile.VLoadType == null) { throw new LPGException("Loadtype was null"); } if (actionProfile.Timeprofile == null) { throw new LPGException("Timeprofile was null"); } if (_ltDict.SimulateLoadtype(actionProfile.VLoadType)) { var profile = CalcDeviceDtoFactory.GetCalcProfileDto(actionProfile.Timeprofile); if (deviceAction.Device == null) { throw new LPGException("Device was null"); } var cdl = CalcDeviceDtoFactory.MakeCalcDeviceLoads(deviceAction.Device, _ltDict); var lt = _ltDict.Ltdtodict[actionProfile.VLoadType]; 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); } if (deviceAction.Device.DeviceCategory == null) { throw new LPGException("Device was null"); } DeviceCategoryDto devcat = deviceCategoryDtos.Single(x => x.FullCategoryName == deviceAction.Device?.DeviceCategory?.FullPath); var cautodev = new CalcAutoDevDto(deviceAction.Device.Name, profile, lt.Name, lt.Guid, cdl, (double)hhautodev.TimeStandardDeviation, devcat.Guid, householdKey, actionProfile.Multiplier, calcLocation.Name, calcLocation.Guid, devcat.FullCategoryName, Guid.NewGuid().ToStrGuid(), availref, reqDtos, devcat.FullCategoryName); autodevs.Add(cautodev); //cautodev.ApplyBitArry(, _ltDict.LtDict[actionProfile.VLoadType]); } } }
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); }