GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 65.6% 21 / 0 / 32
Functions: 100.0% 1 / 0 / 1
Branches: 36.7% 22 / 0 / 60

src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.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/EnergyManagementSystemConstructionIndexVariable.hpp"
9 #include "../../model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp"
10 //#include "../../model/Construction.hpp"
11
12 #include <utilities/idd/EnergyManagementSystem_ConstructionIndexVariable_FieldEnums.hxx>
13 #include "../../utilities/idd/IddEnums.hpp"
14 #include <utilities/idd/IddEnums.hxx>
15
16 using namespace openstudio::model;
17
18 namespace openstudio {
19
20 namespace energyplus {
21
22 2 OptionalModelObject ReverseTranslator::translateEnergyManagementSystemConstructionIndexVariable(const WorkspaceObject& workspaceObject) {
23
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_ConstructionIndexVariable) {
24 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_ConstructionIndexVariable");
25 ✗ return boost::none;
26 }
27
28
1/1
✓ Branch 1 taken 2 times.
2 OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ConstructionIndexVariableFields::Name);
29
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (!s1) {
30 ✗ LOG(Error, "WorkspaceObject EnergyManagementSystem_ConstructionIndexVariable has no Name");
31 ✗ return boost::none;
32 }
33
34
1/1
✓ Branch 1 taken 2 times.
2 OptionalString s = workspaceObject.getString(EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName);
35
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (!s) {
36 ✗ LOG(Error, workspaceObject.nameString() + ": has no ConstructionObjectName");
37 ✗ return boost::none;
38 }
39
40
1/1
✓ Branch 1 taken 2 times.
2 Workspace workspace = workspaceObject.workspace();
41
42
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (s) {
43 //std::vector<WorkspaceObject> wsObjects = workspace.getObjectsByTypeAndName(IddObjectType::Construction, *s);
44
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 std::vector<WorkspaceObject> wsObjects = workspace.getObjectsByName(*s);
45
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (wsObjects.size() > 1) {
46 ✗ LOG(Error, workspaceObject.nameString() + ": Construction is not unique. More than 1 object with that name.");
47 ✗ return boost::none;
48 }
49
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (wsObjects.empty()) {
50 ✗ LOG(Error, workspaceObject.nameString() + ": Construction not found.");
51 ✗ return boost::none;
52 } else {
53
1/1
✓ Branch 2 taken 2 times.
2 boost::optional<model::ModelObject> modelObject = translateAndMapWorkspaceObject(wsObjects[0]);
54
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (modelObject) {
55
1/1
✓ Branch 1 taken 2 times.
2 openstudio::model::EnergyManagementSystemConstructionIndexVariable emsConstructionIndexVariable(m_model);
56
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 emsConstructionIndexVariable.setName(*s1);
57
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 emsConstructionIndexVariable.setConstructionObject(modelObject.get());
58
1/1
✓ Branch 1 taken 2 times.
2 return emsConstructionIndexVariable;
59 2 }
60 2 }
61 2 }
62 ✗ return boost::none;
63 2 }
64
65 } // namespace energyplus
66
67 } // namespace openstudio
68