GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 141
Functions: 0.0% 0 / 0 / 1
Branches: 0.0% 0 / 0 / 276

src/energyplus/ReverseTranslator/ReverseTranslateZoneCrossMixing.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/ZoneMixing.hpp"
9 #include "../../model/ZoneMixing_Impl.hpp"
10 #include "../../model/ThermalZone.hpp"
11 #include "../../model/ThermalZone_Impl.hpp"
12 #include "../../model/Space.hpp"
13 #include "../../model/Space_Impl.hpp"
14 #include "../../model/Schedule.hpp"
15 #include "../../model/Schedule_Impl.hpp"
16
17 #include <utilities/idd/ZoneCrossMixing_FieldEnums.hxx>
18 #include "../../utilities/idd/IddEnums.hpp"
19 #include <utilities/idd/IddEnums.hxx>
20
21 #include "../../utilities/core/Assert.hpp"
22
23 using namespace openstudio::model;
24
25 namespace openstudio {
26
27 namespace energyplus {
28
29 ✗ OptionalModelObject ReverseTranslator::translateZoneCrossMixing(const WorkspaceObject& workspaceObject) {
30 ✗ if (workspaceObject.iddObject().type() != IddObjectType::ZoneCrossMixing) {
31 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: ZoneCrossMixing");
32 ✗ return boost::none;
33 }
34
35 ✗ OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::ZoneCrossMixingFields::ZoneorSpaceName);
36 ✗ OptionalThermalZone zone;
37 ✗ if (target) {
38 ✗ if (OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target)) {
39 ✗ if (target->iddObject().type() == IddObjectType::Zone) {
40 // Zone maps to Space in RT
41 ✗ if (auto s_ = modelObject->optionalCast<Space>()) {
42 ✗ zone = s_->thermalZone();
43 ✗ }
44 } else {
45 // It's a space, but we don't allow mapping to a space in model SDK for now, and we don't have a Space RT... so we'll never get here
46 }
47 ✗ }
48 }
49
50 ✗ if (!zone) {
51 ✗ return boost::none;
52 }
53
54 ✗ target = workspaceObject.getTarget(openstudio::ZoneCrossMixingFields::SourceZoneorSpaceName);
55 ✗ OptionalThermalZone sourceZone;
56 ✗ if (target) {
57 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
58 ✗ if (target->iddObject().type() == IddObjectType::Zone) {
59 // Zone maps to Space in RT
60 ✗ if (auto s_ = modelObject->optionalCast<Space>()) {
61 ✗ sourceZone = s_->thermalZone();
62 ✗ }
63 } else {
64 // It's a space, but we don't allow mapping to a space in model SDK for now, and we don't have a Space RT... so we'll never get here
65 }
66 ✗ }
67
68 ✗ if (!sourceZone) {
69 ✗ return boost::none;
70 }
71
72 // Create the mixing object
73 ✗ openstudio::model::ZoneMixing mixing(*zone);
74 ✗ mixing.setSourceZone(*sourceZone);
75
76 // Create the reverse mixing object
77 ✗ openstudio::model::ZoneMixing reverseMixing(*sourceZone);
78 ✗ reverseMixing.setSourceZone(*zone);
79
80 ✗ OptionalString s = workspaceObject.name();
81 ✗ if (s) {
82 ✗ mixing.setName(*s);
83 ✗ reverseMixing.setName(*s + " Reverse");
84 }
85
86 ✗ target = workspaceObject.getTarget(openstudio::ZoneCrossMixingFields::ScheduleName);
87 ✗ if (target) {
88 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
89 ✗ if (modelObject) {
90 ✗ if (modelObject->optionalCast<Schedule>()) {
91 ✗ auto s = modelObject->cast<Schedule>();
92 ✗ mixing.setSchedule(s);
93 ✗ reverseMixing.setSchedule(s);
94 ✗ }
95 }
96 ✗ }
97
98 ✗ s = workspaceObject.getString(openstudio::ZoneCrossMixingFields::DesignFlowRateCalculationMethod, true);
99 ✗ OS_ASSERT(s);
100
101 ✗ OptionalDouble d;
102 ✗ if (istringEqual("Flow/Zone", *s)) {
103 ✗ d = workspaceObject.getDouble(openstudio::ZoneCrossMixingFields::DesignFlowRate);
104 ✗ if (d) {
105 ✗ mixing.setDesignFlowRate(*d);
106 ✗ reverseMixing.setDesignFlowRate(*d);
107 } else {
108 ✗ LOG(Error, "Flow/Zone value not found for workspace object " << workspaceObject);
109 }
110 ✗ } else if (istringEqual("Flow/Area", *s)) {
111 ✗ d = workspaceObject.getDouble(openstudio::ZoneCrossMixingFields::FlowRateperFloorArea);
112 ✗ if (d) {
113 ✗ mixing.setFlowRateperFloorArea(*d);
114 ✗ reverseMixing.setFlowRateperFloorArea(*d);
115 } else {
116 ✗ LOG(Error, "Flow/Area value not found for workspace object " << workspaceObject);
117 }
118 ✗ } else if (istringEqual("Flow/Person", *s)) {
119 ✗ d = workspaceObject.getDouble(openstudio::ZoneCrossMixingFields::FlowRateperPerson);
120 ✗ if (d) {
121 ✗ mixing.setFlowRateperPerson(*d);
122 ✗ reverseMixing.setFlowRateperPerson(*d);
123 } else {
124 ✗ LOG(Error, "Flow/Person value not found for workspace object " << workspaceObject);
125 }
126 ✗ } else if (istringEqual("AirChanges/Hour", *s)) {
127 ✗ d = workspaceObject.getDouble(openstudio::ZoneCrossMixingFields::AirChangesperHour);
128 ✗ if (d) {
129 ✗ mixing.setAirChangesperHour(*d);
130 ✗ reverseMixing.setAirChangesperHour(*d);
131 } else {
132 ✗ LOG(Error, "AirChanges/Hour value not found for workspace object " << workspaceObject);
133 }
134 } else {
135 ✗ LOG(Error, "Unknown DesignFlowRateCalculationMethod value for workspace object" << workspaceObject);
136 }
137
138 ✗ d = workspaceObject.getDouble(openstudio::ZoneCrossMixingFields::DeltaTemperature);
139 ✗ if (d) {
140 ✗ mixing.setDeltaTemperature(*d);
141 ✗ reverseMixing.setDeltaTemperature(*d);
142 }
143
144 ✗ target = workspaceObject.getTarget(openstudio::ZoneCrossMixingFields::DeltaTemperatureScheduleName);
145 ✗ if (target) {
146 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
147 ✗ if (modelObject) {
148 ✗ if (auto s = modelObject->optionalCast<Schedule>()) {
149 ✗ mixing.setDeltaTemperatureSchedule(s.get());
150 ✗ reverseMixing.setDeltaTemperatureSchedule(s.get());
151 ✗ }
152 }
153 ✗ }
154
155 ✗ target = workspaceObject.getTarget(openstudio::ZoneCrossMixingFields::MinimumReceivingTemperatureScheduleName);
156 ✗ if (target) {
157 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
158 ✗ if (modelObject) {
159 ✗ if (auto s = modelObject->optionalCast<Schedule>()) {
160 ✗ mixing.setMinimumReceivingTemperatureSchedule(s.get());
161 ✗ reverseMixing.setMinimumReceivingTemperatureSchedule(s.get());
162 ✗ }
163 }
164 ✗ }
165
166 ✗ target = workspaceObject.getTarget(openstudio::ZoneCrossMixingFields::MaximumReceivingTemperatureScheduleName);
167 ✗ if (target) {
168 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
169 ✗ if (modelObject) {
170 ✗ if (auto s = modelObject->optionalCast<Schedule>()) {
171 ✗ mixing.setMaximumReceivingTemperatureSchedule(s.get());
172 ✗ reverseMixing.setMaximumReceivingTemperatureSchedule(s.get());
173 ✗ }
174 }
175 ✗ }
176
177 ✗ target = workspaceObject.getTarget(openstudio::ZoneCrossMixingFields::MinimumSourceTemperatureScheduleName);
178 ✗ if (target) {
179 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
180 ✗ if (modelObject) {
181 ✗ if (auto s = modelObject->optionalCast<Schedule>()) {
182 ✗ mixing.setMinimumSourceTemperatureSchedule(s.get());
183 ✗ reverseMixing.setMinimumSourceTemperatureSchedule(s.get());
184 ✗ }
185 }
186 ✗ }
187
188 ✗ target = workspaceObject.getTarget(openstudio::ZoneCrossMixingFields::MaximumSourceTemperatureScheduleName);
189 ✗ if (target) {
190 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
191 ✗ if (modelObject) {
192 ✗ if (auto s = modelObject->optionalCast<Schedule>()) {
193 ✗ mixing.setMaximumSourceTemperatureSchedule(s.get());
194 ✗ reverseMixing.setMaximumSourceTemperatureSchedule(s.get());
195 ✗ }
196 }
197 ✗ }
198
199 ✗ target = workspaceObject.getTarget(openstudio::ZoneCrossMixingFields::MinimumOutdoorTemperatureScheduleName);
200 ✗ if (target) {
201 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
202 ✗ if (modelObject) {
203 ✗ if (auto s = modelObject->optionalCast<Schedule>()) {
204 ✗ mixing.setMinimumOutdoorTemperatureSchedule(s.get());
205 ✗ reverseMixing.setMinimumOutdoorTemperatureSchedule(s.get());
206 ✗ }
207 }
208 ✗ }
209
210 ✗ target = workspaceObject.getTarget(openstudio::ZoneCrossMixingFields::MaximumOutdoorTemperatureScheduleName);
211 ✗ if (target) {
212 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
213 ✗ if (modelObject) {
214 ✗ if (auto s = modelObject->optionalCast<Schedule>()) {
215 ✗ mixing.setMaximumOutdoorTemperatureSchedule(s.get());
216 ✗ reverseMixing.setMaximumOutdoorTemperatureSchedule(s.get());
217 ✗ }
218 }
219 ✗ }
220
221 ✗ return mixing;
222 ✗ }
223
224 } // namespace energyplus
225
226 } // namespace openstudio
227