GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 86.0% 37 / 0 / 43
Functions: 100.0% 1 / 0 / 1
Branches: 74.1% 60 / 0 / 81

src/energyplus/ForwardTranslator/ForwardTranslateAirTerminalSingleDuctConstantVolumeNoReheat.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/AirTerminalSingleDuctConstantVolumeNoReheat.hpp"
9 #include "../../model/AirTerminalSingleDuctConstantVolumeNoReheat_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/ZoneHVAC_AirDistributionUnit_FieldEnums.hxx>
15 #include <utilities/idd/AirTerminal_SingleDuct_ConstantVolume_NoReheat_FieldEnums.hxx>
16 #include "../../utilities/idd/IddEnums.hpp"
17 #include <utilities/idd/IddEnums.hxx>
18 #include <utilities/idd/IddFactory.hxx>
19
20 using namespace openstudio::model;
21
22 namespace openstudio {
23
24 namespace energyplus {
25
26 boost::optional<IdfObject>
27 72 ForwardTranslator::translateAirTerminalSingleDuctConstantVolumeNoReheat(AirTerminalSingleDuctConstantVolumeNoReheat& modelObject) {
28 72 OptionalModelObject temp;
29 72 OptionalString optS;
30 72 boost::optional<double> value;
31 72 std::string s;
32
33
3/3
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
72 std::string baseName = modelObject.name().get();
34
35
2/2
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
72 IdfObject _airDistributionUnit(openstudio::IddObjectType::ZoneHVAC_AirDistributionUnit);
36
2/2
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
72 _airDistributionUnit.setName("ADU " + baseName); //ADU: Air Distribution Unit
37
38
2/2
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
72 IdfObject idfObject(openstudio::IddObjectType::AirTerminal_SingleDuct_ConstantVolume_NoReheat);
39
1/1
✓ Branch 1 taken 72 times.
72 idfObject.setName(baseName);
40
41 // hook up required objects
42 try {
43 72 idfObject.setString(openstudio::AirTerminal_SingleDuct_ConstantVolume_NoReheatFields::AvailabilityScheduleName,
44
4/4
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
✓ Branch 10 taken 72 times.
72 modelObject.availabilitySchedule().name().get());
45 ✗ } catch (std::exception& e) {
46 ✗ LOG(Error, "Could not translate " << modelObject.briefDescription() << ", because " << e.what() << ".");
47 ✗ return boost::none;
48 ✗ }
49
50 // Register the ATU and the ADU
51
1/1
✓ Branch 1 taken 72 times.
72 m_idfObjects.push_back(idfObject);
52
1/1
✓ Branch 1 taken 72 times.
72 m_idfObjects.push_back(_airDistributionUnit);
53
54 72 boost::optional<std::string> inletNodeName;
55 72 boost::optional<std::string> outletNodeName;
56
57
3/3
✓ Branch 1 taken 72 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 15 times.
144 if (boost::optional<ModelObject> inletModelObject = modelObject.inletModelObject()) {
58
3/4
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 6 taken 57 times.
✗ Branch 7 not taken.
114 if (boost::optional<Node> inletNode = inletModelObject->optionalCast<Node>()) {
59
4/4
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 7 taken 57 times.
✓ Branch 10 taken 57 times.
57 inletNodeName = inletNode->name().get();
60 57 }
61 72 }
62
63
3/3
✓ Branch 1 taken 72 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 15 times.
144 if (boost::optional<ModelObject> outletModelObject = modelObject.outletModelObject()) {
64
3/4
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 6 taken 57 times.
✗ Branch 7 not taken.
114 if (boost::optional<Node> outletNode = outletModelObject->optionalCast<Node>()) {
65
4/4
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 7 taken 57 times.
✓ Branch 10 taken 57 times.
57 outletNodeName = outletNode->name().get();
66 57 }
67 72 }
68
69
5/6
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57 times.
✓ Branch 5 taken 15 times.
129 if (inletNodeName && outletNodeName) {
70
2/2
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
57 idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_NoReheatFields::AirInletNodeName, inletNodeName.get());
71
2/2
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
57 idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_NoReheatFields::AirOutletNodeName, outletNodeName.get());
72 }
73
74
2/3
✓ Branch 1 taken 72 times.
✓ Branch 3 taken 72 times.
✗ Branch 4 not taken.
72 if (modelObject.isMaximumAirFlowRateAutosized()) {
75
2/2
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
144 idfObject.setString(openstudio::AirTerminal_SingleDuct_ConstantVolume_NoReheatFields::MaximumAirFlowRate, "AutoSize");
76 ✗ } else if ((value = modelObject.maximumAirFlowRate())) {
77 ✗ idfObject.setDouble(openstudio::AirTerminal_SingleDuct_ConstantVolume_NoReheatFields::MaximumAirFlowRate, value.get());
78 }
79
80 // Populate fields for AirDistributionUnit
81
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 15 times.
72 if (outletNodeName) {
82
2/2
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
57 _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirDistributionUnitOutletNodeName, outletNodeName.get());
83 }
84
3/3
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
72 _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirTerminalObjectType, idfObject.iddObject().name());
85
3/3
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
72 _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirTerminalName, idfObject.name().get());
86
87 // We return the ADU
88
1/1
✓ Branch 1 taken 72 times.
72 return _airDistributionUnit;
89 72 }
90
91 } // namespace energyplus
92
93 } // namespace openstudio
94