src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.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/EnergyManagementSystemActuator.hpp" | ||
| 9 | #include "../../model/EnergyManagementSystemActuator_Impl.hpp" | ||
| 10 | |||
| 11 | #include <utilities/idd/EnergyManagementSystem_Actuator_FieldEnums.hxx> | ||
| 12 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 13 | #include <utilities/idd/IddEnums.hxx> | ||
| 14 | |||
| 15 | using namespace openstudio::model; | ||
| 16 | |||
| 17 | namespace openstudio { | ||
| 18 | |||
| 19 | namespace energyplus { | ||
| 20 | |||
| 21 | 10 | OptionalModelObject ReverseTranslator::translateEnergyManagementSystemActuator(const WorkspaceObject& workspaceObject) { | |
| 22 |
4/5✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 10 times.
|
10 | if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Actuator) { |
| 23 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_Actuator"); | |
| 24 | ✗ | return boost::none; | |
| 25 | } | ||
| 26 | |||
| 27 |
1/1✓ Branch 1 taken 10 times.
|
10 | OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::Name); |
| 28 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
|
10 | if (!s1) { |
| 29 | ✗ | LOG(Error, "WorkspaceObject EnergyManagementSystem_Actuator has no name"); | |
| 30 | ✗ | return boost::none; | |
| 31 | } | ||
| 32 | |||
| 33 |
1/1✓ Branch 1 taken 10 times.
|
10 | OptionalString s = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName); |
| 34 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
|
10 | if (!s) { |
| 35 | ✗ | LOG(Error, workspaceObject.nameString() + ": has no ActuatedComponentUniqueName"); | |
| 36 | ✗ | return boost::none; | |
| 37 | } | ||
| 38 | |||
| 39 |
1/1✓ Branch 1 taken 10 times.
|
10 | Workspace workspace = workspaceObject.workspace(); |
| 40 | |||
| 41 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if (s) { |
| 42 |
2/2✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
|
10 | std::vector<WorkspaceObject> wsObjects = workspace.getObjectsByName(*s); |
| 43 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
|
10 | if (wsObjects.size() > 1) { |
| 44 | ✗ | LOG(Error, workspaceObject.nameString() + ": ActuatedComponentUniqueName is not unique. More than 1 object with that name."); | |
| 45 | ✗ | return boost::none; | |
| 46 | } | ||
| 47 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 2 taken 1 time.
|
10 | if (wsObjects.empty()) { |
| 48 |
7/7✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 15 taken 9 times.
✓ Branch 18 taken 9 times.
✓ Branch 21 taken 9 times.
|
9 | LOG(Error, workspaceObject.nameString() + ": ActuatedComponentUniqueName not found."); |
| 49 | 9 | return boost::none; | |
| 50 | } else { | ||
| 51 | //ActuatedComponent's name is unique so we can continue and try to translate that object. | ||
| 52 |
1/1✓ Branch 2 taken 1 time.
|
1 | boost::optional<model::ModelObject> modelObject = translateAndMapWorkspaceObject(wsObjects[0]); |
| 53 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (modelObject) { |
| 54 | ✗ | openstudio::model::EnergyManagementSystemActuator emsActuator(modelObject.get()); | |
| 55 | ✗ | emsActuator.setName(*s1); | |
| 56 | ✗ | emsActuator.setActuatedComponent(modelObject.get()); | |
| 57 | ✗ | s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType); | |
| 58 | ✗ | if (s1) { | |
| 59 | ✗ | emsActuator.setActuatedComponentType(*s1); | |
| 60 | } | ||
| 61 | |||
| 62 | ✗ | s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType); | |
| 63 | ✗ | if (s1) { | |
| 64 | ✗ | emsActuator.setActuatedComponentControlType(*s1); | |
| 65 | } | ||
| 66 | ✗ | return emsActuator; | |
| 67 | ✗ | } else { | |
| 68 |
8/8✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 8 taken 1 time.
✓ Branch 11 taken 1 time.
✓ Branch 14 taken 1 time.
✓ Branch 20 taken 1 time.
✓ Branch 23 taken 1 time.
✓ Branch 26 taken 1 time.
|
1 | LOG(Warn, "ATTENTION: Actuated Object " + wsObjects[0].nameString() + " does not reverse translate. ActuatedComponent is NOT set."); |
| 69 |
1/1✓ Branch 1 taken 1 time.
|
1 | openstudio::model::EnergyManagementSystemActuator emsActuator(m_model); |
| 70 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::Name); |
| 71 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | emsActuator.setName(*s1); |
| 72 |
1/1✓ Branch 1 taken 1 time.
|
1 | s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName); |
| 73 | //Set actuated component as a comment since it cannot be reverse translated. | ||
| 74 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | emsActuator.setComment("Actuated Component Name = " + *s1); |
| 75 |
1/1✓ Branch 1 taken 1 time.
|
1 | s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType); |
| 76 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (s1) { |
| 77 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | emsActuator.setActuatedComponentType(*s1); |
| 78 | } | ||
| 79 | |||
| 80 |
1/1✓ Branch 1 taken 1 time.
|
1 | s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType); |
| 81 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (s1) { |
| 82 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | emsActuator.setActuatedComponentControlType(*s1); |
| 83 | } | ||
| 84 |
1/1✓ Branch 1 taken 1 time.
|
1 | return emsActuator; |
| 85 | 1 | } | |
| 86 | 1 | } | |
| 87 | 10 | } | |
| 88 | ✗ | return boost::none; | |
| 89 | 10 | } | |
| 90 | |||
| 91 | } // namespace energyplus | ||
| 92 | |||
| 93 | } // namespace openstudio | ||
| 94 |