| 617 | } |
| 618 | |
| 619 | bool PlantLoop_Impl::removeBranchWithComponent(HVACComponent component, Splitter splitter, Mixer mixer, bool isSupplyComponent) { |
| 620 | Model _model = model(); |
| 621 | |
| 622 | std::vector<ModelObject> backwardComponents = components(splitter, component); |
| 623 | std::vector<ModelObject> forwardComponents = components(component, mixer); |
| 624 | |
| 625 | // Validate that the component is between the demand splitter and mixer |
| 626 | if (backwardComponents.front().handle() != splitter.handle()) { |
| 627 | return false; |
| 628 | } |
| 629 | |
| 630 | if (backwardComponents.back().handle() != component.handle()) { |
| 631 | return false; |
| 632 | } |
| 633 | |
| 634 | if (forwardComponents.front().handle() != component.handle()) { |
| 635 | return false; |
| 636 | } |
| 637 | |
| 638 | if (forwardComponents.back().handle() != mixer.handle()) { |
| 639 | return false; |
| 640 | } |
| 641 | |
| 642 | // Remove the backwardComponents end because we don't want component twice |
| 643 | backwardComponents.erase(backwardComponents.end() - 1); |
| 644 | |
| 645 | // Combine forwardComponents and backwardComponents for a complete vector of all components on the branch |
| 646 | std::vector<ModelObject> allComponents(backwardComponents.begin(), backwardComponents.end()); |
| 647 | allComponents.insert(allComponents.end(), forwardComponents.begin(), forwardComponents.end()); |
| 648 | |
| 649 | // Remove the splitter and mixer from the vector |
| 650 | allComponents.erase(allComponents.begin()); |
| 651 | allComponents.erase(allComponents.end() - 1); |
| 652 | |
| 653 | for (auto& elem : allComponents) { |
| 654 | if (!elem.optionalCast<Node>()) { |
| 655 | if (boost::optional<StraightComponent> comp = elem.optionalCast<StraightComponent>()) { |
| 656 | elem.remove(); |
| 657 | } else if (boost::optional<WaterToAirComponent> comp = elem.optionalCast<WaterToAirComponent>()) { |
| 658 | comp->removeFromPlantLoop(); |
| 659 | |
| 660 | if (!comp->airLoopHVAC()) { |
| 661 | comp->remove(); |
| 662 | } |
| 663 | } else if (boost::optional<WaterToWaterComponent> comp = elem.optionalCast<WaterToWaterComponent>()) { |
| 664 | if (isSupplyComponent) { |
| 665 | comp->removeFromPlantLoop(); |
| 666 | } else { |
| 667 | comp->removeFromSecondaryPlantLoop(); |
| 668 | } |
| 669 | |
| 670 | if ((!comp->plantLoop()) && (!comp->secondaryPlantLoop())) { |
| 671 | comp->remove(); |
| 672 | } |
| 673 | } |
| 674 | } |
| 675 | } |
| 676 |
nothing calls this directly
no test coverage detected