MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / getData

Method getData

src/model/ModelObject.cpp:138–172  ·  view source on GitHub ↗

Get data associated with this output variable and this object. */

Source from the content-addressed store, hash-verified

136
137 /** Get data associated with this output variable and this object. */
138 openstudio::OptionalTimeSeries ModelObject_Impl::getData(const OutputVariable& variable, const std::string& envPeriod) const {
139 openstudio::OptionalTimeSeries result;
140 OptionalSqlFile sqlFile = this->model().sqlFile();
141
142 if (sqlFile) {
143 OptionalString variableName = variable.getString(OS_Output_VariableFields::VariableName);
144 OptionalString keyValue = variable.getString(OS_Output_VariableFields::KeyValue);
145 OptionalString reportingFrequency = variable.getString(OS_Output_VariableFields::ReportingFrequency, true);
146
147 // solve any issues if key value is '*'
148 keyValue = getSpecificKeyValue(keyValue);
149
150 if (variableName && keyValue) {
151 if (!reportingFrequency) {
152 // default to hourly frequency
153 LOG(Warn, "Variable does not specify reporting frequency, defaulting to hourly.");
154 reportingFrequency = ReportingFrequency(ReportingFrequency::Hourly).valueName();
155 }
156 // use query interface because replaces requested strings with exact strings in database
157 ReportingFrequency rf(ReportingFrequency::Hourly);
158 try {
159 ReportingFrequency rf(boost::trim_copy(*reportingFrequency));
160 } catch (...) {
161 LOG(Warn, "Unrecognized reporting frequency string. Defaulting to hourly.");
162 }
163 SqlFileTimeSeriesQuery q(envPeriod, rf, *variableName, *keyValue);
164 TimeSeriesVector tsVec = sqlFile->timeSeries(q);
165 if (tsVec.size() == 1) {
166 result = tsVec[0];
167 }
168 }
169 }
170
171 return result;
172 }
173
174 // set name from optional string
175 bool ModelObject_Impl::mf_setName(const boost::optional<std::string>& name) {

Callers 3

modelPeakDemandMethod · 0.45
TEST_FFunction · 0.45

Calls 7

modelMethod · 0.95
sqlFileMethod · 0.80
valueNameMethod · 0.80
ReportingFrequencyClass · 0.70
getStringMethod · 0.45
timeSeriesMethod · 0.45
sizeMethod · 0.45

Tested by 1

TEST_FFunction · 0.36