src/energyplus/ReverseTranslator/ReverseTranslateInternalMass.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 "../ReverseTranslator.hpp" | ||
| 7 | |||
| 8 | #include "../../model/InternalMass.hpp" | ||
| 9 | #include "../../model/InternalMass_Impl.hpp" | ||
| 10 | #include "../../model/InternalMassDefinition.hpp" | ||
| 11 | #include "../../model/InternalMassDefinition_Impl.hpp" | ||
| 12 | #include "../../model/Space.hpp" | ||
| 13 | #include "../../model/Space_Impl.hpp" | ||
| 14 | #include "../../model/SpaceType.hpp" | ||
| 15 | #include "../../model/SpaceType_Impl.hpp" | ||
| 16 | #include "../../model/ConstructionBase.hpp" | ||
| 17 | #include "../../model/ConstructionBase_Impl.hpp" | ||
| 18 | |||
| 19 | #include <utilities/idd/InternalMass_FieldEnums.hxx> | ||
| 20 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 21 | #include <utilities/idd/IddEnums.hxx> | ||
| 22 | |||
| 23 | using namespace openstudio::model; | ||
| 24 | |||
| 25 | namespace openstudio { | ||
| 26 | |||
| 27 | namespace energyplus { | ||
| 28 | |||
| 29 | 28 | OptionalModelObject ReverseTranslator::translateInternalMass(const WorkspaceObject& workspaceObject) { | |
| 30 |
4/5✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 28 times.
|
28 | if (workspaceObject.iddObject().type() != IddObjectType::InternalMass) { |
| 31 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: InternalMass"); | |
| 32 | ✗ | return boost::none; | |
| 33 | } | ||
| 34 | |||
| 35 | // create the definition | ||
| 36 |
1/1✓ Branch 1 taken 28 times.
|
28 | openstudio::model::InternalMassDefinition definition(m_model); |
| 37 | |||
| 38 |
1/1✓ Branch 1 taken 28 times.
|
28 | OptionalString s = workspaceObject.name(); |
| 39 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (s) { |
| 40 |
3/3✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
|
28 | definition.setName(*s + " Definition"); |
| 41 | } | ||
| 42 | |||
| 43 |
1/1✓ Branch 1 taken 28 times.
|
28 | OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::InternalMassFields::ConstructionName); |
| 44 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (target) { |
| 45 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); |
| 46 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (modelObject) { |
| 47 |
3/4✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✗ Branch 8 not taken.
|
56 | if (modelObject->optionalCast<ConstructionBase>()) { |
| 48 |
3/3✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
|
28 | definition.setConstruction(modelObject->cast<ConstructionBase>()); |
| 49 | } | ||
| 50 | } | ||
| 51 | 28 | } | |
| 52 | |||
| 53 |
1/1✓ Branch 1 taken 28 times.
|
28 | OptionalDouble d = workspaceObject.getDouble(openstudio::InternalMassFields::SurfaceArea); |
| 54 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (d) { |
| 55 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | definition.setSurfaceArea(*d); |
| 56 | } | ||
| 57 | |||
| 58 | // create the instance | ||
| 59 |
1/1✓ Branch 1 taken 28 times.
|
28 | InternalMass internalMass(definition); |
| 60 | |||
| 61 |
1/1✓ Branch 1 taken 28 times.
|
28 | s = workspaceObject.name(); |
| 62 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (s) { |
| 63 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | internalMass.setName(*s); |
| 64 | } | ||
| 65 | |||
| 66 |
1/1✓ Branch 1 taken 28 times.
|
28 | target = workspaceObject.getTarget(openstudio::InternalMassFields::ZoneorZoneListName); |
| 67 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (target) { |
| 68 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); |
| 69 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (modelObject) { |
| 70 |
3/4✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✗ Branch 8 not taken.
|
56 | if (modelObject->optionalCast<Space>()) { |
| 71 |
3/3✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
|
28 | internalMass.setSpace(modelObject->cast<Space>()); |
| 72 | ✗ | } else if (modelObject->optionalCast<SpaceType>()) { | |
| 73 | ✗ | internalMass.setSpaceType(modelObject->cast<SpaceType>()); | |
| 74 | } | ||
| 75 | } | ||
| 76 | 28 | } | |
| 77 | |||
| 78 |
1/1✓ Branch 1 taken 28 times.
|
28 | return internalMass; |
| 79 | 28 | } | |
| 80 | |||
| 81 | } // namespace energyplus | ||
| 82 | |||
| 83 | } // namespace openstudio | ||
| 84 |