src/energyplus/ReverseTranslator/ReverseTranslateBuilding.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/Building.hpp" | ||
| 9 | #include "../../model/Building_Impl.hpp" | ||
| 10 | #include "../../model/Site.hpp" | ||
| 11 | #include "../../model/Site_Impl.hpp" | ||
| 12 | #include "../../model/SimulationControl.hpp" | ||
| 13 | #include "../../model/SimulationControl_Impl.hpp" | ||
| 14 | |||
| 15 | #include <utilities/idd/Building_FieldEnums.hxx> | ||
| 16 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 17 | #include <utilities/idd/IddEnums.hxx> | ||
| 18 | |||
| 19 | using namespace openstudio::model; | ||
| 20 | |||
| 21 | namespace openstudio { | ||
| 22 | |||
| 23 | namespace energyplus { | ||
| 24 | |||
| 25 | 73 | OptionalModelObject ReverseTranslator::translateBuilding(const WorkspaceObject& workspaceObject) { | |
| 26 |
4/5✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
✓ Branch 7 taken 73 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 73 times.
|
73 | if (workspaceObject.iddObject().type() != IddObjectType::Building) { |
| 27 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: Building"); | |
| 28 | ✗ | return boost::none; | |
| 29 | } | ||
| 30 | |||
| 31 | // ensure that site and simulation control have been mapped | ||
| 32 |
4/4✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
✓ Branch 10 taken 10 times.
✓ Branch 11 taken 73 times.
|
83 | for (const WorkspaceObject& siteObject : m_workspace.getObjectsByType(IddObjectType::Site_Location)) { |
| 33 |
1/1✓ Branch 1 taken 10 times.
|
10 | translateAndMapWorkspaceObject(siteObject); |
| 34 | 73 | } | |
| 35 | |||
| 36 |
4/4✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
✓ Branch 10 taken 44 times.
✓ Branch 11 taken 73 times.
|
117 | for (const WorkspaceObject& simControlObject : m_workspace.getObjectsByType(IddObjectType::SimulationControl)) { |
| 37 |
1/1✓ Branch 1 taken 44 times.
|
44 | translateAndMapWorkspaceObject(simControlObject); |
| 38 | 73 | } | |
| 39 | |||
| 40 | // create the building | ||
| 41 |
1/1✓ Branch 1 taken 73 times.
|
73 | openstudio::model::Building building = m_model.getUniqueModelObject<Building>(); |
| 42 | |||
| 43 |
1/1✓ Branch 1 taken 73 times.
|
73 | OptionalString s = workspaceObject.name(); |
| 44 |
1/2✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
|
73 | if (s) { |
| 45 |
2/2✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
|
73 | building.setName(*s); |
| 46 | } | ||
| 47 | |||
| 48 |
1/1✓ Branch 1 taken 73 times.
|
73 | OptionalDouble d = workspaceObject.getDouble(openstudio::BuildingFields::NorthAxis); |
| 49 |
2/2✓ Branch 0 taken 17 times.
✓ Branch 1 taken 56 times.
|
73 | if (d) { |
| 50 |
2/2✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
|
17 | building.setNorthAxis(*d); |
| 51 | } | ||
| 52 | |||
| 53 | // fields that go to site | ||
| 54 |
1/1✓ Branch 1 taken 73 times.
|
73 | s = workspaceObject.getString(openstudio::BuildingFields::Terrain); |
| 55 |
1/2✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
|
73 | if (s) { |
| 56 |
1/1✓ Branch 1 taken 73 times.
|
73 | boost::optional<Site> site = m_model.getOptionalUniqueModelObject<Site>(); |
| 57 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 63 times.
|
73 | if (site) { |
| 58 |
3/3✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
|
10 | site->setTerrain(*s); |
| 59 | } | ||
| 60 | 73 | } | |
| 61 | |||
| 62 | // fields that go to simulation control | ||
| 63 |
1/1✓ Branch 1 taken 73 times.
|
73 | d = workspaceObject.getDouble(openstudio::BuildingFields::LoadsConvergenceToleranceValue); |
| 64 |
2/2✓ Branch 0 taken 17 times.
✓ Branch 1 taken 56 times.
|
73 | if (d) { |
| 65 |
2/2✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
|
17 | boost::optional<SimulationControl> simulationControl = m_model.getUniqueModelObject<SimulationControl>(); |
| 66 |
1/2✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
|
17 | if (simulationControl) { |
| 67 |
3/3✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
|
17 | simulationControl->setLoadsConvergenceToleranceValue(*d); |
| 68 | } | ||
| 69 | 17 | } | |
| 70 | |||
| 71 |
1/1✓ Branch 1 taken 73 times.
|
73 | d = workspaceObject.getDouble(openstudio::BuildingFields::TemperatureConvergenceToleranceValue); |
| 72 |
2/2✓ Branch 0 taken 17 times.
✓ Branch 1 taken 56 times.
|
73 | if (d) { |
| 73 |
2/2✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
|
17 | boost::optional<SimulationControl> simulationControl = m_model.getUniqueModelObject<SimulationControl>(); |
| 74 |
1/2✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
|
17 | if (simulationControl) { |
| 75 |
3/3✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
|
17 | simulationControl->setTemperatureConvergenceToleranceValue(*d); |
| 76 | } | ||
| 77 | 17 | } | |
| 78 | |||
| 79 |
1/1✓ Branch 1 taken 73 times.
|
73 | s = workspaceObject.getString(openstudio::BuildingFields::SolarDistribution); |
| 80 |
1/2✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
|
73 | if (s) { |
| 81 |
2/2✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
|
73 | boost::optional<SimulationControl> simulationControl = m_model.getUniqueModelObject<SimulationControl>(); |
| 82 |
1/2✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
|
73 | if (simulationControl) { |
| 83 |
3/3✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
✓ Branch 7 taken 73 times.
|
73 | simulationControl->setSolarDistribution(*s); |
| 84 | } | ||
| 85 | 73 | } | |
| 86 | |||
| 87 |
1/1✓ Branch 1 taken 73 times.
|
73 | OptionalInt i = workspaceObject.getInt(openstudio::BuildingFields::MaximumNumberofWarmupDays); |
| 88 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 60 times.
|
73 | if (i) { |
| 89 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
|
13 | boost::optional<SimulationControl> simulationControl = m_model.getUniqueModelObject<SimulationControl>(); |
| 90 |
1/2✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
|
13 | if (simulationControl) { |
| 91 |
3/3✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
|
13 | simulationControl->setMaximumNumberofWarmupDays(*i); |
| 92 | } | ||
| 93 | 13 | } | |
| 94 | |||
| 95 |
1/1✓ Branch 1 taken 73 times.
|
73 | i = workspaceObject.getInt(openstudio::BuildingFields::MinimumNumberofWarmupDays); |
| 96 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 58 times.
|
73 | if (i) { |
| 97 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | boost::optional<SimulationControl> simulationControl = m_model.getUniqueModelObject<SimulationControl>(); |
| 98 |
1/2✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
|
15 | if (simulationControl) { |
| 99 |
3/3✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
|
15 | simulationControl->setMinimumNumberofWarmupDays(*i); |
| 100 | } | ||
| 101 | 15 | } | |
| 102 | |||
| 103 |
1/1✓ Branch 1 taken 73 times.
|
73 | return building; |
| 104 | 73 | } | |
| 105 | |||
| 106 | } // namespace energyplus | ||
| 107 | |||
| 108 | } // namespace openstudio | ||
| 109 |