GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 74.0% 57 / 0 / 77
Functions: 100.0% 1 / 0 / 1
Branches: 42.9% 100 / 0 / 233

src/energyplus/ReverseTranslator/ReverseTranslateChillerElectricASHRAE205.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/ChillerElectricASHRAE205.hpp"
9
10 #include "../../model/Schedule.hpp"
11 #include "../../model/Schedule_Impl.hpp"
12
13 #include "../../model/ThermalZone.hpp"
14 #include "../../model/ThermalZone_Impl.hpp"
15 #include "../../model/Space.hpp"
16 #include "../../model/Space_Impl.hpp"
17
18 #include "../../model/ExternalFile.hpp"
19
20 #include <utilities/idd/Chiller_Electric_ASHRAE205_FieldEnums.hxx>
21 #include <utilities/idd/IddEnums.hxx>
22
23 using namespace openstudio::model;
24
25 namespace openstudio {
26
27 namespace energyplus {
28
29 1 boost::optional<ModelObject> ReverseTranslator::translateChillerElectricASHRAE205(const WorkspaceObject& workspaceObject) {
30
31
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 std::string fileName = workspaceObject.getString(Chiller_Electric_ASHRAE205Fields::RepresentationFileName).get();
32
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<ExternalFile> extfile = ExternalFile::getExternalFile(m_model, fileName);
33
34
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!extfile) {
35 ✗ LOG(Error, "Could not translate " << workspaceObject.briefDescription() << ", cannot find Representation File \"" << fileName << "\"");
36 ✗ return boost::none;
37 }
38
39 boost::optional<std::string> ambientTemperatureIndicator_ =
40
1/1
✓ Branch 1 taken 1 time.
1 workspaceObject.getString(Chiller_Electric_ASHRAE205Fields::AmbientTemperatureIndicator);
41
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!ambientTemperatureIndicator_) {
42 ✗ LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot find required property 'Ambient Temperature Indicator'");
43 ✗ return boost::none;
44 }
45
46
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 openstudio::model::ChillerElectricASHRAE205 modelObject(extfile.get());
47
48 // Name
49
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<std::string> _name = workspaceObject.name()) {
50
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setName(_name.get());
51 1 }
52
53 // Performance Interpolation Method: Optional String
54 1 if (boost::optional<std::string> _performanceInterpolationMethod =
55
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 workspaceObject.getString(Chiller_Electric_ASHRAE205Fields::PerformanceInterpolationMethod)) {
56
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setPerformanceInterpolationMethod(_performanceInterpolationMethod.get());
57 1 }
58
59 // Rated Capacity: Optional Double
60
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
2 if (boost::optional<double> _ratedCapacity = workspaceObject.getDouble(Chiller_Electric_ASHRAE205Fields::RatedCapacity)) {
61 ✗ modelObject.setRatedCapacity(_ratedCapacity.get());
62 }
63
64 // Sizing Factor: Optional Double
65
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<double> _sizingFactor = workspaceObject.getDouble(Chiller_Electric_ASHRAE205Fields::SizingFactor)) {
66
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setSizingFactor(_sizingFactor.get());
67 }
68
69 // Ambient Temperature Indicator: Required String
70
4/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
3 if (openstudio::istringEqual("Schedule", ambientTemperatureIndicator_.get())) {
71
72 // Ambient Temperature Schedule Name: Optional Object
73 ✗ if (auto wo_sch_ = workspaceObject.getTarget(Chiller_Electric_ASHRAE205Fields::AmbientTemperatureScheduleName)) {
74 ✗ if (auto mo_sch_ = translateAndMapWorkspaceObject(wo_sch_.get())) {
75 ✗ if (boost::optional<Schedule> sch_ = mo_sch_->optionalCast<Schedule>()) {
76 ✗ modelObject.setAmbientTemperatureSchedule(sch_.get());
77 } else {
78 ✗ LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Ambient Temperature Schedule Name'");
79 ✗ }
80 ✗ }
81 } else {
82 ✗ LOG(Warn, workspaceObject.briefDescription()
83 << " has an Ambient Temperature Indicator of type 'Schedule', but no Schedule assigned. Falling back to 'Outdoors'");
84 ✗ }
85
4/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
3 } else if (openstudio::istringEqual("Zone", ambientTemperatureIndicator_.get())) {
86
87 // Ambient Temperature Zone Name: Optional Object
88
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (auto wo_z_ = workspaceObject.getTarget(Chiller_Electric_ASHRAE205Fields::AmbientTemperatureZoneName)) {
89
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (auto mo_ = translateAndMapWorkspaceObject(wo_z_.get())) {
90 // Zone is translated, and a Space is returned instead
91
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<Space> space_ = mo_->optionalCast<Space>()) {
92
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (auto z_ = space_->thermalZone()) {
93
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setAmbientTemperatureZone(z_.get());
94 1 }
95 } else {
96 ✗ LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Ambient Temperature Zone Name'");
97 1 }
98 1 }
99 } else {
100 ✗ LOG(Warn, workspaceObject.briefDescription()
101 << " has an Ambient Temperature Indicator of type 'Zone', but no Zone assigned. Falling back to 'Outdoors'");
102 1 }
103 } else {
104 // Ambient Temperature Outdoor Air Node Name: Optional Node
105 ✗ if (boost::optional<std::string> s_ = workspaceObject.getString(Chiller_Electric_ASHRAE205Fields::AmbientTemperatureOutdoorAirNodeName)) {
106 ✗ modelObject.setAmbientTemperatureOutdoorAirNodeName(s_.get());
107 ✗ }
108 }
109
110 // Chilled Water Maximum Requested Flow Rate: Optional Double
111 1 if (boost::optional<double> _chilledWaterMaximumRequestedFlowRate =
112
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 workspaceObject.getDouble(Chiller_Electric_ASHRAE205Fields::ChilledWaterMaximumRequestedFlowRate)) {
113
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setChilledWaterMaximumRequestedFlowRate(_chilledWaterMaximumRequestedFlowRate.get());
114 }
115
116 // Condenser Maximum Requested Flow Rate: Optional Double
117 1 if (boost::optional<double> _condenserMaximumRequestedFlowRate =
118
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 workspaceObject.getDouble(Chiller_Electric_ASHRAE205Fields::CondenserMaximumRequestedFlowRate)) {
119
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setCondenserMaximumRequestedFlowRate(_condenserMaximumRequestedFlowRate.get());
120 }
121
122 // Chiller Flow Mode: Optional String
123
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<std::string> _chillerFlowMode = workspaceObject.getString(Chiller_Electric_ASHRAE205Fields::ChillerFlowMode)) {
124
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setChillerFlowMode(_chillerFlowMode.get());
125 1 }
126
127
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<double> _oilCoolerDesignFlowRate = workspaceObject.getDouble(Chiller_Electric_ASHRAE205Fields::OilCoolerDesignFlowRate)) {
128
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setOilCoolerDesignFlowRate(_oilCoolerDesignFlowRate.get());
129 }
130
131 // Auxiliary Cooling Design Flow Rate: Optional Double
132 1 if (boost::optional<double> _auxiliaryCoolingDesignFlowRate =
133
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 workspaceObject.getDouble(Chiller_Electric_ASHRAE205Fields::AuxiliaryCoolingDesignFlowRate)) {
134
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setAuxiliaryCoolingDesignFlowRate(_auxiliaryCoolingDesignFlowRate.get());
135 }
136
137 // End-Use Subcategory: Optional String
138
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<std::string> _endUseSubcategory = workspaceObject.getString(Chiller_Electric_ASHRAE205Fields::EndUseSubcategory)) {
139
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setEndUseSubcategory(_endUseSubcategory.get());
140 1 }
141
142
1/4
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 if (workspaceObject.getTarget(Chiller_Electric_ASHRAE205Fields::ChilledWaterInletNodeName)
143
3/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
3 || workspaceObject.getTarget(Chiller_Electric_ASHRAE205Fields::ChilledWaterOutletNodeName)
144
3/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
3 || workspaceObject.getTarget(Chiller_Electric_ASHRAE205Fields::CondenserInletNodeName)
145
3/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
3 || workspaceObject.getTarget(Chiller_Electric_ASHRAE205Fields::CondenserOutletNodeName)
146
3/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
3 || workspaceObject.getTarget(Chiller_Electric_ASHRAE205Fields::HeatRecoveryInletNodeName)
147
3/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
3 || workspaceObject.getTarget(Chiller_Electric_ASHRAE205Fields::HeatRecoveryOutletNodeName)
148
3/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
3 || workspaceObject.getTarget(Chiller_Electric_ASHRAE205Fields::OilCoolerInletNodeName)
149
3/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
3 || workspaceObject.getTarget(Chiller_Electric_ASHRAE205Fields::OilCoolerOutletNodeName)
150
3/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
3 || workspaceObject.getTarget(Chiller_Electric_ASHRAE205Fields::AuxiliaryInletNodeName)
151
6/12
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✓ Branch 12 taken 1 time.
✗ Branch 13 not taken.
✓ Branch 15 taken 1 time.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
4 || workspaceObject.getTarget(Chiller_Electric_ASHRAE205Fields::AuxiliaryOutletNodeName)) {
152 ✗ LOG(Warn, "For " << workspaceObject.briefDescription() << " Loop Connections are NOT ReverseTranslated.");
153 }
154
155
1/1
✓ Branch 1 taken 1 time.
1 return modelObject;
156 1 } // End of translate function
157
158 } // end namespace energyplus
159 } // end namespace openstudio
160