| 754 | } |
| 755 | |
| 756 | std::vector<SummaryData> SqlFile_Impl::getSummaryData() const { |
| 757 | std::vector<SummaryData> retval; |
| 758 | |
| 759 | if (m_db) { |
| 760 | sqlite3_stmt* sqlStmtPtr; |
| 761 | |
| 762 | std::string stmt = "select sum(VariableValue), VariableName, ReportingFrequency, VariableUnits " |
| 763 | "from ReportMeterData, ReportMeterDataDictionary " |
| 764 | "where (ReportMeterData.ReportMeterDataDictionaryIndex = ReportMeterDataDictionary.ReportMeterDataDictionaryIndex) " |
| 765 | " and VariableType='Sum' " |
| 766 | " group by VariableName, ReportingFrequency, VariableUnits"; |
| 767 | |
| 768 | sqlite3_prepare_v2(m_db, stmt.c_str(), -1, &sqlStmtPtr, nullptr); |
| 769 | while (sqlite3_step(sqlStmtPtr) == SQLITE_ROW) { |
| 770 | double value = sqlite3_column_double(sqlStmtPtr, 0); |
| 771 | std::string variablename = columnText(sqlite3_column_text(sqlStmtPtr, 1)); |
| 772 | std::string reportingfrequency = columnText(sqlite3_column_text(sqlStmtPtr, 2)); |
| 773 | std::string units = columnText(sqlite3_column_text(sqlStmtPtr, 3)); |
| 774 | |
| 775 | size_t colon = variablename.find(':'); |
| 776 | |
| 777 | if (colon == std::string::npos) { |
| 778 | LOG(Error, "Unable to parse variable name, no ':' found " + variablename); |
| 779 | } else { |
| 780 | std::string fueltype = variablename.substr(0, colon); |
| 781 | std::string installlocation = variablename.substr(colon + 1); |
| 782 | |
| 783 | try { |
| 784 | retval.push_back(SummaryData(value, openstudio::parseUnitString(units), openstudio::ReportingFrequency(reportingfrequency), |
| 785 | openstudio::FuelType(fueltype), openstudio::InstallLocationType(installlocation)) |
| 786 | |
| 787 | ); |
| 788 | } catch (const std::exception& e) { |
| 789 | LOG(Error, "Error adding / parsing summary data: " << e.what()); |
| 790 | } |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | sqlite3_finalize(sqlStmtPtr); |
| 795 | } |
| 796 | |
| 797 | return retval; |
| 798 | } |
| 799 | |
| 800 | void SqlFile_Impl::retrieveDataDictionary() { |
| 801 | std::string table; |
nothing calls this directly
no test coverage detected