GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 57.6% 118 / 0 / 205
Functions: 66.1% 39 / 0 / 59
Branches: 36.5% 77 / 0 / 211

src/model/ExteriorLights.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 "ExteriorLights.hpp"
7 #include "ExteriorLights_Impl.hpp"
8
9 #include "Model.hpp"
10 #include "ExteriorLightsDefinition.hpp"
11 #include "ExteriorLightsDefinition_Impl.hpp"
12 #include "Schedule.hpp"
13 #include "Schedule_Impl.hpp"
14 #include "ScheduleConstant.hpp"
15 #include "Facility.hpp"
16 #include "Facility_Impl.hpp"
17
18 #include <utilities/idd/IddFactory.hxx>
19
20 #include <utilities/idd/OS_Exterior_Lights_FieldEnums.hxx>
21 #include <utilities/idd/IddEnums.hxx>
22
23 #include "../utilities/core/Assert.hpp"
24
25 namespace openstudio {
26 namespace model {
27
28 namespace detail {
29
30 24 ExteriorLights_Impl::ExteriorLights_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
31 24 : ExteriorLoadInstance_Impl(idfObject, model, keepHandle) {
32
4/6
✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 24 times.
✗ Branch 13 not taken.
24 OS_ASSERT(idfObject.iddObject().type() == ExteriorLights::iddObjectType());
33 24 }
34
35 5 ExteriorLights_Impl::ExteriorLights_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
36 5 : ExteriorLoadInstance_Impl(other, model, keepHandle) {
37
4/6
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 13 not taken.
5 OS_ASSERT(other.iddObject().type() == ExteriorLights::iddObjectType());
38 5 }
39
40 4 ExteriorLights_Impl::ExteriorLights_Impl(const ExteriorLights_Impl& other, Model_Impl* model, bool keepHandle)
41 4 : ExteriorLoadInstance_Impl(other, model, keepHandle) {}
42
43 1 boost::optional<ParentObject> ExteriorLights_Impl::parent() const {
44
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 return facility();
45 }
46
47 ✗ const std::vector<std::string>& ExteriorLights_Impl::outputVariableNames() const {
48 ✗ static const std::vector<std::string> result{"Exterior Lights Electricity Rate", "Exterior Lights Electricity Energy"};
49 ✗ return result;
50 ✗ }
51
52 ✗ IddObjectType ExteriorLights_Impl::iddObjectType() const {
53 ✗ return ExteriorLights::iddObjectType();
54 }
55
56 ✗ std::vector<ScheduleTypeKey> ExteriorLights_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
57 ✗ std::vector<ScheduleTypeKey> result;
58 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
59 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
60 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
61 ✗ if (std::find(b, e, OS_Exterior_LightsFields::ScheduleName) != e) {
62 ✗ result.push_back(ScheduleTypeKey("ExteriorLights", "Exterior Lights"));
63 }
64 ✗ return result;
65 ✗ }
66
67 43 int ExteriorLights_Impl::definitionIndex() const {
68 43 return OS_Exterior_LightsFields::ExteriorLightsDefinitionName;
69 }
70
71 4 ExteriorLightsDefinition ExteriorLights_Impl::exteriorLightsDefinition() const {
72
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 return this->definition().cast<ExteriorLightsDefinition>();
73 }
74
75 19 bool ExteriorLights_Impl::setExteriorLightsDefinition(const ExteriorLightsDefinition& exteriorLightsDefinition) {
76
3/3
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
19 return this->setPointer(this->definitionIndex(), exteriorLightsDefinition.handle());
77 }
78
79 ✗ bool ExteriorLights_Impl::setDefinition(const ExteriorLoadDefinition& definition) {
80 ✗ bool result = false;
81 ✗ boost::optional<ExteriorLightsDefinition> exteriorLightsDefinition = definition.optionalCast<ExteriorLightsDefinition>();
82 ✗ if (exteriorLightsDefinition) {
83 ✗ result = setExteriorLightsDefinition(*exteriorLightsDefinition);
84 }
85 ✗ return result;
86 ✗ }
87
88 7 boost::optional<Schedule> ExteriorLights_Impl::schedule() const {
89
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_Exterior_LightsFields::ScheduleName);
90 }
91
92 6 std::string ExteriorLights_Impl::controlOption() const {
93
1/1
✓ Branch 1 taken 6 times.
6 boost::optional<std::string> value = getString(OS_Exterior_LightsFields::ControlOption, true);
94
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 4 not taken.
6 OS_ASSERT(value);
95
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
12 return value.get();
96 6 }
97
98 2 bool ExteriorLights_Impl::isControlOptionDefaulted() const {
99 2 return isEmpty(OS_Exterior_LightsFields::ControlOption);
100 }
101
102 4 double ExteriorLights_Impl::multiplier() const {
103
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<double> value = getDouble(OS_Exterior_LightsFields::Multiplier, true);
104
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(value);
105
1/1
✓ Branch 1 taken 4 times.
8 return value.get();
106 }
107
108 2 bool ExteriorLights_Impl::isMultiplierDefaulted() const {
109 2 return isEmpty(OS_Exterior_LightsFields::Multiplier);
110 }
111
112 3 std::string ExteriorLights_Impl::endUseSubcategory() const {
113
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<std::string> value = getString(OS_Exterior_LightsFields::EndUseSubcategory, true);
114
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(value);
115
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 return value.get();
116 3 }
117
118 2 bool ExteriorLights_Impl::isEndUseSubcategoryDefaulted() const {
119 2 return isEmpty(OS_Exterior_LightsFields::EndUseSubcategory);
120 }
121
122 20 bool ExteriorLights_Impl::setSchedule(Schedule& schedule) {
123
3/3
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 7 taken 20 times.
80 bool result = ModelObject_Impl::setSchedule(OS_Exterior_LightsFields::ScheduleName, "ExteriorLights", "Exterior Lights", schedule);
124 20 return result;
125 }
126
127 1 void ExteriorLights_Impl::resetSchedule() {
128
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_Exterior_LightsFields::ScheduleName, "");
129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
130 1 }
131
132 9 bool ExteriorLights_Impl::setControlOption(const std::string& controlOption) {
133 9 bool result = setString(OS_Exterior_LightsFields::ControlOption, controlOption);
134 9 return result;
135 }
136
137 ✗ void ExteriorLights_Impl::resetControlOption() {
138 ✗ bool result = setString(OS_Exterior_LightsFields::ControlOption, "");
139 ✗ OS_ASSERT(result);
140 ✗ }
141
142 1 bool ExteriorLights_Impl::setMultiplier(double multiplier) {
143 1 bool result = setDouble(OS_Exterior_LightsFields::Multiplier, multiplier);
144 1 return result;
145 }
146
147 ✗ void ExteriorLights_Impl::resetMultiplier() {
148 ✗ bool result = setString(OS_Exterior_LightsFields::Multiplier, "");
149 ✗ OS_ASSERT(result);
150 ✗ }
151
152 24 bool ExteriorLights_Impl::setEndUseSubcategory(const std::string& endUseSubcategory) {
153 24 bool result = setString(OS_Exterior_LightsFields::EndUseSubcategory, endUseSubcategory);
154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 OS_ASSERT(result);
155 24 return result;
156 }
157
158 ✗ void ExteriorLights_Impl::resetEndUseSubcategory() {
159 ✗ bool result = setString(OS_Exterior_LightsFields::EndUseSubcategory, "");
160 ✗ OS_ASSERT(result);
161 ✗ }
162
163 2 Facility ExteriorLights_Impl::facility() const {
164
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return model().getUniqueModelObject<Facility>();
165 }
166
167 ✗ std::vector<std::string> ExteriorLights_Impl::controlOptionValues() const {
168 ✗ return ExteriorLights::controlOptionValues();
169 }
170
171 ✗ boost::optional<ModelObject> ExteriorLights_Impl::exteriorLightsDefinitionAsModelObject() const {
172 ✗ OptionalModelObject result = exteriorLightsDefinition();
173 ✗ return result;
174 }
175
176 ✗ boost::optional<ModelObject> ExteriorLights_Impl::scheduleAsModelObject() const {
177 ✗ OptionalModelObject result;
178 ✗ if (auto t_schedule = schedule()) {
179 ✗ result = t_schedule->cast<ModelObject>();
180 ✗ }
181 ✗ return result;
182 ✗ }
183
184 ✗ boost::optional<ModelObject> ExteriorLights_Impl::facilityAsModelObject() const {
185 ✗ OptionalModelObject result = facility();
186 ✗ return result;
187 }
188
189 ✗ bool ExteriorLights_Impl::setExteriorLightsDefinitionAsModelObject(const boost::optional<ModelObject>& modelObject) {
190 ✗ if (modelObject) {
191 ✗ OptionalExteriorLightsDefinition intermediate = modelObject->optionalCast<ExteriorLightsDefinition>();
192 ✗ if (intermediate) {
193 ✗ return setExteriorLightsDefinition(*intermediate);
194 }
195 ✗ }
196 ✗ return false;
197 }
198
199 ✗ bool ExteriorLights_Impl::setScheduleAsModelObject(const boost::optional<ModelObject>& modelObject) {
200 ✗ if (modelObject) {
201 ✗ OptionalSchedule intermediate = modelObject->optionalCast<Schedule>();
202 ✗ if (intermediate) {
203 ✗ Schedule schedule(*intermediate);
204 ✗ return setSchedule(schedule);
205 ✗ }
206 ✗ }
207 ✗ return false;
208 }
209
210 ✗ std::vector<EMSActuatorNames> ExteriorLights_Impl::emsActuatorNames() const {
211 ✗ std::vector<EMSActuatorNames> actuators{{"ExteriorLights", "Electric Power"}};
212 ✗ return actuators;
213 ✗ }
214
215 ✗ std::vector<std::string> ExteriorLights_Impl::emsInternalVariableNames() const {
216 ✗ std::vector<std::string> types;
217 ✗ return types;
218 }
219 } // namespace detail
220
221 14 ExteriorLights::ExteriorLights(const ExteriorLightsDefinition& definition, bool useControlOptionAstronomicalClock)
222 14 : ExteriorLoadInstance(ExteriorLights::iddObjectType(), definition) {
223
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 5 not taken.
14 OS_ASSERT(getImpl<detail::ExteriorLights_Impl>());
224
225
1/1
✓ Branch 1 taken 14 times.
14 bool ok = setExteriorLightsDefinition(definition);
226
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 3 not taken.
14 OS_ASSERT(ok);
227
228
2/2
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
14 auto defaultSchedule = definition.model().alwaysOnDiscreteSchedule();
229
1/1
✓ Branch 1 taken 14 times.
14 ok = setSchedule(defaultSchedule);
230
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 3 not taken.
14 OS_ASSERT(ok);
231
232
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
14 if (useControlOptionAstronomicalClock) {
233
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 ok = setControlOption("AstronomicalClock");
234
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
2 OS_ASSERT(ok);
235 }
236
237 /*
238 *ok = this->setMultiplier(1.0);
239 *OS_ASSERT(ok);
240 */
241
2/2
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
14 ok = this->setEndUseSubcategory("General");
242
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 3 not taken.
14 OS_ASSERT(ok);
243 14 }
244
245 5 ExteriorLights::ExteriorLights(const ExteriorLightsDefinition& definition, Schedule& schedule)
246 5 : ExteriorLoadInstance(ExteriorLights::iddObjectType(), definition) {
247
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 5 not taken.
5 OS_ASSERT(getImpl<detail::ExteriorLights_Impl>());
248
249
1/1
✓ Branch 1 taken 5 times.
5 bool ok = setExteriorLightsDefinition(definition);
250
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
5 OS_ASSERT(ok);
251
1/1
✓ Branch 1 taken 5 times.
5 ok = setSchedule(schedule);
252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!ok) {
253 ✗ remove();
254 ✗ LOG_AND_THROW("Could not set " << briefDescription() << "'s schedule to " << schedule.briefDescription() << ".");
255 }
256
257 /*
258 *ok = this->setMultiplier(1.0);
259 *OS_ASSERT(ok);
260 */
261
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 ok = this->setEndUseSubcategory("General");
262
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
5 OS_ASSERT(ok);
263 5 }
264
265 7658 IddObjectType ExteriorLights::iddObjectType() {
266
1/1
✓ Branch 1 taken 7658 times.
7658 IddObjectType result(IddObjectType::OS_Exterior_Lights);
267 7658 return result;
268 }
269
270 ✗ std::vector<std::string> ExteriorLights::controlOptionValues() {
271 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Exterior_LightsFields::ControlOption);
272 }
273
274 ✗ std::vector<std::string> ExteriorLights::validControlOptionValues() {
275 ✗ return ExteriorLights::controlOptionValues();
276 }
277
278 4 ExteriorLightsDefinition ExteriorLights::exteriorLightsDefinition() const {
279
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ExteriorLights_Impl>()->exteriorLightsDefinition();
280 }
281
282 7 boost::optional<Schedule> ExteriorLights::schedule() const {
283
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::ExteriorLights_Impl>()->schedule();
284 }
285
286 6 std::string ExteriorLights::controlOption() const {
287
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::ExteriorLights_Impl>()->controlOption();
288 }
289
290 2 bool ExteriorLights::isControlOptionDefaulted() const {
291
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ExteriorLights_Impl>()->isControlOptionDefaulted();
292 }
293
294 4 double ExteriorLights::multiplier() const {
295
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ExteriorLights_Impl>()->multiplier();
296 }
297
298 2 bool ExteriorLights::isMultiplierDefaulted() const {
299
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ExteriorLights_Impl>()->isMultiplierDefaulted();
300 }
301
302 3 std::string ExteriorLights::endUseSubcategory() const {
303
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::ExteriorLights_Impl>()->endUseSubcategory();
304 }
305
306 2 bool ExteriorLights::isEndUseSubcategoryDefaulted() const {
307
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ExteriorLights_Impl>()->isEndUseSubcategoryDefaulted();
308 }
309
310 19 bool ExteriorLights::setExteriorLightsDefinition(const ExteriorLightsDefinition& exteriorLightsDefinition) {
311
1/1
✓ Branch 3 taken 19 times.
19 return getImpl<detail::ExteriorLights_Impl>()->setExteriorLightsDefinition(exteriorLightsDefinition);
312 }
313
314 20 bool ExteriorLights::setSchedule(Schedule& schedule) {
315
1/1
✓ Branch 3 taken 20 times.
20 return getImpl<detail::ExteriorLights_Impl>()->setSchedule(schedule);
316 }
317
318 1 void ExteriorLights::resetSchedule() {
319
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ExteriorLights_Impl>()->resetSchedule();
320 1 }
321
322 9 bool ExteriorLights::setControlOption(const std::string& controlOption) {
323
1/1
✓ Branch 3 taken 9 times.
9 return getImpl<detail::ExteriorLights_Impl>()->setControlOption(controlOption);
324 }
325
326 ✗ void ExteriorLights::resetControlOption() {
327 ✗ getImpl<detail::ExteriorLights_Impl>()->resetControlOption();
328 ✗ }
329
330 1 bool ExteriorLights::setMultiplier(double multiplier) {
331
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ExteriorLights_Impl>()->setMultiplier(multiplier);
332 }
333
334 ✗ void ExteriorLights::resetMultiplier() {
335 ✗ getImpl<detail::ExteriorLights_Impl>()->resetMultiplier();
336 ✗ }
337
338 24 bool ExteriorLights::setEndUseSubcategory(const std::string& endUseSubcategory) {
339
1/1
✓ Branch 3 taken 24 times.
24 return getImpl<detail::ExteriorLights_Impl>()->setEndUseSubcategory(endUseSubcategory);
340 }
341
342 ✗ void ExteriorLights::resetEndUseSubcategory() {
343 ✗ getImpl<detail::ExteriorLights_Impl>()->resetEndUseSubcategory();
344 ✗ }
345
346 1 Facility ExteriorLights::facility() const {
347
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ExteriorLights_Impl>()->facility();
348 }
349
350 /// @cond
351
1/1
✓ Branch 3 taken 11 times.
11 ExteriorLights::ExteriorLights(std::shared_ptr<detail::ExteriorLights_Impl> impl) : ExteriorLoadInstance(std::move(impl)) {}
352 /// @endcond
353
354 } // namespace model
355 } // namespace openstudio
356