GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 78.9% 30 / 0 / 38
Functions: 100.0% 1 / 0 / 1
Branches: 49.0% 47 / 0 / 96

src/energyplus/ReverseTranslator/ReverseTranslateSurfaceControlMovableInsulation.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/SurfaceControlMovableInsulation.hpp"
9 #include "../../model/SurfaceControlMovableInsulation_Impl.hpp"
10 #include "../../model/Surface.hpp"
11 #include "../../model/Surface_Impl.hpp"
12 #include "../../model/Material.hpp"
13 #include "../../model/Material_Impl.hpp"
14 #include "../../model/Schedule.hpp"
15 #include "../../model/Schedule_Impl.hpp"
16
17 #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp"
18
19 #include <utilities/idd/SurfaceControl_MovableInsulation_FieldEnums.hxx>
20 #include "../../utilities/idd/IddEnums.hpp"
21 #include <utilities/idd/IddEnums.hxx>
22
23 #include "../../utilities/core/Assert.hpp"
24
25 using namespace openstudio::model;
26
27 namespace openstudio {
28
29 namespace energyplus {
30
31 2 OptionalModelObject ReverseTranslator::translateSurfaceControlMovableInsulation(const WorkspaceObject& workspaceObject) {
32
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::SurfaceControl_MovableInsulation) {
33 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: SurfaceControlMovableInsulation");
34 ✗ return boost::none;
35 }
36
37 // Surface and Material are both required fields and not defaulted in the model Ctor, so make sure we can find them
38 // before we instantiate a SCMI ModelObject
39 2 OptionalWorkspaceObject target;
40
41 2 boost::optional<Surface> surface;
42
2/3
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
4 if ((target = workspaceObject.getTarget(openstudio::SurfaceControl_MovableInsulationFields::SurfaceName))) {
43
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
44
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (modelObject) {
45
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
4 if (modelObject->optionalCast<Surface>()) {
46
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 surface = modelObject->cast<Surface>();
47 }
48 }
49 2 } else {
50 ✗ LOG(Error, "Could not find surface attached to SurfaceControlMovableInsulation object");
51 ✗ return boost::none;
52 }
53
54 2 boost::optional<Material> material;
55
2/3
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
4 if ((target = workspaceObject.getTarget(openstudio::SurfaceControl_MovableInsulationFields::MaterialName))) {
56
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
57
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (modelObject) {
58
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
4 if (modelObject->optionalCast<Material>()) {
59
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 material = modelObject->cast<Material>();
60 }
61 }
62 2 } else {
63 ✗ LOG(Error, "Could not find material for SurfaceControlMovableInsulation object attached to " << surface->briefDescription());
64 ✗ return boost::none;
65 }
66
67
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 SurfaceControlMovableInsulation surfaceControlMovableInsulation(*surface, *material);
68
69 // Required-fields but defaulted in model Ctor: Log an Info if not found, but continue processing
70
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<std::string> insulationType = workspaceObject.getString(openstudio::SurfaceControl_MovableInsulationFields::InsulationType)) {
71
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 surfaceControlMovableInsulation.setInsulationType(*insulationType);
72 } else {
73 ✗ LOG(Info, "Defaulting Insulation Type for SurfaceControlMovableInsulation object attached to " << surface->briefDescription());
74 2 }
75
76
2/3
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
4 if ((target = workspaceObject.getTarget(openstudio::SurfaceControl_MovableInsulationFields::ScheduleName))) {
77
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
78
6/12
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
6 if (modelObject && modelObject->optionalCast<Schedule>()) {
79
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 auto schedule = modelObject->cast<Schedule>();
80
1/1
✓ Branch 1 taken 2 times.
2 surfaceControlMovableInsulation.setSchedule(schedule);
81 2 }
82 2 } else {
83 ✗ LOG(Info, "Defaulting Schedule Name for SurfaceControlMovableInsulation object attached to " << surface->briefDescription());
84 }
85
86
1/1
✓ Branch 1 taken 2 times.
2 return surfaceControlMovableInsulation;
87 2 }
88
89 } // namespace energyplus
90
91 } // namespace openstudio
92