| 61 | } |
| 62 | |
| 63 | bool SetpointManager_Impl::addToNode(Node& node) { |
| 64 | if (node.model() != this->model()) { |
| 65 | return false; |
| 66 | } |
| 67 | |
| 68 | // Erase any existing setpoint manager that has the same control variable |
| 69 | // eg you can't have two temperature ones. But Humidity ones can be MaximumHumidityRatio or MinimumHumidityRatio so you can have a Min and Max |
| 70 | std::vector<SetpointManager> _setpointManagers = node.setpointManagers(); |
| 71 | if (!_setpointManagers.empty()) { |
| 72 | for (auto it = _setpointManagers.begin(); it != _setpointManagers.end(); ++it) { |
| 73 | if (istringEqual(this->controlVariable(), it->controlVariable())) { |
| 74 | it->remove(); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | if (OptionalAirLoopHVAC airLoop = node.airLoopHVAC()) { |
| 80 | // If this is one of the regular nodes of the supply path (eg not in the AirLoopHVACOASys) |
| 81 | if (airLoop->supplyComponent(node.handle())) { |
| 82 | return this->setSetpointNode(node); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | if (OptionalAirLoopHVACOutdoorAirSystem oaSystem = node.airLoopHVACOutdoorAirSystem()) { |
| 87 | // We only accept it if it's neither the relief or the OA node (doesn't make sense to place one there) |
| 88 | if ((node != oaSystem->outboardReliefNode()) && (node != oaSystem->outboardOANode())) { |
| 89 | return this->setSetpointNode(node); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // If the specific SPM (derived class) is allowed on PlantLoop, then we allow it on the supply side, |
| 94 | // or the demand side EXCEPT on a demand branch |
| 95 | if (boost::optional<PlantLoop> plant = node.plantLoop()) { |
| 96 | if (this->isAllowedOnPlantLoop()) { |
| 97 | // If it's the supply side |
| 98 | if (plant->supplyComponent(node.handle())) { |
| 99 | return this->setSetpointNode(node); |
| 100 | } else { |
| 101 | // On the demand side |
| 102 | Splitter splitter = plant->demandSplitter(); |
| 103 | Mixer mixer = plant->demandMixer(); |
| 104 | // We check that the node is NOT between the splitter and the mixer |
| 105 | auto branchcomps = plant->demandComponents(splitter, mixer); |
| 106 | if (std::find(branchcomps.begin(), branchcomps.end(), node) == branchcomps.end()) { |
| 107 | return this->setSetpointNode(node); |
| 108 | } else { |
| 109 | LOG(Info, this->briefDescription() << " cannot be added on a demand branch"); |
| 110 | } |
| 111 | } |
| 112 | } else { |
| 113 | LOG(Info, "This SetpointManager cannot be connected to a PlantLoop, for " << this->briefDescription()); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | return false; |
| 118 | } |
| 119 | |
| 120 | std::vector<openstudio::IdfObject> SetpointManager_Impl::remove() { |
nothing calls this directly
no test coverage detected