GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 64.3% 218 / 0 / 339
Functions: 68.0% 51 / 0 / 75
Branches: 52.7% 263 / 0 / 499

src/model/OutputMeter.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 "OutputMeter.hpp"
7 #include "OutputMeter_Impl.hpp"
8
9 #include "Model.hpp"
10 #include "Facility.hpp"
11 #include "Facility_Impl.hpp"
12 #include "Building.hpp"
13 #include "Building_Impl.hpp"
14 #include "EnergyManagementSystemSensor.hpp"
15 #include "EnergyManagementSystemSensor_Impl.hpp"
16
17 #include <utilities/idd/IddFactory.hxx>
18
19 #include <utilities/idd/OS_Output_Meter_FieldEnums.hxx>
20 #include <utilities/idd/IddEnums.hxx>
21
22 #include "../utilities/data/DataEnums.hpp"
23 #include "../utilities/data/TimeSeries.hpp"
24 #include "../utilities/sql/SqlFile.hpp"
25 #include "../utilities/sql/SqlFileEnums.hpp"
26 #include "../utilities/core/Assert.hpp"
27
28 #include <boost/regex.hpp>
29 #include <boost/algorithm/string.hpp>
30 #include <boost/algorithm/string/replace.hpp>
31
32 namespace openstudio {
33 namespace model {
34
35 namespace detail {
36
37 3299 OutputMeter_Impl::OutputMeter_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
38 3299 : ModelObject_Impl(idfObject, model, keepHandle) {
39
4/6
✓ Branch 1 taken 3299 times.
✓ Branch 4 taken 3299 times.
✓ Branch 7 taken 3299 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3299 times.
✗ Branch 13 not taken.
3299 OS_ASSERT(idfObject.iddObject().type() == OutputMeter::iddObjectType());
40 3299 }
41
42 130 OutputMeter_Impl::OutputMeter_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
43 130 : ModelObject_Impl(other, model, keepHandle) {
44
4/6
✓ Branch 1 taken 130 times.
✓ Branch 4 taken 130 times.
✓ Branch 7 taken 130 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 130 times.
✗ Branch 13 not taken.
130 OS_ASSERT(other.iddObject().type() == OutputMeter::iddObjectType());
45 130 }
46
47 452 OutputMeter_Impl::OutputMeter_Impl(const OutputMeter_Impl& other, Model_Impl* model, bool keepHandle)
48 452 : ModelObject_Impl(other, model, keepHandle) {}
49
50 3 const std::vector<std::string>& OutputMeter_Impl::outputVariableNames() const {
51
3/4
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
3 static const std::vector<std::string> result;
52 3 return result;
53 }
54
55 3 IddObjectType OutputMeter_Impl::iddObjectType() const {
56 3 return OutputMeter::iddObjectType();
57 }
58
59 ✗ boost::optional<ParentObject> OutputMeter_Impl::parent() const {
60 ✗ boost::optional<ParentObject> result;
61 ✗ boost::optional<InstallLocationType> installLocationType = this->installLocationType();
62 ✗ if (installLocationType) {
63 ✗ switch (installLocationType->value()) {
64 ✗ case InstallLocationType::Facility:
65 ✗ result = this->model().getOptionalUniqueModelObject<Facility>();
66 ✗ break;
67 ✗ case InstallLocationType::Building:
68 ✗ result = this->model().building();
69 ✗ break;
70 ✗ default:;
71 }
72 }
73 ✗ return result;
74 ✗ }
75
76 2 std::vector<openstudio::IdfObject> OutputMeter_Impl::remove() {
77 //Note: Cant do /object-list implementation for EMS Sensor since Auto Naming of Objects causes issues.
78 // Instead, doing an /alpha getString implementation so we need to manually remove any referring Sensors
79
1/1
✓ Branch 1 taken 2 times.
2 const Model m = this->model();
80
81
1/1
✓ Branch 1 taken 2 times.
2 std::vector<EnergyManagementSystemSensor> objects = m.getConcreteModelObjects<EnergyManagementSystemSensor>();
82
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 2 times.
5 for (auto& sensor : objects) {
83
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 2 times.
6 if (sensor.outputMeter()) {
84
5/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 16 taken 1 time.
✗ Branch 17 not taken.
1 if (sensor.outputMeter().get().name() == this->name()) {
85
1/1
✓ Branch 1 taken 1 time.
1 sensor.remove();
86 }
87 }
88 }
89
1/1
✓ Branch 1 taken 2 times.
4 return ModelObject_Impl::remove();
90 2 }
91
92 40475 std::string OutputMeter_Impl::name() const {
93
1/1
✓ Branch 1 taken 40475 times.
40475 boost::optional<std::string> value = getString(OS_Output_MeterFields::Name, true);
94
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 40475 times.
✗ Branch 4 not taken.
40475 OS_ASSERT(value);
95
2/2
✓ Branch 1 taken 40475 times.
✓ Branch 4 taken 40475 times.
80950 return value.get();
96 40475 }
97
98 2155 std::string OutputMeter_Impl::reportingFrequency() const {
99
1/1
✓ Branch 1 taken 2155 times.
2155 boost::optional<std::string> value = getString(OS_Output_MeterFields::ReportingFrequency, true);
100
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2155 times.
✗ Branch 4 not taken.
2155 OS_ASSERT(value);
101
2/2
✓ Branch 1 taken 2155 times.
✓ Branch 4 taken 2155 times.
4310 return value.get();
102 2155 }
103
104 398 bool OutputMeter_Impl::isReportingFrequencyDefaulted() const {
105 398 return isEmpty(OS_Output_MeterFields::ReportingFrequency);
106 }
107
108 1597 bool OutputMeter_Impl::meterFileOnly() const {
109
1/1
✓ Branch 1 taken 1597 times.
1597 boost::optional<std::string> value = getString(OS_Output_MeterFields::MeterFileOnly, true);
110
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 1597 times.
✗ Branch 4 not taken.
1597 OS_ASSERT(value);
111
3/3
✓ Branch 1 taken 1597 times.
✓ Branch 4 taken 1597 times.
✓ Branch 7 taken 1597 times.
3194 return openstudio::istringEqual(value.get(), "True");
112 1597 }
113
114 ✗ bool OutputMeter_Impl::isMeterFileOnlyDefaulted() const {
115 ✗ return isEmpty(OS_Output_MeterFields::MeterFileOnly);
116 }
117
118 776 bool OutputMeter_Impl::cumulative() const {
119
1/1
✓ Branch 1 taken 776 times.
776 boost::optional<std::string> value = getString(OS_Output_MeterFields::Cumulative, true);
120
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 776 times.
✗ Branch 4 not taken.
776 OS_ASSERT(value);
121
3/3
✓ Branch 1 taken 776 times.
✓ Branch 4 taken 776 times.
✓ Branch 7 taken 776 times.
1552 return openstudio::istringEqual(value.get(), "True");
122 776 }
123
124 1 bool OutputMeter_Impl::isCumulativeDefaulted() const {
125 1 return isEmpty(OS_Output_MeterFields::Cumulative);
126 }
127
128 7138 boost::optional<std::string> OutputMeter_Impl::specificEndUse() const {
129 7138 boost::optional<std::string> result;
130
1/1
✓ Branch 1 taken 7138 times.
7138 std::string myName = name();
131
1/1
✓ Branch 1 taken 7138 times.
7138 boost::smatch matches;
132
3/4
✓ Branch 1 taken 7138 times.
✓ Branch 4 taken 7138 times.
✓ Branch 7 taken 7138 times.
✗ Branch 8 not taken.
7138 if (boost::regex_search(myName, matches, OutputMeter::meterRegex())) {
133 // match is always true but may be empty
134
4/4
✓ Branch 1 taken 7138 times.
✓ Branch 4 taken 7138 times.
✓ Branch 7 taken 17 times.
✓ Branch 8 taken 7121 times.
7138 if (matches[1].first != matches[1].second) {
135
4/4
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
✓ Branch 10 taken 17 times.
34 result = std::string(matches[1].first, matches[1].second);
136 }
137 }
138
139 14276 return result;
140 7138 }
141
142 8978 boost::optional<EndUseType> OutputMeter_Impl::endUseType() const {
143 8978 boost::optional<EndUseType> result;
144
1/1
✓ Branch 1 taken 8978 times.
8978 std::string myName = name();
145
1/1
✓ Branch 1 taken 8978 times.
8978 boost::smatch matches;
146
3/4
✓ Branch 1 taken 8978 times.
✓ Branch 4 taken 8978 times.
✓ Branch 7 taken 8978 times.
✗ Branch 8 not taken.
8978 if (boost::regex_search(myName, matches, OutputMeter::meterRegex())) {
147
3/3
✓ Branch 1 taken 8978 times.
✓ Branch 3 taken 3939 times.
✓ Branch 4 taken 5039 times.
8978 if (matches[2].matched) {
148
5/5
✓ Branch 1 taken 3939 times.
✓ Branch 4 taken 3939 times.
✓ Branch 7 taken 3939 times.
✓ Branch 10 taken 3939 times.
✓ Branch 13 taken 3939 times.
7878 result = EndUseType(std::string(matches[2].first, matches[2].second));
149 }
150 }
151
152 17956 return result;
153 8978 }
154
155 8413 boost::optional<FuelType> OutputMeter_Impl::fuelType() const {
156 8413 boost::optional<FuelType> result;
157
1/1
✓ Branch 1 taken 8413 times.
8413 std::string myName = name();
158
1/1
✓ Branch 1 taken 8413 times.
8413 boost::smatch matches;
159
3/4
✓ Branch 1 taken 8413 times.
✓ Branch 4 taken 8413 times.
✓ Branch 7 taken 8413 times.
✗ Branch 8 not taken.
8413 if (boost::regex_search(myName, matches, OutputMeter::meterRegex())) {
160
3/3
✓ Branch 1 taken 8413 times.
✓ Branch 3 taken 6483 times.
✓ Branch 4 taken 1930 times.
8413 if (matches[3].matched) {
161
5/5
✓ Branch 1 taken 6483 times.
✓ Branch 4 taken 6483 times.
✓ Branch 7 taken 6483 times.
✓ Branch 10 taken 6483 times.
✓ Branch 13 taken 6483 times.
12966 result = FuelType(std::string(matches[3].first, matches[3].second));
162 }
163 }
164
165 16826 return result;
166 8413 }
167
168 8147 boost::optional<InstallLocationType> OutputMeter_Impl::installLocationType() const {
169 8147 boost::optional<InstallLocationType> result;
170
1/1
✓ Branch 1 taken 8147 times.
8147 std::string myName = name();
171
1/1
✓ Branch 1 taken 8147 times.
8147 boost::smatch matches;
172
3/4
✓ Branch 1 taken 8147 times.
✓ Branch 4 taken 8147 times.
✓ Branch 7 taken 8147 times.
✗ Branch 8 not taken.
8147 if (boost::regex_search(myName, matches, OutputMeter::meterRegex())) {
173
3/3
✓ Branch 1 taken 8147 times.
✓ Branch 3 taken 7257 times.
✓ Branch 4 taken 890 times.
8147 if (matches[4].matched) {
174
5/5
✓ Branch 1 taken 7257 times.
✓ Branch 4 taken 7257 times.
✓ Branch 7 taken 7257 times.
✓ Branch 10 taken 7257 times.
✓ Branch 13 taken 7257 times.
14514 result = InstallLocationType(std::string(matches[4].first, matches[4].second));
175 }
176 }
177
178 16294 return result;
179 8147 }
180
181 7153 boost::optional<std::string> OutputMeter_Impl::specificInstallLocation() const {
182 7153 boost::optional<std::string> result;
183
1/1
✓ Branch 1 taken 7153 times.
7153 std::string myName = name();
184
1/1
✓ Branch 1 taken 7153 times.
7153 boost::smatch matches;
185
3/4
✓ Branch 1 taken 7153 times.
✓ Branch 4 taken 7153 times.
✓ Branch 7 taken 7153 times.
✗ Branch 8 not taken.
7153 if (boost::regex_search(myName, matches, OutputMeter::meterRegex())) {
186 // match is always true but may be empty
187
4/4
✓ Branch 1 taken 7153 times.
✓ Branch 4 taken 7153 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 7151 times.
7153 if (matches[5].first != matches[5].second) {
188
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
4 result = std::string(matches[5].first, matches[5].second);
189 }
190 }
191
192 14306 return result;
193 7153 }
194
195 1208 bool OutputMeter_Impl::setReportingFrequency(const std::string& reportingFrequency) {
196 1208 return setString(OS_Output_MeterFields::ReportingFrequency, reportingFrequency);
197 }
198
199 ✗ void OutputMeter_Impl::resetReportingFrequency() {
200 ✗ bool result = setString(OS_Output_MeterFields::ReportingFrequency, "");
201 ✗ OS_ASSERT(result);
202 ✗ }
203
204 563 bool OutputMeter_Impl::setMeterFileOnly(bool meterFileOnly) {
205 563 bool result = false;
206
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 294 times.
563 if (meterFileOnly) {
207
2/2
✓ Branch 1 taken 269 times.
✓ Branch 4 taken 269 times.
807 result = setString(OS_Output_MeterFields::MeterFileOnly, "True");
208 } else {
209
2/2
✓ Branch 1 taken 294 times.
✓ Branch 4 taken 294 times.
882 result = setString(OS_Output_MeterFields::MeterFileOnly, "False");
210 }
211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 563 times.
563 OS_ASSERT(result);
212 563 return result;
213 }
214
215 ✗ void OutputMeter_Impl::resetMeterFileOnly() {
216 ✗ bool result = setString(OS_Output_MeterFields::MeterFileOnly, "");
217 ✗ OS_ASSERT(result);
218 ✗ }
219
220 561 bool OutputMeter_Impl::setCumulative(bool cumulative) {
221 561 bool result = false;
222
2/2
✓ Branch 0 taken 245 times.
✓ Branch 1 taken 316 times.
561 if (cumulative) {
223
2/2
✓ Branch 1 taken 245 times.
✓ Branch 4 taken 245 times.
735 result = setString(OS_Output_MeterFields::Cumulative, "True");
224 } else {
225
2/2
✓ Branch 1 taken 316 times.
✓ Branch 4 taken 316 times.
948 result = setString(OS_Output_MeterFields::Cumulative, "False");
226 }
227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 561 times.
561 OS_ASSERT(result);
228 561 return result;
229 }
230
231 ✗ void OutputMeter_Impl::resetCumulative() {
232 ✗ bool result = setString(OS_Output_MeterFields::Cumulative, "");
233 ✗ OS_ASSERT(result);
234 ✗ }
235
236 15 bool OutputMeter_Impl::setSpecificEndUse(const std::string& endUse) {
237
1/1
✓ Branch 1 taken 15 times.
15 auto object = getObject<ModelObject>();
238
239
6/6
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
✓ Branch 13 taken 15 times.
✓ Branch 16 taken 15 times.
15 std::string name = OutputMeter::getName(endUse, endUseType(), fuelType(), installLocationType(), specificInstallLocation());
240
241
1/1
✓ Branch 1 taken 15 times.
15 bool result = object.setString(OS_Output_MeterFields::Name, name);
242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if (!result) {
243 ✗ LOG(Error, "Could not set name to '" << name << "'");
244 }
245
246 15 return result;
247 15 }
248
249 ✗ bool OutputMeter_Impl::resetSpecificEndUse() {
250 ✗ return setSpecificEndUse("");
251 }
252
253 2004 bool OutputMeter_Impl::setEndUseType(EndUseType type) {
254
1/1
✓ Branch 1 taken 2004 times.
2004 auto object = getObject<ModelObject>();
255
256
6/6
✓ Branch 1 taken 2004 times.
✓ Branch 4 taken 2004 times.
✓ Branch 7 taken 2004 times.
✓ Branch 10 taken 2004 times.
✓ Branch 13 taken 2004 times.
✓ Branch 16 taken 2004 times.
2004 std::string name = OutputMeter::getName(specificEndUse(), type, fuelType(), installLocationType(), specificInstallLocation());
257
258
1/1
✓ Branch 1 taken 2004 times.
2004 bool result = object.setString(OS_Output_MeterFields::Name, name);
259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2004 times.
2004 if (!result) {
260 ✗ LOG(Error, "Could not set name to '" << name << "'");
261 }
262
263 2004 return result;
264 2004 }
265
266 ✗ bool OutputMeter_Impl::resetEndUseType() {
267 ✗ auto object = getObject<ModelObject>();
268
269 ✗ std::string name = OutputMeter::getName(specificEndUse(), boost::none, fuelType(), installLocationType(), specificInstallLocation());
270
271 ✗ bool result = object.setString(OS_Output_MeterFields::Name, name);
272 ✗ if (!result) {
273 ✗ LOG(Error, "Could not set name to '" << name << "'");
274 }
275
276 ✗ return result;
277 ✗ }
278
279 2567 bool OutputMeter_Impl::setFuelType(FuelType type) {
280
281
8/8
✓ Branch 1 taken 2567 times.
✓ Branch 4 taken 2566 times.
✓ Branch 5 taken 1 time.
✓ Branch 7 taken 2566 times.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 2565 times.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 2565 times.
2567 if ((type == FuelType::Geothermal) || (type == FuelType::Solar)) {
282
13/13
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 2 times.
✓ Branch 31 taken 2 times.
✓ Branch 34 taken 2 times.
✓ Branch 38 taken 2 times.
✓ Branch 41 taken 2 times.
2 LOG_AND_THROW("OutputMeter cannot be instantiated with a FuelType 'Geothermal' nor 'Solar'.");
283 }
284
285
1/1
✓ Branch 1 taken 2565 times.
2565 auto object = getObject<ModelObject>();
286
287
6/6
✓ Branch 1 taken 2565 times.
✓ Branch 4 taken 2565 times.
✓ Branch 7 taken 2565 times.
✓ Branch 10 taken 2565 times.
✓ Branch 13 taken 2565 times.
✓ Branch 16 taken 2565 times.
2565 std::string name = OutputMeter::getName(specificEndUse(), endUseType(), type, installLocationType(), specificInstallLocation());
288
289
1/1
✓ Branch 1 taken 2565 times.
2565 bool result = object.setString(OS_Output_MeterFields::Name, name);
290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2565 times.
2565 if (!result) {
291 ✗ LOG(Error, "Could not set name to '" << name << "'");
292 }
293
294 2565 return result;
295 2565 }
296
297 ✗ bool OutputMeter_Impl::resetFuelType() {
298 ✗ auto object = getObject<ModelObject>();
299
300 ✗ std::string name = OutputMeter::getName(specificEndUse(), endUseType(), boost::none, installLocationType(), specificInstallLocation());
301
302 ✗ bool result = object.setString(OS_Output_MeterFields::Name, name);
303 ✗ if (!result) {
304 ✗ LOG(Error, "Could not set name to '" << name << "'");
305 }
306
307 ✗ return result;
308 ✗ }
309
310 2556 bool OutputMeter_Impl::setInstallLocationType(InstallLocationType type) {
311
1/1
✓ Branch 1 taken 2556 times.
2556 auto object = getObject<ModelObject>();
312
313
6/6
✓ Branch 1 taken 2556 times.
✓ Branch 4 taken 2556 times.
✓ Branch 7 taken 2556 times.
✓ Branch 10 taken 2556 times.
✓ Branch 13 taken 2556 times.
✓ Branch 16 taken 2556 times.
2556 std::string name = OutputMeter::getName(specificEndUse(), endUseType(), fuelType(), type, specificInstallLocation());
314
315
1/1
✓ Branch 1 taken 2556 times.
2556 bool result = object.setString(OS_Output_MeterFields::Name, name);
316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2556 times.
2556 if (!result) {
317 ✗ LOG(Error, "Could not set name to '" << name << "'");
318 }
319
320 2556 return result;
321 2556 }
322
323 ✗ bool OutputMeter_Impl::resetInstallLocationType() {
324 ✗ auto object = getObject<ModelObject>();
325
326 ✗ std::string name = OutputMeter::getName(specificEndUse(), endUseType(), fuelType(), boost::none, specificInstallLocation());
327
328 ✗ bool result = object.setString(OS_Output_MeterFields::Name, name);
329 ✗ if (!result) {
330 ✗ LOG(Error, "Could not set name to '" << name << "'");
331 }
332
333 ✗ return result;
334 ✗ }
335
336 ✗ bool OutputMeter_Impl::setSpecificInstallLocation(const std::string& locationName) {
337 ✗ auto object = getObject<ModelObject>();
338
339 ✗ std::string name = OutputMeter::getName(specificEndUse(), endUseType(), fuelType(), installLocationType(), locationName);
340
341 ✗ bool result = object.setString(OS_Output_MeterFields::Name, name);
342 ✗ if (!result) {
343 ✗ LOG(Error, "Could not set name to '" << name << "'");
344 }
345
346 ✗ return result;
347 ✗ }
348
349 ✗ bool OutputMeter_Impl::resetSpecificInstallLocation() {
350 ✗ return setSpecificInstallLocation("");
351 }
352
353 1 openstudio::OptionalTimeSeries OutputMeter_Impl::getData(const std::string& envPeriod) const {
354
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 return getData(envPeriod, specificInstallLocation());
355 }
356
357 1 openstudio::OptionalTimeSeries OutputMeter_Impl::getData(const std::string& envPeriod, const OptionalString& specificInstallLocation) const {
358 1 openstudio::OptionalTimeSeries result;
359
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 OptionalSqlFile sqlFile = model().sqlFile();
360
361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (sqlFile) {
362 ✗ auto object = getObject<ModelObject>();
363
364 // get name using specific install location passed in
365 ✗ std::string name;
366 ✗ if (specificInstallLocation) {
367 name =
368 ✗ OutputMeter::getName(specificEndUse(), endUseType(), fuelType(), installLocationType(), boost::to_upper_copy(*specificInstallLocation));
369 } else {
370 ✗ name = OutputMeter::getName(specificEndUse(), endUseType(), fuelType(), installLocationType(), specificInstallLocation);
371 }
372
373 ✗ std::string frequency = this->reportingFrequency();
374 ✗ if (openstudio::istringEqual(frequency, "RunPeriod")) {
375 ✗ frequency = "Run Period";
376 ✗ } else if (openstudio::istringEqual(frequency, "Timestep")) {
377 ✗ frequency = "Zone Timestep";
378 ✗ } else if (openstudio::istringEqual(frequency, "Detailed")) {
379 ✗ frequency = "HVAC System Timestep";
380 }
381
382 // currently the key value is not associated with the meter, it is part of the name
383 ✗ result = sqlFile->timeSeries(envPeriod, frequency, name, "");
384
385 ✗ if (!result) {
386 ✗ LOG(Debug, "Query for envPeriod = '" << envPeriod << "', frequency = '" << frequency << "', name = '" << name
387 << "', keyValue = '' did not return a TimeSeries");
388 }
389 ✗ }
390
391 2 return result;
392 1 }
393
394 } // namespace detail
395
396 3162 OutputMeter::OutputMeter(const Model& model) : ModelObject(OutputMeter::iddObjectType(), model) {
397
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 3162 times.
✗ Branch 5 not taken.
3162 OS_ASSERT(getImpl<detail::OutputMeter_Impl>());
398 // Don't keep the automatic name
399
2/2
✓ Branch 1 taken 3162 times.
✓ Branch 4 taken 3162 times.
6324 setName("");
400 3162 }
401
402 15342 IddObjectType OutputMeter::iddObjectType() {
403
1/1
✓ Branch 1 taken 15342 times.
15342 IddObjectType result(IddObjectType::OS_Output_Meter);
404 15342 return result;
405 }
406
407 ✗ std::vector<std::string> OutputMeter::reportingFrequencyValues() {
408 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Output_MeterFields::ReportingFrequency);
409 }
410
411 39890 boost::regex OutputMeter::meterRegex() {
412 // DLM: Must put more specific terms, e.g. HeatingCoils, before less specific terms, e.g. Heating
413 static const boost::regex result(
414 "^(.*?)?:?(InteriorLights|ExteriorLights|InteriorEquipment|ExteriorEquipment|Fans|Pumps|HeatingCoils|Heating|CoolingCoils|Cooling|"
415 "HeatRejection|Humidifier|HeatRecoveryForCooling|HeatRecoveryForHeating|HeatRecovery|WaterSystems|Cogeneration|Refrigeration|Chillers|Boilers|"
416 "Baseboard)?:?(Electricity|Gasoline|NaturalGas|Diesel|Coal|FuelOilNo1|FuelOilNo2|Propane|Water|DistrictHeatingSteam|DistrictCooling|"
417
5/7
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 39679 times.
✓ Branch 3 taken 202 times.
✓ Branch 4 taken 9 times.
✓ Branch 6 taken 202 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
39890 "DistrictHeatingWater|OtherFuel1|OtherFuel2|EnergyTransfer)?:?(Facility|Building|HVAC|Zone|System|Plant)?:?([^:]*?)?$");
418 39890 return result;
419 }
420
421 7346 std::string OutputMeter::getName(const boost::optional<std::string>& specificEndUseType, const boost::optional<EndUseType>& endUseType,
422 const boost::optional<FuelType>& fuelType, const boost::optional<InstallLocationType>& installLocationType,
423 const boost::optional<std::string>& specificInstallLocation) {
424 7346 std::string result;
425
426
6/7
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 7316 times.
✓ Branch 3 taken 30 times.
✓ Branch 6 taken 30 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 30 times.
✓ Branch 9 taken 7316 times.
7346 if (specificEndUseType && !specificEndUseType->empty()) {
427
2/2
✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
30 result += *specificEndUseType;
428 }
429
2/2
✓ Branch 0 taken 2203 times.
✓ Branch 1 taken 5143 times.
7346 if (endUseType) {
430
2/2
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 2173 times.
2203 if (!result.empty()) {
431
1/1
✓ Branch 1 taken 30 times.
30 result += ":";
432 }
433
3/3
✓ Branch 1 taken 2203 times.
✓ Branch 4 taken 2203 times.
✓ Branch 7 taken 2203 times.
2203 result += endUseType->valueName();
434 }
435
2/2
✓ Branch 0 taken 5422 times.
✓ Branch 1 taken 1924 times.
7346 if (fuelType) {
436
2/2
✓ Branch 1 taken 2180 times.
✓ Branch 2 taken 3242 times.
5422 if (!result.empty()) {
437
1/1
✓ Branch 1 taken 2180 times.
2180 result += ":";
438 }
439 result +=
440
3/3
✓ Branch 1 taken 5422 times.
✓ Branch 4 taken 5422 times.
✓ Branch 7 taken 5422 times.
5422 fuelType->valueDescription(); // same as valueName for all, except for FuelType::Gas where it returns "NaturalGas" which is what we want
441 }
442
2/2
✓ Branch 0 taken 6457 times.
✓ Branch 1 taken 889 times.
7346 if (installLocationType) {
443 // there is a weird corner case to handle 'InteriorLights:Electricity:Facility' -> 'InteriorLights:Electricity'
444 // this might not catch all cases
445
8/8
✓ Branch 1 taken 6457 times.
✓ Branch 4 taken 6457 times.
✓ Branch 7 taken 1727 times.
✓ Branch 8 taken 4730 times.
✓ Branch 10 taken 1319 times.
✓ Branch 11 taken 408 times.
✓ Branch 12 taken 6049 times.
✓ Branch 13 taken 408 times.
6457 if (installLocationType.get() != InstallLocationType::Facility || !endUseType) {
446
2/2
✓ Branch 1 taken 4148 times.
✓ Branch 2 taken 1901 times.
6049 if (!result.empty()) {
447
1/1
✓ Branch 1 taken 4148 times.
4148 result += ":";
448 }
449
3/3
✓ Branch 1 taken 6049 times.
✓ Branch 4 taken 6049 times.
✓ Branch 7 taken 6049 times.
6049 result += installLocationType->valueName();
450 }
451 }
452
2/7
✗ Branch 0 not taken.
✓ Branch 1 taken 7346 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7346 times.
7346 if (specificInstallLocation && !specificInstallLocation->empty()) {
453 ✗ if (!result.empty()) {
454 ✗ result += ":";
455 }
456 ✗ result += *specificInstallLocation;
457 }
458
7/7
✓ Branch 1 taken 7346 times.
✓ Branch 4 taken 7346 times.
✓ Branch 7 taken 7346 times.
✓ Branch 10 taken 7346 times.
✓ Branch 13 taken 7346 times.
✓ Branch 16 taken 7346 times.
✓ Branch 19 taken 7346 times.
7346 LOG(Debug, "getName result = '" << result << "'");
459 7346 return result;
460 ✗ }
461
462 645 std::string OutputMeter::name() const {
463
1/1
✓ Branch 3 taken 645 times.
645 return getImpl<detail::OutputMeter_Impl>()->name();
464 }
465
466 2155 std::string OutputMeter::reportingFrequency() const {
467
1/1
✓ Branch 3 taken 2155 times.
2155 return getImpl<detail::OutputMeter_Impl>()->reportingFrequency();
468 }
469
470 398 bool OutputMeter::isReportingFrequencyDefaulted() const {
471
1/1
✓ Branch 3 taken 398 times.
398 return getImpl<detail::OutputMeter_Impl>()->isReportingFrequencyDefaulted();
472 }
473
474 1597 bool OutputMeter::meterFileOnly() const {
475
1/1
✓ Branch 3 taken 1597 times.
1597 return getImpl<detail::OutputMeter_Impl>()->meterFileOnly();
476 }
477
478 ✗ bool OutputMeter::isMeterFileOnlyDefaulted() const {
479 ✗ return getImpl<detail::OutputMeter_Impl>()->isMeterFileOnlyDefaulted();
480 }
481
482 776 bool OutputMeter::cumulative() const {
483
1/1
✓ Branch 3 taken 776 times.
776 return getImpl<detail::OutputMeter_Impl>()->cumulative();
484 }
485
486 1 bool OutputMeter::isCumulativeDefaulted() const {
487
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::OutputMeter_Impl>()->isCumulativeDefaulted();
488 }
489
490 13 boost::optional<std::string> OutputMeter::specificEndUse() const {
491
1/1
✓ Branch 3 taken 13 times.
13 return getImpl<detail::OutputMeter_Impl>()->specificEndUse();
492 }
493
494 3842 boost::optional<EndUseType> OutputMeter::endUseType() const {
495
1/1
✓ Branch 3 taken 3842 times.
3842 return getImpl<detail::OutputMeter_Impl>()->endUseType();
496 }
497
498 3838 boost::optional<FuelType> OutputMeter::fuelType() const {
499
1/1
✓ Branch 3 taken 3838 times.
3838 return getImpl<detail::OutputMeter_Impl>()->fuelType();
500 }
501
502 3563 boost::optional<InstallLocationType> OutputMeter::installLocationType() const {
503
1/1
✓ Branch 3 taken 3563 times.
3563 return getImpl<detail::OutputMeter_Impl>()->installLocationType();
504 }
505
506 12 boost::optional<std::string> OutputMeter::specificInstallLocation() const {
507
1/1
✓ Branch 3 taken 12 times.
12 return getImpl<detail::OutputMeter_Impl>()->specificInstallLocation();
508 }
509
510 1208 bool OutputMeter::setReportingFrequency(const std::string& reportingFrequency) {
511
1/1
✓ Branch 3 taken 1208 times.
1208 return getImpl<detail::OutputMeter_Impl>()->setReportingFrequency(reportingFrequency);
512 }
513
514 ✗ void OutputMeter::resetReportingFrequency() {
515 ✗ getImpl<detail::OutputMeter_Impl>()->resetReportingFrequency();
516 ✗ }
517
518 563 bool OutputMeter::setMeterFileOnly(bool meterFileOnly) {
519
1/1
✓ Branch 3 taken 563 times.
563 return getImpl<detail::OutputMeter_Impl>()->setMeterFileOnly(meterFileOnly);
520 }
521
522 ✗ void OutputMeter::resetMeterFileOnly() {
523 ✗ getImpl<detail::OutputMeter_Impl>()->resetMeterFileOnly();
524 ✗ }
525
526 561 bool OutputMeter::setCumulative(bool cumulative) {
527
1/1
✓ Branch 3 taken 561 times.
561 return getImpl<detail::OutputMeter_Impl>()->setCumulative(cumulative);
528 }
529
530 ✗ void OutputMeter::resetCumulative() {
531 ✗ getImpl<detail::OutputMeter_Impl>()->resetCumulative();
532 ✗ }
533
534 15 bool OutputMeter::setSpecificEndUse(const std::string& endUse) {
535
1/1
✓ Branch 3 taken 15 times.
15 return getImpl<detail::OutputMeter_Impl>()->setSpecificEndUse(endUse);
536 }
537
538 ✗ bool OutputMeter::resetSpecificEndUse() {
539 ✗ return getImpl<detail::OutputMeter_Impl>()->resetSpecificEndUse();
540 }
541
542 2004 bool OutputMeter::setEndUseType(EndUseType type) {
543
1/1
✓ Branch 3 taken 2004 times.
2004 return getImpl<detail::OutputMeter_Impl>()->setEndUseType(type);
544 }
545
546 ✗ bool OutputMeter::resetEndUseType() {
547 ✗ return getImpl<detail::OutputMeter_Impl>()->resetEndUseType();
548 }
549
550 2567 bool OutputMeter::setFuelType(FuelType type) {
551
1/1
✓ Branch 3 taken 2565 times.
2567 return getImpl<detail::OutputMeter_Impl>()->setFuelType(type);
552 }
553
554 ✗ bool OutputMeter::resetFuelType() {
555 ✗ return getImpl<detail::OutputMeter_Impl>()->resetFuelType();
556 }
557
558 2556 bool OutputMeter::setInstallLocationType(InstallLocationType type) {
559
1/1
✓ Branch 3 taken 2556 times.
2556 return getImpl<detail::OutputMeter_Impl>()->setInstallLocationType(type);
560 }
561
562 ✗ bool OutputMeter::resetInstallLocationType() {
563 ✗ return getImpl<detail::OutputMeter_Impl>()->resetInstallLocationType();
564 }
565
566 ✗ bool OutputMeter::setSpecificInstallLocation(const std::string& locationName) {
567 ✗ return getImpl<detail::OutputMeter_Impl>()->setSpecificInstallLocation(locationName);
568 }
569
570 ✗ bool OutputMeter::resetSpecificInstallLocation() {
571 ✗ return getImpl<detail::OutputMeter_Impl>()->resetSpecificInstallLocation();
572 }
573
574 1 openstudio::OptionalTimeSeries OutputMeter::getData(const std::string& envPeriod) const {
575
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::OutputMeter_Impl>()->getData(envPeriod);
576 }
577
578 ✗ openstudio::OptionalTimeSeries OutputMeter::getData(const std::string& envPeriod, const OptionalString& specificInstallLocation) const {
579 ✗ return getImpl<detail::OutputMeter_Impl>()->getData(envPeriod, specificInstallLocation);
580 }
581
582 2 std::vector<IdfObject> OutputMeter::remove() {
583
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::OutputMeter_Impl>()->remove();
584 }
585
586 ✗ bool MeterFuelTypeEquals(const OutputMeter& meter, const FuelType& ft) {
587 ✗ OptionalFuelType oft = meter.fuelType();
588 ✗ if (oft && (oft.get() == ft)) {
589 ✗ return true;
590 }
591 ✗ return false;
592 ✗ }
593
594 /// @cond
595
1/1
✓ Branch 3 taken 3025 times.
3025 OutputMeter::OutputMeter(std::shared_ptr<detail::OutputMeter_Impl> impl) : ModelObject(std::move(impl)) {}
596 /// @endcond
597
598 } // namespace model
599 } // namespace openstudio
600