src/energyplus/ForwardTranslator/ForwardTranslatePortList.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "../ForwardTranslator.hpp" | ||
| 7 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 8 | #include "../../model/Node.hpp" | ||
| 9 | #include "../../model/Node_Impl.hpp" | ||
| 10 | #include "../../model/PortList.hpp" | ||
| 11 | #include "../../model/PortList_Impl.hpp" | ||
| 12 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 13 | #include <utilities/idd/IddEnums.hxx> | ||
| 14 | #include <utilities/idd/NodeList_FieldEnums.hxx> | ||
| 15 | |||
| 16 | using namespace openstudio::model; | ||
| 17 | |||
| 18 | namespace openstudio { | ||
| 19 | |||
| 20 | namespace energyplus { | ||
| 21 | |||
| 22 | 236 | boost::optional<IdfObject> ForwardTranslator::translatePortList(PortList& modelObject) { | |
| 23 | 236 | OptionalString s; | |
| 24 | 236 | OptionalDouble d; | |
| 25 | 236 | OptionalModelObject temp; | |
| 26 | |||
| 27 | // Create a new IddObjectType::NodeList | ||
| 28 | // If you don't want a node list based on the port list, don't use this translator | ||
| 29 | |||
| 30 |
1/1✓ Branch 1 taken 236 times.
|
236 | std::vector<ModelObject> modelObjects = modelObject.modelObjects(); |
| 31 | |||
| 32 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 236 times.
|
236 | if (modelObjects.empty()) { |
| 33 | // do not write out this object | ||
| 34 | ✗ | return boost::none; | |
| 35 | } | ||
| 36 | |||
| 37 |
2/2✓ Branch 1 taken 236 times.
✓ Branch 4 taken 236 times.
|
236 | IdfObject idfObject(IddObjectType::NodeList); |
| 38 | |||
| 39 | // Name | ||
| 40 |
1/1✓ Branch 1 taken 236 times.
|
236 | s = modelObject.name(); |
| 41 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
|
236 | if (s) { |
| 42 | ✗ | idfObject.setName(*s); | |
| 43 | } | ||
| 44 | |||
| 45 |
2/2✓ Branch 5 taken 238 times.
✓ Branch 6 taken 236 times.
|
474 | for (const auto& modelObject : modelObjects) { |
| 46 |
2/3✓ Branch 1 taken 238 times.
✓ Branch 3 taken 238 times.
✗ Branch 4 not taken.
|
476 | if (boost::optional<Node> node = modelObject.optionalCast<Node>()) { |
| 47 |
1/1✓ Branch 1 taken 238 times.
|
238 | IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); |
| 48 | |||
| 49 |
4/4✓ Branch 1 taken 238 times.
✓ Branch 4 taken 238 times.
✓ Branch 7 taken 238 times.
✓ Branch 10 taken 238 times.
|
238 | group.setString(NodeListExtensibleFields::NodeName, node->name().get()); |
| 50 | 476 | } | |
| 51 | } | ||
| 52 | |||
| 53 |
1/1✓ Branch 1 taken 236 times.
|
236 | m_idfObjects.push_back(idfObject); |
| 54 | |||
| 55 |
1/1✓ Branch 1 taken 236 times.
|
236 | return idfObject; |
| 56 | 236 | } | |
| 57 | |||
| 58 | } // namespace energyplus | ||
| 59 | |||
| 60 | } // namespace openstudio | ||
| 61 |