private void MakeAffordanceTimelimit([NotNull] TemperatureProfile temperatureProfile, [NotNull] GeographicLocation geographicLocation, [NotNull] Random rnd, [NotNull][ItemNotNull] List <VacationTimeframe> vacationTimeframes, [NotNull] string holidayKey, [NotNull] List <DateTime> bridgeDays, AffordanceWithTimeLimit aff, [NotNull] out AvailabilityDataReferenceDto availabilityDataReference) { //time limit stuff if (aff.Affordance.TimeLimit == null) { throw new DataIntegrityException("The time limit on the affordance was null. Please fix", aff.Affordance); } var tl = aff.Affordance.TimeLimit; if (aff.TimeLimit != null) { tl = aff.TimeLimit; } if (tl.RootEntry == null) { throw new LPGException("Root Entry was null"); } var tmparr = tl.RootEntry.GetOneYearArray( _cp.InternalStepsize, _cp.InternalStartTime, _cp.InternalEndTime, temperatureProfile, geographicLocation, rnd, vacationTimeframes, holidayKey, out var tmpBridgeDays, aff.StartMinusTime, aff.StartPlusTime, aff.EndMinusTime, aff.EndPlusTime); foreach (var tmpBridgeDay in tmpBridgeDays) { if (!bridgeDays.Contains(tmpBridgeDay)) { bridgeDays.Add(tmpBridgeDay); } } // invertieren von erlaubten zu verbotenen zeiten tmparr = tmparr.Not(); availabilityDataReference = _availabilityDtoRepository.MakeNewReference(tl.Name, tmparr); }
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); }