GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 65.7% 23 / 0 / 35
Functions: 100.0% 1 / 0 / 1
Branches: 39.1% 25 / 0 / 64

src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.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/EnergyManagementSystemCurveOrTableIndexVariable.hpp"
9 #include "../../model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp"
10 #include "../../model/Curve.hpp"
11 #include "../../model/Curve_Impl.hpp"
12
13 #include <utilities/idd/EnergyManagementSystem_CurveOrTableIndexVariable_FieldEnums.hxx>
14 #include "../../utilities/idd/IddEnums.hpp"
15 #include <utilities/idd/IddEnums.hxx>
16
17 using namespace openstudio::model;
18
19 namespace openstudio {
20
21 namespace energyplus {
22
23 1 OptionalModelObject ReverseTranslator::translateEnergyManagementSystemCurveOrTableIndexVariable(const WorkspaceObject& workspaceObject) {
24
4/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
1 if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable) {
25 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_CurveOrTableIndexVariable");
26 ✗ return boost::none;
27 }
28
29
1/1
✓ Branch 1 taken 1 time.
1 OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_CurveOrTableIndexVariableFields::Name);
30
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!s1) {
31 ✗ LOG(Error, "WorkspaceObject EnergyManagementSystem_CurveOrTableIndexVariable has no name");
32 ✗ return boost::none;
33 }
34
35
1/1
✓ Branch 1 taken 1 time.
1 OptionalString s = workspaceObject.getString(EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName);
36
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!s) {
37 ✗ LOG(Error, workspaceObject.nameString() + ": has no CurveorTableObjectName");
38 ✗ return boost::none;
39 }
40
41
1/1
✓ Branch 1 taken 1 time.
1 Workspace workspace = workspaceObject.workspace();
42
43
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (s) {
44 //for ( WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) {
45
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 std::vector<WorkspaceObject> wsObjects = workspace.getObjectsByName(*s);
46
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (wsObjects.size() > 1) {
47 ✗ LOG(Error, workspaceObject.nameString() + ": CurveorTableObject is not unique. More than 1 object with that name.");
48 ✗ return boost::none;
49 }
50
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (wsObjects.empty()) {
51 ✗ LOG(Error, workspaceObject.nameString() + ": CurveorTableObject not found.");
52 ✗ return boost::none;
53 } else {
54
1/1
✓ Branch 2 taken 1 time.
1 boost::optional<model::ModelObject> modelObject = translateAndMapWorkspaceObject(wsObjects[0]);
55
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (modelObject) {
56
1/1
✓ Branch 1 taken 1 time.
1 openstudio::model::EnergyManagementSystemCurveOrTableIndexVariable emsCurveOrTableIndexVariable(m_model);
57
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 emsCurveOrTableIndexVariable.setName(*s1);
58
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 boost::optional<model::Curve> curve = modelObject.get().optionalCast<model::Curve>();
59
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (curve) {
60
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 emsCurveOrTableIndexVariable.setCurveOrTableObject(curve.get());
61
1/1
✓ Branch 1 taken 1 time.
1 return emsCurveOrTableIndexVariable;
62 }
63 ✗ return boost::none;
64 1 }
65 1 }
66 1 }
67 ✗ return boost::none;
68 1 }
69
70 } // namespace energyplus
71
72 } // namespace openstudio
73