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]); } } }
public List <CalcAutoDevDto> MakeCalcAutoDevDtos( [NotNull][ItemNotNull] List <IAutonomousDevice> autoDevices, EnergyIntensityType energyIntensity, [NotNull] HouseholdKey householdKey, [NotNull][ItemNotNull] List <VacationTimeframe> vacationTimeframes, [NotNull] string holidayKey, [NotNull][ItemNotNull] ObservableCollection <DeviceAction> deviceActions, [NotNull] LocationDtoDict locationDict, [NotNull] TemperatureProfile temperatureProfile, [NotNull] GeographicLocation geographicLocation, [ItemNotNull][NotNull] List <DeviceCategoryDto> deviceCategoryDtos) { var autodevs = new List <CalcAutoDevDto>(autoDevices.Count); //// zur kategorien zuordnung var allAutonomousDevices = new List <IAssignableDevice>(); allAutonomousDevices.AddRange(autoDevices.Select(x => x.Device)); foreach (var hhautodev in autoDevices) { var busyarr = new BitArray(_calcParameters.InternalTimesteps); busyarr.SetAll(false); Logger.Debug( "Determining the permitted times for each autonomous device. Device: " + hhautodev.Name); if (hhautodev.TimeLimit?.RootEntry == null) { throw new DataIntegrityException("Time limit was null"); } busyarr = hhautodev.TimeLimit.RootEntry.GetOneYearArray( _calcParameters.InternalStepsize, _calcParameters.InternalStartTime, _calcParameters.InternalEndTime, temperatureProfile, geographicLocation, _rnd, vacationTimeframes, holidayKey, out _, 0, 0, 0, 0); // invertieren von erlaubten zu verbotenen zeiten busyarr = busyarr.Not(); var timeprofilereference = _availabilityDtoRepository.MakeNewReference(hhautodev.TimeLimit.Name, busyarr); if (hhautodev.Location == null) { throw new DataIntegrityException("Location was null"); } var calcLocation = locationDict.LocationDict[hhautodev.Location]; if (hhautodev.Device == null) { throw new DataIntegrityException("Device was null"); } switch (hhautodev.Device.AssignableDeviceType) { case AssignableDeviceType.Device: case AssignableDeviceType.DeviceCategory: if (hhautodev.LoadType == null || hhautodev.TimeProfile == null) { throw new LPGException("load type was null"); } if (_loadTypeDictionary.SimulateLoadtype(hhautodev.LoadType)) { var profile = GetCalcProfileDto(hhautodev.TimeProfile); var rd = _picker.GetAutoDeviceDeviceFromDeviceCategoryOrDevice( hhautodev.Device, allAutonomousDevices, energyIntensity, deviceActions, hhautodev.Location.IntID); var cdl = MakeCalcDeviceLoads(rd, _loadTypeDictionary); var ltdto = _loadTypeDictionary.GetLoadtypeDtoByLoadType(hhautodev.LoadType); List <VariableRequirementDto> requirementDtos = new List <VariableRequirementDto>(); if (hhautodev.Variable != null) { var myVariable = _calcVariableRepositoryDtoFactory.RegisterVariableIfNotRegistered(hhautodev.Variable, hhautodev.Location, householdKey, locationDict); VariableRequirementDto req = new VariableRequirementDto(hhautodev.Variable.Name, hhautodev.VariableValue, calcLocation.Name, calcLocation.Guid, hhautodev.VariableCondition, myVariable.Guid); requirementDtos.Add(req); } if (rd.DeviceCategory == null) { throw new LPGException("Device category was null"); } var deviceCategoryDto = deviceCategoryDtos.Single(x => x.FullCategoryName == rd.DeviceCategory.FullPath); var cautodev = new CalcAutoDevDto(rd.Name, profile, ltdto.Name, ltdto.Guid, cdl, (double)hhautodev.TimeStandardDeviation, deviceCategoryDto.Guid, householdKey, 1, calcLocation.Name, calcLocation.Guid, deviceCategoryDto.FullCategoryName, Guid.NewGuid().ToStrGuid(), timeprofilereference, requirementDtos, deviceCategoryDto.FullCategoryName); autodevs.Add(cautodev); } break; case AssignableDeviceType.DeviceAction: case AssignableDeviceType.DeviceActionGroup: var deviceAction = _picker.GetAutoDeviceActionFromGroup(hhautodev.Device, allAutonomousDevices, energyIntensity, deviceActions, hhautodev.Location.IntID); foreach (var actionProfile in deviceAction.Profiles) { if (actionProfile.VLoadType == null) { throw new DataIntegrityException("Vloadtype was null"); } if (actionProfile.Timeprofile == null) { throw new DataIntegrityException("Timeprofile was null"); } if (_loadTypeDictionary.SimulateLoadtype(actionProfile.VLoadType)) { var profile = GetCalcProfileDto(actionProfile.Timeprofile); if (deviceAction.Device == null) { throw new LPGException("Device was null"); } var cdl = MakeCalcDeviceLoads(deviceAction.Device, _loadTypeDictionary); var lt = _loadTypeDictionary.GetLoadtypeDtoByLoadType(actionProfile.VLoadType); List <VariableRequirementDto> requirementDtos = new List <VariableRequirementDto>(); if (hhautodev.Variable != null) { var myVariable = _calcVariableRepositoryDtoFactory.RegisterVariableIfNotRegistered(hhautodev.Variable, hhautodev.Location, householdKey, locationDict); VariableRequirementDto req = new VariableRequirementDto(hhautodev.Variable?.Name, hhautodev.VariableValue, calcLocation.Name, calcLocation.Guid, hhautodev.VariableCondition, myVariable.Guid); requirementDtos.Add(req); } if (deviceAction.Device.DeviceCategory == null) { throw new LPGException("device category was null"); } var deviceCategoryDto = 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, deviceCategoryDto.Guid, householdKey, actionProfile.Multiplier, calcLocation.Name, calcLocation.Guid, deviceAction.Device.DeviceCategory.FullPath, Guid.NewGuid().ToStrGuid(), timeprofilereference, requirementDtos, deviceCategoryDto.FullCategoryName); autodevs.Add(cautodev); } } break; default: throw new LPGException("Forgotten AssignableDeviceType. Please Report!"); } } return(autodevs); }
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); }