GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 91.4% 32 / 0 / 35
Functions: 100.0% 1 / 0 / 1
Branches: 75.7% 53 / 0 / 70

src/energyplus/ForwardTranslator/ForwardTranslateCoilHeatingElectric.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/Model.hpp"
8 #include "../../model/CoilHeatingElectric.hpp"
9 #include "../../model/CoilHeatingElectric_Impl.hpp"
10 #include "../../model/Schedule.hpp"
11 #include "../../model/Schedule_Impl.hpp"
12 #include "../../model/Node.hpp"
13 #include "../../model/Node_Impl.hpp"
14 #include <utilities/idd/Coil_Heating_Electric_FieldEnums.hxx>
15 #include "../../utilities/idd/IddEnums.hpp"
16 #include <utilities/idd/IddEnums.hxx>
17 #include <utilities/idd/IddFactory.hxx>
18
19 using namespace openstudio::model;
20
21 using namespace std;
22
23 namespace openstudio {
24
25 namespace energyplus {
26
27 36 boost::optional<IdfObject> ForwardTranslator::translateCoilHeatingElectric(CoilHeatingElectric& modelObject) {
28 36 boost::optional<std::string> s;
29 36 boost::optional<double> value;
30
31
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
36 IdfObject idfObject(IddObjectType::Coil_Heating_Electric);
32
33
1/1
✓ Branch 1 taken 36 times.
36 m_idfObjects.push_back(idfObject);
34
35 // Name
36
37
1/1
✓ Branch 1 taken 36 times.
36 s = modelObject.name();
38
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (s) {
39
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
36 idfObject.setName(*s);
40 }
41
42 // AvailabilityScheduleName
43
44
3/4
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 8 taken 36 times.
✗ Branch 9 not taken.
72 if (boost::optional<Schedule> schedule = modelObject.availabilitySchedule()) {
45
3/4
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
72 if (boost::optional<IdfObject> _schedule = translateAndMapModelObject(schedule.get())) {
46
4/4
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
✓ Branch 10 taken 36 times.
36 idfObject.setString(Coil_Heating_ElectricFields::AvailabilityScheduleName, _schedule->name().get());
47 36 }
48 36 }
49
50 // Efficiency
51
52
3/4
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
✗ Branch 8 not taken.
72 if ((value = modelObject.efficiency())) {
53
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
36 idfObject.setDouble(Coil_Heating_ElectricFields::Efficiency, value.get());
54 }
55
56 // Nominal Capacity
57
58
2/3
✓ Branch 1 taken 36 times.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
36 if (modelObject.isNominalCapacityAutosized()) {
59
2/2
✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
72 idfObject.setString(Coil_Heating_ElectricFields::NominalCapacity, "Autosize");
60 ✗ } else if ((value = modelObject.nominalCapacity())) {
61 ✗ idfObject.setDouble(Coil_Heating_ElectricFields::NominalCapacity, value.get());
62 }
63
64 // Air Inlet Node Name
65
66
3/3
✓ Branch 1 taken 36 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 35 times.
72 if (boost::optional<ModelObject> mo = modelObject.inletModelObject()) {
67
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (boost::optional<Node> node = mo->optionalCast<Node>()) {
68
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 idfObject.setString(Coil_Heating_ElectricFields::AirInletNodeName, node->name().get());
69 1 }
70 36 }
71
72 // Air Outlet Node Name
73
74
3/3
✓ Branch 1 taken 36 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 35 times.
72 if (boost::optional<ModelObject> mo = modelObject.outletModelObject()) {
75
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (boost::optional<Node> node = mo->optionalCast<Node>()) {
76
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 idfObject.setString(Coil_Heating_ElectricFields::AirOutletNodeName, node->name().get());
77 // For now we write the temp setpoint node as the Coil Outlet Node
78
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 idfObject.setString(Coil_Heating_ElectricFields::TemperatureSetpointNodeName, node->name().get());
79 1 }
80 36 }
81
82 // Temperature Setpoint Node Name
83 // If it was hardset we actually use that, otherwise keep above default (coil outlet)
84
2/3
✓ Branch 1 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
72 if (boost::optional<Node> node = modelObject.temperatureSetpointNode()) {
85 ✗ idfObject.setString(Coil_Heating_ElectricFields::TemperatureSetpointNodeName, node->name().get());
86 36 }
87
88
1/1
✓ Branch 1 taken 36 times.
72 return idfObject;
89 36 }
90
91 } // namespace energyplus
92
93 } // namespace openstudio
94