| 318 | } |
| 319 | |
| 320 | bool ZoneHVACComponent_Impl::addToNode(Node& node) { |
| 321 | bool result = false; |
| 322 | |
| 323 | boost::optional<ThermalZone> thermalZone; |
| 324 | boost::optional<AirTerminalSingleDuctInletSideMixer> terminal; |
| 325 | |
| 326 | if (boost::optional<ModelObject> outlet = node.outletModelObject()) { |
| 327 | if (boost::optional<PortList> pl = outlet->optionalCast<PortList>()) { |
| 328 | thermalZone = pl->thermalZone(); |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | if (boost::optional<ModelObject> inlet = node.inletModelObject()) { |
| 333 | terminal = inlet->optionalCast<AirTerminalSingleDuctInletSideMixer>(); |
| 334 | } |
| 335 | |
| 336 | if (thermalZone && terminal) { |
| 337 | if (this->thermalZone()) { |
| 338 | removeFromThermalZone(); |
| 339 | } |
| 340 | thermalZone->setUseIdealAirLoads(false); |
| 341 | auto thisObject = getObject<ZoneHVACComponent>(); |
| 342 | thermalZone->addEquipment(thisObject); |
| 343 | thermalZone->setCoolingPriority(thisObject, 1); |
| 344 | thermalZone->setHeatingPriority(thisObject, 1); |
| 345 | Model t_model = model(); |
| 346 | ModelObject thisModelObject = getObject<model::ZoneHVACComponent>(); |
| 347 | unsigned targetPort = node.connectedObjectPort(node.outletPort()).get(); |
| 348 | ModelObject targetModelObject = node.connectedObject(node.outletPort()).get(); |
| 349 | Node newNode(t_model); |
| 350 | t_model.connect(node, node.outletPort(), thisModelObject, inletPort()); |
| 351 | t_model.connect(thisModelObject, outletPort(), newNode, newNode.inletPort()); |
| 352 | t_model.connect(newNode, newNode.outletPort(), targetModelObject, targetPort); |
| 353 | |
| 354 | Node exhaustNode(t_model); |
| 355 | PortList exhaustPortList = thermalZone->exhaustPortList(); |
| 356 | unsigned nextPort = exhaustPortList.nextPort(); |
| 357 | t_model.connect(exhaustPortList, nextPort, exhaustNode, exhaustNode.inletPort()); |
| 358 | t_model.connect(exhaustNode, exhaustNode.outletPort(), terminal.get(), terminal->secondaryAirInletPort()); |
| 359 | |
| 360 | result = true; |
| 361 | } |
| 362 | |
| 363 | return result; |
| 364 | } |
| 365 | |
| 366 | void ZoneHVACComponent_Impl::removeFromInletSideMixer() { |
| 367 | if (boost::optional<AirLoopHVAC> t_airLoopHVAC = airLoopHVAC()) { |
no test coverage detected