GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 86.7% 39 / 0 / 45
Functions: 100.0% 1 / 0 / 1
Branches: 63.5% 61 / 0 / 96

src/energyplus/ReverseTranslator/ReverseTranslateZoneInfiltrationFlowCoefficient.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/Model.hpp"
9 #include "../../model/SpaceInfiltrationFlowCoefficient.hpp"
10 #include "../../model/SpaceInfiltrationFlowCoefficient_Impl.hpp"
11 #include "../../model/Space.hpp"
12 #include "../../model/Space_Impl.hpp"
13 #include "../../model/ThermalZone.hpp"
14 #include "../../model/ThermalZone_Impl.hpp"
15 #include "../../model/SpaceType.hpp"
16 #include "../../model/SpaceType_Impl.hpp"
17 #include "../../model/Schedule.hpp"
18 #include "../../model/Schedule_Impl.hpp"
19
20 #include <utilities/idd/ZoneInfiltration_FlowCoefficient_FieldEnums.hxx>
21 #include "../../utilities/idd/IddEnums.hpp"
22 #include <utilities/idd/IddEnums.hxx>
23 #include <utilities/idd/IddFactory.hxx>
24
25 using namespace openstudio::model;
26
27 namespace openstudio {
28
29 namespace energyplus {
30
31 4 OptionalModelObject ReverseTranslator::translateZoneInfiltrationFlowCoefficient(const WorkspaceObject& workspaceObject) {
32
4/5
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4 times.
4 if (workspaceObject.iddObject().type() != IddObjectType::ZoneInfiltration_FlowCoefficient) {
33 ✗ LOG(Error, "WorkspaceObject " << workspaceObject.briefDescription() << " is not IddObjectType: SpaceInfiltration_FlowCoefficient");
34 ✗ return boost::none;
35 }
36
37
1/1
✓ Branch 1 taken 4 times.
4 OptionalWorkspaceObject zoneTarget = workspaceObject.getTarget(ZoneInfiltration_FlowCoefficientFields::ZoneorSpaceName);
38
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
4 if (!zoneTarget) {
39
8/8
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 17 taken 2 times.
✓ Branch 20 taken 2 times.
✓ Branch 23 taken 2 times.
2 LOG(Error, "WorkspaceObject " << workspaceObject.briefDescription() << " has no Zone Name assigned, not ReverseTranslating it.");
40 2 return boost::none;
41 }
42
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalModelObject zoneModelObject = translateAndMapWorkspaceObject(*zoneTarget);
43
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (!zoneModelObject) {
44 ✗ LOG(Error, "For WorkspaceObject " << workspaceObject.briefDescription()
45 << ", failed to Reverse Translate the ZoneName object, so not ReverseTranslating it.");
46 ✗ return boost::none;
47 }
48
49 // create the instance
50
1/1
✓ Branch 1 taken 2 times.
2 SpaceInfiltrationFlowCoefficient spaceInfiltrationFlowCoefficient(m_model);
51
52
1/1
✓ Branch 1 taken 2 times.
2 OptionalString s = workspaceObject.name();
53
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (s) {
54
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 spaceInfiltrationFlowCoefficient.setName(*s);
55 }
56
57
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
4 if (zoneModelObject->optionalCast<Space>()) {
58
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 spaceInfiltrationFlowCoefficient.setSpace(zoneModelObject->cast<Space>());
59 ✗ } else if (zoneModelObject->optionalCast<SpaceType>()) {
60 ✗ spaceInfiltrationFlowCoefficient.setSpaceType(zoneModelObject->cast<SpaceType>());
61 }
62
63 // This is a required field technically, but it's ok if if it's missing here since not required in model API.
64
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (auto target = workspaceObject.getTarget(ZoneInfiltration_FlowCoefficientFields::ScheduleName)) {
65
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
66
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (modelObject) {
67
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
4 if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) {
68
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 Schedule schedule(*intermediate);
69
1/1
✓ Branch 1 taken 2 times.
2 spaceInfiltrationFlowCoefficient.setSchedule(schedule);
70 4 }
71 }
72 4 }
73
74
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<double> value = workspaceObject.getDouble(ZoneInfiltration_FlowCoefficientFields::FlowCoefficient);
75
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (value) {
76
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 spaceInfiltrationFlowCoefficient.setFlowCoefficient(value.get());
77 }
78
79
1/1
✓ Branch 1 taken 2 times.
2 value = workspaceObject.getDouble(ZoneInfiltration_FlowCoefficientFields::StackCoefficient);
80
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (value) {
81
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 spaceInfiltrationFlowCoefficient.setStackCoefficient(value.get());
82 }
83
84
1/1
✓ Branch 1 taken 2 times.
2 value = workspaceObject.getDouble(ZoneInfiltration_FlowCoefficientFields::PressureExponent);
85
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (value) {
86
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 spaceInfiltrationFlowCoefficient.setPressureExponent(value.get());
87 }
88
89
1/1
✓ Branch 1 taken 2 times.
2 value = workspaceObject.getDouble(ZoneInfiltration_FlowCoefficientFields::WindCoefficient);
90
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (value) {
91
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 spaceInfiltrationFlowCoefficient.setWindCoefficient(value.get());
92 }
93
94
1/1
✓ Branch 1 taken 2 times.
2 value = workspaceObject.getDouble(ZoneInfiltration_FlowCoefficientFields::ShelterFactor);
95
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (value) {
96
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 spaceInfiltrationFlowCoefficient.setShelterFactor(value.get());
97 }
98
99
1/1
✓ Branch 1 taken 2 times.
2 return spaceInfiltrationFlowCoefficient;
100 4 }
101
102 } // namespace energyplus
103
104 } // namespace openstudio
105