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

Method getElecOrGasUse

src/utilities/sql/SqlFile_Impl.cpp:1189–1244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1187 }
1188
1189 OptionalDouble SqlFile_Impl::getElecOrGasUse(bool bGetGas) const {
1190 boost::optional<std::vector<std::string>> selectedRowNames;
1191
1192 boost::optional<std::vector<std::string>> qualifiedRowNames;
1193 boost::optional<std::vector<std::string>> fuelTypeRowNames;
1194 OptionalDouble result;
1195
1196 std::string fuelType;
1197 if (bGetGas) {
1198 fuelType = "'COMM GAS'";
1199 } else {
1200 fuelType = "'COMM ELECT'";
1201 }
1202
1203 std::string query("select rowname from TabularDataWithStrings where TableName = 'Tariff Summary' and ColumnName = 'Group' and Value = ");
1204 query += fuelType;
1205
1206 selectedRowNames = execAndReturnVectorOfString(
1207 "select rowname from TabularDataWithStrings where TableName = 'Tariff Summary' and (ColumnName = 'Selected' and Value = 'Yes')");
1208 qualifiedRowNames = execAndReturnVectorOfString(
1209 "select rowname from TabularDataWithStrings where TableName = 'Tariff Summary' and (ColumnName = 'Qualified' and Value = 'Yes')");
1210 fuelTypeRowNames = execAndReturnVectorOfString(query);
1211
1212 if (!selectedRowNames || !qualifiedRowNames || !fuelTypeRowNames) {
1213 return result;
1214 }
1215
1216 std::vector<std::string> names;
1217 for (unsigned i = 0; i < selectedRowNames->size(); i++) {
1218 for (unsigned j = 0; j < qualifiedRowNames->size(); j++) {
1219 if (selectedRowNames->at(i) == qualifiedRowNames->at(j)) {
1220 names.push_back(selectedRowNames->at(i));
1221 }
1222 }
1223 }
1224
1225 std::string name;
1226 for (unsigned i = 0; i < names.size(); i++) {
1227 for (unsigned j = 0; j < fuelTypeRowNames->size(); j++) {
1228 if (names.at(i) == fuelTypeRowNames->at(j)) {
1229 name = names.at(i);
1230 break;
1231 }
1232 }
1233 }
1234 if (name.empty()) {
1235 return result;
1236 }
1237
1238 query = "SELECT value from TabularDataWithStrings where ReportName = 'Tariff Report' and ReportForString = '";
1239 query += name;
1240 query += "' and TableName = 'Native Variables' and ColumnName = 'Sum' and RowName = 'TotalEnergy'";
1241 result = execAndReturnFirstDouble(query);
1242
1243 return result;
1244 }
1245
1246 OptionalDouble SqlFile_Impl::getElecOrGasCost(bool bGetGas) const {

Callers

nothing calls this directly

Calls 5

execAndReturnFirstDoubleFunction · 0.70
sizeMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected