LCOV - code coverage report
Current view: top level - EnergyPlus - SQLiteProcedures.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 100.0 % 129 129
Test Date: 2025-05-22 16:09:37 Functions: 100.0 % 22 22

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : #ifndef SQLiteProcedures_hh_INCLUDED
      49              : #define SQLiteProcedures_hh_INCLUDED
      50              : 
      51              : // C++ Headers
      52              : #include <fstream>
      53              : #include <iosfwd>
      54              : #include <map>
      55              : #include <memory>
      56              : #include <sqlite3.h>
      57              : 
      58              : // ObjexxFCL Headers
      59              : #include <ObjexxFCL/Array1D.hh>
      60              : #include <ObjexxFCL/Array2D.hh>
      61              : 
      62              : // EnergyPlus Headers
      63              : #include <EnergyPlus/Construction.hh>
      64              : #include <EnergyPlus/Data/BaseData.hh>
      65              : #include <EnergyPlus/DataHeatBalance.hh>
      66              : #include <EnergyPlus/DataRoomAirModel.hh>
      67              : #include <EnergyPlus/EnergyPlus.hh>
      68              : #include <EnergyPlus/FileSystem.hh>
      69              : #include <EnergyPlus/Material.hh>
      70              : #include <EnergyPlus/OutputProcessor.hh>
      71              : 
      72              : namespace EnergyPlus {
      73              : 
      74              : // Forward
      75              : struct EnergyPlusData;
      76              : 
      77              : class SQLiteProcedures
      78              : {
      79              : protected:
      80              :     SQLiteProcedures(std::shared_ptr<std::ostream> const &errorStream, std::shared_ptr<sqlite3> const &db);
      81              :     SQLiteProcedures(std::shared_ptr<std::ostream> const &errorStream,
      82              :                      bool writeOutputToSQLite,
      83              :                      fs::path const &dbName,
      84              :                      fs::path const &errorFilePath);
      85              : 
      86              :     int sqliteExecuteCommand(std::string_view commandBuffer);
      87              :     int sqlitePrepareStatement(sqlite3_stmt *&stmt, std::string_view stmtBuffer);
      88              : 
      89              :     int sqliteBindText(sqlite3_stmt *stmt, const int stmtInsertLocationIndex, std::string_view textBuffer);
      90              :     int sqliteBindInteger(sqlite3_stmt *stmt, const int stmtInsertLocationIndex, const int intToInsert);
      91              :     int sqliteBindDouble(sqlite3_stmt *stmt, const int stmtInsertLocationIndex, const double doubleToInsert);
      92              :     int sqliteBindNULL(sqlite3_stmt *stmt, const int stmtInsertLocationIndex);
      93              :     int sqliteBindLogical(sqlite3_stmt *stmt, const int stmtInsertLocationIndex, const bool valueToInsert);
      94              : 
      95              :     // This assumes a Foreign Key must be greater than 0 to be a valid Foreign Key, otherwise it sets the field to NULL.
      96              :     int sqliteBindForeignKey(sqlite3_stmt *stmt, const int stmtInsertLocationIndex, const int intToInsert);
      97              : 
      98              :     bool sqliteStepValidity(int const rc);
      99              :     int sqliteStepCommand(sqlite3_stmt *stmt);
     100              :     int sqliteResetCommand(sqlite3_stmt *stmt);
     101              :     bool sqliteWithinTransaction();
     102              :     // int sqliteClearBindings(sqlite3_stmt * stmt);
     103              :     // int sqliteFinalizeCommand(sqlite3_stmt * stmt);
     104              : 
     105              :     bool m_writeOutputToSQLite;
     106              :     std::shared_ptr<std::ostream> m_errorStream;
     107              :     std::shared_ptr<sqlite3> m_db;
     108              : };
     109              : 
     110              : class SQLite : SQLiteProcedures
     111              : {
     112              : public:
     113              :     // Friend SQLiteFixture which is the gtest fixture class for testing SQLite
     114              :     // This allows for testing of private methods in SQLite
     115              :     friend class SQLiteFixture;
     116              : 
     117              :     void addScheduleData(int const number, std::string_view name, std::string_view type, double const minValue, double const maxValue);
     118              :     void addZoneData(int const number, DataHeatBalance::ZoneData const &zoneData);
     119              :     void addZoneListData(int const number, DataHeatBalance::ZoneListData const &zoneListData);
     120              :     void addSurfaceData(int const number, DataSurfaces::SurfaceData const &surfaceData, std::string_view surfaceClass);
     121              :     void addZoneGroupData(int const number, DataHeatBalance::ZoneGroupData const &zoneGroupData);
     122              :     void addMaterialData(int const number, Material::MaterialBase const *materialData);
     123              :     void addConstructionData(int const number, Construction::ConstructionProps const &constructionData, double const &constructionUValue);
     124              :     void addNominalLightingData(int const number, DataHeatBalance::LightsData const &nominalLightingData);
     125              :     void addNominalPeopleData(int const number, DataHeatBalance::PeopleData const &nominalPeopleData);
     126              :     void addNominalElectricEquipmentData(int const number, DataHeatBalance::ZoneEquipData const &nominalElectricEquipmentData);
     127              :     void addNominalGasEquipmentData(int const number, DataHeatBalance::ZoneEquipData const &nominalGasEquipmentData);
     128              :     void addNominalSteamEquipmentData(int const number, DataHeatBalance::ZoneEquipData const &nominalSteamEquipmentData);
     129              :     void addNominalHotWaterEquipmentData(int const number, DataHeatBalance::ZoneEquipData const &nominalHotWaterEquipmentData);
     130              :     void addNominalOtherEquipmentData(int const number, DataHeatBalance::ZoneEquipData const &nominalOtherEquipmentData);
     131              :     void addNominalBaseboardData(int const number, DataHeatBalance::BBHeatData const &nominalBaseboardData);
     132              :     void addInfiltrationData(int const number, DataHeatBalance::InfiltrationData const &infiltrationData);
     133              :     void addVentilationData(int const number, DataHeatBalance::VentilationData const &ventilationData);
     134              :     void addRoomAirModelData(int const number, RoomAir::AirModelData const &roomAirModelData);
     135              : 
     136              :     // Open the DB and prepare for writing data
     137              :     // Create all of the tables on construction
     138              :     SQLite(std::shared_ptr<std::ostream> errorStream,
     139              :            fs::path const &dbName,
     140              :            fs::path const &errorFilePath,
     141              :            bool writeOutputToSQLite = false,
     142              :            bool writeTabularDataToSQLite = false);
     143              : 
     144              :     // Close database and free prepared statements
     145              :     virtual ~SQLite();
     146              : 
     147              :     bool writeOutputToSQLite() const;
     148              :     bool writeTabularDataToSQLite() const;
     149              : 
     150              :     // Begin a transaction
     151              :     void sqliteBegin();
     152              : 
     153              :     // Commit a transaction
     154              :     void sqliteCommit();
     155              : 
     156              :     // Rollback a transaction (cancel)
     157              :     void sqliteRollback();
     158              : 
     159              :     // Rollback to a named savepoint (nested transaction)
     160              :     void sqliteRollbackToSavepoint(std::string_view savepoint_name);
     161              : 
     162              :     // Release a named savepoint (nested transaction)
     163              :     void sqliteReleaseSavepoint(std::string_view savepoint_name);
     164              : 
     165              :     // create a named savepoint (nested transaction)
     166              :     void sqliteCreateSavepoint(std::string_view savepoint_name);
     167              : 
     168              :     // Within a current transaction
     169              :     bool sqliteWithinTransaction();
     170              : 
     171              :     void createSQLiteReportDictionaryRecord(int const reportVariableReportID,
     172              :                                             OutputProcessor::StoreType const storeType,
     173              :                                             std::string_view indexGroup,
     174              :                                             std::string_view keyedValueString,
     175              :                                             std::string_view const variableName,
     176              :                                             OutputProcessor::TimeStepType const timeStepType,
     177              :                                             std::string_view units,
     178              :                                             OutputProcessor::ReportFreq const reportFreq,
     179              :                                             bool isMeter,
     180              :                                             std::string_view const ScheduleName = {});
     181              : 
     182              :     void createSQLiteReportDataRecord(int const recordIndex,
     183              :                                       Real64 const value,
     184              :                                       OutputProcessor::ReportFreq const reportFreq = OutputProcessor::ReportFreq::Invalid,
     185              :                                       Real64 const minValue = 0.0,
     186              :                                       int const minValueDate = -1,
     187              :                                       Real64 const maxValue = 0.0,
     188              :                                       int const maxValueDate = -1,
     189              :                                       int const minutesPerTimeStep = -1);
     190              : 
     191              :     void createSQLiteTimeIndexRecord(OutputProcessor::ReportFreq const reportFreq,
     192              :                                      int const recordIndex,
     193              :                                      int const CumlativeSimulationDays,
     194              :                                      int const curEnvirNum,
     195              :                                      int const simulationYear,
     196              :                                      bool const curYearIsLeapYear,
     197              :                                      int const Month = -1,
     198              :                                      int const DayOfMonth = -1,
     199              :                                      int const Hour = -1,
     200              :                                      Real64 const EndMinute = -1.0,
     201              :                                      Real64 const StartMinute = -1.0,
     202              :                                      int const DST = -1,
     203              :                                      std::string_view const DayType = "",
     204              :                                      bool const warmupFlag = false);
     205              : 
     206              :     void createYearlyTimeIndexRecord(int const simulationYear, int const curEnvirNum);
     207              : 
     208              :     void addSQLiteZoneSizingRecord(std::string_view ZoneName,   // the name of the zone
     209              :                                    std::string_view LoadType,   // the description of the input variable
     210              :                                    Real64 const CalcDesLoad,    // the value from the sizing calculation [W]
     211              :                                    Real64 const UserDesLoad,    // the value from the sizing calculation modified by user input [W]
     212              :                                    Real64 const CalcDesFlow,    // calculated design air flow rate [m3/s]
     213              :                                    Real64 const UserDesFlow,    // user input or modified design air flow rate [m3/s]
     214              :                                    std::string_view DesDayName, // the name of the design day that produced the peak
     215              :                                    std::string_view PeakHrMin,  // time stamp of the peak
     216              :                                    Real64 const PeakTemp,       // temperature at peak [C]
     217              :                                    Real64 const PeakHumRat,     // humidity ratio at peak [kg water/kg dry air]
     218              :                                    Real64 const MinOAVolFlow,   // zone design minimum outside air flow rate [m3/s]
     219              :                                    Real64 const DOASHeatAddRate // zone design heat addition rate from the DOAS [W]
     220              :     );
     221              : 
     222              :     void addSQLiteSystemSizingRecord(std::string_view SysName,      // the name of the system
     223              :                                      std::string_view LoadType,     // either "Cooling" or "Heating"
     224              :                                      std::string_view PeakLoadType, // either "Sensible" or "Total"
     225              :                                      Real64 const UserDesCap,       // User  Design Capacity
     226              :                                      Real64 const CalcDesVolFlow,   // Calculated Cooling Design Air Flow Rate
     227              :                                      Real64 const UserDesVolFlow,   // User Cooling Design Air Flow Rate
     228              :                                      std::string_view DesDayName,   // the name of the design day that produced the peak
     229              :                                      std::string_view PeakHrMin     // time stamp of the peak
     230              :     );
     231              : 
     232              :     void addSQLiteComponentSizingRecord(std::string_view CompType, // the type of the component
     233              :                                         std::string_view CompName, // the name of the component
     234              :                                         std::string_view VarDesc,  // the description of the input variable
     235              :                                         Real64 const VarValue      // the value from the sizing calculation
     236              :     );
     237              : 
     238              :     void createSQLiteDaylightMapTitle(
     239              :         int const mapNum, std::string_view mapName, std::string_view environmentName, int const zone, std::string_view refPts, Real64 const zCoord);
     240              : 
     241              :     void createSQLiteDaylightMap(int const mapNum,
     242              :                                  int const year,
     243              :                                  int const month,
     244              :                                  int const dayOfMonth,
     245              :                                  int const hourOfDay,
     246              :                                  int const nX,
     247              :                                  Array1D<Real64> const &x,
     248              :                                  int const nY,
     249              :                                  Array1D<Real64> const &y,
     250              :                                  Array2<Real64> const &illuminance);
     251              : 
     252              :     void createSQLiteTabularDataRecords(Array2D_string const &body, // row,column
     253              :                                         Array1D_string const &rowLabels,
     254              :                                         Array1D_string const &columnLabels,
     255              :                                         std::string_view ReportName,
     256              :                                         std::string_view ReportForString,
     257              :                                         std::string_view TableName);
     258              : 
     259              :     void createSQLiteSimulationsRecord(int const ID, std::string_view verString, std::string_view currentDateTime);
     260              : 
     261              :     void createSQLiteErrorRecord(int const simulationIndex, int const errorType, std::string_view errorMessage, int const cnt);
     262              : 
     263              :     void updateSQLiteErrorRecord(std::string const &errorMessage);
     264              : 
     265              :     void updateSQLiteSimulationRecord(bool const completed, bool const completedSuccessfully, int const id = 1);
     266              : 
     267              :     void updateSQLiteSimulationRecord(int const id, int const numOfTimeStepInHour);
     268              : 
     269              :     void createSQLiteEnvironmentPeriodRecord(const int curEnvirNum,
     270              :                                              std::string_view environmentName,
     271              :                                              const Constant::KindOfSim kindOfSim,
     272              :                                              const int simulationIndex = 1);
     273              : 
     274              :     void sqliteWriteMessage(std::string_view message);
     275              : 
     276              :     void createZoneExtendedOutput();
     277              : 
     278              :     void initializeIndexes();
     279              : 
     280              : private:
     281              :     int createSQLiteStringTableRecord(std::string_view stringValue, int const stringType);
     282              : 
     283              :     static void adjustReportingHourAndMinutes(int &hour, int &minutes);
     284              :     // Given combinedString, parse out units and description.
     285              :     // Example: Given combinedString "Total Energy [GJ]", return "Total Energy"
     286              :     // in description and "GJ" in units.
     287              :     static void parseUnitsAndDescription(std::string_view combinedString, std::string &units, std::string &description);
     288              : 
     289              :     static int logicalToInteger(const bool value);
     290              : 
     291              :     void initializeReportDataDictionaryTable();
     292              :     void initializeReportDataTables();
     293              :     void initializeTimeIndicesTable();
     294              :     void initializeZoneInfoTable();
     295              :     void initializeZoneInfoZoneListTable();
     296              :     void initializeNominalPeopleTable();
     297              :     void initializeNominalLightingTable();
     298              :     void initializeNominalElectricEquipmentTable();
     299              :     void initializeNominalGasEquipmentTable();
     300              :     void initializeNominalSteamEquipmentTable();
     301              :     void initializeNominalHotWaterEquipmentTable();
     302              :     void initializeNominalOtherEquipmentTable();
     303              :     void initializeNominalBaseboardHeatTable();
     304              :     void initializeSurfacesTable();
     305              :     void initializeConstructionsTables();
     306              :     void initializeMaterialsTable();
     307              :     void initializeZoneListTable();
     308              :     void initializeZoneGroupTable();
     309              :     void initializeNominalInfiltrationTable();
     310              :     void initializeNominalVentilationTable();
     311              :     void initializeZoneSizingTable();
     312              :     void initializeSystemSizingTable();
     313              :     void initializeComponentSizingTable();
     314              :     void initializeRoomAirModelTable();
     315              :     void initializeSchedulesTable();
     316              :     void initializeDaylightMapTables();
     317              :     void initializeViews();
     318              :     void initializeSimulationsTable();
     319              :     void initializeEnvironmentPeriodsTable();
     320              :     void initializeErrorsTable();
     321              :     void initializeTabularDataTable();
     322              :     void initializeTabularDataView();
     323              : 
     324              :     bool m_writeTabularDataToSQLite;
     325              :     int m_sqlDBTimeIndex;
     326              : 
     327              :     int m_hourlyReportIndex = 0;
     328              :     int m_hourlyDataIndex = 0;
     329              :     int m_tabularDataIndex = 0;
     330              :     int m_stringIndex = 1;
     331              :     std::map<std::pair<std::string, int>, int> m_tabularStrings;
     332              :     int m_errorIndex = 0;
     333              :     int m_dataIndex = 0;
     334              :     int m_extendedDataIndex = 0;
     335              :     int m_zoneSizingIndex = 0;
     336              :     int m_systemSizingIndex = 0;
     337              :     int m_componentSizingIndex = 0;
     338              : 
     339              :     sqlite3_stmt *m_reportDataInsertStmt;
     340              :     sqlite3_stmt *m_reportExtendedDataInsertStmt;
     341              :     sqlite3_stmt *m_reportDictionaryInsertStmt;
     342              :     sqlite3_stmt *m_timeIndexInsertStmt;
     343              :     sqlite3_stmt *m_zoneInfoInsertStmt;
     344              :     sqlite3_stmt *m_zoneInfoZoneListInsertStmt;
     345              :     sqlite3_stmt *m_nominalLightingInsertStmt;
     346              :     sqlite3_stmt *m_nominalElectricEquipmentInsertStmt;
     347              :     sqlite3_stmt *m_nominalGasEquipmentInsertStmt;
     348              :     sqlite3_stmt *m_nominalSteamEquipmentInsertStmt;
     349              :     sqlite3_stmt *m_nominalHotWaterEquipmentInsertStmt;
     350              :     sqlite3_stmt *m_nominalOtherEquipmentInsertStmt;
     351              :     sqlite3_stmt *m_nominalBaseboardHeatInsertStmt;
     352              :     sqlite3_stmt *m_surfaceInsertStmt;
     353              :     sqlite3_stmt *m_constructionInsertStmt;
     354              :     sqlite3_stmt *m_constructionLayerInsertStmt;
     355              :     sqlite3_stmt *m_materialInsertStmt;
     356              :     sqlite3_stmt *m_zoneListInsertStmt;
     357              :     sqlite3_stmt *m_zoneGroupInsertStmt;
     358              :     sqlite3_stmt *m_infiltrationInsertStmt;
     359              :     sqlite3_stmt *m_ventilationInsertStmt;
     360              :     sqlite3_stmt *m_nominalPeopleInsertStmt;
     361              :     sqlite3_stmt *m_zoneSizingInsertStmt;
     362              :     sqlite3_stmt *m_systemSizingInsertStmt;
     363              :     sqlite3_stmt *m_componentSizingInsertStmt;
     364              :     sqlite3_stmt *m_roomAirModelInsertStmt;
     365              :     sqlite3_stmt *m_groundTemperatureInsertStmt;
     366              :     sqlite3_stmt *m_weatherFileInsertStmt;
     367              :     sqlite3_stmt *m_scheduleInsertStmt;
     368              :     sqlite3_stmt *m_daylightMapTitleInsertStmt;
     369              :     sqlite3_stmt *m_daylightMapHourlyTitleInsertStmt;
     370              :     sqlite3_stmt *m_daylightMapHourlyDataInsertStmt;
     371              :     sqlite3_stmt *m_environmentPeriodInsertStmt;
     372              :     sqlite3_stmt *m_simulationsInsertStmt;
     373              :     sqlite3_stmt *m_tabularDataInsertStmt;
     374              :     sqlite3_stmt *m_stringsInsertStmt;
     375              :     sqlite3_stmt *m_stringsLookUpStmt;
     376              :     sqlite3_stmt *m_errorInsertStmt;
     377              :     sqlite3_stmt *m_errorUpdateStmt;
     378              :     sqlite3_stmt *m_simulationUpdateStmt;
     379              :     sqlite3_stmt *m_simulationDataUpdateStmt;
     380              :     sqlite3_stmt *m_rollbackToSavepointStmt;
     381              :     sqlite3_stmt *m_createSavepointStmt;
     382              :     sqlite3_stmt *m_releaseSavepointStmt;
     383              : 
     384              :     static const int LocalReportEach;     //  Write out each time UpdatedataandLocalReport is called
     385              :     static const int LocalReportTimeStep; //  Write out at 'EndTimeStepFlag'
     386              :     static const int LocalReportHourly;   //  Write out at 'EndHourFlag'
     387              :     static const int LocalReportDaily;    //  Write out at 'EndDayFlag'
     388              :     static const int LocalReportMonthly;  //  Write out at end of month (must be determined)
     389              :     static const int LocalReportSim;      //  Write out once per environment 'EndEnvrnFlag'
     390              :     static const int LocalReportYearly;   //  Write out once per year
     391              :     static const int ReportNameId;
     392              :     static const int ReportForStringId;
     393              :     static const int TableNameId;
     394              :     static const int RowNameId;
     395              :     static const int ColumnNameId;
     396              :     static const int UnitsId;
     397              : 
     398              :     class SQLiteData : public SQLiteProcedures
     399              :     {
     400              :     protected:
     401              :         SQLiteData(std::shared_ptr<std::ostream> const &errorStream, std::shared_ptr<sqlite3> const &db);
     402              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) = 0;
     403              :     };
     404              : 
     405              :     class Schedule : SQLiteData
     406              :     {
     407              :     public:
     408           46 :         Schedule(std::shared_ptr<std::ostream> const &errorStream,
     409              :                  std::shared_ptr<sqlite3> const &db,
     410              :                  int const scheduleNumber,
     411              :                  std::string_view scheduleName,
     412              :                  std::string_view scheduleType,
     413              :                  double const scheduleMinValue,
     414              :                  double const scheduleMaxValue)
     415          138 :             : SQLiteData(errorStream, db), number(scheduleNumber), name(scheduleName), type(scheduleType), minValue(scheduleMinValue),
     416           46 :               maxValue(scheduleMaxValue)
     417              :         {
     418           46 :         }
     419              : 
     420              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     421              : 
     422              :     private:
     423              :         int const number;
     424              :         std::string const name;
     425              :         std::string const type;
     426              :         double const minValue;
     427              :         double const maxValue;
     428              :     };
     429              : 
     430              :     class Surface : SQLiteData
     431              :     {
     432              :     public:
     433           49 :         Surface(std::shared_ptr<std::ostream> const &errorStream,
     434              :                 std::shared_ptr<sqlite3> const &db,
     435              :                 int const surfaceNumber,
     436              :                 DataSurfaces::SurfaceData const &surfaceData,
     437              :                 std::string_view surfaceClass)
     438           98 :             : SQLiteData(errorStream, db), number(surfaceNumber), name(surfaceData.Name), construction(surfaceData.Construction),
     439           49 :               surfaceClass(surfaceClass), area(surfaceData.Area), grossArea(surfaceData.GrossArea), perimeter(surfaceData.Perimeter),
     440           49 :               azimuth(surfaceData.Azimuth), height(surfaceData.Height), reveal(surfaceData.Reveal), shape(surfaceData.Shape),
     441           49 :               sides(surfaceData.Sides), tilt(surfaceData.Tilt), width(surfaceData.Width), heatTransSurf(surfaceData.HeatTransSurf),
     442           49 :               baseSurf(surfaceData.BaseSurf), zone(surfaceData.Zone), extBoundCond(surfaceData.ExtBoundCond), extSolar(surfaceData.ExtSolar),
     443           49 :               extWind(surfaceData.ExtWind)
     444              :         {
     445           49 :         }
     446              : 
     447              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     448              : 
     449              :     private:
     450              :         int const number;
     451              :         std::string const &name;
     452              :         int const &construction;
     453              :         std::string const surfaceClass;
     454              :         double const &area;
     455              :         double const &grossArea;
     456              :         double const &perimeter;
     457              :         double const &azimuth;
     458              :         double const &height;
     459              :         double const &reveal;
     460              :         DataSurfaces::SurfaceShape const &shape;
     461              :         int const &sides;
     462              :         double const &tilt;
     463              :         double const &width;
     464              :         bool const &heatTransSurf;
     465              :         int const &baseSurf;
     466              :         int const &zone;
     467              :         int const &extBoundCond;
     468              :         bool const &extSolar;
     469              :         bool const &extWind;
     470              :     };
     471              : 
     472              :     class Zone : SQLiteData
     473              :     {
     474              :     public:
     475           10 :         Zone(std::shared_ptr<std::ostream> const &errorStream,
     476              :              std::shared_ptr<sqlite3> const &db,
     477              :              int const zoneNumber,
     478              :              DataHeatBalance::ZoneData const &zoneData)
     479           20 :             : SQLiteData(errorStream, db), number(zoneNumber), name(zoneData.Name), relNorth(zoneData.RelNorth), originX(zoneData.OriginX),
     480           10 :               originY(zoneData.OriginY), originZ(zoneData.OriginZ), centroidX(zoneData.Centroid.x), centroidY(zoneData.Centroid.y),
     481           10 :               centroidZ(zoneData.Centroid.z), ofType(zoneData.OfType), multiplier(zoneData.Multiplier), listMultiplier(zoneData.ListMultiplier),
     482           10 :               minimumX(zoneData.MinimumX), maximumX(zoneData.MaximumX), minimumY(zoneData.MinimumY), maximumY(zoneData.MaximumY),
     483           10 :               minimumZ(zoneData.MinimumZ), maximumZ(zoneData.MaximumZ), ceilingHeight(zoneData.CeilingHeight), volume(zoneData.Volume),
     484           10 :               insideConvectionAlgo(zoneData.IntConvAlgo), outsideConvectionAlgo(zoneData.ExtConvAlgo), floorArea(zoneData.FloorArea),
     485           10 :               extGrossWallArea(zoneData.ExtGrossWallArea), extNetWallArea(zoneData.ExtNetWallArea), extWindowArea(zoneData.ExtWindowArea),
     486           10 :               isPartOfTotalArea(zoneData.isPartOfTotalArea)
     487              :         {
     488           10 :         }
     489              : 
     490              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     491              : 
     492              :     private:
     493              :         int const number;
     494              :         std::string const &name;
     495              :         double const &relNorth;
     496              :         double const &originX;
     497              :         double const &originY;
     498              :         double const &originZ;
     499              :         double const &centroidX;
     500              :         double const &centroidY;
     501              :         double const &centroidZ;
     502              :         int const &ofType;
     503              :         int const &multiplier;
     504              :         int const &listMultiplier;
     505              :         double const &minimumX;
     506              :         double const &maximumX;
     507              :         double const &minimumY;
     508              :         double const &maximumY;
     509              :         double const &minimumZ;
     510              :         double const &maximumZ;
     511              :         double const &ceilingHeight;
     512              :         double const &volume;
     513              :         Convect::HcInt const &insideConvectionAlgo;
     514              :         Convect::HcExt const &outsideConvectionAlgo;
     515              :         double const &floorArea;
     516              :         double const &extGrossWallArea;
     517              :         double const &extNetWallArea;
     518              :         double const &extWindowArea;
     519              :         bool const &isPartOfTotalArea;
     520              :     };
     521              : 
     522              :     class ZoneList : SQLiteData
     523              :     {
     524              :     public:
     525            2 :         ZoneList(std::shared_ptr<std::ostream> const &errorStream,
     526              :                  std::shared_ptr<sqlite3> const &db,
     527              :                  int const zoneListNumber,
     528              :                  DataHeatBalance::ZoneListData const &zoneListData)
     529            2 :             : SQLiteData(errorStream, db), number(zoneListNumber), name(zoneListData.Name), zones(zoneListData.Zone)
     530              :         {
     531            2 :         }
     532              : 
     533              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     534              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt, sqlite3_stmt *subInsertStmt);
     535              : 
     536              :     private:
     537              :         int const number;
     538              :         std::string const &name;
     539              :         Array1D_int const &zones;
     540              :     };
     541              : 
     542              :     class ZoneGroup : SQLiteData
     543              :     {
     544              :     public:
     545            2 :         ZoneGroup(std::shared_ptr<std::ostream> const &errorStream,
     546              :                   std::shared_ptr<sqlite3> const &db,
     547              :                   int const zoneGroupNumber,
     548              :                   DataHeatBalance::ZoneGroupData const &zoneGroupData)
     549            4 :             : SQLiteData(errorStream, db), number(zoneGroupNumber), name(zoneGroupData.Name), zoneList(zoneGroupData.ZoneList),
     550            2 :               multiplier(zoneGroupData.Multiplier)
     551              :         {
     552            2 :         }
     553              : 
     554              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     555              : 
     556              :     private:
     557              :         int const number;
     558              :         std::string const &name;
     559              :         int const &zoneList;
     560              :         int const &multiplier;
     561              :     };
     562              : 
     563              :     class Material : SQLiteData
     564              :     {
     565              :     public:
     566           33 :         Material(std::shared_ptr<std::ostream> const &errorStream,
     567              :                  std::shared_ptr<sqlite3> const &db,
     568              :                  int const materialNumber,
     569              :                  EnergyPlus::Material::MaterialBase const *materialData)
     570           66 :             : SQLiteData(errorStream, db), number(materialNumber), name(materialData->Name), group(materialData->group),
     571           33 :               roughness(materialData->Roughness), conductivity(materialData->Conductivity), density(materialData->Density),
     572              :               // isoMoistCap(materialData->IsoMoistCap),
     573           33 :               porosity(materialData->Porosity), resistance(materialData->Resistance), rOnly(materialData->ROnly), specHeat(materialData->SpecHeat),
     574              :               // thermGradCoef(materialData->ThermGradCoef),
     575           33 :               thickness(materialData->Thickness), vaporDiffus(materialData->VaporDiffus)
     576              :         {
     577           33 :         }
     578              : 
     579              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     580              : 
     581              :     private:
     582              :         int const number;
     583              :         std::string const &name;
     584              :         EnergyPlus::Material::Group const &group;
     585              :         EnergyPlus::Material::SurfaceRoughness const &roughness;
     586              :         double const &conductivity;
     587              :         double const &density;
     588              :         // double const &isoMoistCap;
     589              :         double const &porosity;
     590              :         double const &resistance;
     591              :         bool const &rOnly;
     592              :         double const &specHeat;
     593              :         // double const &thermGradCoef;
     594              :         double const &thickness;
     595              :         double const &vaporDiffus;
     596              :     };
     597              : 
     598              :     class Construction : SQLiteData
     599              :     {
     600              :     public:
     601           17 :         Construction(std::shared_ptr<std::ostream> const &errorStream,
     602              :                      std::shared_ptr<sqlite3> const &db,
     603              :                      int const constructionNumber,
     604              :                      EnergyPlus::Construction::ConstructionProps const &constructionData,
     605              :                      double const &constructionUValue)
     606           34 :             : SQLiteData(errorStream, db), number(constructionNumber), name(constructionData.Name), totLayers(constructionData.TotLayers),
     607           17 :               totSolidLayers(constructionData.TotSolidLayers), totGlassLayers(constructionData.TotGlassLayers),
     608           17 :               insideAbsorpVis(constructionData.InsideAbsorpVis), outsideAbsorpVis(constructionData.OutsideAbsorpVis),
     609           17 :               insideAbsorpSolar(constructionData.InsideAbsorpSolar), outsideAbsorpSolar(constructionData.OutsideAbsorpSolar),
     610           17 :               insideAbsorpThermal(constructionData.InsideAbsorpThermal), outsideAbsorpThermal(constructionData.OutsideAbsorpThermal),
     611           17 :               outsideRoughness(constructionData.OutsideRoughness), typeIsWindow(constructionData.TypeIsWindow), uValue(constructionUValue)
     612              :         {
     613           51 :             for (int layerNum = 1; layerNum <= constructionData.TotLayers; ++layerNum) {
     614           34 :                 constructionLayers.push_back(std::unique_ptr<Construction::ConstructionLayer>(
     615           34 :                     new ConstructionLayer(m_errorStream, m_db, number, layerNum, constructionData.LayerPoint(layerNum))));
     616              :             }
     617           17 :         }
     618              : 
     619              :         // only inserts construction
     620              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     621              :         // inserts construction and construction layers
     622              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt, sqlite3_stmt *subInsertStmt);
     623              : 
     624              :     private:
     625              :         int const number;
     626              :         std::string const &name;
     627              :         int const &totLayers;
     628              :         int const &totSolidLayers;
     629              :         int const &totGlassLayers;
     630              :         double const &insideAbsorpVis;
     631              :         double const &outsideAbsorpVis;
     632              :         double const &insideAbsorpSolar;
     633              :         double const &outsideAbsorpSolar;
     634              :         double const &insideAbsorpThermal;
     635              :         double const &outsideAbsorpThermal;
     636              :         EnergyPlus::Material::SurfaceRoughness const &outsideRoughness;
     637              :         bool const &typeIsWindow;
     638              :         double const &uValue;
     639              : 
     640              :         class ConstructionLayer : SQLiteData
     641              :         {
     642              :         public:
     643           34 :             ConstructionLayer(std::shared_ptr<std::ostream> const &errorStream,
     644              :                               std::shared_ptr<sqlite3> const &db,
     645              :                               int const &constructNumber,
     646              :                               int const layerNumber,
     647              :                               int const &layerPoint)
     648           34 :                 : SQLiteData(errorStream, db), constructNumber(constructNumber), layerNumber(layerNumber), layerPoint(layerPoint)
     649              :             {
     650           34 :             }
     651              : 
     652              :             virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     653              : 
     654              :         private:
     655              :             int const &constructNumber;
     656              :             int const layerNumber;
     657              :             int const &layerPoint;
     658              :         };
     659              : 
     660              :         std::vector<std::unique_ptr<Construction::ConstructionLayer>> constructionLayers;
     661              :     };
     662              : 
     663              :     class NominalLighting : SQLiteData
     664              :     {
     665              :     public:
     666            6 :         NominalLighting(std::shared_ptr<std::ostream> const &errorStream,
     667              :                         std::shared_ptr<sqlite3> const &db,
     668              :                         int const nominalLightingNumber,
     669              :                         DataHeatBalance::LightsData const &nominalLightingData)
     670           12 :             : SQLiteData(errorStream, db), number(nominalLightingNumber), name(nominalLightingData.Name), zonePtr(nominalLightingData.ZonePtr),
     671            6 :               sched(nominalLightingData.sched), designLevel(nominalLightingData.DesignLevel),
     672            6 :               fractionReturnAir(nominalLightingData.FractionReturnAir), fractionRadiant(nominalLightingData.FractionRadiant),
     673            6 :               fractionShortWave(nominalLightingData.FractionShortWave), fractionReplaceable(nominalLightingData.FractionReplaceable),
     674            6 :               fractionConvected(nominalLightingData.FractionConvected), endUseSubcategory(nominalLightingData.EndUseSubcategory)
     675              :         {
     676            6 :         }
     677              : 
     678              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     679              : 
     680              :     private:
     681              :         int const number;
     682              :         std::string const &name;
     683              :         int const &zonePtr;
     684              :         Sched::Schedule const *sched;
     685              :         double const &designLevel;
     686              :         double const &fractionReturnAir;
     687              :         double const &fractionRadiant;
     688              :         double const &fractionShortWave;
     689              :         double const &fractionReplaceable;
     690              :         double const &fractionConvected;
     691              :         std::string const &endUseSubcategory;
     692              :     };
     693              : 
     694              :     class NominalPeople : SQLiteData
     695              :     {
     696              :     public:
     697            5 :         NominalPeople(std::shared_ptr<std::ostream> const &errorStream,
     698              :                       std::shared_ptr<sqlite3> const &db,
     699              :                       int const nominalPeopleNumber,
     700              :                       DataHeatBalance::PeopleData const &nominalPeopleData)
     701           10 :             : SQLiteData(errorStream, db), number(nominalPeopleNumber), name(nominalPeopleData.Name), zonePtr(nominalPeopleData.ZonePtr),
     702            5 :               numberOfPeople(nominalPeopleData.NumberOfPeople), numberOfPeopleSched(nominalPeopleData.sched),
     703            5 :               activityLevelSched(nominalPeopleData.activityLevelSched), fractionRadiant(nominalPeopleData.FractionRadiant),
     704            5 :               fractionConvected(nominalPeopleData.FractionConvected), workEffSched(nominalPeopleData.workEffSched),
     705            5 :               clothingSched(nominalPeopleData.clothingSched), airVelocitySched(nominalPeopleData.airVelocitySched), fanger(nominalPeopleData.Fanger),
     706            5 :               pierce(nominalPeopleData.Pierce), ksu(nominalPeopleData.KSU), mrtCalcType(nominalPeopleData.MRTCalcType),
     707            5 :               surfacePtr(nominalPeopleData.SurfacePtr), angleFactorListName(nominalPeopleData.AngleFactorListName),
     708            5 :               angleFactorListPtr(nominalPeopleData.AngleFactorListPtr), userSpecSensFrac(nominalPeopleData.UserSpecSensFrac),
     709            5 :               show55Warning(nominalPeopleData.Show55Warning)
     710              :         {
     711            5 :         }
     712              : 
     713              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     714              : 
     715              :     private:
     716              :         int const number;
     717              :         std::string const &name;
     718              :         int const &zonePtr;
     719              :         double const &numberOfPeople;
     720              :         Sched::Schedule const *numberOfPeopleSched;
     721              :         Sched::Schedule const *activityLevelSched;
     722              :         double const &fractionRadiant;
     723              :         double const &fractionConvected;
     724              :         Sched::Schedule const *workEffSched;
     725              :         Sched::Schedule const *clothingSched;
     726              :         Sched::Schedule const *airVelocitySched;
     727              :         bool const &fanger;
     728              :         bool const &pierce;
     729              :         bool const &ksu;
     730              :         DataHeatBalance::CalcMRT const &mrtCalcType;
     731              :         int const &surfacePtr;
     732              :         std::string const &angleFactorListName;
     733              :         int const &angleFactorListPtr;
     734              :         double const &userSpecSensFrac;
     735              :         bool const &show55Warning;
     736              :     };
     737              : 
     738              :     class NominalElectricEquipment : SQLiteData
     739              :     {
     740              :     public:
     741            7 :         NominalElectricEquipment(std::shared_ptr<std::ostream> const &errorStream,
     742              :                                  std::shared_ptr<sqlite3> const &db,
     743              :                                  int const nominalElectricEquipmentNumber,
     744              :                                  DataHeatBalance::ZoneEquipData const &nominalElectricEquipmentData)
     745           14 :             : SQLiteData(errorStream, db), number(nominalElectricEquipmentNumber), name(nominalElectricEquipmentData.Name),
     746            7 :               zonePtr(nominalElectricEquipmentData.ZonePtr), sched(nominalElectricEquipmentData.sched),
     747            7 :               designLevel(nominalElectricEquipmentData.DesignLevel), fractionLatent(nominalElectricEquipmentData.FractionLatent),
     748            7 :               fractionRadiant(nominalElectricEquipmentData.FractionRadiant), fractionLost(nominalElectricEquipmentData.FractionLost),
     749            7 :               fractionConvected(nominalElectricEquipmentData.FractionConvected), endUseSubcategory(nominalElectricEquipmentData.EndUseSubcategory)
     750              :         {
     751            7 :         }
     752              : 
     753              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     754              : 
     755              :     private:
     756              :         int const number;
     757              :         std::string const &name;
     758              :         int const &zonePtr;
     759              :         Sched::Schedule const *sched;
     760              :         double const &designLevel;
     761              :         double const &fractionLatent;
     762              :         double const &fractionRadiant;
     763              :         double const &fractionLost;
     764              :         double const &fractionConvected;
     765              :         std::string const &endUseSubcategory;
     766              :     };
     767              : 
     768              :     class NominalGasEquipment : SQLiteData
     769              :     {
     770              :     public:
     771            2 :         NominalGasEquipment(std::shared_ptr<std::ostream> const &errorStream,
     772              :                             std::shared_ptr<sqlite3> const &db,
     773              :                             int const nominalGasEquipmentNumber,
     774              :                             DataHeatBalance::ZoneEquipData const &nominalGasEquipmentData)
     775            4 :             : SQLiteData(errorStream, db), number(nominalGasEquipmentNumber), name(nominalGasEquipmentData.Name),
     776            2 :               zonePtr(nominalGasEquipmentData.ZonePtr), sched(nominalGasEquipmentData.sched), designLevel(nominalGasEquipmentData.DesignLevel),
     777            2 :               fractionLatent(nominalGasEquipmentData.FractionLatent), fractionRadiant(nominalGasEquipmentData.FractionRadiant),
     778            2 :               fractionLost(nominalGasEquipmentData.FractionLost), fractionConvected(nominalGasEquipmentData.FractionConvected),
     779            2 :               endUseSubcategory(nominalGasEquipmentData.EndUseSubcategory)
     780              :         {
     781            2 :         }
     782              : 
     783              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     784              : 
     785              :     private:
     786              :         int const number;
     787              :         std::string const &name;
     788              :         int const &zonePtr;
     789              :         Sched::Schedule const *sched;
     790              :         double const &designLevel;
     791              :         double const &fractionLatent;
     792              :         double const &fractionRadiant;
     793              :         double const &fractionLost;
     794              :         double const &fractionConvected;
     795              :         std::string const &endUseSubcategory;
     796              :     };
     797              : 
     798              :     class NominalSteamEquipment : SQLiteData
     799              :     {
     800              :     public:
     801            2 :         NominalSteamEquipment(std::shared_ptr<std::ostream> const &errorStream,
     802              :                               std::shared_ptr<sqlite3> const &db,
     803              :                               int const nominalSteamEquipmentNumber,
     804              :                               DataHeatBalance::ZoneEquipData const &nominalSteamEquipmentData)
     805            4 :             : SQLiteData(errorStream, db), number(nominalSteamEquipmentNumber), name(nominalSteamEquipmentData.Name),
     806            2 :               zonePtr(nominalSteamEquipmentData.ZonePtr), sched(nominalSteamEquipmentData.sched), designLevel(nominalSteamEquipmentData.DesignLevel),
     807            2 :               fractionLatent(nominalSteamEquipmentData.FractionLatent), fractionRadiant(nominalSteamEquipmentData.FractionRadiant),
     808            2 :               fractionLost(nominalSteamEquipmentData.FractionLost), fractionConvected(nominalSteamEquipmentData.FractionConvected),
     809            2 :               endUseSubcategory(nominalSteamEquipmentData.EndUseSubcategory)
     810              :         {
     811            2 :         }
     812              : 
     813              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     814              : 
     815              :     private:
     816              :         int const number;
     817              :         std::string const &name;
     818              :         int const &zonePtr;
     819              :         Sched::Schedule const *sched;
     820              :         double const &designLevel;
     821              :         double const &fractionLatent;
     822              :         double const &fractionRadiant;
     823              :         double const &fractionLost;
     824              :         double const &fractionConvected;
     825              :         std::string const &endUseSubcategory;
     826              :     };
     827              : 
     828              :     class NominalHotWaterEquipment : SQLiteData
     829              :     {
     830              :     public:
     831            2 :         NominalHotWaterEquipment(std::shared_ptr<std::ostream> const &errorStream,
     832              :                                  std::shared_ptr<sqlite3> const &db,
     833              :                                  int const nominalHotWaterEquipmentNumber,
     834              :                                  DataHeatBalance::ZoneEquipData const &nominalHotWaterEquipmentData)
     835            4 :             : SQLiteData(errorStream, db), number(nominalHotWaterEquipmentNumber), name(nominalHotWaterEquipmentData.Name),
     836            2 :               zonePtr(nominalHotWaterEquipmentData.ZonePtr), sched(nominalHotWaterEquipmentData.sched),
     837            2 :               designLevel(nominalHotWaterEquipmentData.DesignLevel), fractionLatent(nominalHotWaterEquipmentData.FractionLatent),
     838            2 :               fractionRadiant(nominalHotWaterEquipmentData.FractionRadiant), fractionLost(nominalHotWaterEquipmentData.FractionLost),
     839            2 :               fractionConvected(nominalHotWaterEquipmentData.FractionConvected), endUseSubcategory(nominalHotWaterEquipmentData.EndUseSubcategory)
     840              :         {
     841            2 :         }
     842              : 
     843              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     844              : 
     845              :     private:
     846              :         int const number;
     847              :         std::string const &name;
     848              :         int const &zonePtr;
     849              :         Sched::Schedule const *sched;
     850              :         double const &designLevel;
     851              :         double const &fractionLatent;
     852              :         double const &fractionRadiant;
     853              :         double const &fractionLost;
     854              :         double const &fractionConvected;
     855              :         std::string const &endUseSubcategory;
     856              :     };
     857              : 
     858              :     class NominalOtherEquipment : SQLiteData
     859              :     {
     860              :     public:
     861            2 :         NominalOtherEquipment(std::shared_ptr<std::ostream> const &errorStream,
     862              :                               std::shared_ptr<sqlite3> const &db,
     863              :                               int const nominalOtherEquipmentNumber,
     864              :                               DataHeatBalance::ZoneEquipData const &nominalOtherEquipmentData)
     865            4 :             : SQLiteData(errorStream, db), number(nominalOtherEquipmentNumber), name(nominalOtherEquipmentData.Name),
     866            2 :               zonePtr(nominalOtherEquipmentData.ZonePtr), sched(nominalOtherEquipmentData.sched), designLevel(nominalOtherEquipmentData.DesignLevel),
     867            2 :               fractionLatent(nominalOtherEquipmentData.FractionLatent), fractionRadiant(nominalOtherEquipmentData.FractionRadiant),
     868            2 :               fractionLost(nominalOtherEquipmentData.FractionLost), fractionConvected(nominalOtherEquipmentData.FractionConvected),
     869            2 :               endUseSubcategory(nominalOtherEquipmentData.EndUseSubcategory)
     870              :         {
     871            2 :         }
     872              : 
     873              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     874              : 
     875              :     private:
     876              :         int const number;
     877              :         std::string const &name;
     878              :         int const &zonePtr;
     879              :         Sched::Schedule const *sched;
     880              :         double const &designLevel;
     881              :         double const &fractionLatent;
     882              :         double const &fractionRadiant;
     883              :         double const &fractionLost;
     884              :         double const &fractionConvected;
     885              :         std::string const &endUseSubcategory;
     886              :     };
     887              : 
     888              :     class NominalBaseboardHeat : SQLiteData
     889              :     {
     890              :     public:
     891            2 :         NominalBaseboardHeat(std::shared_ptr<std::ostream> const &errorStream,
     892              :                              std::shared_ptr<sqlite3> const &db,
     893              :                              int const nominalBaseboardHeatNumber,
     894              :                              DataHeatBalance::BBHeatData const &nominalBaseboardHeatData)
     895            4 :             : SQLiteData(errorStream, db), number(nominalBaseboardHeatNumber), name(nominalBaseboardHeatData.Name),
     896            2 :               zonePtr(nominalBaseboardHeatData.ZonePtr), sched(nominalBaseboardHeatData.sched),
     897            2 :               capatLowTemperature(nominalBaseboardHeatData.CapatLowTemperature), lowTemperature(nominalBaseboardHeatData.LowTemperature),
     898            2 :               capatHighTemperature(nominalBaseboardHeatData.CapatHighTemperature), highTemperature(nominalBaseboardHeatData.HighTemperature),
     899            2 :               fractionRadiant(nominalBaseboardHeatData.FractionRadiant), fractionConvected(nominalBaseboardHeatData.FractionConvected),
     900            2 :               endUseSubcategory(nominalBaseboardHeatData.EndUseSubcategory)
     901              :         {
     902            2 :         }
     903              : 
     904              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     905              : 
     906              :     private:
     907              :         int const number;
     908              :         std::string const &name;
     909              :         int const &zonePtr;
     910              :         Sched::Schedule const *sched;
     911              :         double const &capatLowTemperature;
     912              :         double const &lowTemperature;
     913              :         double const &capatHighTemperature;
     914              :         double const &highTemperature;
     915              :         double const &fractionRadiant;
     916              :         double const &fractionConvected;
     917              :         std::string const &endUseSubcategory;
     918              :     };
     919              : 
     920              :     class Infiltration : SQLiteData
     921              :     {
     922              :     public:
     923            4 :         Infiltration(std::shared_ptr<std::ostream> const &errorStream,
     924              :                      std::shared_ptr<sqlite3> const &db,
     925              :                      int const infiltrationNumber,
     926              :                      DataHeatBalance::InfiltrationData const &infiltrationData)
     927            8 :             : SQLiteData(errorStream, db), number(infiltrationNumber), name(infiltrationData.Name), zonePtr(infiltrationData.ZonePtr),
     928            4 :               sched(infiltrationData.sched), designLevel(infiltrationData.DesignLevel)
     929              :         {
     930            4 :         }
     931              : 
     932              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     933              : 
     934              :     private:
     935              :         int const number;
     936              :         std::string const &name;
     937              :         int const &zonePtr;
     938              :         Sched::Schedule const *sched;
     939              :         double const &designLevel;
     940              :     };
     941              : 
     942              :     class Ventilation : SQLiteData
     943              :     {
     944              :     public:
     945            2 :         Ventilation(std::shared_ptr<std::ostream> const &errorStream,
     946              :                     std::shared_ptr<sqlite3> const &db,
     947              :                     int const ventilationNumber,
     948              :                     DataHeatBalance::VentilationData const &ventilationData)
     949            4 :             : SQLiteData(errorStream, db), number(ventilationNumber), name(ventilationData.Name), zonePtr(ventilationData.ZonePtr),
     950            2 :               sched(ventilationData.availSched), designLevel(ventilationData.DesignLevel)
     951              :         {
     952            2 :         }
     953              : 
     954              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     955              : 
     956              :     private:
     957              :         int const number;
     958              :         std::string const &name;
     959              :         int const &zonePtr;
     960              :         Sched::Schedule const *sched;
     961              :         double const &designLevel;
     962              :     };
     963              : 
     964              :     class RoomAirModel : SQLiteData
     965              :     {
     966              :     public:
     967            9 :         RoomAirModel(std::shared_ptr<std::ostream> const &errorStream,
     968              :                      std::shared_ptr<sqlite3> const &db,
     969              :                      int const roomAirModelNumber,
     970              :                      RoomAir::AirModelData const &roomAirModelData)
     971           18 :             : SQLiteData(errorStream, db), number(roomAirModelNumber), airModelName(roomAirModelData.Name), airModel(roomAirModelData.AirModel),
     972            9 :               tempCoupleScheme(roomAirModelData.TempCoupleScheme), simAirModel(roomAirModelData.SimAirModel)
     973              :         {
     974            9 :         }
     975              : 
     976              :         virtual bool insertIntoSQLite(sqlite3_stmt *insertStmt) override;
     977              : 
     978              :     private:
     979              :         int const number;
     980              :         std::string const &airModelName;
     981              :         RoomAir::RoomAirModel const &airModel;
     982              :         RoomAir::CouplingScheme const &tempCoupleScheme;
     983              :         bool const &simAirModel;
     984              :     };
     985              : 
     986              :     std::vector<std::unique_ptr<SQLite::Zone>> zones;
     987              :     std::vector<std::unique_ptr<SQLite::ZoneList>> zoneLists;
     988              :     std::vector<std::unique_ptr<SQLite::ZoneGroup>> zoneGroups;
     989              :     std::vector<std::unique_ptr<SQLite::Schedule>> schedules;
     990              :     std::vector<std::unique_ptr<SQLite::Surface>> surfaces;
     991              :     std::vector<std::unique_ptr<SQLite::Material>> materials;
     992              :     std::vector<std::unique_ptr<SQLite::Construction>> constructions;
     993              :     std::vector<std::unique_ptr<SQLite::NominalLighting>> nominalLightings;
     994              :     std::vector<std::unique_ptr<SQLite::NominalPeople>> nominalPeoples;
     995              :     std::vector<std::unique_ptr<SQLite::NominalElectricEquipment>> nominalElectricEquipments;
     996              :     std::vector<std::unique_ptr<SQLite::NominalGasEquipment>> nominalGasEquipments;
     997              :     std::vector<std::unique_ptr<SQLite::NominalSteamEquipment>> nominalSteamEquipments;
     998              :     std::vector<std::unique_ptr<SQLite::NominalHotWaterEquipment>> nominalHotWaterEquipments;
     999              :     std::vector<std::unique_ptr<SQLite::NominalOtherEquipment>> nominalOtherEquipments;
    1000              :     std::vector<std::unique_ptr<SQLite::NominalBaseboardHeat>> nominalBaseboardHeats;
    1001              :     std::vector<std::unique_ptr<SQLite::Infiltration>> infiltrations;
    1002              :     std::vector<std::unique_ptr<SQLite::Ventilation>> ventilations;
    1003              :     std::vector<std::unique_ptr<SQLite::RoomAirModel>> roomAirModels;
    1004              : };
    1005              : 
    1006              : bool ParseSQLiteInput(EnergyPlusData &state, bool &writeOutputToSQLite, bool &writeTabularDataToSQLite);
    1007              : 
    1008              : std::unique_ptr<SQLite> CreateSQLiteDatabase(EnergyPlusData &state);
    1009              : 
    1010              : void CreateSQLiteZoneExtendedOutput(EnergyPlusData &state);
    1011              : 
    1012              : struct SQLiteProceduresData : BaseGlobalStruct
    1013              : {
    1014              :     std::unique_ptr<SQLite> sqlite;
    1015         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
    1016              :     {
    1017         2126 :     }
    1018              : 
    1019         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
    1020              :     {
    1021         1152 :     }
    1022              : 
    1023         2100 :     void clear_state() override
    1024              :     {
    1025         2100 :         sqlite.reset(); // probably not necessary, as it is recreated in ManageSimulation, but it should be fine to delete it here
    1026         2100 :     }
    1027              : };
    1028              : 
    1029              : } // namespace EnergyPlus
    1030              : 
    1031              : #endif
        

Generated by: LCOV version 2.0-1