| 105 | } |
| 106 | |
| 107 | std::vector<IdfObject> AirTerminalSingleDuctInletSideMixer_Impl::remove() { |
| 108 | Model _model = this->model(); |
| 109 | auto thisObject = this->getObject<AirTerminalSingleDuctInletSideMixer>(); |
| 110 | boost::optional<ThermalZone> t_thermalZone; |
| 111 | boost::optional<ZoneHVACComponent> t_zoneComp; |
| 112 | |
| 113 | if (boost::optional<AirLoopHVAC> t_airLoopHVAC = airLoopHVAC()) { |
| 114 | std::vector<ZoneHVACComponent> zoneComps = |
| 115 | subsetCastVector<ZoneHVACComponent>(t_airLoopHVAC->demandComponents(thisObject, t_airLoopHVAC->demandOutletNode())); |
| 116 | if (!zoneComps.empty()) { |
| 117 | t_zoneComp = zoneComps.front(); |
| 118 | t_thermalZone = t_zoneComp->thermalZone(); |
| 119 | t_zoneComp->removeFromThermalZone(); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | boost::optional<ModelObject> sourceModelObject = this->inletModelObject(); |
| 124 | boost::optional<unsigned> sourcePort = this->connectedObjectPort(this->inletPort()); |
| 125 | |
| 126 | boost::optional<ModelObject> targetModelObject = this->outletModelObject(); |
| 127 | boost::optional<unsigned> targetPort = this->connectedObjectPort(this->outletPort()); |
| 128 | |
| 129 | std::vector<ThermalZone> thermalZones = _model.getConcreteModelObjects<ThermalZone>(); |
| 130 | for (auto& thermalZone : thermalZones) { |
| 131 | std::vector<ModelObject> equipment = thermalZone.equipment(); |
| 132 | |
| 133 | if (std::find(equipment.begin(), equipment.end(), thisObject) != equipment.end()) { |
| 134 | thermalZone.removeEquipment(thisObject); |
| 135 | |
| 136 | break; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | if (sourcePort && sourceModelObject && targetPort && targetModelObject) { |
| 141 | if (boost::optional<Node> inletNode = sourceModelObject->optionalCast<Node>()) { |
| 142 | if (boost::optional<ModelObject> source2ModelObject = inletNode->inletModelObject()) { |
| 143 | if (boost::optional<unsigned> source2Port = inletNode->connectedObjectPort(inletNode->inletPort())) { |
| 144 | _model.connect(source2ModelObject.get(), source2Port.get(), targetModelObject.get(), targetPort.get()); |
| 145 | |
| 146 | inletNode->disconnect(); |
| 147 | inletNode->remove(); |
| 148 | |
| 149 | std::vector<IdfObject> result = StraightComponent_Impl::remove(); |
| 150 | if (t_thermalZone) { |
| 151 | t_zoneComp->addToThermalZone(t_thermalZone.get()); |
| 152 | } |
| 153 | return result; |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | model().disconnect(getObject<ModelObject>(), inletPort()); |
| 160 | model().disconnect(getObject<ModelObject>(), outletPort()); |
| 161 | |
| 162 | return StraightComponent_Impl::remove(); |
| 163 | } |
| 164 |
nothing calls this directly
no test coverage detected