GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 67.4% 29 / 0 / 43
Functions: 100.0% 1 / 0 / 1
Branches: 41.9% 54 / 0 / 129

src/energyplus/ReverseTranslator/ReverseTranslateZoneMRTCalculation.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/People.hpp"
9 #include "../../model/People_Impl.hpp"
10 #include "../../model/Space.hpp"
11 #include "../../model/Space_Impl.hpp"
12 #include "../../model/ThermalZone.hpp"
13 #include "../../model/ThermalZone_Impl.hpp"
14 #include "../../model/ZoneMRTCalculation.hpp"
15 #include "../../model/ZoneMRTCalculation_Impl.hpp"
16
17 #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp"
18
19 #include <utilities/idd/ZoneMRTCalculation_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::translateZoneMRTCalculation(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::ZoneMRTCalculation) {
33 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: ZoneMRTCalculation");
34 ✗ return boost::none;
35 }
36
37
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<WorkspaceObject> zoneTarget = workspaceObject.getTarget(ZoneMRTCalculationFields::ZoneName);
38
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (!zoneTarget) {
39 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't find associated Zone.");
40 ✗ return boost::none;
41 }
42
43
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalModelObject zoneModelObject = translateAndMapWorkspaceObject(*zoneTarget);
44
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (!zoneModelObject) {
45 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't translate associated Zone.");
46 ✗ return boost::none;
47 }
48
49 2 boost::optional<ThermalZone> thermalZone;
50
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
4 if (boost::optional<Space> space = zoneModelObject->optionalCast<Space>()) {
51
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 thermalZone = space->thermalZone();
52 2 }
53
54
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (!thermalZone) {
55 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't find associated ThermalZone.");
56 ✗ return boost::none;
57 }
58
59
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 openstudio::model::ZoneMRTCalculation zoneMRTCalculation = thermalZone->getZoneMRTCalculation();
60
61
3/3
✓ Branch 1 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 2 times.
4 for (const IdfExtensibleGroup& idfGroup : workspaceObject.extensibleGroups()) {
62
1/1
✓ Branch 1 taken 2 times.
2 auto workspaceGroup = idfGroup.cast<WorkspaceExtensibleGroup>();
63
64
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<WorkspaceObject> peopleTarget = workspaceGroup.getTarget(ZoneMRTCalculationExtensibleFields::PeopleName);
65
1/1
✓ Branch 1 taken 2 times.
2 OptionalDouble mRTWeightingFactor = workspaceGroup.getDouble(ZoneMRTCalculationExtensibleFields::MRTWeightingFactor);
66
67
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
2 if (!peopleTarget || !mRTWeightingFactor) {
68 ✗ LOG(Error, "Could not retrieve an MRTWeightingFactor group for " << workspaceObject.briefDescription() << ". Continuing with the rest.");
69 ✗ continue;
70 ✗ }
71
72
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalModelObject peopleModelObject = translateAndMapWorkspaceObject(*peopleTarget);
73
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (peopleModelObject) {
74
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
4 if (boost::optional<People> people = peopleModelObject->optionalCast<People>()) {
75 try {
76
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 1 time.
2 MRTWeightingFactor weightingFactor(people.get(), mRTWeightingFactor.get());
77
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 if (!zoneMRTCalculation.addMRTWeightingFactor(weightingFactor)) {
78 ✗ LOG(Warn, "Adding MRTWeightingFactor in ThermalZone " << thermalZone->nameString()
79 << " failed for mRTWeightingFactor=" << weightingFactor << ".");
80 }
81 2 } catch (...) {
82
16/16
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 37 taken 1 time.
✓ Branch 42 taken 1 time.
✓ Branch 45 taken 1 time.
✓ Branch 48 taken 1 time.
1 LOG(Error, "Could not create MRTWeightingFactor in ThermalZone " << thermalZone->nameString() << " for people=("
83 << people->briefDescription()
84 << ") and mRTWeightingFactor=" << mRTWeightingFactor.get() << ".");
85 1 }
86 } else {
87 ✗ LOG(Error, "Could not translate People for an MRTWeightingFactor group in " << workspaceObject.briefDescription() << ".");
88 2 }
89 } else {
90 ✗ LOG(Error, "Could not translate People for an MRTWeightingFactor group in " << workspaceObject.briefDescription() << ".");
91 }
92 4 }
93
94
1/1
✓ Branch 1 taken 2 times.
2 return zoneMRTCalculation;
95 2 }
96
97 } // namespace energyplus
98
99 } // namespace openstudio
100