MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / disconnect

Method disconnect

src/model/Model.cpp:1420–1508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1418 }
1419
1420 void Model_Impl::disconnect(ModelObject object, unsigned port) {
1421 if (boost::optional<HVACComponent> hvacComponent = object.optionalCast<HVACComponent>()) {
1422 std::shared_ptr<HVACComponent_Impl> hvacComponentImpl;
1423 hvacComponentImpl = hvacComponent->getImpl<HVACComponent_Impl>();
1424 hvacComponentImpl->m_airLoopHVAC = boost::none;
1425 hvacComponentImpl->m_airLoopHVACOutdoorAirSystem = boost::none;
1426 hvacComponentImpl->m_plantLoop = boost::none;
1427 }
1428
1429 if (boost::optional<WaterToWaterComponent> waterToWaterComponent = object.optionalCast<WaterToWaterComponent>()) {
1430 std::shared_ptr<WaterToWaterComponent_Impl> waterToWaterComponentImpl;
1431 waterToWaterComponentImpl = waterToWaterComponent->getImpl<WaterToWaterComponent_Impl>();
1432 waterToWaterComponentImpl->m_secondaryPlantLoop = boost::none;
1433 waterToWaterComponentImpl->m_tertiaryPlantLoop = boost::none;
1434 }
1435
1436 Model m = model();
1437 OptionalModelObject optionalObject;
1438 OptionalUnsigned optionalPort;
1439 OptionalWorkspaceObject wo;
1440
1441 // find a connection that exists at the given object and port
1442 if (boost::optional<Connection> connection = object.getModelObjectTarget<Connection>(port)) {
1443 boost::optional<ModelObject> sourceObject;
1444 boost::optional<ModelObject> targetObject;
1445 boost::optional<unsigned> sourcePort;
1446 boost::optional<unsigned> targetPort;
1447
1448 sourceObject = connection->sourceObject();
1449 sourcePort = connection->sourceObjectPort();
1450
1451 targetObject = connection->targetObject();
1452 targetPort = connection->targetObjectPort();
1453
1454 // This resets the cache
1455 if (targetObject) {
1456 if (boost::optional<HVACComponent> hvacComponent = targetObject->optionalCast<HVACComponent>()) {
1457 std::shared_ptr<HVACComponent_Impl> hvacComponentImpl;
1458 hvacComponentImpl = hvacComponent->getImpl<HVACComponent_Impl>();
1459 hvacComponentImpl->m_airLoopHVAC = boost::none;
1460 hvacComponentImpl->m_airLoopHVACOutdoorAirSystem = boost::none;
1461 hvacComponentImpl->m_plantLoop = boost::none;
1462 }
1463
1464 if (boost::optional<WaterToWaterComponent> waterToWaterComponent = targetObject->optionalCast<WaterToWaterComponent>()) {
1465 std::shared_ptr<WaterToWaterComponent_Impl> waterToWaterComponentImpl;
1466 waterToWaterComponentImpl = waterToWaterComponent->getImpl<WaterToWaterComponent_Impl>();
1467 waterToWaterComponentImpl->m_secondaryPlantLoop = boost::none;
1468 waterToWaterComponentImpl->m_tertiaryPlantLoop = boost::none;
1469 }
1470 }
1471
1472 if (targetObject && targetPort) {
1473 if (boost::optional<PortList> portList = targetObject->optionalCast<PortList>()) {
1474 portList->getImpl<model::detail::PortList_Impl>()->removePort(targetPort.get());
1475 } else {
1476 targetObject->setString(targetPort.get(), "");
1477 }

Callers 15

removeMethod · 0.45
removeMethod · 0.45
removeMethod · 0.45
removeMethod · 0.45
removeMethod · 0.45
removeSupplySplitterMethod · 0.45
removeMethod · 0.45
removeMethod · 0.45
removeMethod · 0.45
removeMethod · 0.45

Calls 8

sourceObjectMethod · 0.80
sourceObjectPortMethod · 0.80
targetObjectMethod · 0.80
targetObjectPortMethod · 0.80
removePortMethod · 0.80
getMethod · 0.45
setStringMethod · 0.45
removeMethod · 0.45

Tested by 10

TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36