| 333 | } |
| 334 | |
| 335 | bool AirLoopHVAC_Impl::addBranchForZoneImpl(ThermalZone& thermalZone, AirLoopHVAC& airLoopHVAC, Splitter& splitter, Mixer& mixer, |
| 336 | bool removeCurrentZones, OptionalHVACComponent& optAirTerminal) { |
| 337 | Model _model = thermalZone.model(); |
| 338 | |
| 339 | if ((optAirTerminal && _model != optAirTerminal->model()) || _model != splitter.model() || _model != mixer.model()) { |
| 340 | return false; |
| 341 | } |
| 342 | |
| 343 | if (optAirTerminal && optAirTerminal->airLoopHVAC()) { |
| 344 | return false; |
| 345 | } |
| 346 | |
| 347 | if (thermalZone.isPlenum()) { |
| 348 | return false; |
| 349 | } |
| 350 | |
| 351 | if (!airLoopHVAC.demandComponent(splitter.handle())) { |
| 352 | return false; |
| 353 | } |
| 354 | |
| 355 | if (!airLoopHVAC.demandComponent(mixer.handle())) { |
| 356 | return false; |
| 357 | } |
| 358 | |
| 359 | if (optAirTerminal && !airLoopHVAC.getImpl<detail::AirLoopHVAC_Impl>()->isTerminalTypeValid(optAirTerminal.get())) { |
| 360 | return false; |
| 361 | } |
| 362 | |
| 363 | auto currentloops = thermalZone.airLoopHVACs(); |
| 364 | auto h = airLoopHVAC.handle(); |
| 365 | for (const auto& loop : currentloops) { |
| 366 | if (h == loop.handle()) { |
| 367 | return false; |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | auto lastThermalZone = zoneForLastBranch(mixer); |
| 372 | auto lastAirTerminal = terminalForLastBranch(mixer); |
| 373 | auto modelObjects = airLoopHVAC.demandComponents(splitter, mixer); |
| 374 | auto hasSupplyPlenum = !subsetCastVector<AirLoopHVACSupplyPlenum>(modelObjects).empty(); |
| 375 | auto hasReturnPlenum = !subsetCastVector<AirLoopHVACReturnPlenum>(modelObjects).empty(); |
| 376 | |
| 377 | // If all of these conditions are met, then clone the "last" air terminal |
| 378 | if ((!optAirTerminal) && (!hasSupplyPlenum) && (!hasReturnPlenum) && lastThermalZone && lastAirTerminal) { |
| 379 | // clone the air terminal |
| 380 | Model t_model = airLoopHVAC.model(); |
| 381 | auto airTerminal = lastAirTerminal->clone(t_model).cast<HVACComponent>(); |
| 382 | optAirTerminal = airTerminal; |
| 383 | |
| 384 | // Reconnect the cloned terminal to the plant loop(s) |
| 385 | |
| 386 | // Special case for FourPipeInduction for now, which has both a cooling and heating plantLoop |
| 387 | if (lastAirTerminal->iddObjectType() == IddObjectType::OS_AirTerminal_SingleDuct_ConstantVolume_FourPipeInduction) { |
| 388 | |
| 389 | // Safe to directly cast |
| 390 | auto lastAtuFourPipe = lastAirTerminal->cast<AirTerminalSingleDuctConstantVolumeFourPipeInduction>(); |
| 391 | auto newAtuFourPipe = airTerminal.cast<AirTerminalSingleDuctConstantVolumeFourPipeInduction>(); |
| 392 |
nothing calls this directly
no test coverage detected