src/energyplus/ReverseTranslator/ReverseTranslateExteriorLights.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/ExteriorLights.hpp" | ||
| 9 | #include "../../model/ExteriorLights_Impl.hpp" | ||
| 10 | #include "../../model/ExteriorLightsDefinition.hpp" | ||
| 11 | #include "../../model/ExteriorLightsDefinition_Impl.hpp" | ||
| 12 | #include "../../model/Schedule.hpp" | ||
| 13 | #include "../../model/Schedule_Impl.hpp" | ||
| 14 | |||
| 15 | #include <utilities/idd/Exterior_Lights_FieldEnums.hxx> | ||
| 16 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 17 | #include <utilities/idd/IddEnums.hxx> | ||
| 18 | |||
| 19 | #include "../../utilities/core/Assert.hpp" | ||
| 20 | |||
| 21 | namespace openstudio { | ||
| 22 | namespace energyplus { | ||
| 23 | |||
| 24 | 4 | boost::optional<model::ModelObject> ReverseTranslator::translateExteriorLights(const WorkspaceObject& workspaceObject) { | |
| 25 |
4/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4 times.
|
4 | if (workspaceObject.iddObject().type() != IddObjectType::Exterior_Lights) { |
| 26 | ✗ | LOG(Error, "WorkspaceObject " << workspaceObject.briefDescription() << " is not of IddObjectType::Exterior_Lights."); | |
| 27 | ✗ | return boost::none; | |
| 28 | } | ||
| 29 | |||
| 30 |
1/1✓ Branch 1 taken 4 times.
|
4 | model::ExteriorLightsDefinition definition(m_model); |
| 31 | |||
| 32 | 4 | OptionalString s; | |
| 33 | 4 | OptionalDouble d; | |
| 34 | |||
| 35 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
8 | if ((s = workspaceObject.name())) { |
| 36 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | definition.setName(*s + " Definition"); |
| 37 | } | ||
| 38 | |||
| 39 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
8 | if ((d = workspaceObject.getDouble(Exterior_LightsFields::DesignLevel))) { |
| 40 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | definition.setDesignLevel(*d); |
| 41 | } | ||
| 42 | |||
| 43 | 4 | model::OptionalExteriorLights exteriorLights; | |
| 44 | 4 | model::OptionalSchedule schedule; | |
| 45 | |||
| 46 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
8 | if (OptionalWorkspaceObject target = workspaceObject.getTarget(Exterior_LightsFields::ScheduleName)) { |
| 47 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
|
8 | if (model::OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target)) { |
| 48 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | schedule = modelObject->optionalCast<model::Schedule>(); |
| 49 | 4 | } | |
| 50 | 4 | } | |
| 51 | |||
| 52 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (schedule) { |
| 53 | try { | ||
| 54 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | exteriorLights = model::ExteriorLights(definition, *schedule); |
| 55 | ✗ | } catch (std::exception& e) { | |
| 56 | ✗ | LOG(Warn, "Could not reverse translate " << workspaceObject.briefDescription() << " in full, because " << e.what() << "."); | |
| 57 | ✗ | } | |
| 58 | } | ||
| 59 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if (!exteriorLights) { |
| 60 | ✗ | exteriorLights = model::ExteriorLights(definition); | |
| 61 | } | ||
| 62 | |||
| 63 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
|
4 | OS_ASSERT(exteriorLights); |
| 64 | |||
| 65 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
8 | if ((s = workspaceObject.name())) { |
| 66 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | exteriorLights->setName(*s); |
| 67 | } | ||
| 68 | |||
| 69 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
8 | if ((s = workspaceObject.getString(Exterior_LightsFields::ControlOption, false, true))) { |
| 70 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | exteriorLights->setControlOption(*s); |
| 71 | } | ||
| 72 | |||
| 73 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
8 | if ((s = workspaceObject.getString(Exterior_LightsFields::EndUseSubcategory, false, true))) { |
| 74 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | exteriorLights->setEndUseSubcategory(*s); |
| 75 | } | ||
| 76 | |||
| 77 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | return *exteriorLights; |
| 78 | 4 | } | |
| 79 | |||
| 80 | } // namespace energyplus | ||
| 81 | } // namespace openstudio | ||
| 82 |