src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.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/EnergyManagementSystemProgramCallingManager.hpp" | ||
| 9 | #include "../../model/EnergyManagementSystemProgramCallingManager_Impl.hpp" | ||
| 10 | #include "../../model/EnergyManagementSystemProgram.hpp" | ||
| 11 | #include "../../model/EnergyManagementSystemProgram_Impl.hpp" | ||
| 12 | |||
| 13 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 14 | #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp" | ||
| 15 | |||
| 16 | #include <utilities/idd/EnergyManagementSystem_ProgramCallingManager_FieldEnums.hxx> | ||
| 17 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 18 | #include <utilities/idd/IddEnums.hxx> | ||
| 19 | |||
| 20 | using namespace openstudio::model; | ||
| 21 | |||
| 22 | namespace openstudio { | ||
| 23 | |||
| 24 | namespace energyplus { | ||
| 25 | |||
| 26 | 2 | OptionalModelObject ReverseTranslator::translateEnergyManagementSystemProgramCallingManager(const WorkspaceObject& workspaceObject) { | |
| 27 |
4/5✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
|
2 | if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_ProgramCallingManager) { |
| 28 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_ProgramCallingManager"); | |
| 29 | ✗ | return boost::none; | |
| 30 | } | ||
| 31 | |||
| 32 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalString s = workspaceObject.getString(EnergyManagementSystem_ProgramCallingManagerFields::Name); |
| 33 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!s) { |
| 34 | ✗ | LOG(Error, "WorkspaceObject EnergyManagementSystem_ProgramCallingManager has no name"); | |
| 35 | ✗ | return boost::none; | |
| 36 | } | ||
| 37 | |||
| 38 | //make sure all other objects are translated first except below | ||
| 39 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 8 taken 36 times.
✓ Branch 9 taken 2 times.
|
38 | for (const WorkspaceObject& workspaceObject : m_workspace.objects()) { |
| 40 |
4/6✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 8 taken 30 times.
✓ Branch 9 taken 6 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
72 | if ((workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Program) |
| 41 |
11/14✓ Branch 1 taken 36 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 32 times.
✓ Branch 9 taken 32 times.
✓ Branch 12 taken 32 times.
✓ Branch 15 taken 30 times.
✓ Branch 16 taken 2 times.
✓ Branch 17 taken 32 times.
✓ Branch 18 taken 4 times.
✓ Branch 20 taken 36 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
72 | && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_ProgramCallingManager)) { |
| 42 |
1/1✓ Branch 1 taken 30 times.
|
30 | translateAndMapWorkspaceObject(workspaceObject); |
| 43 | } | ||
| 44 | 2 | } | |
| 45 | |||
| 46 |
1/1✓ Branch 1 taken 2 times.
|
2 | openstudio::model::EnergyManagementSystemProgramCallingManager emsProgramCallingManager(m_model); |
| 47 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | emsProgramCallingManager.setName(*s); |
| 48 | |||
| 49 |
1/1✓ Branch 1 taken 2 times.
|
2 | s = workspaceObject.getString(EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint); |
| 50 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!s) { |
| 51 | ✗ | LOG(Error, emsProgramCallingManager.nameString() + ": has no EnergyPlusModelCallingPoint"); | |
| 52 | ✗ | return boost::none; | |
| 53 | } else { | ||
| 54 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | emsProgramCallingManager.setCallingPoint(*s); |
| 55 | } | ||
| 56 | |||
| 57 |
1/1✓ Branch 1 taken 2 times.
|
2 | Workspace workspace = workspaceObject.workspace(); |
| 58 | |||
| 59 |
1/1✓ Branch 1 taken 2 times.
|
2 | unsigned n = workspaceObject.numExtensibleGroups(); |
| 60 | 2 | OptionalWorkspaceObject owo; | |
| 61 | 2 | OptionalModelObject omo; | |
| 62 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
|
7 | for (unsigned i = 0; i < n; ++i) { |
| 63 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
10 | owo = workspaceObject.getExtensibleGroup(i).cast<WorkspaceExtensibleGroup>().getTarget( |
| 64 | 5 | EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName); | |
| 65 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (owo) { |
| 66 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | omo = translateAndMapWorkspaceObject(owo.get()); |
| 67 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (omo) { |
| 68 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | emsProgramCallingManager.addProgram(omo.get().cast<EnergyManagementSystemProgram>()); |
| 69 | } | ||
| 70 | } | ||
| 71 | } | ||
| 72 |
1/1✓ Branch 1 taken 2 times.
|
2 | return emsProgramCallingManager; |
| 73 | 2 | } | |
| 74 | |||
| 75 | } // namespace energyplus | ||
| 76 | |||
| 77 | } // namespace openstudio | ||
| 78 |