| 111 | } |
| 112 | |
| 113 | bool AirLoopHVACReturnPlenum_Impl::addToNode(Node& node) { |
| 114 | bool result = true; |
| 115 | |
| 116 | Model _model = model(); |
| 117 | // Is the node in this model |
| 118 | if (node.model() != _model) { |
| 119 | return false; |
| 120 | } |
| 121 | |
| 122 | auto thisObject = getObject<AirLoopHVACReturnPlenum>(); |
| 123 | |
| 124 | auto outletObj = node.outletModelObject(); |
| 125 | auto inletObj = node.inletModelObject(); |
| 126 | |
| 127 | boost::optional<ZoneHVACComponent> zoneHVAC; |
| 128 | if (outletObj) { |
| 129 | zoneHVAC = outletObj->optionalCast<ZoneHVACComponent>(); |
| 130 | } |
| 131 | |
| 132 | // Plenum can be attached to ZoneHVAC OR AirLoopHVAC |
| 133 | if (zoneHVAC) { |
| 134 | // don't let a plenum connect to ZoneHVAC and AirLoopHVAC at the same time |
| 135 | if (airLoopHVAC()) { |
| 136 | result = false; |
| 137 | } |
| 138 | |
| 139 | boost::optional<ThermalZone> zone; |
| 140 | |
| 141 | if (inletObj) { |
| 142 | auto pl = inletObj->optionalCast<PortList>(); |
| 143 | if (pl) { |
| 144 | zone = pl->thermalZone(); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | if (!zone) { |
| 149 | result = false; |
| 150 | } |
| 151 | |
| 152 | if (result) { |
| 153 | _model.connect(node, node.outletPort(), thisObject, thisObject.nextInletPort()); |
| 154 | |
| 155 | Node zoneHVACInletNode(_model); |
| 156 | _model.connect(zoneHVACInletNode, zoneHVACInletNode.outletPort(), zoneHVAC.get(), zoneHVAC->inletPort()); |
| 157 | auto pl = inducedAirOutletPortList(); |
| 158 | _model.connect(pl, pl.nextPort(), zoneHVACInletNode, zoneHVACInletNode.inletPort()); |
| 159 | } |
| 160 | } else { |
| 161 | // Is the node part of an air loop |
| 162 | auto nodeAirLoop = node.airLoopHVAC(); |
| 163 | |
| 164 | if (!nodeAirLoop) { |
| 165 | result = false; |
| 166 | } |
| 167 | |
| 168 | // Is this plenum already connected to a different air loop |
| 169 | auto currentAirLoopHVAC = airLoopHVAC(); |
| 170 | if (currentAirLoopHVAC && (currentAirLoopHVAC.get() != nodeAirLoop)) { |
nothing calls this directly
no test coverage detected