GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 91.7% 22 / 0 / 24
Functions: 100.0% 1 / 0 / 1
Branches: 78.7% 37 / 0 / 47

src/energyplus/ReverseTranslator/ReverseTranslateZoneList.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/SpaceType.hpp"
9 #include "../../model/SpaceType_Impl.hpp"
10 #include "../../model/Space.hpp"
11 #include "../../model/Space_Impl.hpp"
12
13 #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp"
14
15 #include <utilities/idd/ZoneList_FieldEnums.hxx>
16 #include "../../utilities/idd/IddEnums.hpp"
17 #include <utilities/idd/IddEnums.hxx>
18
19 using namespace openstudio::model;
20
21 namespace openstudio {
22
23 namespace energyplus {
24
25 14 OptionalModelObject ReverseTranslator::translateZoneList(const WorkspaceObject& workspaceObject) {
26
4/5
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 14 times.
14 if (workspaceObject.iddObject().type() != IddObjectType::ZoneList) {
27 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: ZoneList");
28 ✗ return boost::none;
29 }
30
31
1/1
✓ Branch 1 taken 14 times.
14 openstudio::model::SpaceType spaceType(m_model);
32
33
1/1
✓ Branch 1 taken 14 times.
14 OptionalString s = workspaceObject.name();
34
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (s) {
35
2/2
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
14 spaceType.setName(*s);
36 }
37
38 // Note that this is coarse: it will create a space type for each Zonelist it finds, but if a zone is referenced by multiple zonelists,
39 // its spaces will end up with a spacetype corresponding to the last Zonelist it found that references it.
40 // You'll get a warning that the previous SpaceType was overwritten though
41
3/3
✓ Branch 1 taken 14 times.
✓ Branch 8 taken 28 times.
✓ Branch 9 taken 14 times.
42 for (const IdfExtensibleGroup& idfGroup : workspaceObject.extensibleGroups()) {
42
1/1
✓ Branch 1 taken 28 times.
28 auto workspaceGroup = idfGroup.cast<WorkspaceExtensibleGroup>();
43
44
1/1
✓ Branch 1 taken 28 times.
28 OptionalWorkspaceObject target = workspaceGroup.getTarget(0);
45
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if (target) {
46
2/2
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
28 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
47
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if (modelObject) {
48
3/4
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✗ Branch 8 not taken.
56 if (modelObject->optionalCast<Space>()) {
49
2/2
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
28 auto space = modelObject->cast<Space>();
50
51
3/3
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 26 times.
56 if (space.spaceType()) {
52
9/9
✓ 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 16 taken 2 times.
✓ Branch 20 taken 2 times.
✓ Branch 23 taken 2 times.
✓ Branch 26 taken 2 times.
2 LOG(Warn, "Overriding previously assigned SpaceType for Space '" << space.name().get() << "'");
53 }
54
55
1/1
✓ Branch 1 taken 28 times.
28 space.setSpaceType(spaceType);
56 28 }
57 }
58 28 }
59 42 }
60
61
1/1
✓ Branch 1 taken 14 times.
14 return spaceType;
62 14 }
63
64 } // namespace energyplus
65
66 } // namespace openstudio
67