GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 91.3% 42 / 0 / 46
Functions: 100.0% 1 / 0 / 1
Branches: 71.4% 55 / 0 / 77

src/energyplus/ForwardTranslator/ForwardTranslateWaterUseConnections.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 "../ForwardTranslator.hpp"
7 #include "../../model/WaterUseConnections.hpp"
8 #include "../../model/WaterUseConnections_Impl.hpp"
9 #include "../../model/WaterUseEquipment.hpp"
10 #include "../../model/WaterUseEquipment_Impl.hpp"
11 #include "../../model/Model.hpp"
12 #include "../../model/Schedule.hpp"
13 #include "../../model/Schedule_Impl.hpp"
14 #include "../../model/Node.hpp"
15 #include "../../model/Node_Impl.hpp"
16 #include "../../utilities/core/Assert.hpp"
17 #include <utilities/idd/WaterUse_Connections_FieldEnums.hxx>
18 #include <utilities/idd/IddEnums.hxx>
19 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
20
21 using namespace openstudio::model;
22
23 using namespace std;
24
25 namespace openstudio {
26
27 namespace energyplus {
28
29 11 boost::optional<IdfObject> ForwardTranslator::translateWaterUseConnections(WaterUseConnections& modelObject) {
30 11 boost::optional<std::string> s;
31 11 boost::optional<double> value;
32 11 OptionalSchedule schedule;
33
34
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 IdfObject idfObject(IddObjectType::WaterUse_Connections);
35
36
1/1
✓ Branch 1 taken 11 times.
11 m_idfObjects.push_back(idfObject);
37
38 // Name
39
40
1/1
✓ Branch 1 taken 11 times.
11 s = modelObject.name();
41
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (s) {
42
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setName(*s);
43 }
44
45 // InletNodeName
46
47
2/3
✓ Branch 1 taken 11 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
22 if (boost::optional<ModelObject> mo = modelObject.inletModelObject()) {
48
3/4
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
22 if (boost::optional<Node> node = mo->optionalCast<Node>()) {
49
4/4
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
11 idfObject.setString(WaterUse_ConnectionsFields::InletNodeName, node->name().get());
50 11 }
51 11 }
52
53 // OutletNodeName
54
55
2/3
✓ Branch 1 taken 11 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
22 if (boost::optional<ModelObject> mo = modelObject.outletModelObject()) {
56
3/4
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
22 if (boost::optional<Node> node = mo->optionalCast<Node>()) {
57
4/4
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
11 idfObject.setString(WaterUse_ConnectionsFields::OutletNodeName, node->name().get());
58 11 }
59 11 }
60
61 // Hot Water Supply Temperature Schedule Name
62
63
2/3
✓ Branch 1 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
22 if (boost::optional<Schedule> s = modelObject.hotWaterSupplyTemperatureSchedule()) {
64 ✗ translateAndMapModelObject(s.get());
65
66 ✗ idfObject.setString(WaterUse_ConnectionsFields::HotWaterSupplyTemperatureScheduleName, s->name().get());
67 11 }
68
69 // Cold Water Supply Temperature Schedule Name
70
71
2/3
✓ Branch 1 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
22 if (boost::optional<Schedule> s = modelObject.coldWaterSupplyTemperatureSchedule()) {
72 ✗ translateAndMapModelObject(s.get());
73
74 ✗ idfObject.setString(WaterUse_ConnectionsFields::ColdWaterSupplyTemperatureScheduleName, s->name().get());
75 11 }
76
77 // Drain Water Heat Exchanger Type
78
79
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 s = modelObject.drainWaterHeatExchangerType();
80
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (s) {
81
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setString(WaterUse_ConnectionsFields::DrainWaterHeatExchangerType, *s);
82 }
83
84 // Drain Water Heat Exchanger Destination
85
86
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 s = modelObject.drainWaterHeatExchangerDestination();
87
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (s) {
88
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setString(WaterUse_ConnectionsFields::DrainWaterHeatExchangerDestination, *s);
89 }
90
91 // Drain Water Heat Exchanger U-Factor Times Area
92
93
1/1
✓ Branch 1 taken 11 times.
11 value = modelObject.drainWaterHeatExchangerUFactorTimesArea();
94
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 10 times.
11 if (value) {
95
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(WaterUse_ConnectionsFields::DrainWaterHeatExchangerUFactorTimesArea, value.get());
96 }
97
98 // Water Use Equipment 1 Name
99
100
1/1
✓ Branch 1 taken 11 times.
11 std::vector<WaterUseEquipment> equipment = modelObject.waterUseEquipment();
101
102
2/2
✓ Branch 5 taken 22 times.
✓ Branch 6 taken 11 times.
33 for (auto& elem : equipment) {
103
1/1
✓ Branch 1 taken 22 times.
22 boost::optional<IdfObject> _equipment = translateAndMapModelObject(elem);
104
105
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (_equipment) {
106
1/1
✓ Branch 1 taken 22 times.
22 IdfExtensibleGroup group = idfObject.pushExtensibleGroup();
107
108
4/4
✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 7 taken 22 times.
✓ Branch 10 taken 22 times.
22 group.setString(WaterUse_ConnectionsExtensibleFields::WaterUseEquipmentName, _equipment->name().get());
109 22 }
110 22 }
111
112
1/1
✓ Branch 1 taken 11 times.
22 return idfObject;
113 11 }
114
115 } // namespace energyplus
116 } // namespace openstudio
117