GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 41.3% 993 / 0 / 2405
Functions: 18.5% 61 / 0 / 330
Branches: 41.4% 1397 / 0 / 3372

src/utilities/sql/SqlFile_Impl.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 "SqlFile_Impl.hpp"
7 #include "SqlFileTimeSeriesQuery.hpp"
8 #include "PreparedStatement.hpp"
9
10 #include "../time/Calendar.hpp"
11 #include "../filetypes/EpwFile.hpp"
12 #include "../core/Containers.hpp"
13 #include "../core/Assert.hpp"
14 #include "../core/ASCIIStrings.hpp"
15 #include "../core/StringHelpers.hpp"
16
17 #include <OpenStudio.hxx>
18
19 #include <sqlite3.h>
20
21 using boost::multi_index_container;
22 using boost::multi_index::indexed_by;
23 using boost::multi_index::ordered_unique;
24 using boost::multi_index::ordered_non_unique;
25 using boost::multi_index::tag;
26 using boost::multi_index::composite_key;
27 using boost::multi_index::member;
28
29 namespace openstudio {
30
31 namespace detail {
32
33 12666 std::string columnText(const unsigned char* column) {
34
2/2
✓ Branch 0 taken 956 times.
✓ Branch 1 taken 11710 times.
12666 if (column == nullptr) {
35 956 return {};
36 }
37
1/1
✓ Branch 1 taken 11710 times.
35130 return {reinterpret_cast<const char*>(column)};
38 }
39
40 101 SqlFile_Impl::SqlFile_Impl(const openstudio::path& path, const bool createIndexes)
41 101 : m_path(path),
42 101 m_connectionOpen(false),
43 101 m_supportedVersion(false),
44 101 m_hasYear(true),
45 101 m_hasIlluminanceMapYear(true),
46
1/1
✓ Branch 2 taken 101 times.
101 m_illuminanceMapHasOnly2RefPts(false) {
47
2/3
✓ Branch 1 taken 101 times.
✓ Branch 3 taken 101 times.
✗ Branch 4 not taken.
101 if (openstudio::filesystem::exists(m_path)) {
48
2/2
✓ Branch 1 taken 101 times.
✓ Branch 4 taken 101 times.
101 m_path = openstudio::filesystem::canonical(m_path);
49 }
50
1/1
✓ Branch 1 taken 101 times.
101 reopen();
51
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if (createIndexes) {
52
1/1
✓ Branch 1 taken 101 times.
101 this->createIndexes();
53 }
54 101 }
55
56 1 SqlFile_Impl::SqlFile_Impl(const openstudio::path& t_path, const openstudio::EpwFile& t_epwFile, const openstudio::DateTime& t_simulationTime,
57 1 const openstudio::Calendar& t_calendar, const bool createIndexes)
58
1/1
✓ Branch 2 taken 1 time.
1 : m_path(t_path) {
59
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 if (openstudio::filesystem::exists(m_path)) {
60 ✗ m_path = openstudio::filesystem::canonical(m_path);
61 }
62
1/1
✓ Branch 2 taken 1 time.
2 m_sqliteFilename = toString(m_path.make_preferred().native());
63
1/1
✓ Branch 1 taken 1 time.
1 std::string fileName = m_sqliteFilename;
64 1 m_hasYear = true;
65 1 m_hasIlluminanceMapYear = true;
66 1 m_illuminanceMapHasOnly2RefPts = false;
67
68 1 bool initschema = false;
69
70
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
1 if (!openstudio::filesystem::exists(m_path)) {
71 1 initschema = true;
72 }
73
74
1/1
✓ Branch 2 taken 1 time.
1 int code = sqlite3_open_v2(fileName.c_str(), &m_db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE, nullptr);
75 1 m_connectionOpen = (code == 0);
76
77
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (initschema) {
78
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 execAndThrowOnError(
79 /* extracted from real eplusout.sql */
80 "CREATE TABLE Simulations (SimulationIndex INTEGER PRIMARY KEY, EnergyPlusVersion TEXT, TimeStamp TEXT, NumTimestepsPerHour INTEGER, "
81 "Completed BOOL, CompletedSuccessfully BOOL);"
82 "CREATE TABLE EnvironmentPeriods ( EnvironmentPeriodIndex INTEGER PRIMARY KEY, SimulationIndex INTEGER, EnvironmentName TEXT, "
83 "EnvironmentType INTEGER, FOREIGN KEY(SimulationIndex) REFERENCES Simulations(SimulationIndex) ON DELETE CASCADE ON UPDATE CASCADE );"
84 "CREATE TABLE Errors ( ErrorIndex INTEGER PRIMARY KEY, SimulationIndex INTEGER, ErrorType INTEGER, ErrorMessage TEXT, Count INTEGER, FOREIGN "
85 "KEY(SimulationIndex) REFERENCES Simulations(SimulationIndex) ON DELETE CASCADE ON UPDATE CASCADE );"
86 "CREATE TABLE Time (TimeIndex INTEGER PRIMARY KEY, Year INTEGER, Month INTEGER, Day INTEGER, Hour INTEGER, Minute INTEGER, Dst INTEGER, "
87 "Interval INTEGER, IntervalType INTEGER, SimulationDays INTEGER, DayType TEXT, EnvironmentPeriodIndex INTEGER, WarmupFlag INTEGER);"
88 "CREATE TABLE Zones (ZoneIndex INTEGER PRIMARY KEY, ZoneName TEXT, RelNorth REAL, OriginX REAL, OriginY REAL, OriginZ REAL, CentroidX REAL, "
89 "CentroidY REAL, CentroidZ REAL, OfType INTEGER, Multiplier REAL, ListMultiplier REAL, MinimumX REAL, MaximumX REAL, MinimumY REAL, MaximumY "
90 "REAL, MinimumZ REAL, MaximumZ REAL, CeilingHeight REAL, Volume REAL, InsideConvectionAlgo INTEGER, OutsideConvectionAlgo INTEGER, FloorArea "
91 "REAL, ExtGrossWallArea REAL, ExtNetWallArea REAL, ExtWindowArea REAL, IsPartOfTotalArea INTEGER);"
92 "CREATE TABLE ZoneLists ( ZoneListIndex INTEGER PRIMARY KEY, Name TEXT);"
93 "CREATE TABLE ZoneGroups ( ZoneGroupIndex INTEGER PRIMARY KEY, ZoneGroupName TEXT, ZoneListIndex INTEGER, ZoneListMultiplier INTEGER, "
94 "FOREIGN KEY(ZoneListIndex) REFERENCES ZoneLists(ZoneListIndex) ON UPDATE CASCADE );"
95 "CREATE TABLE ZoneInfoZoneLists (ZoneListIndex INTEGER NOT NULL, ZoneIndex INTEGER NOT NULL, PRIMARY KEY(ZoneListIndex, ZoneIndex), FOREIGN "
96 "KEY(ZoneListIndex) REFERENCES ZoneLists(ZoneListIndex) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(ZoneIndex) REFERENCES "
97 "Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE CASCADE );"
98 "CREATE TABLE Schedules (ScheduleIndex INTEGER PRIMARY KEY, ScheduleName TEXT, ScheduleType TEXT, ScheduleMinimum REAL, ScheduleMaximum "
99 "REAL);"
100 "CREATE TABLE Materials ( MaterialIndex INTEGER PRIMARY KEY, Name TEXT, MaterialType INTEGER, Roughness INTEGER, Conductivity REAL, Density "
101 "REAL, IsoMoistCap REAL, Porosity REAL, Resistance REAL, ROnly INTEGER, SpecHeat REAL, ThermGradCoef REAL, Thickness REAL, VaporDiffus REAL "
102 ");"
103 "CREATE TABLE Constructions ( ConstructionIndex INTEGER PRIMARY KEY, Name TEXT, TotalLayers INTEGER, TotalSolidLayers INTEGER, "
104 "TotalGlassLayers INTEGER, InsideAbsorpVis REAL, OutsideAbsorpVis REAL, InsideAbsorpSolar REAL, OutsideAbsorpSolar REAL, InsideAbsorpThermal "
105 "REAL, OutsideAbsorpThermal REAL, OutsideRoughness INTEGER, TypeIsWindow INTEGER, Uvalue REAL);"
106 "CREATE TABLE ConstructionLayers ( ConstructionLayersIndex INTEGER PRIMARY KEY, ConstructionIndex INTEGER, LayerIndex INTEGER, MaterialIndex "
107 "INTEGER, FOREIGN KEY(ConstructionIndex) REFERENCES Constructions(ConstructionIndex) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN "
108 "KEY(MaterialIndex) REFERENCES Materials(MaterialIndex) ON UPDATE CASCADE );"
109 "CREATE TABLE Surfaces ( SurfaceIndex INTEGER PRIMARY KEY, SurfaceName TEXT, ConstructionIndex INTEGER, ClassName TEXT, Area REAL, GrossArea "
110 "REAL, Perimeter REAL, Azimuth REAL, Height REAL, Reveal REAL, Shape INTEGER, Sides INTEGER, Tilt REAL, Width REAL, HeatTransferSurf "
111 "INTEGER, BaseSurfaceIndex INTEGER, ZoneIndex INTEGER, ExtBoundCond INTEGER, ExtSolar INTEGER, ExtWind INTEGER, FOREIGN "
112 "KEY(ConstructionIndex) REFERENCES Constructions(ConstructionIndex) ON UPDATE CASCADE, FOREIGN KEY(BaseSurfaceIndex) REFERENCES "
113 "Surfaces(SurfaceIndex) ON UPDATE CASCADE, FOREIGN KEY(ZoneIndex) REFERENCES Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE CASCADE );"
114 "CREATE TABLE ReportDataDictionary(ReportDataDictionaryIndex INTEGER PRIMARY KEY, IsMeter INTEGER, Type TEXT, IndexGroup TEXT, TimestepType "
115 "TEXT, KeyValue TEXT, Name TEXT, ReportingFrequency TEXT, ScheduleName TEXT, Units TEXT);"
116 "CREATE TABLE ReportData (ReportDataIndex INTEGER PRIMARY KEY, TimeIndex INTEGER, ReportDataDictionaryIndex INTEGER, Value REAL, FOREIGN "
117 "KEY(TimeIndex) REFERENCES Time(TimeIndex) ON DELETE CASCADE ON UPDATE CASCADE FOREIGN KEY(ReportDataDictionaryIndex) REFERENCES "
118 "ReportDataDictionary(ReportDataDictionaryIndex) ON DELETE CASCADE ON UPDATE CASCADE );"
119 "CREATE TABLE ReportExtendedData (ReportExtendedDataIndex INTEGER PRIMARY KEY, ReportDataIndex INTEGER, MaxValue REAL, MaxMonth INTEGER, "
120 "MaxDay INTEGER, MaxHour INTEGER, MaxStartMinute INTEGER, MaxMinute INTEGER, MinValue REAL, MinMonth INTEGER, MinDay INTEGER, MinHour "
121 "INTEGER, MinStartMinute INTEGER, MinMinute INTEGER, FOREIGN KEY(ReportDataIndex) REFERENCES ReportData(ReportDataIndex) ON DELETE CASCADE "
122 "ON UPDATE CASCADE );"
123 "CREATE TABLE NominalPeople ( NominalPeopleIndex INTEGER PRIMARY KEY, ObjectName TEXT, ZoneIndex INTEGER,NumberOfPeople INTEGER, "
124 "NumberOfPeopleScheduleIndex INTEGER, ActivityScheduleIndex INTEGER, FractionRadiant REAL, FractionConvected REAL, "
125 "WorkEfficiencyScheduleIndex INTEGER, ClothingEfficiencyScheduleIndex INTEGER, AirVelocityScheduleIndex INTEGER, Fanger INTEGER, Pierce "
126 "INTEGER, KSU INTEGER, MRTCalcType INTEGER, SurfaceIndex INTEGER, AngleFactorListName TEXT, AngleFactorList INTEGER, "
127 "UserSpecifeidSensibleFraction REAL, Show55Warning INTEGER, FOREIGN KEY(ZoneIndex) REFERENCES Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE "
128 "CASCADE, FOREIGN KEY(NumberOfPeopleScheduleIndex) REFERENCES Schedules(ScheduleIndex) ON UPDATE CASCADE, FOREIGN KEY(ActivityScheduleIndex) "
129 "REFERENCES Schedules(ScheduleIndex) ON UPDATE CASCADE, FOREIGN KEY(WorkEfficiencyScheduleIndex) REFERENCES Schedules(ScheduleIndex) ON "
130 "UPDATE CASCADE, FOREIGN KEY(ClothingEfficiencyScheduleIndex) REFERENCES Schedules(ScheduleIndex) ON UPDATE CASCADE, FOREIGN "
131 "KEY(AirVelocityScheduleIndex) REFERENCES Schedules(ScheduleIndex) ON UPDATE CASCADE, FOREIGN KEY(SurfaceIndex) REFERENCES "
132 "Surfaces(SurfaceIndex) ON UPDATE CASCADE );"
133 "CREATE TABLE NominalLighting ( NominalLightingIndex INTEGER PRIMARY KEY, ObjectName TEXT, ZoneIndex INTEGER, ScheduleIndex INTEGER, "
134 "DesignLevel REAL, FractionReturnAir REAL, FractionRadiant REAL, FractionShortWave REAL, FractionReplaceable REAL, FractionConvected REAL, "
135 "EndUseSubcategory TEXT, FOREIGN KEY(ZoneIndex) REFERENCES Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(ScheduleIndex) "
136 "REFERENCES Schedules(ScheduleIndex) ON UPDATE CASCADE );"
137 "CREATE TABLE NominalElectricEquipment (NominalElectricEquipmentIndex INTEGER PRIMARY KEY, ObjectName TEXT, ZoneIndex INTEGER, ScheduleIndex "
138 "INTEGER, DesignLevel REAL, FractionLatent REAL, FractionRadiant REAL, FractionLost REAL, FractionConvected REAL, EndUseSubcategory TEXT, "
139 "FOREIGN KEY(ZoneIndex) REFERENCES Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(ScheduleIndex) REFERENCES "
140 "Schedules(ScheduleIndex) ON UPDATE CASCADE );"
141 "CREATE TABLE NominalGasEquipment( NominalGasEquipmentIndex INTEGER PRIMARY KEY, ObjectName TEXT, ZoneIndex INTEGER, ScheduleIndex INTEGER, "
142 "DesignLevel REAL, FractionLatent REAL, FractionRadiant REAL, FractionLost REAL, FractionConvected REAL, EndUseSubcategory TEXT, FOREIGN "
143 "KEY(ZoneIndex) REFERENCES Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(ScheduleIndex) REFERENCES "
144 "Schedules(ScheduleIndex) ON UPDATE CASCADE );"
145 "CREATE TABLE NominalSteamEquipment( NominalSteamEquipmentIndex INTEGER PRIMARY KEY, ObjectName TEXT, ZoneIndex INTEGER, ScheduleIndex "
146 "INTEGER, DesignLevel REAL, FractionLatent REAL, FractionRadiant REAL, FractionLost REAL, FractionConvected REAL, EndUseSubcategory TEXT, "
147 "FOREIGN KEY(ZoneIndex) REFERENCES Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(ScheduleIndex) REFERENCES "
148 "Schedules(ScheduleIndex) ON UPDATE CASCADE );"
149 "CREATE TABLE NominalHotWaterEquipment(NominalHotWaterEquipmentIndex INTEGER PRIMARY KEY, ObjectName TEXT, ZoneIndex INTEGER, SchedNo "
150 "INTEGER, DesignLevel REAL, FractionLatent REAL, FractionRadiant REAL, FractionLost REAL, FractionConvected REAL, EndUseSubcategory TEXT, "
151 "FOREIGN KEY(ZoneIndex) REFERENCES Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(SchedNo) REFERENCES "
152 "Schedules(ScheduleIndex) ON UPDATE CASCADE );"
153 "CREATE TABLE NominalOtherEquipment( NominalOtherEquipmentIndex INTEGER PRIMARY KEY, ObjectName TEXT, ZoneIndex INTEGER, ScheduleIndex "
154 "INTEGER, DesignLevel REAL, FractionLatent REAL, FractionRadiant REAL, FractionLost REAL, FractionConvected REAL, EndUseSubcategory TEXT, "
155 "FOREIGN KEY(ZoneIndex) REFERENCES Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(ScheduleIndex) REFERENCES "
156 "Schedules(ScheduleIndex) ON UPDATE CASCADE );"
157 "CREATE TABLE NominalBaseboardHeaters ( NominalBaseboardHeaterIndex INTEGER PRIMARY KEY, ObjectName TEXT, ZoneIndex INTEGER, ScheduleIndex "
158 "INTEGER, CapatLowTemperature REAL, LowTemperature REAL, CapatHighTemperature REAL, HighTemperature REAL, FractionRadiant REAL, "
159 "FractionConvected REAL, EndUseSubcategory TEXT, FOREIGN KEY(ZoneIndex) REFERENCES Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE CASCADE, "
160 "FOREIGN KEY(ScheduleIndex) REFERENCES Schedules(ScheduleIndex) ON UPDATE CASCADE );"
161 "CREATE TABLE NominalInfiltration ( NominalInfiltrationIndex INTEGER PRIMARY KEY, ObjectName TEXT, ZoneIndex INTEGER, ScheduleIndex INTEGER, "
162 "DesignLevel REAL, FOREIGN KEY(ZoneIndex) REFERENCES Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(ScheduleIndex) "
163 "REFERENCES Schedules(ScheduleIndex) ON UPDATE CASCADE );"
164 "CREATE TABLE NominalVentilation ( NominalVentilationIndex INTEGER PRIMARY KEY, ObjectName TEXT, ZoneIndex INTEGER, ScheduleIndex INTEGER, "
165 "DesignLevel REAL, FOREIGN KEY(ZoneIndex) REFERENCES Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(ScheduleIndex) "
166 "REFERENCES Schedules(ScheduleIndex) ON UPDATE CASCADE );"
167 "CREATE TABLE ZoneSizes ( ZoneSizesIndex INTEGER PRIMARY KEY, ZoneName TEXT, LoadType TEXT, CalcDesLoad REAL, UserDesLoad REAL, CalcDesFlow "
168 "REAL, UserDesFlow REAL, DesDayName TEXT, PeakHrMin TEXT, PeakTemp REAL, PeakHumRat REAL, CalcOutsideAirFlow REAL);"
169 "CREATE TABLE SystemSizes (SystemSizesIndex INTEGER PRIMARY KEY, SystemName TEXT, Description TEXT, Value REAL, Units TEXT);"
170 "CREATE TABLE ComponentSizes (ComponentSizesIndex INTEGER PRIMARY KEY, CompType TEXT, CompName TEXT, Description TEXT, Value REAL, Units "
171 "TEXT);"
172 "CREATE TABLE RoomAirModels (ZoneIndex INTEGER PRIMARY KEY, AirModelName TEXT, AirModelType INTEGER, TempCoupleScheme INTEGER, SimAirModel "
173 "INTEGER);"
174 "CREATE TABLE DaylightMaps ( MapNumber INTEGER PRIMARY KEY, MapName TEXT, Environment TEXT, Zone INTEGER, ReferencePt1 TEXT, ReferencePt2 "
175 "TEXT, Z REAL, FOREIGN KEY(Zone) REFERENCES Zones(ZoneIndex) ON DELETE CASCADE ON UPDATE CASCADE );"
176 "CREATE TABLE DaylightMapHourlyReports ( HourlyReportIndex INTEGER PRIMARY KEY, MapNumber INTEGER, Year INTEGER, Month INTEGER, DayOfMonth "
177 "INTEGER, Hour INTEGER, FOREIGN KEY(MapNumber) REFERENCES DaylightMaps(MapNumber) ON DELETE CASCADE ON UPDATE CASCADE );"
178 "CREATE TABLE DaylightMapHourlyData ( HourlyDataIndex INTEGER PRIMARY KEY, HourlyReportIndex INTEGER, X REAL, Y REAL, Illuminance REAL, "
179 "FOREIGN KEY(HourlyReportIndex) REFERENCES DaylightMapHourlyReports(HourlyReportIndex) ON DELETE CASCADE ON UPDATE CASCADE );"
180 "CREATE TABLE StringTypes ( StringTypeIndex INTEGER PRIMARY KEY, Value TEXT);"
181 "CREATE TABLE Strings ( StringIndex INTEGER PRIMARY KEY, StringTypeIndex INTEGER, Value TEXT, UNIQUE(StringTypeIndex, Value), FOREIGN "
182 "KEY(StringTypeIndex) REFERENCES StringTypes(StringTypeIndex) ON UPDATE CASCADE );"
183 "CREATE TABLE TabularData ( TabularDataIndex INTEGER PRIMARY KEY, ReportNameIndex INTEGER, ReportForStringIndex INTEGER, TableNameIndex "
184 "INTEGER, RowNameIndex INTEGER, ColumnNameIndex INTEGER, UnitsIndex INTEGER, SimulationIndex INTEGER, RowId INTEGER, ColumnId INTEGER, Value "
185 "TEXT Value TEXT, FOREIGN KEY(ReportNameIndex) REFERENCES Strings(StringIndex) ON UPDATE CASCADE FOREIGN KEY(ReportForStringIndex) "
186 "REFERENCES Strings(StringIndex) ON UPDATE CASCADE FOREIGN KEY(TableNameIndex) REFERENCES Strings(StringIndex) ON UPDATE CASCADE FOREIGN "
187 "KEY(RowNameIndex) REFERENCES Strings(StringIndex) ON UPDATE CASCADE FOREIGN KEY(ColumnNameIndex) REFERENCES Strings(StringIndex) ON UPDATE "
188 "CASCADE FOREIGN KEY(UnitsIndex) REFERENCES Strings(StringIndex) ON UPDATE CASCADE FOREIGN KEY(SimulationIndex) REFERENCES "
189 "Simulations(SimulationIndex) ON DELETE CASCADE ON UPDATE CASCADE );"
190 "CREATE VIEW ReportVariableWithTime AS SELECT rd.ReportDataIndex, rd.TimeIndex, rd.ReportDataDictionaryIndex, red.ReportExtendedDataIndex, "
191 "rd.Value, t.Month, t.Day, t.Hour, t.Minute, t.Dst, t.Interval, t.IntervalType, t.SimulationDays, t.DayType, t.EnvironmentPeriodIndex, "
192 "t.WarmupFlag, rdd.IsMeter, rdd.Type, rdd.IndexGroup, rdd.TimestepType, rdd.KeyValue, rdd.Name, rdd.ReportingFrequency, rdd.ScheduleName, "
193 "rdd.Units, red.MaxValue, red.MaxMonth, red.MaxDay, red.MaxStartMinute, red.MaxMinute, red.MinValue, red.MinMonth, red.MinDay, "
194 "red.MinStartMinute, red.MinMinute FROM ReportData As rd INNER JOIN ReportDataDictionary As rdd ON rd.ReportDataDictionaryIndex = "
195 "rdd.ReportDataDictionaryIndex LEFT OUTER JOIN ReportExtendedData As red ON rd.ReportDataIndex = red.ReportDataIndex INNER JOIN Time As t ON "
196 "rd.TimeIndex = t.TimeIndex;"
197 "CREATE VIEW ReportVariableData AS SELECT rd.ReportDataIndex As rowid, rd.TimeIndex, rd.ReportDataDictionaryIndex As "
198 "ReportVariableDataDictionaryIndex, rd.Value As VariableValue, red.ReportExtendedDataIndex As ReportVariableExtendedDataIndex FROM "
199 "ReportData As rd LEFT OUTER JOIN ReportExtendedData As red ON rd.ReportDataIndex = red.ReportDataIndex;"
200 "CREATE VIEW ReportVariableDataDictionary AS SELECT rdd.ReportDataDictionaryIndex As ReportVariableDataDictionaryIndex, rdd.Type As "
201 "VariableType, rdd.IndexGroup, rdd.TimestepType, rdd.KeyValue, rdd.Name As VariableName, rdd.ReportingFrequency, rdd.ScheduleName, rdd.Units "
202 "As VariableUnits FROM ReportDataDictionary As rdd;"
203 "CREATE VIEW ReportVariableExtendedData AS SELECT red.ReportExtendedDataIndex As ReportVariableExtendedDataIndex, red.MaxValue, "
204 "red.MaxMonth, red.MaxDay, red.MaxStartMinute, red.MaxMinute, red.MinValue, red.MinMonth, red.MinDay, red.MinStartMinute, red.MinMinute FROM "
205 "ReportExtendedData As red;"
206 "CREATE VIEW ReportMeterData AS SELECT rd.ReportDataIndex As rowid, rd.TimeIndex, rd.ReportDataDictionaryIndex As "
207 "ReportMeterDataDictionaryIndex, rd.Value As VariableValue, red.ReportExtendedDataIndex As ReportVariableExtendedDataIndex FROM ReportData "
208 "As rd LEFT OUTER JOIN ReportExtendedData As red ON rd.ReportDataIndex = red.ReportDataIndex INNER JOIN ReportDataDictionary As rdd ON "
209 "rd.ReportDataDictionaryIndex = rdd.ReportDataDictionaryIndex WHERE rdd.IsMeter = 1;"
210 "CREATE VIEW ReportMeterDataDictionary AS SELECT rdd.ReportDataDictionaryIndex As ReportMeterDataDictionaryIndex, rdd.Type As VariableType, "
211 "rdd.IndexGroup, rdd.TimestepType, rdd.KeyValue, rdd.Name As VariableName, rdd.ReportingFrequency, rdd.ScheduleName, rdd.Units As "
212 "VariableUnits FROM ReportDataDictionary As rdd WHERE rdd.IsMeter = 1;"
213 "CREATE VIEW ReportMeterExtendedData AS SELECT red.ReportExtendedDataIndex As ReportMeterExtendedDataIndex, red.MaxValue, red.MaxMonth, "
214 "red.MaxDay, red.MaxStartMinute, red.MaxMinute, red.MinValue, red.MinMonth, red.MinDay, red.MinStartMinute, red.MinMinute FROM "
215 "ReportExtendedData As red LEFT OUTER JOIN ReportData As rd ON rd.ReportDataIndex = red.ReportDataIndex INNER JOIN ReportDataDictionary As "
216 "rdd ON rd.ReportDataDictionaryIndex = rdd.ReportDataDictionaryIndex WHERE rdd.IsMeter = 1;"
217 "CREATE VIEW TabularDataWithStrings AS SELECT td.TabularDataIndex, td.Value As Value, reportn.Value As ReportName, fs.Value As "
218 "ReportForString, tn.Value As TableName, rn.Value As RowName, cn.Value As ColumnName, u.Value As Units FROM TabularData As td INNER JOIN "
219 "Strings As reportn ON reportn.StringIndex=td.ReportNameIndex INNER JOIN Strings As fs ON fs.StringIndex=td.ReportForStringIndex INNER JOIN "
220 "Strings As tn ON tn.StringIndex=td.TableNameIndex INNER JOIN Strings As rn ON rn.StringIndex=td.RowNameIndex INNER JOIN Strings As cn ON "
221 "cn.StringIndex=td.ColumnNameIndex INNER JOIN Strings As u ON u.StringIndex=td.UnitsIndex;");
222 }
223
224
1/1
✓ Branch 1 taken 1 time.
1 addSimulation(t_epwFile, t_simulationTime, t_calendar);
225
226
1/1
✓ Branch 1 taken 1 time.
1 reopen();
227
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (createIndexes) {
228
1/1
✓ Branch 1 taken 1 time.
1 this->createIndexes();
229 }
230 1 }
231
232 ✗ void SqlFile_Impl::removeIndexes() {
233 ✗ if (m_connectionOpen) {
234 try {
235 ✗ execAndThrowOnError("DROP INDEX IF EXISTS rddMTR;");
236 ✗ } catch (const std::runtime_error& e) {
237 ✗ LOG(Trace, "Error dropping index: " + std::string(e.what()));
238 ✗ }
239
240 try {
241 ✗ execAndThrowOnError("DROP INDEX IF EXISTS redRD;");
242 ✗ } catch (const std::runtime_error& e) {
243 ✗ LOG(Trace, "Error dropping index: " + std::string(e.what()));
244 ✗ }
245
246 try {
247 ✗ execAndThrowOnError("DROP INDEX IF EXISTS rdTI;");
248 ✗ } catch (const std::runtime_error& e) {
249 ✗ LOG(Trace, "Error dropping index: " + std::string(e.what()));
250 ✗ }
251
252 try {
253 ✗ execAndThrowOnError("DROP INDEX IF EXISTS rdDI;");
254 ✗ } catch (const std::runtime_error& e) {
255 ✗ LOG(Trace, "Error dropping index: " + std::string(e.what()));
256 ✗ }
257
258 try {
259 ✗ execAndThrowOnError("DROP INDEX IF EXISTS dmhdHRI;");
260 ✗ } catch (const std::runtime_error& e) {
261 ✗ LOG(Trace, "Error dropping index: " + std::string(e.what()));
262 ✗ }
263
264 try {
265 ✗ execAndThrowOnError("DROP INDEX IF EXISTS dmhrMNI;");
266 ✗ } catch (const std::runtime_error& e) {
267 ✗ LOG(Trace, "Error dropping index: " + std::string(e.what()));
268 ✗ }
269 }
270 ✗ }
271
272 102 void SqlFile_Impl::createIndexes() {
273
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 8 times.
102 if (m_connectionOpen) {
274 try {
275
2/2
✓ Branch 1 taken 94 times.
✓ Branch 4 taken 88 times.
188 execAndThrowOnError("CREATE INDEX IF NOT EXISTS rddMTR ON ReportDataDictionary (IsMeter);");
276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 } catch (const std::runtime_error& e) {
277
7/7
✓ Branch 1 taken 6 times.
✓ Branch 5 taken 6 times.
✓ Branch 8 taken 6 times.
✓ Branch 11 taken 6 times.
✓ Branch 16 taken 6 times.
✓ Branch 19 taken 6 times.
✓ Branch 22 taken 6 times.
18 LOG(Trace, "Error adding index: " + std::string(e.what()));
278 6 }
279
280 try {
281
2/2
✓ Branch 1 taken 94 times.
✓ Branch 4 taken 88 times.
188 execAndThrowOnError("CREATE INDEX IF NOT EXISTS redRD ON ReportExtendedData (ReportDataIndex);");
282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 } catch (const std::runtime_error& e) {
283
7/7
✓ Branch 1 taken 6 times.
✓ Branch 5 taken 6 times.
✓ Branch 8 taken 6 times.
✓ Branch 11 taken 6 times.
✓ Branch 16 taken 6 times.
✓ Branch 19 taken 6 times.
✓ Branch 22 taken 6 times.
18 LOG(Trace, "Error adding index: " + std::string(e.what()));
284 6 }
285
286 try {
287
2/2
✓ Branch 1 taken 94 times.
✓ Branch 4 taken 88 times.
188 execAndThrowOnError("CREATE INDEX IF NOT EXISTS rdTI ON ReportData (TimeIndex ASC);");
288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 } catch (const std::runtime_error& e) {
289
7/7
✓ Branch 1 taken 6 times.
✓ Branch 5 taken 6 times.
✓ Branch 8 taken 6 times.
✓ Branch 11 taken 6 times.
✓ Branch 16 taken 6 times.
✓ Branch 19 taken 6 times.
✓ Branch 22 taken 6 times.
18 LOG(Trace, "Error adding index: " + std::string(e.what()));
290 6 }
291
292 try {
293
2/2
✓ Branch 1 taken 94 times.
✓ Branch 4 taken 88 times.
188 execAndThrowOnError("CREATE INDEX IF NOT EXISTS rdDI ON ReportData (ReportDataDictionaryIndex ASC);");
294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 } catch (const std::runtime_error& e) {
295
7/7
✓ Branch 1 taken 6 times.
✓ Branch 5 taken 6 times.
✓ Branch 8 taken 6 times.
✓ Branch 11 taken 6 times.
✓ Branch 16 taken 6 times.
✓ Branch 19 taken 6 times.
✓ Branch 22 taken 6 times.
18 LOG(Trace, "Error adding index: " + std::string(e.what()));
296 6 }
297
298 try {
299
2/2
✓ Branch 1 taken 94 times.
✓ Branch 4 taken 94 times.
188 execAndThrowOnError("CREATE INDEX IF NOT EXISTS dmhdHRI ON DaylightMapHourlyData (HourlyReportIndex ASC);");
300 ✗ } catch (const std::runtime_error& e) {
301 ✗ LOG(Trace, "Error adding index: " + std::string(e.what()));
302 ✗ }
303
304 try {
305
2/2
✓ Branch 1 taken 94 times.
✓ Branch 4 taken 94 times.
188 execAndThrowOnError("CREATE INDEX IF NOT EXISTS dmhrMNI ON DaylightMapHourlyReports (MapNumber);");
306 ✗ } catch (const std::runtime_error& e) {
307 ✗ LOG(Trace, "Error adding index: " + std::string(e.what()));
308 ✗ }
309 }
310 102 }
311
312 204 SqlFile_Impl::~SqlFile_Impl() {
313 102 close();
314 204 }
315
316 567 void SqlFile_Impl::execAndThrowOnError(const std::string& t_stmt) {
317 567 char* err = nullptr;
318
3/3
✓ Branch 2 taken 567 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 543 times.
567 if (sqlite3_exec(m_db, t_stmt.c_str(), nullptr, nullptr, &err) != SQLITE_OK) {
319 24 std::string errstr;
320
321
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (err) {
322
1/1
✓ Branch 1 taken 24 times.
24 errstr = err;
323
1/1
✓ Branch 1 taken 24 times.
24 sqlite3_free(err);
324 }
325
326
4/4
✓ Branch 2 taken 24 times.
✓ Branch 5 taken 24 times.
✓ Branch 8 taken 24 times.
✓ Branch 11 taken 24 times.
24 throw std::runtime_error("Error executing SQL statement: " + t_stmt + " " + errstr);
327 24 }
328 543 }
329
330 1 void SqlFile_Impl::addSimulation(const openstudio::EpwFile& t_epwFile, const openstudio::DateTime& t_simulationTime,
331 const openstudio::Calendar& t_calendar) {
332
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 int nextSimulationIndex = getNextIndex("simulations", "SimulationIndex");
333
334
1/1
✓ Branch 1 taken 1 time.
1 std::stringstream timeStamp;
335
12/12
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
1 timeStamp << t_simulationTime.date().year() << "." << t_simulationTime.date().monthOfYear().value() << "." << t_simulationTime.date().dayOfMonth()
336
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 << " " << t_simulationTime.time().toString();
337
338
1/1
✓ Branch 1 taken 1 time.
1 std::stringstream version;
339
7/7
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 8 taken 1 time.
✓ Branch 12 taken 1 time.
✓ Branch 15 taken 1 time.
✓ Branch 18 taken 1 time.
✓ Branch 21 taken 1 time.
1 version << "EnergyPlus, VERSION " << energyPlusVersionMajor() << "." << energyPlusVersionMinor() << ", (OpenStudio) YMD=" << timeStamp.str();
340
341
1/1
✓ Branch 1 taken 1 time.
1 std::string insertSimulation = R"(INSERT INTO Simulations (SimulationIndex, EnergyPlusVersion, TimeStamp,
342 NumTimestepsPerHour, Completed, CompletedSuccessfully)
343 VALUES (?, ?, ?, ?, ?, ?);)";
344
345
1/1
✓ Branch 1 taken 1 time.
1 execAndThrowOnError(insertSimulation,
346 // bindArgs
347
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 nextSimulationIndex, version.str(), timeStamp.str(), 6, 6, 1);
348
349
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 int nextEnvironmentPeriodIndex = getNextIndex("EnvironmentPeriods", "EnvironmentPeriodIndex");
350
351
1/1
✓ Branch 1 taken 1 time.
1 std::stringstream envName;
352
5/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
1 envName << t_epwFile.stateProvinceRegion() << " WMO#=" << t_epwFile.wmoNumber();
353
354
1/1
✓ Branch 1 taken 1 time.
1 std::string insertEnvironment = R"(INSERT INTO EnvironmentPeriods (EnvironmentPeriodIndex, SimulationIndex,
355 EnvironmentName, EnvironmentType) VALUES (?, ?, ?, ?);)";
356
1/1
✓ Branch 1 taken 1 time.
1 execAndThrowOnError(insertEnvironment,
357 // bindArgs
358
1/1
✓ Branch 1 taken 1 time.
2 nextEnvironmentPeriodIndex, nextSimulationIndex, envName.str(), 3);
359
360
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 int nextTimeIndex = getNextIndex("time", "TimeIndex");
361
362 1 std::shared_ptr<PreparedStatement> stmt;
363
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
1 if (hasYear()) {
364 1 stmt = std::make_shared<PreparedStatement>(
365 "insert into time (TimeIndex, Year, Month, Day, Hour, Minute, Dst, Interval, IntervalType, SimulationDays, DayType, EnvironmentPeriodIndex, "
366 "WarmupFlag) values (?, ?, ?, ?, ?, 0, 0, 60, 1, ?, ?, ?, null)",
367
1/1
✓ Branch 1 taken 1 time.
2 m_db, true);
368 } else {
369 stmt =
370 ✗ std::make_shared<PreparedStatement>("insert into time (TimeIndex, Month, Day, Hour, Minute, Dst, Interval, IntervalType, SimulationDays, "
371 "DayType, EnvironmentPeriodIndex, WarmupFlag) values (?, ?, ?, ?, 0, 0, 60, 1, ?, ?, ?, null)",
372 ✗ m_db, true);
373 }
374
375 1 int simulationDay = 1;
376
6/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 366 times.
✓ Branch 7 taken 367 times.
✓ Branch 10 taken 367 times.
✓ Branch 12 taken 366 times.
✓ Branch 13 taken 1 time.
367 for (openstudio::Date d = t_calendar.startDate(); d <= t_calendar.endDate(); d += openstudio::Time(1, 0)) {
377
2/2
✓ Branch 0 taken 8784 times.
✓ Branch 1 taken 366 times.
9150 for (int i = 1; i <= 24; ++i) {
378 8784 int b = 0;
379
1/1
✓ Branch 2 taken 8784 times.
8784 stmt->bind(++b, nextTimeIndex);
380
2/3
✓ Branch 1 taken 8784 times.
✓ Branch 3 taken 8784 times.
✗ Branch 4 not taken.
8784 if (hasYear()) {
381
2/2
✓ Branch 2 taken 8784 times.
✓ Branch 5 taken 8784 times.
8784 stmt->bind(++b, d.year());
382 }
383
3/3
✓ Branch 2 taken 8784 times.
✓ Branch 5 taken 8784 times.
✓ Branch 8 taken 8784 times.
8784 stmt->bind(++b, d.monthOfYear().value());
384
2/2
✓ Branch 2 taken 8784 times.
✓ Branch 5 taken 8784 times.
8784 stmt->bind(++b, d.dayOfMonth());
385
1/1
✓ Branch 2 taken 8784 times.
8784 stmt->bind(++b, i);
386
1/1
✓ Branch 2 taken 8784 times.
8784 stmt->bind(++b, simulationDay);
387
388
3/3
✓ Branch 1 taken 8784 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 8520 times.
8784 if (t_calendar.isHoliday(d)) {
389
1/1
✓ Branch 2 taken 264 times.
264 stmt->bind(++b, "Holiday");
390 } else {
391
3/3
✓ Branch 2 taken 8520 times.
✓ Branch 5 taken 8520 times.
✓ Branch 8 taken 8520 times.
8520 stmt->bind(++b, d.dayOfWeek().valueName());
392 }
393
394
1/1
✓ Branch 2 taken 8784 times.
8784 stmt->bind(++b, nextEnvironmentPeriodIndex);
395
396
1/1
✓ Branch 2 taken 8784 times.
8784 stmt->execAndThrowOnError();
397
398 8784 ++nextTimeIndex;
399 }
400
401
1/1
✓ Branch 1 taken 366 times.
366 ++simulationDay;
402 }
403 1 }
404
405 60 bool SqlFile_Impl::connectionOpen() const {
406 60 return m_connectionOpen;
407 }
408
409 11 int SqlFile_Impl::getNextIndex(const std::string& t_tableName, const std::string& t_columnName) {
410 // Interestingly, you CANNOT bind any database identifier (such as the table name / column name) but only litteral values...
411 // boost::optional<int> maxindex = execAndReturnFirstInt("SELECT MAX( ? ) FROM ?", t_columnName, t_tableName);
412
4/4
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
11 std::string query = "SELECT MAX(" + t_columnName + ") FROM " + t_tableName + ";";
413
1/1
✓ Branch 1 taken 11 times.
11 boost::optional<int> maxindex = execAndReturnFirstInt(query);
414
415
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (maxindex) {
416
1/1
✓ Branch 1 taken 11 times.
11 return *maxindex + 1;
417 } else {
418 ✗ return 1;
419 }
420 11 }
421
422 ✗ openstudio::path SqlFile_Impl::path() const {
423 ✗ return m_path;
424 }
425
426 231 bool SqlFile_Impl::close() {
427
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 134 times.
231 if (m_connectionOpen) {
428 97 sqlite3_close(m_db);
429 97 m_connectionOpen = false;
430 }
431 231 return true;
432 }
433
434 104 bool SqlFile_Impl::reopen() {
435 104 bool result = true;
436 try {
437
1/1
✓ Branch 1 taken 104 times.
104 close();
438
1/1
✓ Branch 1 taken 96 times.
104 init();
439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 } catch (const std::exception& e) {
440
9/9
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
✓ Branch 17 taken 8 times.
✓ Branch 21 taken 8 times.
✓ Branch 24 taken 8 times.
✓ Branch 27 taken 8 times.
8 LOG(Error, "Exception while opening database at '" << toString(m_path) << "': " << e.what());
441 8 result = false;
442 8 }
443 104 return result;
444 }
445
446 104 void SqlFile_Impl::init() {
447
1/1
✓ Branch 2 taken 104 times.
208 m_sqliteFilename = toString(m_path.make_preferred().native());
448
1/1
✓ Branch 1 taken 104 times.
104 std::string fileName = m_sqliteFilename;
449
450
1/1
✓ Branch 2 taken 104 times.
104 int code = sqlite3_open_v2(fileName.c_str(), &m_db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE, nullptr);
451
452 104 m_connectionOpen = (code == 0);
453
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if (m_connectionOpen) { // create index on dictionaryIndex for large table reportvariabledata
454
3/3
✓ Branch 1 taken 104 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 96 times.
104 if (!isValidConnection()) {
455
1/1
✓ Branch 1 taken 8 times.
8 sqlite3_close(m_db);
456 8 m_connectionOpen = false;
457
1/1
✓ Branch 2 taken 8 times.
8 throw openstudio::Exception("OpenStudio is not compatible with this file.");
458 }
459 // set a 1 second timeout
460
1/1
✓ Branch 1 taken 96 times.
96 code = sqlite3_busy_timeout(m_db, 1000);
461
462 // set locking mode to exclusive
463 //code = sqlite3_exec(m_db, "PRAGMA locking_mode=EXCLUSIVE", NULL, NULL, NULL);
464
465 // retrieve DataDictionaryTable
466
1/1
✓ Branch 1 taken 96 times.
96 retrieveDataDictionary();
467 } else {
468 ✗ throw openstudio::Exception("File not successfully opened.");
469 }
470 104 }
471
472 ✗ bool SqlFile_Impl::isSupportedVersion() const {
473 ✗ return m_supportedVersion;
474 }
475
476 3384019 bool SqlFile_Impl::hasYear() const {
477 3384019 return m_hasYear;
478 }
479
480 19077 bool SqlFile_Impl::hasIlluminanceMapYear() const {
481 19077 return m_hasIlluminanceMapYear;
482 }
483
484 ✗ boost::optional<double> SqlFile_Impl::assemblyUFactor(const std::string& subSurfaceName) const {
485 ✗ return getExteriorFenestrationValue(subSurfaceName, "Assembly U-Factor");
486 }
487
488 ✗ boost::optional<double> SqlFile_Impl::assemblySHGC(const std::string& subSurfaceName) const {
489 ✗ return getExteriorFenestrationValue(subSurfaceName, "Assembly SHGC");
490 }
491
492 ✗ boost::optional<double> SqlFile_Impl::assemblyVisibleTransmittance(const std::string& subSurfaceName) const {
493 ✗ return getExteriorFenestrationValue(subSurfaceName, "Assembly Visible Transmittance");
494 }
495
496 ✗ boost::optional<double> SqlFile_Impl::getExteriorFenestrationValue(const std::string& subSurfaceName, const std::string& columnName) const {
497 ✗ boost::optional<double> result;
498
499 // Get the object name and transform to the way it is recorded
500 // in the sql file
501 ✗ std::string queryRowName = boost::to_upper_copy(subSurfaceName);
502
503 ✗ std::string s = R"(SELECT Value FROM TabularDataWithStrings
504 WHERE ReportName='EnvelopeSummary'
505 AND ReportForString='Entire Facility'
506 AND TableName='Exterior Fenestration'
507 AND RowName=?
508 AND ColumnName=?)";
509
510 ✗ result = execAndReturnFirstDouble(s, queryRowName, columnName);
511
512 ✗ return result;
513 ✗ }
514
515 104 bool SqlFile_Impl::isValidConnection() {
516
1/1
✓ Branch 1 taken 104 times.
104 std::string energyPlusVersion = this->energyPlusVersion();
517
2/2
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 96 times.
104 if (energyPlusVersion.empty()) {
518 8 return false;
519 }
520
521
1/1
✓ Branch 1 taken 96 times.
96 VersionString version(energyPlusVersion);
522
9/18
✓ Branch 1 taken 96 times.
✓ Branch 4 taken 96 times.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 11 taken 96 times.
✓ Branch 14 taken 96 times.
✓ Branch 16 taken 96 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 96 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 96 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 96 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
96 if (version >= VersionString(7, 0) && version <= VersionString(energyPlusVersionMajor(), energyPlusVersionMinor())) {
523 96 m_supportedVersion = true;
524 } else {
525 ✗ m_supportedVersion = false;
526 ✗ LOG(Warn, "Using unsupported EnergyPlus version " << version.str());
527 }
528
529 // v8.9.0 added the year tag, but it seems it's always zero...
530 // IlluminanceMap Year started in 9.2.0
531 // m_hasYear & m_hasIlluminanceMapYear are both default initialized to true
532
4/4
✓ Branch 1 taken 96 times.
✓ Branch 4 taken 96 times.
✓ Branch 7 taken 15 times.
✓ Branch 8 taken 81 times.
96 if (version < VersionString(9, 2)) {
533 15 m_hasIlluminanceMapYear = false;
534
4/4
✓ Branch 1 taken 81 times.
✓ Branch 4 taken 81 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 77 times.
81 } else if (version < VersionString(9, 6)) {
535 4 m_illuminanceMapHasOnly2RefPts = true;
536 }
537
538
4/4
✓ Branch 1 taken 96 times.
✓ Branch 4 taken 96 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 84 times.
96 if (version < VersionString(8, 9)) {
539 12 m_hasYear = false;
540 } else {
541 // Check if zero
542
2/2
✓ Branch 1 taken 84 times.
✓ Branch 4 taken 84 times.
84 boost::optional<int> maxYear = execAndReturnFirstInt("SELECT MAX(Year) FROM Time");
543
6/7
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 84 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 64 times.
✓ Branch 8 taken 20 times.
✓ Branch 9 taken 64 times.
84 if (!maxYear.is_initialized() || maxYear.get() <= 0) {
544 auto nOtherThanRunPeriod =
545
2/2
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
20 execAndReturnFirstInt("SELECT COUNT(ReportingFrequency) FROM ReportDataDictionary WHERE ReportingFrequency NOT LIKE '%Run Period%'");
546
3/3
✓ Branch 1 taken 20 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 19 times.
20 if (nOtherThanRunPeriod > 0) {
547
8/8
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 17 taken 1 time.
✓ Branch 20 taken 1 time.
✓ Branch 23 taken 1 time.
1 LOG(Warn, "Using EnergyPlusVersion version " << version.str() << " which should have 'Year' field, but it's always zero");
548 } else {
549
5/5
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
✓ Branch 10 taken 19 times.
✓ Branch 13 taken 19 times.
19 LOG(Info, "Your SQLFile does not contain the 'Year' field since you did not request any outputs at a frequency lower than Run Period");
550 }
551 20 m_hasYear = false;
552 }
553 }
554
555 96 return true;
556 104 }
557
558 1 int SqlFile_Impl::insertZone(const std::string& t_name, double t_relNorth, double t_originX, double t_originY, double t_originZ, double t_centroidX,
559 double t_centroidY, double t_centroidZ, int t_ofType, double t_multiplier, double t_listMultiplier, double t_minimumX,
560 double t_maximumX, double t_minimumY, double t_maximumY, double t_minimumZ, double t_maximumZ, double t_ceilingHeight,
561 double t_volume, int t_insideConvectionAlgo, int t_outsideConvectionAlgo, double t_floorArea,
562 double t_extGrossWallArea, double t_extNetWallArea, double t_extWindowArea, bool t_isPartOfTotalArea) {
563
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
4 int zoneIndex = getNextIndex("zones", "ZoneIndex");
564
565
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 execAndThrowOnError("insert into zones (ZoneIndex, ZoneName, RelNorth, OriginX, OriginY, OriginZ, CentroidX, CentroidY, CentroidZ, OfType, "
566 "Multiplier, ListMultiplier, MinimumX, MaximumX, MinimumY, MaximumY, MinimumZ, MaximumZ, CeilingHeight, Volume, "
567 "InsideConvectionAlgo, OutsideConvectionAlgo, FloorArea, ExtGrossWallArea, ExtNetWallArea, ExtWindowArea, IsPartOfTotalArea) "
568 "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
569 // Bind Args
570 zoneIndex, t_name, t_relNorth, t_originX, t_originY, t_originZ, t_centroidX, t_centroidY, t_centroidZ, t_ofType, t_multiplier,
571 t_listMultiplier, t_minimumX, t_maximumX, t_minimumY, t_maximumY, t_minimumZ, t_maximumZ, t_ceilingHeight, t_volume,
572 t_insideConvectionAlgo, t_outsideConvectionAlgo, t_floorArea, t_extGrossWallArea, t_extNetWallArea, t_extWindowArea,
573 t_isPartOfTotalArea);
574
575 1 return zoneIndex;
576 }
577
578 1 void SqlFile_Impl::insertIlluminanceMap(const std::string& t_zoneName, const std::string& t_name, const std::string& t_environmentName,
579 const std::vector<DateTime>& t_times, const std::vector<double>& t_xs, const std::vector<double>& t_ys,
580 double t_z, const std::vector<Matrix>& t_maps) {
581
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 boost::optional<int> zoneIndex = execAndReturnFirstInt("select ZoneIndex from zones where ZoneName=?;", t_zoneName);
582
583
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!zoneIndex) {
584 ✗ throw std::runtime_error("Unknown zone name: " + t_zoneName);
585 }
586
587
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
1 if (t_times.size() != t_maps.size()) {
588 ✗ throw std::runtime_error("Number of times does not match number of maps");
589 }
590
591
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 int mapIndex = getNextIndex("daylightmaps", "MapNumber");
592
593
5/5
✓ Branch 2 taken 1 time.
✓ Branch 6 taken 1 time.
✓ Branch 9 taken 1 time.
✓ Branch 12 taken 1 time.
✓ Branch 15 taken 1 time.
2 std::string referencePt1 = "RefPt1=(" + boost::lexical_cast<std::string>(t_xs.front()) + ":" + boost::lexical_cast<std::string>(t_ys.front())
594
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
3 + ":" + boost::lexical_cast<std::string>(t_z) + ")";
595
596
6/6
✓ Branch 2 taken 1 time.
✓ Branch 6 taken 1 time.
✓ Branch 9 taken 1 time.
✓ Branch 12 taken 1 time.
✓ Branch 15 taken 1 time.
✓ Branch 18 taken 1 time.
2 std::string referencePt2 = "RefPt1=(" + boost::lexical_cast<std::string>(t_xs.back()) + ":" + boost::lexical_cast<std::string>(t_ys.back()) + ":"
597
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 + boost::lexical_cast<std::string>(t_z) + ")";
598
599
1/1
✓ Branch 1 taken 1 time.
1 std::stringstream mapInsert;
600
1/1
✓ Branch 1 taken 1 time.
1 mapInsert << "insert into daylightmaps (MapNumber, MapName, Environment, Zone, ReferencePt1, ReferencePt2, Z) values (" << mapIndex << ", " << "'"
601
9/9
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
1 << t_name << "', " << "'" << t_environmentName << "', " << *zoneIndex << ", " << "'" << referencePt1 << "', " << "'" << referencePt2
602
10/10
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
1 << "', " << t_z << ");";
603
604
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 execAndThrowOnError(mapInsert.str());
605
606
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 int hourlyReportIndex = getNextIndex("daylightmaphourlyreports", "HourlyReportIndex");
607
608 // E+ added the "Year" field to the DaylightMapHourlyReports in version 9.2.0 (NREL/EnergyPlus#7235)
609 // assignment of PreparedStatement does not work, so use a pointer to statement to handle the case where you do or do not have Year
610 1 std::shared_ptr<PreparedStatement> stmt1;
611
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
1 if (hasIlluminanceMapYear()) {
612 1 stmt1 = std::make_shared<PreparedStatement>(
613
1/1
✓ Branch 1 taken 1 time.
2 "insert into daylightmaphourlyreports (HourlyReportIndex, MapNumber, Year, Month, DayOfMonth, Hour) values (?, ?, ?, ?, ?, ?)", m_db, true);
614 } else {
615 ✗ stmt1 = std::make_shared<PreparedStatement>(
616 ✗ "insert into daylightmaphourlyreports (HourlyReportIndex, MapNumber, Month, DayOfMonth, Hour) values (?, ?, ?, ?, ?)", m_db, true);
617 }
618
619
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 time.
3 for (size_t dateidx = 0; dateidx < t_times.size(); ++dateidx) {
620 2 int b = 0;
621
1/1
✓ Branch 2 taken 2 times.
2 stmt1->bind(++b, hourlyReportIndex);
622
1/1
✓ Branch 2 taken 2 times.
2 stmt1->bind(++b, mapIndex);
623
624
1/1
✓ Branch 2 taken 2 times.
2 DateTime dt = t_times[dateidx];
625
626
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 int year = dt.date().year();
627
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 int monthOfYear = dt.date().monthOfYear().value();
628
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 int dayOfMonth = dt.date().dayOfMonth();
629
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 int hours = dt.time().hours();
630 // EnergyPlus deals in a 00:00:01 -> 24:00:00 world instead of
631 // 00:00:00 -> 23:59:59 hrs that the real world uses, so
632 // we are going to adjust for that, so we subtract an hour,
633 // to get it back to the previous day, then we will replace
634 // the hours with 24
635 // \sa illuminanceMapHourlyReportIndex
636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (hours == 0) {
637 ✗ dt -= Time(0, 1);
638 ✗ monthOfYear = dt.date().monthOfYear().value();
639 ✗ dayOfMonth = dt.date().dayOfMonth();
640 ✗ hours = 24;
641 }
642
643
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 if (hasIlluminanceMapYear()) {
644
1/1
✓ Branch 2 taken 2 times.
2 stmt1->bind(++b, year);
645 }
646
1/1
✓ Branch 2 taken 2 times.
2 stmt1->bind(++b, monthOfYear);
647
1/1
✓ Branch 2 taken 2 times.
2 stmt1->bind(++b, dayOfMonth);
648
1/1
✓ Branch 2 taken 2 times.
2 stmt1->bind(++b, hours);
649
650
1/1
✓ Branch 2 taken 2 times.
2 stmt1->execAndThrowOnError();
651
652
3/6
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
2 if (t_xs.size() != t_maps[dateidx].size1() || t_ys.size() != t_maps[dateidx].size2()) {
653 ✗ throw std::runtime_error("map size does not match given x's and y's");
654 }
655
656
2/2
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2 times.
8 for (size_t xidx = 0; xidx < t_xs.size(); ++xidx) {
657
2/2
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 6 times.
18 for (size_t yidx = 0; yidx < t_ys.size(); ++yidx) {
658 // we are already inside of a transaction from stmt1, so not creating a new one here
659 // DLM: when implementing option for hasYear, use pointer to statement, assignment of PreparedStatement does not work
660
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 PreparedStatement stmt2("insert into daylightmaphourlydata (HourlyReportIndex, X, Y, Illuminance) values (?, ?, ?, ?)", m_db, false);
661
662
1/1
✓ Branch 1 taken 12 times.
12 stmt2.bind(1, hourlyReportIndex);
663
1/1
✓ Branch 2 taken 12 times.
12 stmt2.bind(2, t_xs[xidx]);
664
1/1
✓ Branch 2 taken 12 times.
12 stmt2.bind(3, t_ys[yidx]);
665
2/2
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
12 stmt2.bind(4, t_maps[dateidx](xidx, yidx));
666
667
1/1
✓ Branch 1 taken 12 times.
12 stmt2.execAndThrowOnError();
668 12 }
669 }
670
671 2 ++hourlyReportIndex;
672 }
673 1 }
674
675 1 void SqlFile_Impl::insertTimeSeriesData(const std::string& t_variableType, const std::string& t_indexGroup, const std::string& t_timestepType,
676 const std::string& t_keyValue, const std::string& t_variableName,
677 const openstudio::ReportingFrequency& t_reportingFrequency,
678 const boost::optional<std::string>& t_scheduleName, const std::string& t_variableUnits,
679 const openstudio::TimeSeries& t_timeSeries) {
680
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 int datadicindex = getNextIndex("reportdatadictionary", "ReportDataDictionaryIndex");
681
682
1/1
✓ Branch 1 taken 1 time.
1 std::stringstream insertReportDataDictionary;
683 insertReportDataDictionary << "insert into reportdatadictionary (ReportDataDictionaryIndex, IsMeter, Type, IndexGroup, TimestepType, KeyValue, "
684
1/1
✓ Branch 1 taken 1 time.
1 "Name, ReportingFrequency, ScheduleName, Units) values ("
685 << datadicindex << ", " << "'0'," << "'" << t_variableType << "', " << "'" << t_indexGroup << "', " << "'"
686 << t_timestepType << "', " << "'" << t_keyValue << "', " << "'" << t_variableName << "', " << "'"
687
22/22
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 37 taken 1 time.
✓ Branch 40 taken 1 time.
✓ Branch 43 taken 1 time.
✓ Branch 46 taken 1 time.
✓ Branch 49 taken 1 time.
✓ Branch 52 taken 1 time.
✓ Branch 55 taken 1 time.
✓ Branch 58 taken 1 time.
✓ Branch 61 taken 1 time.
✓ Branch 64 taken 1 time.
1 << t_reportingFrequency.valueName() << "', ";
688
689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (t_scheduleName) {
690 ✗ insertReportDataDictionary << "'" << *t_scheduleName << "', ";
691 } else {
692
1/1
✓ Branch 1 taken 1 time.
1 insertReportDataDictionary << "null, ";
693 }
694
695
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 insertReportDataDictionary << "'" << t_variableUnits << "');";
696
697
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 execAndThrowOnError(insertReportDataDictionary.str());
698
699
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 std::vector<double> values = toStandardVector(t_timeSeries.values());
700
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 std::vector<double> days = toStandardVector(t_timeSeries.daysFromFirstReport());
701
702
1/1
✓ Branch 1 taken 1 time.
1 openstudio::DateTime firstdate = t_timeSeries.firstReportDateTime();
703
704 1 std::shared_ptr<PreparedStatement> stmt;
705
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
1 if (hasYear()) {
706 // we'll let stmt1 have the transaction
707 stmt =
708 1 std::make_shared<PreparedStatement>("insert into reportdata (ReportDataIndex, TimeIndex, ReportDataDictionaryIndex, Value) values ( ?, "
709 "(select TimeIndex from time where Year=? and Month=? and Day=? and Hour=? and Minute=? limit 1), ?, ?);",
710
1/1
✓ Branch 1 taken 1 time.
2 m_db, true);
711 } else {
712 ✗ stmt = std::make_shared<PreparedStatement>("insert into reportdata (ReportDataIndex, TimeIndex, ReportDataDictionaryIndex, Value) values ( ?, "
713 "(select TimeIndex from time where Month=? and Day=? and Hour=? and Minute=? limit 1), ?, ?);",
714 ✗ m_db, true);
715 }
716
717
2/2
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 time.
5 for (size_t i = 0; i < values.size(); ++i) {
718
2/2
✓ Branch 2 taken 4 times.
✓ Branch 5 taken 4 times.
4 openstudio::DateTime dt = firstdate + openstudio::Time(days[i]);
719 4 double value = values[i];
720
721
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
4 if (dt.time().seconds() == 59) {
722 // rounding error, let's help
723 ✗ dt += openstudio::Time(0, 0, 0, 1);
724 }
725
726
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
4 if (dt.time().seconds() == 1) {
727 // rounding error, let's help
728 ✗ dt -= openstudio::Time(0, 0, 0, 1);
729 }
730
731
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 int year = dt.date().year();
732
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
4 int month = dt.date().monthOfYear().value();
733
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 int day = dt.date().dayOfMonth();
734
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 int hour = dt.time().hours();
735
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 int minute = dt.time().minutes();
736
737 4 ++hour; // energyplus says time goes from 1-24 not from 0-23
738
739
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
12 int reportdataindex = getNextIndex("reportdata", "ReportDataIndex");
740 4 int b = 0;
741
1/1
✓ Branch 2 taken 4 times.
4 stmt->bind(++b, reportdataindex);
742
2/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
4 if (hasYear()) {
743
1/1
✓ Branch 2 taken 4 times.
4 stmt->bind(++b, year);
744 }
745
1/1
✓ Branch 2 taken 4 times.
4 stmt->bind(++b, month);
746
1/1
✓ Branch 2 taken 4 times.
4 stmt->bind(++b, day);
747
1/1
✓ Branch 2 taken 4 times.
4 stmt->bind(++b, hour);
748
1/1
✓ Branch 2 taken 4 times.
4 stmt->bind(++b, minute);
749
1/1
✓ Branch 2 taken 4 times.
4 stmt->bind(++b, datadicindex);
750
1/1
✓ Branch 2 taken 4 times.
4 stmt->bind(++b, value);
751
752
1/1
✓ Branch 2 taken 4 times.
4 stmt->execAndThrowOnError();
753 }
754 1 }
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 96 void SqlFile_Impl::retrieveDataDictionary() {
801 96 std::string table;
802 96 std::string name;
803 96 std::string keyValue;
804 96 std::string units;
805 96 std::string rf;
806
807
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if (m_db) {
808 int dictionaryIndex;
809 int code;
810
811
1/1
✓ Branch 1 taken 96 times.
96 std::stringstream s;
812 sqlite3_stmt* sqlStmtPtr;
813 96 std::map<int, std::string> envPeriods;
814 96 std::map<int, std::string>::iterator envPeriodsItr;
815
816
1/1
✓ Branch 1 taken 96 times.
96 s << "SELECT EnvironmentPeriodIndex, EnvironmentName FROM EnvironmentPeriods";
817
2/2
✓ Branch 1 taken 96 times.
✓ Branch 5 taken 96 times.
96 sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
818
1/1
✓ Branch 1 taken 96 times.
96 code = sqlite3_step(sqlStmtPtr);
819
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 96 times.
250 while (code == SQLITE_ROW) {
820
3/3
✓ Branch 2 taken 154 times.
✓ Branch 5 taken 154 times.
✓ Branch 8 taken 154 times.
154 std::string queryEnvPeriod = boost::to_upper_copy(columnText(sqlite3_column_text(sqlStmtPtr, 1)));
821
3/3
✓ Branch 1 taken 154 times.
✓ Branch 4 taken 154 times.
✓ Branch 7 taken 154 times.
154 envPeriods.insert(std::pair<int, std::string>(sqlite3_column_int(sqlStmtPtr, 0), queryEnvPeriod));
822
1/1
✓ Branch 1 taken 154 times.
154 code = sqlite3_step(sqlStmtPtr);
823 154 }
824
1/1
✓ Branch 1 taken 96 times.
96 sqlite3_finalize(sqlStmtPtr);
825
826
2/2
✓ Branch 1 taken 96 times.
✓ Branch 4 taken 96 times.
96 s.str("");
827
1/1
✓ Branch 1 taken 96 times.
96 s << "SELECT ReportMeterDataDictionaryIndex, VariableName, KeyValue, ReportingFrequency, VariableUnits";
828
1/1
✓ Branch 1 taken 96 times.
96 s << " FROM ReportMeterDataDictionary";
829
2/2
✓ Branch 1 taken 96 times.
✓ Branch 5 taken 96 times.
96 code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
830
831
1/1
✓ Branch 1 taken 96 times.
96 table = "ReportMeterData";
832
833
1/1
✓ Branch 1 taken 96 times.
96 code = sqlite3_step(sqlStmtPtr);
834
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 96 times.
650 while (code == SQLITE_ROW) {
835
1/1
✓ Branch 1 taken 554 times.
554 dictionaryIndex = sqlite3_column_int(sqlStmtPtr, 0);
836
2/2
✓ Branch 1 taken 554 times.
✓ Branch 4 taken 554 times.
554 name = columnText(sqlite3_column_text(sqlStmtPtr, 1));
837
2/2
✓ Branch 1 taken 554 times.
✓ Branch 4 taken 554 times.
554 keyValue = columnText(sqlite3_column_text(sqlStmtPtr, 2));
838
2/2
✓ Branch 1 taken 554 times.
✓ Branch 4 taken 554 times.
554 rf = columnText(sqlite3_column_text(sqlStmtPtr, 3));
839
2/2
✓ Branch 1 taken 554 times.
✓ Branch 4 taken 554 times.
554 units = columnText(sqlite3_column_text(sqlStmtPtr, 4));
840
841
2/2
✓ Branch 4 taken 786 times.
✓ Branch 5 taken 554 times.
1340 for (envPeriodsItr = envPeriods.begin(); envPeriodsItr != envPeriods.end(); ++envPeriodsItr) {
842
1/1
✓ Branch 3 taken 786 times.
786 std::string queryEnvPeriod = boost::to_upper_copy(envPeriodsItr->second);
843
2/2
✓ Branch 2 taken 786 times.
✓ Branch 5 taken 786 times.
786 m_dataDictionary.insert(DataDictionaryItem(dictionaryIndex, envPeriodsItr->first, name, keyValue, queryEnvPeriod, rf, units, table));
844
21/21
✓ Branch 1 taken 786 times.
✓ Branch 4 taken 786 times.
✓ Branch 7 taken 786 times.
✓ Branch 10 taken 786 times.
✓ Branch 14 taken 786 times.
✓ Branch 17 taken 786 times.
✓ Branch 20 taken 786 times.
✓ Branch 23 taken 786 times.
✓ Branch 26 taken 786 times.
✓ Branch 29 taken 786 times.
✓ Branch 32 taken 786 times.
✓ Branch 35 taken 786 times.
✓ Branch 38 taken 786 times.
✓ Branch 41 taken 786 times.
✓ Branch 44 taken 786 times.
✓ Branch 47 taken 786 times.
✓ Branch 50 taken 786 times.
✓ Branch 53 taken 786 times.
✓ Branch 56 taken 786 times.
✓ Branch 59 taken 786 times.
✓ Branch 62 taken 786 times.
786 LOG(Trace, "Creating data dictionary item " << dictionaryIndex << ", " << (*envPeriodsItr).first << ", " << name << ", " << keyValue << ", "
845 << queryEnvPeriod << ", " << rf << ", " << units << ", " << table << ".");
846 786 }
847
848
1/1
✓ Branch 1 taken 554 times.
554 code = sqlite3_step(sqlStmtPtr);
849 }
850
1/1
✓ Branch 1 taken 96 times.
96 sqlite3_finalize(sqlStmtPtr);
851
852
2/2
✓ Branch 1 taken 96 times.
✓ Branch 4 taken 96 times.
96 s.str("");
853
1/1
✓ Branch 1 taken 96 times.
96 s << "SELECT ReportVariableDatadictionaryIndex, VariableName, KeyValue, ReportingFrequency, VariableUnits";
854
1/1
✓ Branch 1 taken 96 times.
96 s << " FROM ReportVariableDatadictionary";
855
2/2
✓ Branch 1 taken 96 times.
✓ Branch 5 taken 96 times.
96 code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
856
857
1/1
✓ Branch 1 taken 96 times.
96 table = "ReportVariableData";
858
859
1/1
✓ Branch 1 taken 96 times.
96 code = sqlite3_step(sqlStmtPtr);
860
2/2
✓ Branch 0 taken 2493 times.
✓ Branch 1 taken 96 times.
2589 while (code == SQLITE_ROW) {
861
1/1
✓ Branch 1 taken 2493 times.
2493 dictionaryIndex = sqlite3_column_int(sqlStmtPtr, 0);
862
2/2
✓ Branch 1 taken 2493 times.
✓ Branch 4 taken 2493 times.
2493 name = columnText(sqlite3_column_text(sqlStmtPtr, 1));
863
2/2
✓ Branch 1 taken 2493 times.
✓ Branch 4 taken 2493 times.
2493 keyValue = columnText(sqlite3_column_text(sqlStmtPtr, 2));
864
2/2
✓ Branch 1 taken 2493 times.
✓ Branch 4 taken 2493 times.
2493 rf = columnText(sqlite3_column_text(sqlStmtPtr, 3));
865
2/2
✓ Branch 1 taken 2493 times.
✓ Branch 4 taken 2493 times.
2493 units = columnText(sqlite3_column_text(sqlStmtPtr, 4));
866
867
2/2
✓ Branch 4 taken 4071 times.
✓ Branch 5 taken 2493 times.
6564 for (envPeriodsItr = envPeriods.begin(); envPeriodsItr != envPeriods.end(); ++envPeriodsItr) {
868
1/1
✓ Branch 3 taken 4071 times.
4071 std::string queryEnvPeriod = boost::to_upper_copy(envPeriodsItr->second);
869
2/2
✓ Branch 2 taken 4071 times.
✓ Branch 5 taken 4071 times.
4071 m_dataDictionary.insert(DataDictionaryItem(dictionaryIndex, envPeriodsItr->first, name, keyValue, queryEnvPeriod, rf, units, table));
870 4071 }
871
872 // step to next row
873
1/1
✓ Branch 1 taken 2493 times.
2493 code = sqlite3_step(sqlStmtPtr);
874 }
875
1/1
✓ Branch 1 taken 96 times.
96 sqlite3_finalize(sqlStmtPtr);
876 96 }
877
5/5
✓ Branch 1 taken 96 times.
✓ Branch 4 taken 96 times.
✓ Branch 7 taken 96 times.
✓ Branch 10 taken 96 times.
✓ Branch 13 taken 96 times.
96 LOG(Debug, "Dictionary Built");
878 96 }
879
880 17136 boost::optional<double> SqlFile_Impl::energyConsumptionByMonth(const openstudio::EndUseFuelType& t_fuelType,
881 const openstudio::EndUseCategoryType& t_categoryType,
882 const openstudio::MonthOfYear& t_monthOfYear) const {
883 // For backward compatibilty, we had to preserve enum valueNames (first param in enum, ((valueName)(valueDescription))
884 // You need to be careful about what you are passing here... valueName or valueDescription
885
3/3
✓ Branch 2 taken 17136 times.
✓ Branch 5 taken 17136 times.
✓ Branch 8 taken 17136 times.
17136 const std::string reportName = "BUILDING ENERGY PERFORMANCE - " + boost::algorithm::to_upper_copy(t_fuelType.valueDescription());
886 // So this gets tricky, but we have ((Gas)(Natural Gas)). We didn't want to change to ((NaturalGas)(Natural Gas))
887 // So here we take valueDescription ('Natural Gas', then remove the spaces to be NaturalGas)
888
3/3
✓ Branch 2 taken 17136 times.
✓ Branch 5 taken 17136 times.
✓ Branch 8 taken 17136 times.
34272 const std::string columnName = boost::algorithm::to_upper_copy(t_categoryType.valueName()) + ":"
889
4/4
✓ Branch 2 taken 17136 times.
✓ Branch 5 taken 17136 times.
✓ Branch 8 taken 17136 times.
✓ Branch 11 taken 17136 times.
51408 + boost::algorithm::to_upper_copy(boost::algorithm::erase_all_copy(t_fuelType.valueDescription(), " "));
890
1/1
✓ Branch 1 taken 17136 times.
17136 const std::string rowName = t_monthOfYear.valueDescription();
891
892
1/1
✓ Branch 1 taken 17136 times.
17136 const std::string& s = R"(SELECT Value FROM TabularDataWithStrings
893 WHERE ReportName=?
894 AND ReportForString='Meter'
895 AND RowName=?
896 AND ColumnName=?
897 AND Units='J')";
898
899
1/1
✓ Branch 1 taken 17136 times.
34272 return execAndReturnFirstDouble(s, reportName, rowName, columnName);
900 17136 }
901
902 ✗ boost::optional<double> SqlFile_Impl::peakEnergyDemandByMonth(const openstudio::EndUseFuelType& t_fuelType,
903 const openstudio::EndUseCategoryType& t_categoryType,
904 const openstudio::MonthOfYear& t_monthOfYear) const {
905 ✗ const std::string reportName = "BUILDING ENERGY PERFORMANCE - " + boost::algorithm::to_upper_copy(t_fuelType.valueDescription()) + " PEAK DEMAND";
906 ✗ const std::string columnName = boost::algorithm::to_upper_copy(t_categoryType.valueName()) + ":"
907 ✗ + boost::algorithm::to_upper_copy(boost::algorithm::erase_all_copy(t_fuelType.valueDescription(), " "))
908 ✗ + " {AT MAX/MIN}";
909 ✗ const std::string rowName = t_monthOfYear.valueDescription();
910
911 ✗ const std::string& s = R"(SELECT Value FROM TabularDataWithStrings
912 WHERE ReportName=?
913 AND ReportForString='Meter'
914 AND RowName=?
915 AND ColumnName=?
916 AND Units='W')";
917
918 ✗ return execAndReturnFirstDouble(s, reportName, rowName, columnName);
919 ✗ }
920
921 /// hours simulated
922 127 boost::optional<double> SqlFile_Impl::hoursSimulated() const {
923
1/1
✓ Branch 1 taken 127 times.
127 const std::string& s = R"(SELECT Value FROM TabularDataWithStrings
924 WHERE ReportName='InputVerificationandResultsSummary'
925 AND ReportForString='Entire Facility'
926 AND TableName='General'
927 AND RowName='Hours Simulated'
928 AND Units='hrs')";
929
1/1
✓ Branch 1 taken 127 times.
127 boost::optional<double> ret = execAndReturnFirstDouble(s);
930
931
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if (ret) {
932 127 return ret;
933 }
934
935 // Otherwise, let's try to calculate it:
936 ✗ return execAndReturnFirstDouble(
937 "select "
938 " (select max(t.hour + ((t.simulationdays-1) * 24)) as mintime from time t join reportmeterdata r on (t.timeindex=r.timeindex))"
939 " - (select min(t.hour + ((t.simulationdays-1) * 24)) as mintime from time t join reportmeterdata r on (t.timeindex=r.timeindex))"
940 ✗ " + 1;");
941 127 }
942
943 67 boost::optional<double> SqlFile_Impl::netSiteEnergy() const {
944
1/1
✓ Branch 1 taken 67 times.
67 boost::optional<double> hours = hoursSimulated();
945
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
67 if (!hours) {
946 ✗ LOG(Warn, "Reporting Net Site Energy with unknown number of simulation hours");
947
2/3
✓ Branch 1 taken 67 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
67 } else if (*hours != 8760) {
948 ✗ LOG(Warn, "Reporting Net Site Energy with " << *hours << " hrs");
949 }
950
951
1/1
✓ Branch 1 taken 67 times.
67 std::string s = R"(SELECT Value FROM TabularDataWithStrings
952 WHERE ReportName='AnnualBuildingUtilityPerformanceSummary'
953 AND ReportForString='Entire Facility'
954 AND TableName='Site and Source Energy'
955 AND RowName='Net Site Energy'
956 AND ColumnName='Total Energy'
957 AND Units='GJ')";
958
1/1
✓ Branch 1 taken 67 times.
67 boost::optional<double> d = execAndReturnFirstDouble(s);
959
960
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
67 if (!d) {
961 ✗ LOG(Warn, "Tabular results were not found, trying to calculate it ourselves");
962 ✗ std::string s = " \
963 select sum(VariableValue)/1000000000 from ReportMeterData, ReportMeterDataDictionary \
964 where (ReportMeterData.ReportMeterDataDictionaryIndex = ReportMeterDataDictionary.ReportMeterDataDictionaryIndex and variablename not like '%EnergyTransfer%')\
965 group by ReportingFrequency;\
966 ";
967 ✗ d = execAndReturnFirstDouble(s);
968 ✗ }
969
970 67 return d;
971 67 }
972
973 ✗ boost::optional<double> SqlFile_Impl::netSourceEnergy() const {
974 ✗ boost::optional<double> hours = hoursSimulated();
975 ✗ if (!hours) {
976 ✗ LOG(Warn, "Reporting Net Source Energy with unknown number of simulation hours");
977 ✗ } else if (*hours != 8760) {
978 ✗ LOG(Warn, "Reporting Net Source Energy with " << *hours << " hrs");
979 }
980
981 ✗ const std::string& s = R"(SELECT Value FROM TabularDataWithStrings
982 WHERE ReportName='AnnualBuildingUtilityPerformanceSummary'
983 AND ReportForString='Entire Facility'
984 AND TableName='Site and Source Energy'
985 AND RowName='Net Source Energy'
986 AND ColumnName='Total Energy'
987 AND Units='GJ')";
988 ✗ return execAndReturnFirstDouble(s);
989 ✗ }
990
991 ✗ boost::optional<double> SqlFile_Impl::totalSiteEnergy() const {
992 ✗ boost::optional<double> hours = hoursSimulated();
993 ✗ if (!hours) {
994 ✗ LOG(Warn, "Reporting Total Site Energy with unknown number of simulation hours");
995 ✗ } else if (*hours != 8760) {
996 ✗ LOG(Warn, "Reporting Total Site Energy with " << *hours << " hrs");
997 }
998
999 ✗ const std::string& s = R"(SELECT Value FROM TabularDataWithStrings
1000 WHERE ReportName='AnnualBuildingUtilityPerformanceSummary'
1001 AND ReportForString='Entire Facility'
1002 AND TableName='Site and Source Energy'
1003 AND RowName='Total Site Energy'
1004 AND ColumnName='Total Energy'
1005 AND Units='GJ')";
1006 ✗ return execAndReturnFirstDouble(s);
1007 ✗ }
1008
1009 ✗ boost::optional<double> SqlFile_Impl::totalSourceEnergy() const {
1010 ✗ boost::optional<double> hours = hoursSimulated();
1011 ✗ if (!hours) {
1012 ✗ LOG(Warn, "Reporting Total Source Energy with unknown number of simulation hours");
1013 ✗ } else if (*hours != 8760) {
1014 ✗ LOG(Warn, "Reporting Total Source Energy with " << *hours << " hrs");
1015 }
1016
1017 ✗ const std::string& s = R"(SELECT Value FROM TabularDataWithStrings
1018 WHERE ReportName='AnnualBuildingUtilityPerformanceSummary'
1019 AND ReportForString='Entire Facility'
1020 AND TableName='Site and Source Energy'
1021 AND RowName='Total Source Energy'
1022 AND ColumnName='Total Energy'
1023 AND Units='GJ')";
1024 ✗ return execAndReturnFirstDouble(s);
1025 ✗ }
1026
1027 ✗ OptionalDouble SqlFile_Impl::annualTotalCost(const FuelType& fuel) const {
1028 ✗ if (fuel == FuelType::Electricity) {
1029 ✗ return execAndReturnFirstDouble("SELECT Value from TabularDataWithStrings where (reportname = 'Economics Results Summary Report') and "
1030 "(ReportForString = 'Entire Facility') and (TableName = 'Annual Cost') and (ColumnName ='Electricity') and "
1031 ✗ "(((RowName = 'Cost') and (Units = '~~$~~')) or (RowName = 'Cost (~~$~~)'))");
1032 ✗ } else if (fuel == FuelType::Gas) {
1033 ✗ return execAndReturnFirstDouble("SELECT Value from TabularDataWithStrings where (reportname = 'Economics Results Summary Report') and "
1034 "(ReportForString = 'Entire Facility') and (TableName = 'Annual Cost') and (ColumnName ='Natural Gas') and "
1035 ✗ "(((RowName = 'Cost') and (Units = '~~$~~')) or (RowName = 'Cost (~~$~~)'))");
1036 } else {
1037 // E+ lumps all other fuel types under "Other," so we are forced to use the meters table instead.
1038 // This is fragile if there are custom submeters, but this is the only option
1039 ✗ std::string meterName = boost::to_upper_copy(fuel.valueDescription()) + ":FACILITY";
1040
1041 auto rowName = execAndReturnFirstString("SELECT RowName FROM TabularDataWithStrings WHERE ReportName='Economics Results Summary Report' AND "
1042 "ReportForString='Entire Facility' AND TableName='Tariff Summary' AND Value='"
1043 ✗ + meterName + "'");
1044 ✗ if (rowName) {
1045 ✗ return execAndReturnFirstDouble("SELECT Value FROM TabularDataWithStrings WHERE ReportName='Economics Results Summary Report' AND "
1046 "ReportForString='Entire Facility' AND TableName='Tariff Summary' AND RowName='"
1047 ✗ + rowName.get() + "' AND ColumnName='Annual Cost (~~$~~)'");
1048 } else {
1049 ✗ return boost::none; // Return an empty optional double, indicating that there is no annual cost for this energy type
1050 }
1051 ✗ }
1052 }
1053
1054 ✗ OptionalDouble SqlFile_Impl::annualTotalCostPerBldgArea(const FuelType& fuel) const {
1055 // Get the total building area
1056 ✗ boost::optional<double> totalBuildingArea = execAndReturnFirstDouble(
1057 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1058 "Facility') and (TableName = 'Building Area') and (ColumnName = 'Area') and (RowName = 'Total Building Area') and (Units = 'm2')");
1059
1060 // Get the annual energy cost
1061 ✗ boost::optional<double> annualEnergyCost = annualTotalCost(fuel);
1062
1063 // Return the cost per area
1064 ✗ boost::optional<double> costPerArea;
1065 ✗ if ((totalBuildingArea && annualEnergyCost) && (totalBuildingArea > 0.0)) {
1066 ✗ costPerArea = *annualEnergyCost / *totalBuildingArea;
1067 }
1068
1069 ✗ return costPerArea;
1070 }
1071
1072 ✗ OptionalDouble SqlFile_Impl::annualTotalCostPerNetConditionedBldgArea(const FuelType& fuel) const {
1073 // Get the total building area
1074 ✗ boost::optional<double> totalBuildingArea = execAndReturnFirstDouble(
1075 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1076 "Facility') and (TableName = 'Building Area') and (ColumnName = 'Area') and (RowName = 'Net Conditioned Building Area') and (Units = 'm2')");
1077
1078 // Get the annual energy cost
1079 ✗ boost::optional<double> annualEnergyCost = annualTotalCost(fuel);
1080
1081 // Return the cost per area
1082 ✗ boost::optional<double> costPerArea;
1083 ✗ if ((totalBuildingArea && annualEnergyCost) && (totalBuildingArea > 0.0)) {
1084 ✗ costPerArea = *annualEnergyCost / *totalBuildingArea;
1085 }
1086
1087 ✗ return costPerArea;
1088 }
1089
1090 ✗ boost::optional<double> SqlFile_Impl::annualTotalUtilityCost() const {
1091 ✗ double totalCost = 0;
1092
1093 // Loop through all fuels and add up their costs
1094 ✗ for (int i : openstudio::FuelType::getValues()) {
1095 ✗ openstudio::FuelType fuelType(i);
1096
1097 // Get the annual energy cost
1098 ✗ if (boost::optional<double> cost = annualTotalCost(fuelType)) {
1099 ✗ totalCost += *cost;
1100 }
1101 }
1102
1103 ✗ if (totalCost != 0.0) {
1104 ✗ return totalCost;
1105 }
1106
1107 ✗ return boost::none;
1108 }
1109
1110 2 std::vector<std::string> SqlFile_Impl::availableTimeSeries() {
1111 2 std::vector<std::string> vec;
1112 2 std::string timeSeriesName;
1113 2 DataDictionaryTable::index<name>::type::iterator iname;
1114
4/4
✓ Branch 3 taken 102 times.
✓ Branch 8 taken 104 times.
✓ Branch 10 taken 102 times.
✓ Branch 11 taken 2 times.
206 for (iname = m_dataDictionary.get<name>().begin(); iname != m_dataDictionary.get<name>().end(); ++iname) {
1115
2/2
✓ Branch 1 taken 102 times.
✓ Branch 4 taken 102 times.
102 timeSeriesName = (*iname).name;
1116
3/3
✓ Branch 4 taken 102 times.
✓ Branch 7 taken 38 times.
✓ Branch 8 taken 64 times.
102 if (std::find(vec.begin(), vec.end(), timeSeriesName) == vec.end()) {
1117
1/1
✓ Branch 1 taken 38 times.
38 vec.push_back(timeSeriesName);
1118 }
1119 }
1120 4 return vec;
1121 2 };
1122
1123 104 std::vector<std::string> SqlFile_Impl::availableVariableNames(const std::string& envPeriod, const std::string& reportingFrequency) const {
1124
1/1
✓ Branch 2 taken 104 times.
104 std::string queryEnvPeriod = boost::to_upper_copy(envPeriod);
1125
1126 104 std::vector<std::string> vec;
1127 104 std::string variableName;
1128 104 DataDictionaryTable::index<name>::type::iterator iname;
1129
4/4
✓ Branch 3 taken 10504 times.
✓ Branch 8 taken 10608 times.
✓ Branch 10 taken 10504 times.
✓ Branch 11 taken 104 times.
21112 for (iname = m_dataDictionary.get<name>().begin(); iname != m_dataDictionary.get<name>().end(); ++iname) {
1130
7/8
✓ Branch 1 taken 10504 times.
✓ Branch 4 taken 10504 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10504 times.
✓ Branch 10 taken 5143 times.
✓ Branch 11 taken 5361 times.
✓ Branch 12 taken 5143 times.
✓ Branch 13 taken 5361 times.
10504 if ((iname->envPeriod == queryEnvPeriod) && (iname->reportingFrequency == reportingFrequency)) {
1131
2/2
✓ Branch 1 taken 5143 times.
✓ Branch 4 taken 5143 times.
5143 variableName = iname->name;
1132
3/3
✓ Branch 4 taken 5143 times.
✓ Branch 7 taken 2134 times.
✓ Branch 8 taken 3009 times.
5143 if (std::find(vec.begin(), vec.end(), variableName) == vec.end()) {
1133
1/1
✓ Branch 1 taken 2134 times.
2134 vec.push_back(variableName);
1134 }
1135 }
1136 }
1137 208 return vec;
1138 104 }
1139
1140 107 std::vector<std::string> SqlFile_Impl::availableReportingFrequencies(const std::string& envPeriod) {
1141
1/1
✓ Branch 2 taken 107 times.
107 std::string queryEnvPeriod = boost::to_upper_copy(envPeriod);
1142
1143 107 std::vector<std::string> vec;
1144 107 std::string reportingFrequencyName;
1145 107 DataDictionaryTable::index<reportingFrequency>::type::iterator ireportingFrequency;
1146 107 for (ireportingFrequency = m_dataDictionary.get<reportingFrequency>().begin();
1147
4/4
✓ Branch 1 taken 10707 times.
✓ Branch 6 taken 10814 times.
✓ Branch 8 taken 10707 times.
✓ Branch 9 taken 107 times.
21521 ireportingFrequency != m_dataDictionary.get<reportingFrequency>().end(); ++ireportingFrequency) {
1148
2/3
✓ Branch 1 taken 10707 times.
✓ Branch 4 taken 10707 times.
✗ Branch 5 not taken.
10707 if (ireportingFrequency->envPeriod == queryEnvPeriod) {
1149
2/2
✓ Branch 1 taken 10707 times.
✓ Branch 4 taken 10707 times.
10707 reportingFrequencyName = ireportingFrequency->reportingFrequency;
1150
3/3
✓ Branch 4 taken 10707 times.
✓ Branch 7 taken 425 times.
✓ Branch 8 taken 10282 times.
10707 if (std::find(vec.begin(), vec.end(), reportingFrequencyName) == vec.end()) {
1151
1/1
✓ Branch 1 taken 425 times.
425 vec.push_back(reportingFrequencyName);
1152 }
1153 }
1154 }
1155 214 return vec;
1156 107 };
1157
1158 652 OptionalReportingFrequency SqlFile_Impl::reportingFrequencyFromDB(const std::string& dbReportingFrequency) {
1159 // EP+ version specific translation
1160 // use OPENSTUDIO_ENUM string handling
1161 try {
1162
1/1
✓ Branch 1 taken 652 times.
652 ReportingFrequency result(dbReportingFrequency);
1163
1/1
✓ Branch 1 taken 652 times.
652 return result;
1164 ✗ } catch (...) {
1165 ✗ return boost::none;
1166 ✗ }
1167 };
1168
1169 2 boost::optional<EnvironmentType> SqlFile_Impl::environmentType(const std::string& envPeriod) const {
1170 2 boost::optional<EnvironmentType> result;
1171
1/1
✓ Branch 1 taken 2 times.
2 std::string query = "SELECT EnvironmentType FROM environmentperiods WHERE EnvironmentName=? COLLATE NOCASE";
1172
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<int> temp = execAndReturnFirstInt(query, envPeriod);
1173
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (temp) {
1174 try {
1175
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 result = EnvironmentType(*temp);
1176 ✗ } catch (...) {
1177 ✗ LOG(Error, "Could not convert integer value " << *temp << " to EnvironmentType");
1178 ✗ }
1179 }
1180 4 return result;
1181 2 }
1182
1183 ✗ OptionalDouble SqlFile_Impl::economicsEnergyCost() const {
1184 ✗ return execAndReturnFirstDouble(
1185 "SELECT * from TabularDataWithStrings where (reportname = 'Economics Results Summary Report') and (ReportForString = 'Entire Facility') and "
1186 ✗ "(TableName = 'Annual Cost') and (ColumnName ='Total') and (((RowName = 'Cost') and (Units = '~~$~~')) or (RowName = 'Cost (~~$~~)'))");
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 {
1247 ✗ std::string fuelType;
1248 ✗ if (bGetGas) {
1249 ✗ fuelType = "'Natural Gas'";
1250 } else {
1251 ✗ fuelType = "'Electricity'";
1252 }
1253
1254 std::string query("select value from TabularDataWithStrings where TableName = 'Annual Cost' and (((RowName = 'Cost') and (Units = '~~$~~')) or "
1255 ✗ "(RowName = 'Cost (~~$~~)')) and ColumnName = ");
1256 ✗ query += fuelType;
1257
1258 ✗ return execAndReturnFirstDouble(query);
1259 ✗ }
1260
1261 ✗ boost::optional<EndUses> SqlFile_Impl::endUses() const {
1262 ✗ EndUses result;
1263
1264 ✗ for (EndUseFuelType fuelType : result.fuelTypes()) {
1265 ✗ std::string units = result.getUnitsForFuelType(fuelType);
1266 ✗ for (EndUseCategoryType category : result.categories()) {
1267
1268 std::string query = "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and "
1269 "(ReportForString = 'Entire Facility') and (TableName = 'End Uses' ) and (ColumnName ='"
1270 ✗ + fuelType.valueDescription() + "') and (RowName ='" + category.valueDescription() + "') and (Units = '" + units + "')";
1271
1272 ✗ boost::optional<double> value = execAndReturnFirstDouble(query);
1273 ✗ OS_ASSERT(value);
1274
1275 ✗ if (*value != 0.0) {
1276 ✗ result.addEndUse(*value, fuelType, category);
1277 }
1278 ✗ }
1279 ✗ }
1280
1281 ✗ return result;
1282 ✗ }
1283
1284 ✗ OptionalDouble SqlFile_Impl::electricityHeating() const {
1285 ✗ return execAndReturnFirstDouble(
1286 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1287 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName = 'Heating') and (Units = 'GJ')");
1288 }
1289
1290 ✗ OptionalDouble SqlFile_Impl::electricityCooling() const {
1291 ✗ return execAndReturnFirstDouble(
1292 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1293 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName = 'Cooling') and (Units = 'GJ')");
1294 }
1295
1296 ✗ OptionalDouble SqlFile_Impl::electricityInteriorLighting() const {
1297 ✗ return execAndReturnFirstDouble(
1298 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1299 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName = 'Interior Lighting') and (Units = 'GJ')");
1300 }
1301
1302 ✗ OptionalDouble SqlFile_Impl::electricityExteriorLighting() const {
1303 ✗ return execAndReturnFirstDouble(
1304 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1305 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName = 'Exterior Lighting') and (Units = 'GJ')");
1306 }
1307
1308 ✗ OptionalDouble SqlFile_Impl::electricityInteriorEquipment() const {
1309 ✗ return execAndReturnFirstDouble(
1310 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1311 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName = 'Interior Equipment') and (Units = 'GJ')");
1312 }
1313
1314 ✗ OptionalDouble SqlFile_Impl::electricityExteriorEquipment() const {
1315 ✗ return execAndReturnFirstDouble(
1316 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1317 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName = 'Exterior Equipment') and (Units = 'GJ')");
1318 }
1319
1320 ✗ OptionalDouble SqlFile_Impl::electricityFans() const {
1321 ✗ return execAndReturnFirstDouble(
1322 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1323 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName = 'Fans') and (Units = 'GJ')");
1324 }
1325
1326 ✗ OptionalDouble SqlFile_Impl::electricityPumps() const {
1327 ✗ return execAndReturnFirstDouble(
1328 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1329 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName = 'Pumps') and (Units = 'GJ')");
1330 }
1331
1332 ✗ OptionalDouble SqlFile_Impl::electricityHeatRejection() const {
1333 ✗ return execAndReturnFirstDouble(
1334 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1335 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName ='Heat Rejection') and (Units = 'GJ')");
1336 }
1337
1338 ✗ OptionalDouble SqlFile_Impl::electricityHumidification() const {
1339 ✗ return execAndReturnFirstDouble(
1340 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1341 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName = 'Humidification') and (Units = 'GJ')");
1342 }
1343
1344 ✗ OptionalDouble SqlFile_Impl::electricityHeatRecovery() const {
1345 ✗ return execAndReturnFirstDouble(
1346 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1347 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName ='Heat Recovery') and (Units = 'GJ')");
1348 }
1349
1350 ✗ OptionalDouble SqlFile_Impl::electricityWaterSystems() const {
1351 ✗ return execAndReturnFirstDouble(
1352 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1353 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName ='Water Systems') and (Units = 'GJ')");
1354 }
1355
1356 ✗ OptionalDouble SqlFile_Impl::electricityRefrigeration() const {
1357 ✗ return execAndReturnFirstDouble(
1358 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1359 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName ='Refrigeration') and (Units = 'GJ')");
1360 }
1361
1362 ✗ OptionalDouble SqlFile_Impl::electricityGenerators() const {
1363 ✗ return execAndReturnFirstDouble(
1364 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1365 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName ='Generators') and (Units = 'GJ')");
1366 }
1367
1368 ✗ OptionalDouble SqlFile_Impl::electricityTotalEndUses() const {
1369 ✗ return execAndReturnFirstDouble(
1370 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1371 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Electricity') and (RowName ='Total End Uses') and (Units = 'GJ')");
1372 }
1373
1374 ✗ OptionalDouble SqlFile_Impl::naturalGasHeating() const {
1375 ✗ return execAndReturnFirstDouble(
1376 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1377 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Heating') and (Units = 'GJ')");
1378 }
1379
1380 ✗ OptionalDouble SqlFile_Impl::naturalGasCooling() const {
1381 ✗ return execAndReturnFirstDouble(
1382 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1383 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Cooling') and (Units = 'GJ')");
1384 }
1385
1386 ✗ OptionalDouble SqlFile_Impl::naturalGasInteriorLighting() const {
1387 ✗ return execAndReturnFirstDouble(
1388 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1389 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Interior Lighting') and (Units = 'GJ')");
1390 }
1391
1392 ✗ OptionalDouble SqlFile_Impl::naturalGasExteriorLighting() const {
1393 ✗ return execAndReturnFirstDouble(
1394 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1395 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Exterior Lighting') and (Units = 'GJ')");
1396 }
1397
1398 ✗ OptionalDouble SqlFile_Impl::naturalGasInteriorEquipment() const {
1399 ✗ return execAndReturnFirstDouble(
1400 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1401 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Interior Equipment') and (Units = 'GJ')");
1402 }
1403 ✗ OptionalDouble SqlFile_Impl::naturalGasExteriorEquipment() const {
1404 ✗ return execAndReturnFirstDouble(
1405 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1406 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Exterior Equipment') and (Units = 'GJ')");
1407 }
1408
1409 ✗ OptionalDouble SqlFile_Impl::naturalGasFans() const {
1410 ✗ return execAndReturnFirstDouble(
1411 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1412 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Fans') and (Units = 'GJ')");
1413 }
1414
1415 ✗ OptionalDouble SqlFile_Impl::naturalGasPumps() const {
1416 ✗ return execAndReturnFirstDouble(
1417 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1418 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Pumps') and (Units = 'GJ')");
1419 }
1420
1421 ✗ OptionalDouble SqlFile_Impl::naturalGasHeatRejection() const {
1422 ✗ return execAndReturnFirstDouble(
1423 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1424 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Heat Rejection') and (Units = 'GJ')");
1425 }
1426
1427 ✗ OptionalDouble SqlFile_Impl::naturalGasHumidification() const {
1428 ✗ return execAndReturnFirstDouble(
1429 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1430 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Humidification') and (Units = 'GJ')");
1431 }
1432
1433 ✗ OptionalDouble SqlFile_Impl::naturalGasHeatRecovery() const {
1434 ✗ return execAndReturnFirstDouble(
1435 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1436 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Heat Recovery') and (Units = 'GJ')");
1437 }
1438
1439 ✗ OptionalDouble SqlFile_Impl::naturalGasWaterSystems() const {
1440 ✗ return execAndReturnFirstDouble(
1441 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1442 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Water Systems') and (Units = 'GJ')");
1443 }
1444
1445 ✗ OptionalDouble SqlFile_Impl::naturalGasRefrigeration() const {
1446 ✗ return execAndReturnFirstDouble(
1447 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1448 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Refrigeration') and (Units = 'GJ')");
1449 }
1450
1451 ✗ OptionalDouble SqlFile_Impl::naturalGasGenerators() const {
1452 ✗ return execAndReturnFirstDouble(
1453 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1454 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Generators') and (Units = 'GJ')");
1455 }
1456
1457 ✗ OptionalDouble SqlFile_Impl::naturalGasTotalEndUses() const {
1458 ✗ return execAndReturnFirstDouble(
1459 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1460 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Natural Gas') and (RowName ='Total End Uses') and (Units = 'GJ')");
1461 }
1462
1463 /* Gasoline */
1464 ✗ OptionalDouble SqlFile_Impl::gasolineHeating() const {
1465 ✗ return execAndReturnFirstDouble(
1466 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1467 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Heating') and (Units = 'GJ')");
1468 }
1469
1470 ✗ OptionalDouble SqlFile_Impl::gasolineCooling() const {
1471 ✗ return execAndReturnFirstDouble(
1472 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1473 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Cooling') and (Units = 'GJ')");
1474 }
1475
1476 ✗ OptionalDouble SqlFile_Impl::gasolineInteriorLighting() const {
1477 ✗ return execAndReturnFirstDouble(
1478 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1479 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Interior Lighting') and (Units = 'GJ')");
1480 }
1481
1482 ✗ OptionalDouble SqlFile_Impl::gasolineExteriorLighting() const {
1483 ✗ return execAndReturnFirstDouble(
1484 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1485 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Exterior Lighting') and (Units = 'GJ')");
1486 }
1487
1488 ✗ OptionalDouble SqlFile_Impl::gasolineInteriorEquipment() const {
1489 ✗ return execAndReturnFirstDouble(
1490 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1491 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Interior Equipment') and (Units = 'GJ')");
1492 }
1493 ✗ OptionalDouble SqlFile_Impl::gasolineExteriorEquipment() const {
1494 ✗ return execAndReturnFirstDouble(
1495 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1496 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Exterior Equipment') and (Units = 'GJ')");
1497 }
1498
1499 ✗ OptionalDouble SqlFile_Impl::gasolineFans() const {
1500 ✗ return execAndReturnFirstDouble(
1501 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1502 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Fans') and (Units = 'GJ')");
1503 }
1504
1505 ✗ OptionalDouble SqlFile_Impl::gasolinePumps() const {
1506 ✗ return execAndReturnFirstDouble(
1507 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1508 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Pumps') and (Units = 'GJ')");
1509 }
1510
1511 ✗ OptionalDouble SqlFile_Impl::gasolineHeatRejection() const {
1512 ✗ return execAndReturnFirstDouble(
1513 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1514 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Heat Rejection') and (Units = 'GJ')");
1515 }
1516
1517 ✗ OptionalDouble SqlFile_Impl::gasolineHumidification() const {
1518 ✗ return execAndReturnFirstDouble(
1519 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1520 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Humidification') and (Units = 'GJ')");
1521 }
1522
1523 ✗ OptionalDouble SqlFile_Impl::gasolineHeatRecovery() const {
1524 ✗ return execAndReturnFirstDouble(
1525 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1526 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Heat Recovery') and (Units = 'GJ')");
1527 }
1528
1529 ✗ OptionalDouble SqlFile_Impl::gasolineWaterSystems() const {
1530 ✗ return execAndReturnFirstDouble(
1531 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1532 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Water Systems') and (Units = 'GJ')");
1533 }
1534
1535 ✗ OptionalDouble SqlFile_Impl::gasolineRefrigeration() const {
1536 ✗ return execAndReturnFirstDouble(
1537 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1538 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Refrigeration') and (Units = 'GJ')");
1539 }
1540
1541 ✗ OptionalDouble SqlFile_Impl::gasolineGenerators() const {
1542 ✗ return execAndReturnFirstDouble(
1543 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1544 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Generators') and (Units = 'GJ')");
1545 }
1546
1547 ✗ OptionalDouble SqlFile_Impl::gasolineTotalEndUses() const {
1548 ✗ return execAndReturnFirstDouble(
1549 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1550 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Gasoline') and (RowName ='Total End Uses') and (Units = 'GJ')");
1551 }
1552
1553 /* Diesel */
1554 ✗ OptionalDouble SqlFile_Impl::dieselHeating() const {
1555 ✗ return execAndReturnFirstDouble(
1556 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1557 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Heating') and (Units = 'GJ')");
1558 }
1559
1560 ✗ OptionalDouble SqlFile_Impl::dieselCooling() const {
1561 ✗ return execAndReturnFirstDouble(
1562 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1563 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Cooling') and (Units = 'GJ')");
1564 }
1565
1566 ✗ OptionalDouble SqlFile_Impl::dieselInteriorLighting() const {
1567 ✗ return execAndReturnFirstDouble(
1568 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1569 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Interior Lighting') and (Units = 'GJ')");
1570 }
1571
1572 ✗ OptionalDouble SqlFile_Impl::dieselExteriorLighting() const {
1573 ✗ return execAndReturnFirstDouble(
1574 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1575 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Exterior Lighting') and (Units = 'GJ')");
1576 }
1577
1578 ✗ OptionalDouble SqlFile_Impl::dieselInteriorEquipment() const {
1579 ✗ return execAndReturnFirstDouble(
1580 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1581 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Interior Equipment') and (Units = 'GJ')");
1582 }
1583 ✗ OptionalDouble SqlFile_Impl::dieselExteriorEquipment() const {
1584 ✗ return execAndReturnFirstDouble(
1585 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1586 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Exterior Equipment') and (Units = 'GJ')");
1587 }
1588
1589 ✗ OptionalDouble SqlFile_Impl::dieselFans() const {
1590 ✗ return execAndReturnFirstDouble(
1591 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1592 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Fans') and (Units = 'GJ')");
1593 }
1594
1595 ✗ OptionalDouble SqlFile_Impl::dieselPumps() const {
1596 ✗ return execAndReturnFirstDouble(
1597 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1598 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Pumps') and (Units = 'GJ')");
1599 }
1600
1601 ✗ OptionalDouble SqlFile_Impl::dieselHeatRejection() const {
1602 ✗ return execAndReturnFirstDouble(
1603 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1604 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Heat Rejection') and (Units = 'GJ')");
1605 }
1606
1607 ✗ OptionalDouble SqlFile_Impl::dieselHumidification() const {
1608 ✗ return execAndReturnFirstDouble(
1609 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1610 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Humidification') and (Units = 'GJ')");
1611 }
1612
1613 ✗ OptionalDouble SqlFile_Impl::dieselHeatRecovery() const {
1614 ✗ return execAndReturnFirstDouble(
1615 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1616 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Heat Recovery') and (Units = 'GJ')");
1617 }
1618
1619 ✗ OptionalDouble SqlFile_Impl::dieselWaterSystems() const {
1620 ✗ return execAndReturnFirstDouble(
1621 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1622 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Water Systems') and (Units = 'GJ')");
1623 }
1624
1625 ✗ OptionalDouble SqlFile_Impl::dieselRefrigeration() const {
1626 ✗ return execAndReturnFirstDouble(
1627 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1628 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Refrigeration') and (Units = 'GJ')");
1629 }
1630
1631 ✗ OptionalDouble SqlFile_Impl::dieselGenerators() const {
1632 ✗ return execAndReturnFirstDouble(
1633 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1634 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Generators') and (Units = 'GJ')");
1635 }
1636
1637 ✗ OptionalDouble SqlFile_Impl::dieselTotalEndUses() const {
1638 ✗ return execAndReturnFirstDouble(
1639 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1640 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Diesel') and (RowName ='Total End Uses') and (Units = 'GJ')");
1641 }
1642
1643 /* Coal */
1644 ✗ OptionalDouble SqlFile_Impl::coalHeating() const {
1645 ✗ return execAndReturnFirstDouble(
1646 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1647 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Heating') and (Units = 'GJ')");
1648 }
1649
1650 ✗ OptionalDouble SqlFile_Impl::coalCooling() const {
1651 ✗ return execAndReturnFirstDouble(
1652 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1653 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Cooling') and (Units = 'GJ')");
1654 }
1655
1656 ✗ OptionalDouble SqlFile_Impl::coalInteriorLighting() const {
1657 ✗ return execAndReturnFirstDouble(
1658 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1659 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Interior Lighting') and (Units = 'GJ')");
1660 }
1661
1662 ✗ OptionalDouble SqlFile_Impl::coalExteriorLighting() const {
1663 ✗ return execAndReturnFirstDouble(
1664 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1665 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Exterior Lighting') and (Units = 'GJ')");
1666 }
1667
1668 ✗ OptionalDouble SqlFile_Impl::coalInteriorEquipment() const {
1669 ✗ return execAndReturnFirstDouble(
1670 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1671 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Interior Equipment') and (Units = 'GJ')");
1672 }
1673 ✗ OptionalDouble SqlFile_Impl::coalExteriorEquipment() const {
1674 ✗ return execAndReturnFirstDouble(
1675 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1676 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Exterior Equipment') and (Units = 'GJ')");
1677 }
1678
1679 ✗ OptionalDouble SqlFile_Impl::coalFans() const {
1680 ✗ return execAndReturnFirstDouble(
1681 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1682 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Fans') and (Units = 'GJ')");
1683 }
1684
1685 ✗ OptionalDouble SqlFile_Impl::coalPumps() const {
1686 ✗ return execAndReturnFirstDouble(
1687 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1688 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Pumps') and (Units = 'GJ')");
1689 }
1690
1691 ✗ OptionalDouble SqlFile_Impl::coalHeatRejection() const {
1692 ✗ return execAndReturnFirstDouble(
1693 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1694 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Heat Rejection') and (Units = 'GJ')");
1695 }
1696
1697 ✗ OptionalDouble SqlFile_Impl::coalHumidification() const {
1698 ✗ return execAndReturnFirstDouble(
1699 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1700 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Humidification') and (Units = 'GJ')");
1701 }
1702
1703 ✗ OptionalDouble SqlFile_Impl::coalHeatRecovery() const {
1704 ✗ return execAndReturnFirstDouble(
1705 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1706 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Heat Recovery') and (Units = 'GJ')");
1707 }
1708
1709 ✗ OptionalDouble SqlFile_Impl::coalWaterSystems() const {
1710 ✗ return execAndReturnFirstDouble(
1711 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1712 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Water Systems') and (Units = 'GJ')");
1713 }
1714
1715 ✗ OptionalDouble SqlFile_Impl::coalRefrigeration() const {
1716 ✗ return execAndReturnFirstDouble(
1717 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1718 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Refrigeration') and (Units = 'GJ')");
1719 }
1720
1721 ✗ OptionalDouble SqlFile_Impl::coalGenerators() const {
1722 ✗ return execAndReturnFirstDouble(
1723 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1724 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Generators') and (Units = 'GJ')");
1725 }
1726
1727 ✗ OptionalDouble SqlFile_Impl::coalTotalEndUses() const {
1728 ✗ return execAndReturnFirstDouble(
1729 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1730 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Coal') and (RowName ='Total End Uses') and (Units = 'GJ')");
1731 }
1732
1733 /* Fuel Oil No 1 */
1734 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1Heating() const {
1735 ✗ return execAndReturnFirstDouble(
1736 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1737 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Heating') and (Units = 'GJ')");
1738 }
1739
1740 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1Cooling() const {
1741 ✗ return execAndReturnFirstDouble(
1742 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1743 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Cooling') and (Units = 'GJ')");
1744 }
1745
1746 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1InteriorLighting() const {
1747 ✗ return execAndReturnFirstDouble(
1748 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1749 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Interior Lighting') and (Units = 'GJ')");
1750 }
1751
1752 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1ExteriorLighting() const {
1753 ✗ return execAndReturnFirstDouble(
1754 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1755 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Exterior Lighting') and (Units = 'GJ')");
1756 }
1757
1758 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1InteriorEquipment() const {
1759 ✗ return execAndReturnFirstDouble(
1760 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1761 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Interior Equipment') and (Units = 'GJ')");
1762 }
1763 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1ExteriorEquipment() const {
1764 ✗ return execAndReturnFirstDouble(
1765 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1766 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Exterior Equipment') and (Units = 'GJ')");
1767 }
1768
1769 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1Fans() const {
1770 ✗ return execAndReturnFirstDouble(
1771 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1772 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Fans') and (Units = 'GJ')");
1773 }
1774
1775 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1Pumps() const {
1776 ✗ return execAndReturnFirstDouble(
1777 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1778 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Pumps') and (Units = 'GJ')");
1779 }
1780
1781 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1HeatRejection() const {
1782 ✗ return execAndReturnFirstDouble(
1783 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1784 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Heat Rejection') and (Units = 'GJ')");
1785 }
1786
1787 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1Humidification() const {
1788 ✗ return execAndReturnFirstDouble(
1789 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1790 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Humidification') and (Units = 'GJ')");
1791 }
1792
1793 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1HeatRecovery() const {
1794 ✗ return execAndReturnFirstDouble(
1795 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1796 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Heat Recovery') and (Units = 'GJ')");
1797 }
1798
1799 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1WaterSystems() const {
1800 ✗ return execAndReturnFirstDouble(
1801 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1802 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Water Systems') and (Units = 'GJ')");
1803 }
1804
1805 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1Refrigeration() const {
1806 ✗ return execAndReturnFirstDouble(
1807 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1808 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Refrigeration') and (Units = 'GJ')");
1809 }
1810
1811 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1Generators() const {
1812 ✗ return execAndReturnFirstDouble(
1813 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1814 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Generators') and (Units = 'GJ')");
1815 }
1816
1817 ✗ OptionalDouble SqlFile_Impl::fuelOilNo1TotalEndUses() const {
1818 ✗ return execAndReturnFirstDouble(
1819 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1820 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 1') and (RowName ='Total End Uses') and (Units = 'GJ')");
1821 }
1822
1823 /* Fuel Oil No 2 */
1824 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2Heating() const {
1825 ✗ return execAndReturnFirstDouble(
1826 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1827 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Heating') and (Units = 'GJ')");
1828 }
1829
1830 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2Cooling() const {
1831 ✗ return execAndReturnFirstDouble(
1832 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1833 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Cooling') and (Units = 'GJ')");
1834 }
1835
1836 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2InteriorLighting() const {
1837 ✗ return execAndReturnFirstDouble(
1838 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1839 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Interior Lighting') and (Units = 'GJ')");
1840 }
1841
1842 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2ExteriorLighting() const {
1843 ✗ return execAndReturnFirstDouble(
1844 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1845 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Exterior Lighting') and (Units = 'GJ')");
1846 }
1847
1848 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2InteriorEquipment() const {
1849 ✗ return execAndReturnFirstDouble(
1850 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1851 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Interior Equipment') and (Units = 'GJ')");
1852 }
1853 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2ExteriorEquipment() const {
1854 ✗ return execAndReturnFirstDouble(
1855 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1856 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Exterior Equipment') and (Units = 'GJ')");
1857 }
1858
1859 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2Fans() const {
1860 ✗ return execAndReturnFirstDouble(
1861 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1862 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Fans') and (Units = 'GJ')");
1863 }
1864
1865 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2Pumps() const {
1866 ✗ return execAndReturnFirstDouble(
1867 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1868 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Pumps') and (Units = 'GJ')");
1869 }
1870
1871 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2HeatRejection() const {
1872 ✗ return execAndReturnFirstDouble(
1873 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1874 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Heat Rejection') and (Units = 'GJ')");
1875 }
1876
1877 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2Humidification() const {
1878 ✗ return execAndReturnFirstDouble(
1879 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1880 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Humidification') and (Units = 'GJ')");
1881 }
1882
1883 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2HeatRecovery() const {
1884 ✗ return execAndReturnFirstDouble(
1885 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1886 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Heat Recovery') and (Units = 'GJ')");
1887 }
1888
1889 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2WaterSystems() const {
1890 ✗ return execAndReturnFirstDouble(
1891 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1892 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Water Systems') and (Units = 'GJ')");
1893 }
1894
1895 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2Refrigeration() const {
1896 ✗ return execAndReturnFirstDouble(
1897 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1898 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Refrigeration') and (Units = 'GJ')");
1899 }
1900
1901 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2Generators() const {
1902 ✗ return execAndReturnFirstDouble(
1903 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1904 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Generators') and (Units = 'GJ')");
1905 }
1906
1907 ✗ OptionalDouble SqlFile_Impl::fuelOilNo2TotalEndUses() const {
1908 ✗ return execAndReturnFirstDouble(
1909 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1910 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Fuel Oil No 2') and (RowName ='Total End Uses') and (Units = 'GJ')");
1911 }
1912
1913 /* Propane */
1914 ✗ OptionalDouble SqlFile_Impl::propaneHeating() const {
1915 ✗ return execAndReturnFirstDouble(
1916 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1917 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Heating') and (Units = 'GJ')");
1918 }
1919
1920 ✗ OptionalDouble SqlFile_Impl::propaneCooling() const {
1921 ✗ return execAndReturnFirstDouble(
1922 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1923 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Cooling') and (Units = 'GJ')");
1924 }
1925
1926 ✗ OptionalDouble SqlFile_Impl::propaneInteriorLighting() const {
1927 ✗ return execAndReturnFirstDouble(
1928 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1929 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Interior Lighting') and (Units = 'GJ')");
1930 }
1931
1932 ✗ OptionalDouble SqlFile_Impl::propaneExteriorLighting() const {
1933 ✗ return execAndReturnFirstDouble(
1934 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1935 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Exterior Lighting') and (Units = 'GJ')");
1936 }
1937
1938 ✗ OptionalDouble SqlFile_Impl::propaneInteriorEquipment() const {
1939 ✗ return execAndReturnFirstDouble(
1940 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1941 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Interior Equipment') and (Units = 'GJ')");
1942 }
1943 ✗ OptionalDouble SqlFile_Impl::propaneExteriorEquipment() const {
1944 ✗ return execAndReturnFirstDouble(
1945 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1946 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Exterior Equipment') and (Units = 'GJ')");
1947 }
1948
1949 ✗ OptionalDouble SqlFile_Impl::propaneFans() const {
1950 ✗ return execAndReturnFirstDouble(
1951 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1952 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Fans') and (Units = 'GJ')");
1953 }
1954
1955 ✗ OptionalDouble SqlFile_Impl::propanePumps() const {
1956 ✗ return execAndReturnFirstDouble(
1957 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1958 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Pumps') and (Units = 'GJ')");
1959 }
1960
1961 ✗ OptionalDouble SqlFile_Impl::propaneHeatRejection() const {
1962 ✗ return execAndReturnFirstDouble(
1963 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1964 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Heat Rejection') and (Units = 'GJ')");
1965 }
1966
1967 ✗ OptionalDouble SqlFile_Impl::propaneHumidification() const {
1968 ✗ return execAndReturnFirstDouble(
1969 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1970 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Humidification') and (Units = 'GJ')");
1971 }
1972
1973 ✗ OptionalDouble SqlFile_Impl::propaneHeatRecovery() const {
1974 ✗ return execAndReturnFirstDouble(
1975 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1976 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Heat Recovery') and (Units = 'GJ')");
1977 }
1978
1979 ✗ OptionalDouble SqlFile_Impl::propaneWaterSystems() const {
1980 ✗ return execAndReturnFirstDouble(
1981 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1982 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Water Systems') and (Units = 'GJ')");
1983 }
1984
1985 ✗ OptionalDouble SqlFile_Impl::propaneRefrigeration() const {
1986 ✗ return execAndReturnFirstDouble(
1987 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1988 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Refrigeration') and (Units = 'GJ')");
1989 }
1990
1991 ✗ OptionalDouble SqlFile_Impl::propaneGenerators() const {
1992 ✗ return execAndReturnFirstDouble(
1993 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
1994 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Generators') and (Units = 'GJ')");
1995 }
1996
1997 ✗ OptionalDouble SqlFile_Impl::propaneTotalEndUses() const {
1998 ✗ return execAndReturnFirstDouble(
1999 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2000 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Propane') and (RowName ='Total End Uses') and (Units = 'GJ')");
2001 }
2002
2003 /* Other Fuel 1 */
2004 ✗ OptionalDouble SqlFile_Impl::otherFuel1Heating() const {
2005 ✗ return execAndReturnFirstDouble(
2006 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2007 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Heating') and (Units = 'GJ')");
2008 }
2009
2010 ✗ OptionalDouble SqlFile_Impl::otherFuel1Cooling() const {
2011 ✗ return execAndReturnFirstDouble(
2012 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2013 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Cooling') and (Units = 'GJ')");
2014 }
2015
2016 ✗ OptionalDouble SqlFile_Impl::otherFuel1InteriorLighting() const {
2017 ✗ return execAndReturnFirstDouble(
2018 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2019 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Interior Lighting') and (Units = 'GJ')");
2020 }
2021
2022 ✗ OptionalDouble SqlFile_Impl::otherFuel1ExteriorLighting() const {
2023 ✗ return execAndReturnFirstDouble(
2024 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2025 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Exterior Lighting') and (Units = 'GJ')");
2026 }
2027
2028 ✗ OptionalDouble SqlFile_Impl::otherFuel1InteriorEquipment() const {
2029 ✗ return execAndReturnFirstDouble(
2030 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2031 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Interior Equipment') and (Units = 'GJ')");
2032 }
2033 ✗ OptionalDouble SqlFile_Impl::otherFuel1ExteriorEquipment() const {
2034 ✗ return execAndReturnFirstDouble(
2035 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2036 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Exterior Equipment') and (Units = 'GJ')");
2037 }
2038
2039 ✗ OptionalDouble SqlFile_Impl::otherFuel1Fans() const {
2040 ✗ return execAndReturnFirstDouble(
2041 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2042 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Fans') and (Units = 'GJ')");
2043 }
2044
2045 ✗ OptionalDouble SqlFile_Impl::otherFuel1Pumps() const {
2046 ✗ return execAndReturnFirstDouble(
2047 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2048 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Pumps') and (Units = 'GJ')");
2049 }
2050
2051 ✗ OptionalDouble SqlFile_Impl::otherFuel1HeatRejection() const {
2052 ✗ return execAndReturnFirstDouble(
2053 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2054 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Heat Rejection') and (Units = 'GJ')");
2055 }
2056
2057 ✗ OptionalDouble SqlFile_Impl::otherFuel1Humidification() const {
2058 ✗ return execAndReturnFirstDouble(
2059 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2060 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Humidification') and (Units = 'GJ')");
2061 }
2062
2063 ✗ OptionalDouble SqlFile_Impl::otherFuel1HeatRecovery() const {
2064 ✗ return execAndReturnFirstDouble(
2065 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2066 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Heat Recovery') and (Units = 'GJ')");
2067 }
2068
2069 ✗ OptionalDouble SqlFile_Impl::otherFuel1WaterSystems() const {
2070 ✗ return execAndReturnFirstDouble(
2071 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2072 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Water Systems') and (Units = 'GJ')");
2073 }
2074
2075 ✗ OptionalDouble SqlFile_Impl::otherFuel1Refrigeration() const {
2076 ✗ return execAndReturnFirstDouble(
2077 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2078 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Refrigeration') and (Units = 'GJ')");
2079 }
2080
2081 ✗ OptionalDouble SqlFile_Impl::otherFuel1Generators() const {
2082 ✗ return execAndReturnFirstDouble(
2083 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2084 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Generators') and (Units = 'GJ')");
2085 }
2086
2087 ✗ OptionalDouble SqlFile_Impl::otherFuel1TotalEndUses() const {
2088 ✗ return execAndReturnFirstDouble(
2089 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2090 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 1') and (RowName ='Total End Uses') and (Units = 'GJ')");
2091 }
2092
2093 /* Other Fuel 2 */
2094 ✗ OptionalDouble SqlFile_Impl::otherFuel2Heating() const {
2095 ✗ return execAndReturnFirstDouble(
2096 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2097 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Heating') and (Units = 'GJ')");
2098 }
2099
2100 ✗ OptionalDouble SqlFile_Impl::otherFuel2Cooling() const {
2101 ✗ return execAndReturnFirstDouble(
2102 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2103 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Cooling') and (Units = 'GJ')");
2104 }
2105
2106 ✗ OptionalDouble SqlFile_Impl::otherFuel2InteriorLighting() const {
2107 ✗ return execAndReturnFirstDouble(
2108 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2109 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Interior Lighting') and (Units = 'GJ')");
2110 }
2111
2112 ✗ OptionalDouble SqlFile_Impl::otherFuel2ExteriorLighting() const {
2113 ✗ return execAndReturnFirstDouble(
2114 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2115 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Exterior Lighting') and (Units = 'GJ')");
2116 }
2117
2118 ✗ OptionalDouble SqlFile_Impl::otherFuel2InteriorEquipment() const {
2119 ✗ return execAndReturnFirstDouble(
2120 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2121 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Interior Equipment') and (Units = 'GJ')");
2122 }
2123 ✗ OptionalDouble SqlFile_Impl::otherFuel2ExteriorEquipment() const {
2124 ✗ return execAndReturnFirstDouble(
2125 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2126 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Exterior Equipment') and (Units = 'GJ')");
2127 }
2128
2129 ✗ OptionalDouble SqlFile_Impl::otherFuel2Fans() const {
2130 ✗ return execAndReturnFirstDouble(
2131 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2132 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Fans') and (Units = 'GJ')");
2133 }
2134
2135 ✗ OptionalDouble SqlFile_Impl::otherFuel2Pumps() const {
2136 ✗ return execAndReturnFirstDouble(
2137 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2138 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Pumps') and (Units = 'GJ')");
2139 }
2140
2141 ✗ OptionalDouble SqlFile_Impl::otherFuel2HeatRejection() const {
2142 ✗ return execAndReturnFirstDouble(
2143 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2144 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Heat Rejection') and (Units = 'GJ')");
2145 }
2146
2147 ✗ OptionalDouble SqlFile_Impl::otherFuel2Humidification() const {
2148 ✗ return execAndReturnFirstDouble(
2149 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2150 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Humidification') and (Units = 'GJ')");
2151 }
2152
2153 ✗ OptionalDouble SqlFile_Impl::otherFuel2HeatRecovery() const {
2154 ✗ return execAndReturnFirstDouble(
2155 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2156 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Heat Recovery') and (Units = 'GJ')");
2157 }
2158
2159 ✗ OptionalDouble SqlFile_Impl::otherFuel2WaterSystems() const {
2160 ✗ return execAndReturnFirstDouble(
2161 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2162 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Water Systems') and (Units = 'GJ')");
2163 }
2164
2165 ✗ OptionalDouble SqlFile_Impl::otherFuel2Refrigeration() const {
2166 ✗ return execAndReturnFirstDouble(
2167 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2168 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Refrigeration') and (Units = 'GJ')");
2169 }
2170
2171 ✗ OptionalDouble SqlFile_Impl::otherFuel2Generators() const {
2172 ✗ return execAndReturnFirstDouble(
2173 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2174 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Generators') and (Units = 'GJ')");
2175 }
2176
2177 ✗ OptionalDouble SqlFile_Impl::otherFuel2TotalEndUses() const {
2178 ✗ return execAndReturnFirstDouble(
2179 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2180 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Other Fuel 2') and (RowName ='Total End Uses') and (Units = 'GJ')");
2181 }
2182
2183 ✗ OptionalDouble SqlFile_Impl::districtCoolingHeating() const {
2184 ✗ return execAndReturnFirstDouble(
2185 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2186 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Heating') and (Units = 'GJ')");
2187 }
2188
2189 ✗ OptionalDouble SqlFile_Impl::districtCoolingCooling() const {
2190 ✗ return execAndReturnFirstDouble(
2191 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2192 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Cooling') and (Units = 'GJ')");
2193 }
2194
2195 ✗ OptionalDouble SqlFile_Impl::districtCoolingInteriorLighting() const {
2196 ✗ return execAndReturnFirstDouble(
2197 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2198 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Interior Lighting') and (Units = 'GJ')");
2199 }
2200
2201 ✗ OptionalDouble SqlFile_Impl::districtCoolingExteriorLighting() const {
2202 ✗ return execAndReturnFirstDouble(
2203 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2204 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Exterior Lighting') and (Units = 'GJ')");
2205 }
2206
2207 ✗ OptionalDouble SqlFile_Impl::districtCoolingInteriorEquipment() const {
2208 ✗ return execAndReturnFirstDouble(
2209 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2210 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Interior Equipment') and (Units = 'GJ')");
2211 }
2212
2213 ✗ OptionalDouble SqlFile_Impl::districtCoolingExteriorEquipment() const {
2214 ✗ return execAndReturnFirstDouble(
2215 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2216 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Exterior Equipment') and (Units = 'GJ')");
2217 }
2218
2219 ✗ OptionalDouble SqlFile_Impl::districtCoolingFans() const {
2220 ✗ return execAndReturnFirstDouble(
2221 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2222 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Fans') and (Units = 'GJ')");
2223 }
2224
2225 ✗ OptionalDouble SqlFile_Impl::districtCoolingPumps() const {
2226 ✗ return execAndReturnFirstDouble(
2227 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2228 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Pumps') and (Units = 'GJ')");
2229 }
2230
2231 ✗ OptionalDouble SqlFile_Impl::districtCoolingHeatRejection() const {
2232 ✗ return execAndReturnFirstDouble(
2233 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2234 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Heat Rejection') and (Units = 'GJ')");
2235 }
2236
2237 ✗ OptionalDouble SqlFile_Impl::districtCoolingHumidification() const {
2238 ✗ return execAndReturnFirstDouble(
2239 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2240 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Humidification') and (Units = 'GJ')");
2241 }
2242
2243 ✗ OptionalDouble SqlFile_Impl::districtCoolingHeatRecovery() const {
2244 ✗ return execAndReturnFirstDouble(
2245 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2246 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Heat Recovery') and (Units = 'GJ')");
2247 }
2248
2249 ✗ OptionalDouble SqlFile_Impl::districtCoolingWaterSystems() const {
2250 ✗ return execAndReturnFirstDouble(
2251 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2252 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Water Systems') and (Units = 'GJ')");
2253 }
2254
2255 ✗ OptionalDouble SqlFile_Impl::districtCoolingRefrigeration() const {
2256 ✗ return execAndReturnFirstDouble(
2257 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2258 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Refrigeration') and (Units = 'GJ')");
2259 }
2260
2261 ✗ OptionalDouble SqlFile_Impl::districtCoolingGenerators() const {
2262 ✗ return execAndReturnFirstDouble(
2263 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2264 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Generators') and (Units = 'GJ')");
2265 }
2266
2267 ✗ OptionalDouble SqlFile_Impl::districtCoolingTotalEndUses() const {
2268 ✗ return execAndReturnFirstDouble(
2269 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2270 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Cooling') and (RowName ='Total End Uses') and (Units = 'GJ')");
2271 }
2272
2273 ✗ OptionalDouble addTwoOptionalDoubles(OptionalDouble val1_, OptionalDouble val2_) {
2274 ✗ const bool hasVal1 = val1_.has_value();
2275 ✗ const bool hasVal2 = val2_.has_value();
2276 ✗ if (hasVal1 && hasVal2) {
2277 ✗ return *val1_ + *val2_;
2278 ✗ } else if (hasVal1) {
2279 ✗ return *val1_;
2280 ✗ } else if (hasVal2) {
2281 ✗ return *val2_;
2282 }
2283 ✗ return boost::none;
2284 }
2285
2286 ✗ OptionalDouble SqlFile_Impl::districtHeatingHeating() const {
2287 ✗ return addTwoOptionalDoubles(districtHeatingWaterHeating(), districtHeatingSteamHeating());
2288 }
2289
2290 ✗ OptionalDouble SqlFile_Impl::districtHeatingCooling() const {
2291 ✗ return addTwoOptionalDoubles(districtHeatingWaterCooling(), districtHeatingSteamCooling());
2292 }
2293
2294 ✗ OptionalDouble SqlFile_Impl::districtHeatingInteriorLighting() const {
2295 ✗ return addTwoOptionalDoubles(districtHeatingWaterInteriorLighting(), districtHeatingSteamInteriorLighting());
2296 }
2297
2298 ✗ OptionalDouble SqlFile_Impl::districtHeatingExteriorLighting() const {
2299 ✗ return addTwoOptionalDoubles(districtHeatingWaterExteriorLighting(), districtHeatingSteamExteriorLighting());
2300 }
2301
2302 ✗ OptionalDouble SqlFile_Impl::districtHeatingInteriorEquipment() const {
2303 ✗ return addTwoOptionalDoubles(districtHeatingWaterInteriorEquipment(), districtHeatingSteamInteriorEquipment());
2304 }
2305
2306 ✗ OptionalDouble SqlFile_Impl::districtHeatingExteriorEquipment() const {
2307 ✗ return addTwoOptionalDoubles(districtHeatingWaterExteriorEquipment(), districtHeatingSteamExteriorEquipment());
2308 }
2309
2310 ✗ OptionalDouble SqlFile_Impl::districtHeatingFans() const {
2311 ✗ return addTwoOptionalDoubles(districtHeatingWaterFans(), districtHeatingSteamFans());
2312 }
2313
2314 ✗ OptionalDouble SqlFile_Impl::districtHeatingPumps() const {
2315 ✗ return addTwoOptionalDoubles(districtHeatingWaterPumps(), districtHeatingSteamPumps());
2316 }
2317
2318 ✗ OptionalDouble SqlFile_Impl::districtHeatingHeatRejection() const {
2319 ✗ return addTwoOptionalDoubles(districtHeatingWaterHeatRejection(), districtHeatingSteamHeatRejection());
2320 }
2321
2322 ✗ OptionalDouble SqlFile_Impl::districtHeatingHumidification() const {
2323 ✗ return addTwoOptionalDoubles(districtHeatingWaterHumidification(), districtHeatingSteamHumidification());
2324 }
2325
2326 ✗ OptionalDouble SqlFile_Impl::districtHeatingHeatRecovery() const {
2327 ✗ return addTwoOptionalDoubles(districtHeatingWaterHeatRecovery(), districtHeatingSteamHeatRecovery());
2328 }
2329
2330 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterSystems() const {
2331 ✗ return addTwoOptionalDoubles(districtHeatingWaterWaterSystems(), districtHeatingSteamWaterSystems());
2332 }
2333
2334 ✗ OptionalDouble SqlFile_Impl::districtHeatingRefrigeration() const {
2335 ✗ return addTwoOptionalDoubles(districtHeatingWaterRefrigeration(), districtHeatingSteamRefrigeration());
2336 }
2337
2338 ✗ OptionalDouble SqlFile_Impl::districtHeatingGenerators() const {
2339 ✗ return addTwoOptionalDoubles(districtHeatingWaterGenerators(), districtHeatingSteamGenerators());
2340 }
2341
2342 ✗ OptionalDouble SqlFile_Impl::districtHeatingTotalEndUses() const {
2343 ✗ return addTwoOptionalDoubles(districtHeatingWaterTotalEndUses(), districtHeatingSteamTotalEndUses());
2344 }
2345
2346 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterHeating() const {
2347 ✗ return execAndReturnFirstDouble(
2348 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2349 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Heating') and (Units = 'GJ')");
2350 }
2351
2352 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterCooling() const {
2353 ✗ return execAndReturnFirstDouble(
2354 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2355 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Cooling') and (Units = 'GJ')");
2356 }
2357
2358 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterInteriorLighting() const {
2359 ✗ return execAndReturnFirstDouble(
2360 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2361 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Interior Lights') and (Units = 'GJ')");
2362 }
2363
2364 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterExteriorLighting() const {
2365 ✗ return execAndReturnFirstDouble(
2366 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2367 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Exterior Lights') and (Units = 'GJ')");
2368 }
2369
2370 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterInteriorEquipment() const {
2371 ✗ return execAndReturnFirstDouble(
2372 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2373 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Interior Equipment') and (Units = 'GJ')");
2374 }
2375
2376 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterExteriorEquipment() const {
2377 ✗ return execAndReturnFirstDouble(
2378 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2379 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Exterior Equipment') and (Units = 'GJ')");
2380 }
2381
2382 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterFans() const {
2383 ✗ return execAndReturnFirstDouble(
2384 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2385 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Fans') and (Units = 'GJ')");
2386 }
2387
2388 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterPumps() const {
2389 ✗ return execAndReturnFirstDouble(
2390 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2391 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Pumps') and (Units = 'GJ')");
2392 }
2393
2394 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterHeatRejection() const {
2395 ✗ return execAndReturnFirstDouble(
2396 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2397 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Heat Rejection') and (Units = 'GJ')");
2398 }
2399
2400 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterHumidification() const {
2401 ✗ return execAndReturnFirstDouble(
2402 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2403 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Humidification') and (Units = 'GJ')");
2404 }
2405
2406 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterHeatRecovery() const {
2407 ✗ return execAndReturnFirstDouble(
2408 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2409 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Heat Recovery') and (Units = 'GJ')");
2410 }
2411
2412 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterWaterSystems() const {
2413 ✗ return execAndReturnFirstDouble(
2414 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2415 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Water Systems') and (Units = 'GJ')");
2416 }
2417
2418 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterRefrigeration() const {
2419 ✗ return execAndReturnFirstDouble(
2420 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2421 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Refrigeration') and (Units = 'GJ')");
2422 }
2423
2424 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterGenerators() const {
2425 ✗ return execAndReturnFirstDouble(
2426 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2427 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Generators') and (Units = 'GJ')");
2428 }
2429
2430 ✗ OptionalDouble SqlFile_Impl::districtHeatingWaterTotalEndUses() const {
2431 ✗ return execAndReturnFirstDouble(
2432 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2433 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Water') and (RowName ='Total End Uses') and (Units = 'GJ')");
2434 }
2435
2436 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamHeating() const {
2437 ✗ return execAndReturnFirstDouble(
2438 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2439 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Heating') and (Units = 'GJ')");
2440 }
2441
2442 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamCooling() const {
2443 ✗ return execAndReturnFirstDouble(
2444 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2445 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Cooling') and (Units = 'GJ')");
2446 }
2447
2448 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamInteriorLighting() const {
2449 ✗ return execAndReturnFirstDouble(
2450 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2451 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Interior Lights') and (Units = 'GJ')");
2452 }
2453
2454 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamExteriorLighting() const {
2455 ✗ return execAndReturnFirstDouble(
2456 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2457 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Exterior Lights') and (Units = 'GJ')");
2458 }
2459
2460 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamInteriorEquipment() const {
2461 ✗ return execAndReturnFirstDouble(
2462 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2463 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Interior Equipment') and (Units = 'GJ')");
2464 }
2465
2466 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamExteriorEquipment() const {
2467 ✗ return execAndReturnFirstDouble(
2468 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2469 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Exterior Equipment') and (Units = 'GJ')");
2470 }
2471
2472 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamFans() const {
2473 ✗ return execAndReturnFirstDouble(
2474 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2475 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Fans') and (Units = 'GJ')");
2476 }
2477
2478 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamPumps() const {
2479 ✗ return execAndReturnFirstDouble(
2480 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2481 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Pumps') and (Units = 'GJ')");
2482 }
2483
2484 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamHeatRejection() const {
2485 ✗ return execAndReturnFirstDouble(
2486 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2487 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Heat Rejection') and (Units = 'GJ')");
2488 }
2489
2490 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamHumidification() const {
2491 ✗ return execAndReturnFirstDouble(
2492 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2493 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Humidification') and (Units = 'GJ')");
2494 }
2495
2496 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamHeatRecovery() const {
2497 ✗ return execAndReturnFirstDouble(
2498 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2499 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Heat Recovery') and (Units = 'GJ')");
2500 }
2501
2502 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamWaterSystems() const {
2503 ✗ return execAndReturnFirstDouble(
2504 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2505 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Water Systems') and (Units = 'GJ')");
2506 }
2507
2508 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamRefrigeration() const {
2509 ✗ return execAndReturnFirstDouble(
2510 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2511 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Refrigeration') and (Units = 'GJ')");
2512 }
2513
2514 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamGenerators() const {
2515 ✗ return execAndReturnFirstDouble(
2516 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2517 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Generators') and (Units = 'GJ')");
2518 }
2519
2520 ✗ OptionalDouble SqlFile_Impl::districtHeatingSteamTotalEndUses() const {
2521 ✗ return execAndReturnFirstDouble(
2522 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2523 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='District Heating Steam') and (RowName ='Total End Uses') and (Units = 'GJ')");
2524 }
2525
2526 ✗ OptionalDouble SqlFile_Impl::waterHeating() const {
2527 ✗ return execAndReturnFirstDouble(
2528 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2529 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Heating') and (Units = 'm3')");
2530 }
2531
2532 ✗ OptionalDouble SqlFile_Impl::waterCooling() const {
2533 ✗ return execAndReturnFirstDouble(
2534 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2535 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Cooling') and (Units = 'm3')");
2536 }
2537
2538 ✗ OptionalDouble SqlFile_Impl::waterInteriorLighting() const {
2539 ✗ return execAndReturnFirstDouble(
2540 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2541 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Interior Lighting') and (Units = 'm3')");
2542 }
2543
2544 ✗ OptionalDouble SqlFile_Impl::waterExteriorLighting() const {
2545 ✗ return execAndReturnFirstDouble(
2546 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2547 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Exterior Lighting') and (Units = 'm3')");
2548 }
2549
2550 ✗ OptionalDouble SqlFile_Impl::waterInteriorEquipment() const {
2551 ✗ return execAndReturnFirstDouble(
2552 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2553 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Interior Equipment') and (Units = 'm3')");
2554 }
2555
2556 ✗ OptionalDouble SqlFile_Impl::waterExteriorEquipment() const {
2557 ✗ return execAndReturnFirstDouble(
2558 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2559 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Exterior Equipment') and (Units = 'm3')");
2560 }
2561
2562 ✗ OptionalDouble SqlFile_Impl::waterFans() const {
2563 ✗ return execAndReturnFirstDouble(
2564 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2565 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Fans') and (Units = 'm3')");
2566 }
2567
2568 ✗ OptionalDouble SqlFile_Impl::waterPumps() const {
2569 ✗ return execAndReturnFirstDouble(
2570 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2571 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Pumps') and (Units = 'm3')");
2572 }
2573
2574 ✗ OptionalDouble SqlFile_Impl::waterHeatRejection() const {
2575 ✗ return execAndReturnFirstDouble(
2576 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2577 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Heat Rejection') and (Units = 'm3')");
2578 }
2579
2580 ✗ OptionalDouble SqlFile_Impl::waterHumidification() const {
2581 ✗ return execAndReturnFirstDouble(
2582 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2583 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Humidification') and (Units = 'm3')");
2584 }
2585
2586 ✗ OptionalDouble SqlFile_Impl::waterHeatRecovery() const {
2587 ✗ return execAndReturnFirstDouble(
2588 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2589 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Heat Recovery') and (Units = 'm3')");
2590 }
2591
2592 ✗ OptionalDouble SqlFile_Impl::waterWaterSystems() const {
2593 ✗ return execAndReturnFirstDouble(
2594 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2595 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Water Systems') and (Units = 'm3')");
2596 }
2597
2598 ✗ OptionalDouble SqlFile_Impl::waterRefrigeration() const {
2599 ✗ return execAndReturnFirstDouble(
2600 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2601 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Refrigeration') and (Units = 'm3')");
2602 }
2603
2604 ✗ OptionalDouble SqlFile_Impl::waterGenerators() const {
2605 ✗ return execAndReturnFirstDouble(
2606 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2607 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Generators') and (Units = 'm3')");
2608 }
2609
2610 ✗ OptionalDouble SqlFile_Impl::waterTotalEndUses() const {
2611 ✗ return execAndReturnFirstDouble(
2612 "SELECT Value from TabularDataWithStrings where (reportname = 'AnnualBuildingUtilityPerformanceSummary') and (ReportForString = 'Entire "
2613 ✗ "Facility') and (TableName = 'End Uses' ) and (ColumnName ='Water') and (RowName ='Total End Uses') and (Units = 'm3')");
2614 }
2615
2616 ✗ OptionalDouble SqlFile_Impl::hoursHeatingSetpointNotMet() const {
2617 ✗ return execAndReturnFirstDouble(
2618 "SELECT Value FROM TabularDataWithStrings WHERE (ReportName='SystemSummary') AND (ReportForString='Entire Facility') AND (TableName='Time "
2619 ✗ "Setpoint Not Met') AND (RowName = 'Facility') AND (ColumnName='During Heating') AND (Units = 'hr')");
2620 }
2621
2622 ✗ OptionalDouble SqlFile_Impl::hoursCoolingSetpointNotMet() const {
2623 ✗ return execAndReturnFirstDouble(
2624 "SELECT Value FROM TabularDataWithStrings WHERE (ReportName='SystemSummary') AND (ReportForString='Entire Facility') AND (TableName='Time "
2625 ✗ "Setpoint Not Met') AND (RowName = 'Facility') AND (ColumnName='During Cooling') AND (Units = 'hr')");
2626 }
2627
2628 38 std::vector<std::string> SqlFile_Impl::availableEnvPeriods() const {
2629 38 std::vector<std::string> vec;
2630 38 std::string envPeriodName;
2631 38 DataDictionaryTable::index<envPeriod>::type::iterator ienvPeriod;
2632
4/4
✓ Branch 3 taken 3099 times.
✓ Branch 8 taken 3137 times.
✓ Branch 10 taken 3099 times.
✓ Branch 11 taken 38 times.
6236 for (ienvPeriod = m_dataDictionary.get<envPeriod>().begin(); ienvPeriod != m_dataDictionary.get<envPeriod>().end(); ++ienvPeriod) {
2633
2/2
✓ Branch 1 taken 3099 times.
✓ Branch 4 taken 3099 times.
3099 envPeriodName = ienvPeriod->envPeriod;
2634
3/3
✓ Branch 4 taken 3099 times.
✓ Branch 7 taken 96 times.
✓ Branch 8 taken 3003 times.
3099 if (std::find(vec.begin(), vec.end(), envPeriodName) == vec.end()) {
2635
1/1
✓ Branch 1 taken 96 times.
96 vec.push_back(envPeriodName);
2636 }
2637 }
2638 76 return vec;
2639 38 }
2640
2641 1 std::vector<std::string> SqlFile_Impl::availableKeyValues(const std::string& envPeriod, const std::string& reportingFrequency,
2642 const std::string& timeSeriesName) {
2643
1/1
✓ Branch 2 taken 1 time.
1 std::string queryEnvPeriod = boost::to_upper_copy(envPeriod);
2644
2645 1 std::vector<std::string> vec;
2646 1 std::string keyValueName;
2647 1 DataDictionaryTable::index<keyValue>::type::iterator ikeyValue;
2648
4/4
✓ Branch 3 taken 1 time.
✓ Branch 8 taken 2 times.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 1 time.
3 for (ikeyValue = m_dataDictionary.get<keyValue>().begin(); ikeyValue != m_dataDictionary.get<keyValue>().end(); ++ikeyValue) {
2649
7/11
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 time.
✗ Branch 19 not taken.
1 if ((ikeyValue->envPeriod == queryEnvPeriod) && (ikeyValue->reportingFrequency == reportingFrequency) && (ikeyValue->name == timeSeriesName)) {
2650
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 keyValueName = ikeyValue->keyValue;
2651
2/3
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
1 if (std::find(vec.begin(), vec.end(), keyValueName) == vec.end()) {
2652
1/1
✓ Branch 1 taken 1 time.
1 vec.push_back(keyValueName);
2653 }
2654 }
2655 }
2656 2 return vec;
2657 1 }
2658
2659 ✗ openstudio::TimeSeriesVector SqlFile_Impl::timeSeries(const std::string& envPeriod, const std::string& reportingFrequency,
2660 const std::string& timeSeriesName) {
2661
2662 ✗ openstudio::TimeSeriesVector vec;
2663 ✗ openstudio::OptionalTimeSeries ts;
2664
2665 ✗ std::vector<std::string> vecKeyValues = availableKeyValues(envPeriod, reportingFrequency, timeSeriesName);
2666 ✗ std::vector<std::string>::iterator iter;
2667 ✗ for (iter = vecKeyValues.begin(); iter != vecKeyValues.end(); ++iter) {
2668 ✗ ts = timeSeries(envPeriod, reportingFrequency, timeSeriesName, *iter);
2669 ✗ if (ts) {
2670 ✗ vec.push_back(*ts);
2671 }
2672 }
2673 ✗ return vec;
2674 ✗ }
2675
2676 ✗ boost::optional<double> SqlFile_Impl::runPeriodValue(const std::string& envPeriod, const std::string& timeSeriesName, const std::string& keyValue) {
2677 ✗ std::string queryEnvPeriod = boost::to_upper_copy(envPeriod);
2678
2679 DataDictionaryTable::index<envPeriodReportingFrequencyNameKeyValue>::type::iterator iEpRfNKv =
2680 ✗ m_dataDictionary.get<envPeriodReportingFrequencyNameKeyValue>().find(
2681 ✗ boost::make_tuple(queryEnvPeriod, ReportingFrequency(ReportingFrequency::RunPeriod).valueName(), timeSeriesName, keyValue));
2682
2683 ✗ if (iEpRfNKv == m_dataDictionary.get<envPeriodReportingFrequencyNameKeyValue>().end()) {
2684 ✗ return {};
2685 }
2686
2687 ✗ std::stringstream s;
2688 ✗ s << "SELECT VariableValue FROM ";
2689 ✗ s << iEpRfNKv->table;
2690 ✗ s << " INNER JOIN Time t ON .TimeIndex = t.TimeIndex";
2691 // s << " INNER JOIN EnvironmentPeriods ep ON ep.EnvironmentPeriodIndex = t.EnvironmentPeriodIndex";
2692 ✗ if (iEpRfNKv->table == "ReportMeterData") {
2693 ✗ s << " WHERE ReportMeterDataDictionaryIndex=";
2694 ✗ } else if (iEpRfNKv->table == "ReportVariableData") {
2695 ✗ s << " WHERE ReportVariableDataDictionaryIndex=";
2696 }
2697 ✗ s << boost::lexical_cast<std::string>(iEpRfNKv->recordIndex);
2698 // s << " AND ep.EnvironmentName=";
2699 // s << "'" << envPeriod << "'";
2700 ✗ s << " AND t.EnvironmentPeriodIndex=";
2701 ✗ s << boost::lexical_cast<std::string>(iEpRfNKv->envPeriodIndex);
2702
2703 ✗ return execAndReturnFirstDouble(s.str());
2704 ✗ }
2705
2706 ✗ std::vector<double> SqlFile_Impl::timeSeriesValues(const DataDictionaryItem& dataDictionary) {
2707 ✗ std::vector<double> stdValues;
2708
2709 ✗ if (m_db) {
2710 ✗ std::stringstream s;
2711 ✗ s << "SELECT VariableValue FROM ";
2712 ✗ s << dataDictionary.table;
2713 // ensure that there are time indice values for variablevalues (slows from 0.094s to 0.125s)
2714 ✗ s << " rvd INNER JOIN Time ti ON ti.TimeIndex = rvd.TimeIndex";
2715 // s << " INNER JOIN EnvironmentPeriods ep ON ti.EnvironmentPeriodIndex = ep.EnvironmentPeriodIndex";
2716 ✗ if (dataDictionary.table == "ReportMeterData") {
2717 ✗ s << " WHERE rvd.ReportMeterDataDictionaryIndex=";
2718 ✗ } else if (dataDictionary.table == "ReportVariableData") {
2719 ✗ s << " WHERE rvd.ReportVariableDataDictionaryIndex=";
2720 }
2721 ✗ s << boost::lexical_cast<std::string>(dataDictionary.recordIndex);
2722 // s << " AND ep.EnvironmentName = ";
2723 // s << "'" << dataDictionary.envPeriod << "'";
2724 ✗ s << " AND ti.EnvironmentPeriodIndex = ";
2725 ✗ s << boost::lexical_cast<std::string>(dataDictionary.envPeriodIndex);
2726 // assume that timeindices.timeIndex are ordered from start to end
2727 // s << " ORDER BY ti.TimeIndex";
2728
2729 sqlite3_stmt* sqlStmtPtr;
2730
2731 ✗ int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
2732
2733 ✗ code = sqlite3_step(sqlStmtPtr);
2734 ✗ std::stringstream s2;
2735 ✗ s2 << "SQL Query:" << '\n';
2736 ✗ s2 << s.str();
2737 ✗ s2 << "Return Code:" << '\n';
2738 ✗ s2 << code;
2739 ✗ LOG(Debug, s2.str());
2740 ✗ while (code == SQLITE_ROW) {
2741 ✗ stdValues.push_back(sqlite3_column_double(sqlStmtPtr, 0)); // values
2742
2743 ✗ code = sqlite3_step(sqlStmtPtr);
2744 }
2745 ✗ sqlite3_finalize(sqlStmtPtr);
2746 ✗ }
2747
2748 ✗ LOG(Debug, "Created Timeseries with " << stdValues.size() << " values");
2749
2750 ✗ return stdValues;
2751 ✗ }
2752
2753 ✗ openstudio::OptionalDate SqlFile_Impl::timeSeriesStartDate(const DataDictionaryItem& dataDictionary) {
2754 ✗ boost::optional<unsigned> year;
2755 ✗ unsigned int day = 1;
2756 ✗ unsigned int month = 1;
2757 ✗ if (m_db) {
2758 ✗ std::stringstream s;
2759 ✗ s << "SELECT ";
2760 ✗ if (hasYear()) {
2761 ✗ s << "ti.Year, ";
2762 }
2763 ✗ s << "ti.Month, ti.Day from ";
2764 ✗ s << dataDictionary.table;
2765 ✗ s << " rvd INNER JOIN Time ti on ti.TimeIndex = rvd.TimeIndex";
2766 ✗ if (dataDictionary.table == "ReportMeterData") {
2767 ✗ s << " WHERE rvd.ReportMeterDataDictionaryIndex=";
2768 ✗ } else if (dataDictionary.table == "ReportVariableData") {
2769 ✗ s << " WHERE rvd.ReportVariableDataDictionaryIndex=";
2770 }
2771 ✗ s << boost::lexical_cast<std::string>(dataDictionary.recordIndex);
2772 ✗ s << " AND ti.EnvironmentPeriodIndex=";
2773 ✗ s << boost::lexical_cast<std::string>(dataDictionary.envPeriodIndex);
2774
2775 sqlite3_stmt* sqlStmtPtr;
2776 ✗ int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
2777
2778 ✗ code = sqlite3_step(sqlStmtPtr);
2779 ✗ if (code == SQLITE_ROW) {
2780 ✗ int b = 0;
2781 ✗ if (hasYear()) {
2782 ✗ year = sqlite3_column_int(sqlStmtPtr, b++);
2783 }
2784 ✗ month = sqlite3_column_int(sqlStmtPtr, b++);
2785 ✗ day = sqlite3_column_int(sqlStmtPtr, b++);
2786 }
2787 ✗ sqlite3_finalize(sqlStmtPtr);
2788 ✗ }
2789 try {
2790 // DLM@20100707: RunPeriod timeseries return month=0, day=0.
2791 // what is a sensible value to put here? is this a bug in E+?
2792 // DLM: potential leap year problem
2793 ✗ if (year) {
2794 ✗ return openstudio::Date(openstudio::monthOfYear(month), day, *year);
2795 } else {
2796 ✗ return openstudio::Date(openstudio::monthOfYear(month), day);
2797 }
2798 ✗ } catch (...) {
2799 //return min date in time table.
2800 ✗ std::stringstream s;
2801 ✗ s << "SELECT Month, Day, Hour from Time where TimeIndex in (";
2802 ✗ s << "SELECT min(timeIndex) FROM time )";
2803 sqlite3_stmt* sqlStmtPtr;
2804 ✗ int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
2805
2806 ✗ code = sqlite3_step(sqlStmtPtr);
2807 ✗ if (code == SQLITE_ROW) {
2808 ✗ month = sqlite3_column_int(sqlStmtPtr, 0);
2809 ✗ day = sqlite3_column_int(sqlStmtPtr, 1);
2810 }
2811 ✗ sqlite3_finalize(sqlStmtPtr);
2812
2813 // DLM: potential leap year problem
2814 ✗ return openstudio::Date(openstudio::monthOfYear(month), day);
2815 ✗ }
2816 }
2817
2818 ✗ openstudio::OptionalTime SqlFile_Impl::timeSeriesInterval(const DataDictionaryItem& dataDictionary) {
2819 ✗ OptionalReportingFrequency freq = reportingFrequencyFromDB(dataDictionary.reportingFrequency);
2820 ✗ if (!freq) {
2821 ✗ return boost::none;
2822 }
2823
2824 ✗ double minutes = 0;
2825 ✗ switch (freq->value()) {
2826 ✗ case ReportingFrequency::Detailed:
2827 // unsupported
2828 ✗ return boost::none;
2829 break;
2830 ✗ case ReportingFrequency::Timestep:
2831 // unsupported
2832 ✗ return boost::none;
2833 break;
2834 ✗ case ReportingFrequency::Hourly:
2835 // unsupported - warmup days - see trac #236
2836 ✗ return boost::none;
2837 // return boost::optional<openstudio::Time>(openstudio::Time(0,1,0,0));
2838 break;
2839 ✗ case ReportingFrequency::Daily:
2840 ✗ return boost::optional<openstudio::Time>(openstudio::Time(1, 0, 0, 0));
2841 break;
2842 ✗ case ReportingFrequency::Monthly:
2843 // unsupported
2844 ✗ return boost::none;
2845 break;
2846 ✗ case ReportingFrequency::RunPeriod:
2847 // return boost::optional<openstudio::Time>();
2848 ✗ if (m_db) {
2849 ✗ std::stringstream s;
2850 ✗ s << "SELECT Interval from Time where TimeIndex in (";
2851 ✗ s << "SELECT min(ti.timeIndex) FROM ";
2852 ✗ s << dataDictionary.table;
2853 ✗ s << " rvd INNER JOIN Time ti on ti.TimeIndex = rvd.TimeIndex";
2854 ✗ if (dataDictionary.table == "ReportMeterData") {
2855 ✗ s << " WHERE rvd.ReportMeterDataDictionaryIndex=";
2856 ✗ } else if (dataDictionary.table == "ReportVariableData") {
2857 ✗ s << " WHERE rvd.ReportVariableDataDictionaryIndex=";
2858 }
2859 ✗ s << boost::lexical_cast<std::string>(dataDictionary.recordIndex);
2860 ✗ s << " AND ti.EnvironmentPeriodIndex=";
2861 ✗ s << boost::lexical_cast<std::string>(dataDictionary.envPeriodIndex);
2862 ✗ s << ")";
2863
2864 sqlite3_stmt* sqlStmtPtr;
2865 ✗ int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
2866
2867 ✗ code = sqlite3_step(sqlStmtPtr);
2868 ✗ if (code == SQLITE_ROW) {
2869 ✗ minutes = sqlite3_column_double(sqlStmtPtr, 0);
2870 }
2871 ✗ sqlite3_finalize(sqlStmtPtr);
2872 ✗ }
2873 // minutes - 1 to remove starting minute
2874 ✗ return boost::optional<openstudio::Time>(openstudio::Time(0, 0, int(std::ceil(minutes - 1.0)), 0));
2875 break;
2876 ✗ default:
2877 // unsupported
2878 ✗ return boost::none;
2879 break;
2880 }
2881 ✗ }
2882
2883 1 openstudio::DateTime SqlFile_Impl::firstDateTime(bool includeHourAndMinute, int envPeriodIndex) {
2884 // default until added to eplusout.sql from energy plus
2885 1 boost::optional<unsigned> year;
2886 1 unsigned month = 1;
2887 1 unsigned day = 1;
2888 1 unsigned hour = 1;
2889 1 unsigned minute = 0;
2890
2891
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (m_db) {
2892
1/1
✓ Branch 1 taken 1 time.
1 std::stringstream s;
2893
1/1
✓ Branch 1 taken 1 time.
1 s << "SELECT ";
2894
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 if (hasYear()) {
2895 ✗ s << "Year, ";
2896 }
2897
1/1
✓ Branch 1 taken 1 time.
1 s << "Month, Day, Hour, Minute from Time where Month is not NULL and Day is not null and EnvironmentPeriodIndex = " << envPeriodIndex
2898
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 << " LIMIT 1";
2899
2900 sqlite3_stmt* sqlStmtPtr;
2901
2/2
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
1 int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
2902
2903
1/1
✓ Branch 1 taken 1 time.
1 code = sqlite3_step(sqlStmtPtr);
2904
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (code == SQLITE_ROW) {
2905 1 int b = 0;
2906
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 if (hasYear()) {
2907 ✗ year = sqlite3_column_int(sqlStmtPtr, b++);
2908 }
2909
1/1
✓ Branch 1 taken 1 time.
1 month = sqlite3_column_int(sqlStmtPtr, b++);
2910
1/1
✓ Branch 1 taken 1 time.
1 day = sqlite3_column_int(sqlStmtPtr, b++);
2911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (includeHourAndMinute) {
2912 ✗ hour = sqlite3_column_int(sqlStmtPtr, b++);
2913 ✗ minute = sqlite3_column_int(sqlStmtPtr, b++);
2914 } else {
2915 1 hour = 1;
2916 1 minute = 0;
2917 }
2918 }
2919
1/1
✓ Branch 1 taken 1 time.
1 sqlite3_finalize(sqlStmtPtr);
2920 1 }
2921
2922 // Note JM 2019-03-14: Starting with E+ v8.9.0, we actually have Year in the SQL file
2923 // So if we can, we use the actual year, otherwise we initialze with defaults
2924 // and let the Date Ctor figure out the assumed year
2925
3/7
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 12 taken 1 time.
✓ Branch 15 taken 1 time.
1 openstudio::Date date = year ? Date(monthOfYear(month), day, *year) : Date(monthOfYear(month), day);
2926
2927 // DLM: get standard time zone?
2928
1/1
✓ Branch 1 taken 1 time.
1 openstudio::Time time(0, hour, minute, 0);
2929
2930
1/1
✓ Branch 1 taken 1 time.
2 return openstudio::DateTime(date, time);
2931 }
2932
2933 46 openstudio::DateTime SqlFile_Impl::lastDateTime(bool includeHourAndMinute, int envPeriodIndex) {
2934 // default until added to eplusout.sql from energy plus
2935 46 boost::optional<unsigned> year;
2936 46 unsigned month = 1;
2937 46 unsigned day = 1;
2938 46 unsigned hour = 1;
2939 46 unsigned minute = 0;
2940
2941
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if (m_db) {
2942
1/1
✓ Branch 1 taken 46 times.
46 std::stringstream s;
2943
1/1
✓ Branch 1 taken 46 times.
46 s << "SELECT ";
2944
3/3
✓ Branch 1 taken 46 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 14 times.
46 if (hasYear()) {
2945
1/1
✓ Branch 1 taken 32 times.
32 s << "Year, ";
2946 }
2947
1/1
✓ Branch 1 taken 46 times.
46 s << "Month, Day, Hour, Minute from Time where Month is not NULL and Day is not null and EnvironmentPeriodIndex = " << envPeriodIndex
2948
2/2
✓ Branch 1 taken 46 times.
✓ Branch 4 taken 46 times.
46 << " order by TimeIndex DESC LIMIT 1";
2949
2950 sqlite3_stmt* sqlStmtPtr;
2951
2/2
✓ Branch 1 taken 46 times.
✓ Branch 5 taken 46 times.
46 int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
2952
2953
1/1
✓ Branch 1 taken 46 times.
46 code = sqlite3_step(sqlStmtPtr);
2954
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if (code == SQLITE_ROW) {
2955 46 int b = 0;
2956
3/3
✓ Branch 1 taken 46 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 14 times.
46 if (hasYear()) {
2957
2/2
✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
32 year = sqlite3_column_int(sqlStmtPtr, b++);
2958 }
2959
1/1
✓ Branch 1 taken 46 times.
46 month = sqlite3_column_int(sqlStmtPtr, b++);
2960
1/1
✓ Branch 1 taken 46 times.
46 day = sqlite3_column_int(sqlStmtPtr, b++);
2961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if (includeHourAndMinute) {
2962 ✗ hour = sqlite3_column_int(sqlStmtPtr, b++);
2963 ✗ minute = sqlite3_column_int(sqlStmtPtr, b++);
2964 } else {
2965 46 hour = 24;
2966 46 minute = 0;
2967 }
2968 }
2969
1/1
✓ Branch 1 taken 46 times.
46 sqlite3_finalize(sqlStmtPtr);
2970 46 }
2971
2972 // Note JM 2019-03-14: Starting with E+ v8.9.0, we actually have Year in the SQL file
2973 // So if we can, we use the actual year, otherwise we initialze with defaults
2974 // and let the Date Ctor figure out the assumed year
2975
7/7
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 14 times.
✓ Branch 3 taken 32 times.
✓ Branch 6 taken 32 times.
✓ Branch 9 taken 32 times.
✓ Branch 12 taken 14 times.
✓ Branch 15 taken 14 times.
46 openstudio::Date date = year ? Date(monthOfYear(month), day, *year) : Date(monthOfYear(month), day);
2976
2977 // DLM: get standard time zone?
2978
1/1
✓ Branch 1 taken 46 times.
46 openstudio::Time time(0, hour, minute, 0);
2979
2980
1/1
✓ Branch 1 taken 46 times.
92 return openstudio::DateTime(date, time);
2981 }
2982
2983 196 openstudio::OptionalTimeSeries SqlFile_Impl::timeSeries(const DataDictionaryItem& dataDictionary) {
2984 196 openstudio::OptionalTimeSeries ts;
2985
1/1
✓ Branch 1 taken 196 times.
196 std::string units = dataDictionary.units;
2986
2987 196 boost::optional<openstudio::DateTime> firstReportDateTime;
2988 196 std::vector<long> stdSecondsFromFirstReport;
2989
1/1
✓ Branch 1 taken 196 times.
196 stdSecondsFromFirstReport.reserve(8760);
2990
2991 196 std::vector<double> stdValues;
2992
1/1
✓ Branch 1 taken 196 times.
196 stdValues.reserve(8760);
2993 196 boost::optional<unsigned> reportingIntervalMinutes;
2994
2995
1/1
✓ Branch 1 taken 196 times.
196 ReportingFrequency reportingFrequency(ReportingFrequency::RunPeriod);
2996 196 bool isIntervalTimeSeries = false;
2997 try {
2998
1/1
✓ Branch 1 taken 196 times.
196 reportingFrequency = ReportingFrequency(dataDictionary.reportingFrequency);
2999
4/4
✓ Branch 1 taken 196 times.
✓ Branch 5 taken 167 times.
✓ Branch 8 taken 134 times.
✓ Branch 9 taken 33 times.
363 isIntervalTimeSeries = (reportingFrequency == ReportingFrequency::Timestep) || (reportingFrequency == ReportingFrequency::Hourly)
3000
5/5
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 29 times.
✓ Branch 3 taken 134 times.
✓ Branch 6 taken 29 times.
✓ Branch 7 taken 105 times.
363 || (reportingFrequency == ReportingFrequency::Daily);
3001
3002 ✗ } catch (const std::exception&) {
3003 ✗ }
3004
3005
1/2
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
196 if (m_db) {
3006
1/1
✓ Branch 1 taken 196 times.
196 std::string energyPlusVersion = this->energyPlusVersion();
3007
1/1
✓ Branch 1 taken 196 times.
196 VersionString version(energyPlusVersion);
3008
3009
1/1
✓ Branch 1 taken 196 times.
196 std::stringstream s;
3010 // v8.9.0 added the 'Year' field
3011
1/1
✓ Branch 1 taken 196 times.
196 s << "SELECT dt.VariableValue, ";
3012
3/3
✓ Branch 1 taken 196 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 79 times.
196 if (hasYear()) {
3013
1/1
✓ Branch 1 taken 117 times.
117 s << "Time.Year, ";
3014 }
3015 s << "Time.Month, Time.Day, "
3016 // << "Time.Hour, Time.Minute, "
3017
2/2
✓ Branch 1 taken 196 times.
✓ Branch 4 taken 196 times.
196 << "Time.Interval FROM ";
3018
1/1
✓ Branch 1 taken 196 times.
196 s << dataDictionary.table;
3019
1/1
✓ Branch 1 taken 196 times.
196 s << " dt INNER JOIN Time ON Time.timeIndex = dt.TimeIndex";
3020
1/1
✓ Branch 1 taken 196 times.
196 s << " WHERE ";
3021
3/3
✓ Branch 1 taken 196 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 195 times.
196 if (dataDictionary.table == "ReportMeterData") {
3022
1/1
✓ Branch 1 taken 1 time.
1 s << " dt.ReportMeterDataDictionaryIndex=";
3023
2/3
✓ Branch 1 taken 195 times.
✓ Branch 3 taken 195 times.
✗ Branch 4 not taken.
195 } else if (dataDictionary.table == "ReportVariableData") {
3024
1/1
✓ Branch 1 taken 195 times.
195 s << " dt.ReportVariableDataDictionaryIndex=";
3025 }
3026
2/2
✓ Branch 1 taken 196 times.
✓ Branch 4 taken 196 times.
196 s << boost::lexical_cast<std::string>(dataDictionary.recordIndex);
3027
1/1
✓ Branch 1 taken 196 times.
196 s << " AND Time.EnvironmentPeriodIndex = ";
3028
2/2
✓ Branch 1 taken 196 times.
✓ Branch 4 taken 196 times.
196 s << boost::lexical_cast<std::string>(dataDictionary.envPeriodIndex);
3029
3030 sqlite3_stmt* sqlStmtPtr;
3031
3032
2/2
✓ Branch 1 taken 196 times.
✓ Branch 5 taken 196 times.
196 int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
3033
3034
1/1
✓ Branch 1 taken 196 times.
196 code = sqlite3_step(sqlStmtPtr);
3035
1/1
✓ Branch 1 taken 196 times.
196 std::stringstream s2;
3036
2/2
✓ Branch 1 taken 196 times.
✓ Branch 4 taken 196 times.
196 s2 << "SQL Query:" << '\n';
3037
2/2
✓ Branch 1 taken 196 times.
✓ Branch 4 taken 196 times.
196 s2 << s.str();
3038
2/2
✓ Branch 1 taken 196 times.
✓ Branch 4 taken 196 times.
196 s2 << "Return Code:" << '\n';
3039
1/1
✓ Branch 1 taken 196 times.
196 s2 << code;
3040
6/6
✓ Branch 1 taken 196 times.
✓ Branch 4 taken 196 times.
✓ Branch 7 taken 196 times.
✓ Branch 11 taken 196 times.
✓ Branch 14 taken 196 times.
✓ Branch 17 taken 196 times.
196 LOG(Debug, s2.str());
3041
3042 196 long cumulativeSeconds = 0;
3043
3044
2/2
✓ Branch 0 taken 3374823 times.
✓ Branch 1 taken 196 times.
3375019 while (code == SQLITE_ROW) {
3045 3374823 int b = 0;
3046
1/1
✓ Branch 1 taken 3374823 times.
3374823 double value = sqlite3_column_double(sqlStmtPtr, b++);
3047
1/1
✓ Branch 1 taken 3374823 times.
3374823 stdValues.push_back(value);
3048
3049 3374823 boost::optional<unsigned> year;
3050
3/3
✓ Branch 1 taken 3374823 times.
✓ Branch 3 taken 1889468 times.
✓ Branch 4 taken 1485355 times.
3374823 if (hasYear()) {
3051
2/2
✓ Branch 1 taken 1889468 times.
✓ Branch 4 taken 1889468 times.
1889468 year = sqlite3_column_int(sqlStmtPtr, b++);
3052 // As of EnergyPlus 9.4 and perhaps earlier, the anual run periods will have a valid year,
3053 // however the sizing periods will have year = 0
3054
3/3
✓ Branch 1 taken 1889468 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 1889452 times.
1889468 if (year.get() == 0) {
3055 16 year.reset();
3056 }
3057 }
3058
3059
1/1
✓ Branch 1 taken 3374823 times.
3374823 unsigned month = sqlite3_column_int(sqlStmtPtr, b++);
3060
1/1
✓ Branch 1 taken 3374823 times.
3374823 unsigned day = sqlite3_column_int(sqlStmtPtr, b++);
3061
3062 // In cases where you report the same meter key for eg at Daily and at Timestep frequency
3063 // the intervalMinutes will be reported by E+ for the Timestep one, so you get the wrong one for Daily...
3064 // And since we can compute this easily, might as well do it
3065 unsigned intervalMinutes;
3066
3/3
✓ Branch 1 taken 3374823 times.
✓ Branch 4 taken 280324 times.
✓ Branch 5 taken 3094499 times.
3374823 if (reportingFrequency == ReportingFrequency::Hourly) {
3067 280324 intervalMinutes = 60;
3068
3/3
✓ Branch 1 taken 3094499 times.
✓ Branch 4 taken 10585 times.
✓ Branch 5 taken 3083914 times.
3094499 } else if (reportingFrequency == ReportingFrequency::Daily) {
3069 10585 intervalMinutes = 24 * 60;
3070
3/3
✓ Branch 1 taken 3083914 times.
✓ Branch 4 taken 348 times.
✓ Branch 5 taken 3083566 times.
3083914 } else if (reportingFrequency == ReportingFrequency::Monthly) {
3071 348 intervalMinutes = day * 24 * 60;
3072 } else {
3073 // If Detailed, Timestep, RunPeriod, or Annual: it varies
3074
1/1
✓ Branch 1 taken 3083566 times.
3083566 intervalMinutes = sqlite3_column_int(sqlStmtPtr, b); // Notice I'm not incrementing the counter here on purpose
3075
3076
3/3
✓ Branch 1 taken 3083566 times.
✓ Branch 4 taken 17 times.
✓ Branch 5 taken 3083549 times.
3083566 if (reportingFrequency == ReportingFrequency::Annual) {
3077 // Annual actually reports blank for Month, Day, Minute **and Interval** up to 9.3.0 at least
3078 // We cannot let it be zero (when blank), since it will make the firstReportDateTime creation fail below
3079 // cf https://github.com/NREL/EnergyPlus/issues/7939
3080
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if (intervalMinutes == 0) {
3081 17 intervalMinutes = 365 * 24 * 60;
3082 ✗ } else if ((intervalMinutes != 365 * 24 * 60) && (intervalMinutes != 366 * 24 * 60)) {
3083 // Issue a Debug log, but retain value. Technically Annual reports on 12/31, regardless of when the start date was
3084 ✗ LOG(Debug, "For an 'Annual' frequency, intervalMinutes (= " << intervalMinutes << ") doesn't correspond to 365 or 366 days");
3085 }
3086 }
3087 }
3088 // Don't forget to increment the counter anyway, no matter whether we did call sqlite3_column_int or not
3089 3374823 ++b;
3090
3091
8/8
✓ Branch 1 taken 3374823 times.
✓ Branch 3 taken 1142581 times.
✓ Branch 4 taken 2232242 times.
✓ Branch 6 taken 1142581 times.
✓ Branch 8 taken 114258 times.
✓ Branch 9 taken 1028323 times.
✓ Branch 10 taken 114258 times.
✓ Branch 11 taken 3260565 times.
3374823 if ((version.major() == 8) && (version.minor() == 3)) {
3092 // workaround for bug in E+ 8.3, issue #1692
3093
3/3
✓ Branch 1 taken 114258 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 114257 times.
114258 if (reportingFrequency == ReportingFrequency::RunPeriod) {
3094
1/1
✓ Branch 1 taken 1 time.
1 DateTime firstDateTime = this->firstDateTime(false, dataDictionary.envPeriodIndex);
3095
1/1
✓ Branch 1 taken 1 time.
1 DateTime lastDateTime = this->lastDateTime(false, dataDictionary.envPeriodIndex);
3096
1/1
✓ Branch 1 taken 1 time.
1 Time deltaT = lastDateTime - firstDateTime;
3097
1/1
✓ Branch 1 taken 1 time.
1 intervalMinutes = (unsigned)deltaT.totalMinutes() + 60;
3098 }
3099 }
3100
3101
2/2
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 3374627 times.
3374823 if (!firstReportDateTime) {
3102
3/4
✓ Branch 0 taken 151 times.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 151 times.
196 if ((month == 0) || (day == 0)) {
3103 // gets called for RunPeriod reports
3104
2/2
✓ Branch 1 taken 45 times.
✓ Branch 4 taken 45 times.
45 firstReportDateTime = lastDateTime(false, dataDictionary.envPeriodIndex);
3105 } else {
3106 // DLM: get standard time zone?
3107
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 92 times.
151 if (intervalMinutes >= 24 * 60) {
3108 // Daily or Monthly
3109
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 3 not taken.
59 OS_ASSERT(intervalMinutes % (24 * 60) == 0);
3110
8/8
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 27 times.
✓ Branch 3 taken 32 times.
✓ Branch 6 taken 32 times.
✓ Branch 9 taken 32 times.
✓ Branch 12 taken 32 times.
✓ Branch 15 taken 32 times.
✓ Branch 18 taken 27 times.
86 firstReportDateTime = year ? openstudio::DateTime(openstudio::Date(month, day, *year), openstudio::Time(1, 0, 0, 0))
3111
4/4
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
✓ Branch 7 taken 27 times.
✓ Branch 10 taken 59 times.
86 : openstudio::DateTime(openstudio::Date(month, day), openstudio::Time(1, 0, 0, 0));
3112 } else {
3113
8/8
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 39 times.
✓ Branch 3 taken 53 times.
✓ Branch 6 taken 53 times.
✓ Branch 9 taken 53 times.
✓ Branch 12 taken 53 times.
✓ Branch 15 taken 53 times.
✓ Branch 18 taken 39 times.
131 firstReportDateTime = year ? openstudio::DateTime(openstudio::Date(month, day, *year), openstudio::Time(0, 0, intervalMinutes, 0))
3114
4/4
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
✓ Branch 7 taken 39 times.
✓ Branch 10 taken 92 times.
131 : openstudio::DateTime(openstudio::Date(month, day), openstudio::Time(0, 0, intervalMinutes, 0));
3115 }
3116 }
3117 }
3118
3119 // Use the new way to create the time series with nonzero first entry
3120 3374823 cumulativeSeconds += 60 * intervalMinutes;
3121
1/1
✓ Branch 1 taken 3374823 times.
3374823 stdSecondsFromFirstReport.push_back(cumulativeSeconds);
3122
3123 // check if this interval is same as the others
3124
6/6
✓ Branch 0 taken 1815149 times.
✓ Branch 1 taken 1559674 times.
✓ Branch 3 taken 91 times.
✓ Branch 4 taken 1815058 times.
✓ Branch 5 taken 91 times.
✓ Branch 6 taken 3374732 times.
3374823 if (isIntervalTimeSeries && !reportingIntervalMinutes) {
3125
1/1
✓ Branch 1 taken 91 times.
91 reportingIntervalMinutes = intervalMinutes;
3126
5/7
✓ Branch 0 taken 1815058 times.
✓ Branch 1 taken 1559674 times.
✓ Branch 3 taken 1815058 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1815058 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3374732 times.
3374732 } else if (reportingIntervalMinutes && (reportingIntervalMinutes.get() != intervalMinutes)) {
3127 ✗ isIntervalTimeSeries = false;
3128 ✗ reportingIntervalMinutes.reset();
3129 }
3130
3131 // step to next row
3132
1/1
✓ Branch 1 taken 3374823 times.
3374823 code = sqlite3_step(sqlStmtPtr);
3133 }
3134
3135 // must finalize to prevent memory leaks
3136
1/1
✓ Branch 1 taken 196 times.
196 sqlite3_finalize(sqlStmtPtr);
3137
3138
3/6
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 196 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 196 times.
✗ Branch 6 not taken.
196 if (firstReportDateTime && !stdSecondsFromFirstReport.empty()) {
3139
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 105 times.
196 if (isIntervalTimeSeries) {
3140
2/2
✓ Branch 1 taken 91 times.
✓ Branch 4 taken 91 times.
91 openstudio::Time intervalTime(0, 0, *reportingIntervalMinutes, 0);
3141
1/1
✓ Branch 1 taken 91 times.
91 openstudio::Vector values = createVector(stdValues);
3142
3/3
✓ Branch 1 taken 91 times.
✓ Branch 4 taken 91 times.
✓ Branch 7 taken 91 times.
91 ts = openstudio::TimeSeries(*firstReportDateTime, intervalTime, values, units);
3143 91 } else {
3144
1/1
✓ Branch 1 taken 105 times.
105 openstudio::Vector values = createVector(stdValues);
3145
3/3
✓ Branch 1 taken 105 times.
✓ Branch 4 taken 105 times.
✓ Branch 7 taken 105 times.
105 ts = openstudio::TimeSeries(*firstReportDateTime, stdSecondsFromFirstReport, values, units);
3146 105 }
3147 }
3148 196 }
3149
3150 392 return ts;
3151 196 }
3152
3153 ✗ openstudio::DateTimeVector SqlFile_Impl::dateTimeVec(const DataDictionaryItem& dataDictionary) {
3154 ✗ openstudio::DateTimeVector dateTimes;
3155
3156 ✗ if (m_db) {
3157 ✗ std::stringstream s;
3158 ✗ s << "SELECT ";
3159 ✗ if (hasYear()) {
3160 ✗ s << "Time.Year, ";
3161 }
3162 ✗ s << "Time.Month, Time.Day, Time.Hour, Time.Minute, Time.Dst FROM ";
3163 ✗ s << dataDictionary.table;
3164 ✗ s << " dt INNER JOIN Time ON Time.TimeIndex = dt.TimeIndex";
3165 ✗ s << " WHERE ";
3166 ✗ if (dataDictionary.table == "ReportMeterData") {
3167 ✗ s << " dt.ReportMeterDataDictionaryIndex=";
3168 ✗ } else if (dataDictionary.table == "ReportVariableData") {
3169 ✗ s << " dt.ReportVariableDataDictionaryIndex=";
3170 }
3171 ✗ s << boost::lexical_cast<std::string>(dataDictionary.recordIndex);
3172 ✗ s << " AND Time.EnvironmentPeriodIndex = ";
3173 ✗ s << boost::lexical_cast<std::string>(dataDictionary.envPeriodIndex);
3174
3175 sqlite3_stmt* sqlStmtPtr;
3176
3177 ✗ int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
3178
3179 ✗ code = sqlite3_step(sqlStmtPtr);
3180 ✗ std::stringstream s2;
3181 ✗ s2 << "SQL Query:" << '\n';
3182 ✗ s2 << s.str() << '\n';
3183 ✗ s2 << "Return Code:" << '\n';
3184 ✗ s2 << code;
3185 ✗ LOG(Debug, s2.str());
3186 ✗ while (code == SQLITE_ROW) {
3187 ✗ boost::optional<unsigned> year;
3188 unsigned month;
3189 unsigned day;
3190 unsigned hour;
3191 unsigned minute; //, simulationDay;
3192
3193 ✗ int b = 0;
3194 ✗ if (hasYear()) {
3195 ✗ year = sqlite3_column_int(sqlStmtPtr, b++);
3196 }
3197 ✗ month = sqlite3_column_int(sqlStmtPtr, b++);
3198 ✗ day = sqlite3_column_int(sqlStmtPtr, b++);
3199 ✗ hour = sqlite3_column_int(sqlStmtPtr, b++);
3200 ✗ minute = sqlite3_column_int(sqlStmtPtr, b++);
3201
3202 // Note JM 2019-03-14: E+ v8.9.0 added Year
3203 ✗ openstudio::Date date = year ? openstudio::Date(monthOfYear(month), day, *year) : openstudio::Date(monthOfYear(month), day);
3204 // DLM: get standard time zone?
3205
3206 ✗ openstudio::DateTime dateTime(date, openstudio::Time(0, hour, minute, 0));
3207 ✗ dateTimes.push_back(dateTime);
3208
3209 // step to next row
3210 ✗ code = sqlite3_step(sqlStmtPtr);
3211 }
3212 // must finalize to prevent memory leaks
3213 ✗ sqlite3_finalize(sqlStmtPtr);
3214 ✗ }
3215
3216 ✗ return dateTimes;
3217 ✗ }
3218
3219 1276 openstudio::OptionalTimeSeries SqlFile_Impl::timeSeries(const std::string& envPeriod, const std::string& reportingFrequency,
3220 const std::string& timeSeriesName, const std::string& keyValue) {
3221 //std::string queryEnvPeriod = envPeriod;
3222
1/1
✓ Branch 2 taken 1276 times.
1276 std::string queryEnvPeriod = boost::to_upper_copy(envPeriod);
3223
3224
13/13
✓ Branch 1 taken 1276 times.
✓ Branch 4 taken 1276 times.
✓ Branch 7 taken 1276 times.
✓ Branch 10 taken 1276 times.
✓ Branch 13 taken 1276 times.
✓ Branch 16 taken 1276 times.
✓ Branch 19 taken 1276 times.
✓ Branch 22 taken 1276 times.
✓ Branch 25 taken 1276 times.
✓ Branch 28 taken 1276 times.
✓ Branch 31 taken 1276 times.
✓ Branch 34 taken 1276 times.
✓ Branch 37 taken 1276 times.
1276 LOG(Debug, "Making time series for envPeriod = '" << queryEnvPeriod << "', reportingFrequency = '" << reportingFrequency
3225 << "', timeSeriesName = '" << timeSeriesName << "', keyValue = '" << keyValue << "'");
3226
3227 1276 openstudio::OptionalTimeSeries ts;
3228 DataDictionaryTable::index<envPeriodReportingFrequencyNameKeyValue>::type::iterator iEpRfNKv =
3229
1/1
✓ Branch 2 taken 1276 times.
2552 m_dataDictionary.get<envPeriodReportingFrequencyNameKeyValue>().find(
3230
1/1
✓ Branch 1 taken 1276 times.
2552 boost::make_tuple(queryEnvPeriod, reportingFrequency, timeSeriesName, keyValue));
3231
3232
3/3
✓ Branch 3 taken 1276 times.
✓ Branch 5 taken 633 times.
✓ Branch 6 taken 643 times.
1276 if (iEpRfNKv == m_dataDictionary.get<envPeriodReportingFrequencyNameKeyValue>().end()) {
3233 // not found
3234
13/13
✓ Branch 1 taken 633 times.
✓ Branch 4 taken 633 times.
✓ Branch 7 taken 633 times.
✓ Branch 10 taken 633 times.
✓ Branch 13 taken 633 times.
✓ Branch 16 taken 633 times.
✓ Branch 19 taken 633 times.
✓ Branch 22 taken 633 times.
✓ Branch 25 taken 633 times.
✓ Branch 28 taken 633 times.
✓ Branch 31 taken 633 times.
✓ Branch 34 taken 633 times.
✓ Branch 37 taken 633 times.
633 LOG(Debug, "Tuple: " << queryEnvPeriod << ", " << reportingFrequency << ", " << timeSeriesName << ", " << keyValue
3235 << " not found in data dictionary.");
3236
3237 // DLM: this is not optimal, we should be making the find on the data dictionary case insensitive or using
3238 // the functionality of mf_makeConsistent(std::vector<SqlFileTimeSeriesQuery>& queries)
3239
1/1
✓ Branch 2 taken 633 times.
633 std::string upperKeyValue = boost::to_upper_copy(keyValue);
3240
2/2
✓ Branch 1 taken 348 times.
✓ Branch 2 taken 285 times.
633 if (upperKeyValue != keyValue) {
3241
12/12
✓ Branch 1 taken 348 times.
✓ Branch 4 taken 348 times.
✓ Branch 7 taken 348 times.
✓ Branch 10 taken 348 times.
✓ Branch 13 taken 348 times.
✓ Branch 16 taken 348 times.
✓ Branch 19 taken 348 times.
✓ Branch 22 taken 348 times.
✓ Branch 25 taken 348 times.
✓ Branch 28 taken 348 times.
✓ Branch 31 taken 348 times.
✓ Branch 34 taken 348 times.
348 LOG(Debug, "Trying query: " << queryEnvPeriod << ", " << reportingFrequency << ", " << timeSeriesName << ", " << upperKeyValue);
3242
1/1
✓ Branch 1 taken 348 times.
348 ts = timeSeries(queryEnvPeriod, reportingFrequency, timeSeriesName, upperKeyValue);
3243 }
3244
3245
2/2
✓ Branch 1 taken 314 times.
✓ Branch 2 taken 319 times.
633 if (!ts) {
3246
16/26
✓ Branch 1 taken 314 times.
✓ Branch 4 taken 314 times.
✓ Branch 6 taken 290 times.
✓ Branch 7 taken 24 times.
✓ Branch 9 taken 290 times.
✓ Branch 12 taken 290 times.
✓ Branch 14 taken 58 times.
✓ Branch 15 taken 232 times.
✓ Branch 16 taken 290 times.
✓ Branch 17 taken 24 times.
✓ Branch 19 taken 290 times.
✓ Branch 20 taken 24 times.
✓ Branch 21 taken 314 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 314 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 232 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
1522 if (istringEqual("Annual", reportingFrequency) || istringEqual("Environment", reportingFrequency)) {
3247
12/12
✓ Branch 1 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 10 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 34 taken 82 times.
82 LOG(Debug, "Trying query: " << queryEnvPeriod << ", " << "Run Period" << ", " << timeSeriesName << ", " << upperKeyValue);
3248
2/2
✓ Branch 1 taken 82 times.
✓ Branch 4 taken 82 times.
164 ts = timeSeries(queryEnvPeriod, "Run Period", timeSeriesName, keyValue);
3249 }
3250 }
3251
3252
2/2
✓ Branch 1 taken 232 times.
✓ Branch 2 taken 401 times.
633 if (!ts) {
3253
1/1
✓ Branch 1 taken 232 times.
232 openstudio::OptionalReportingFrequency freq = reportingFrequencyFromDB(reportingFrequency);
3254
1/2
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
232 if (freq) {
3255
4/4
✓ Branch 1 taken 232 times.
✓ Branch 4 taken 232 times.
✓ Branch 8 taken 174 times.
✓ Branch 9 taken 58 times.
232 if (reportingFrequency != freq->valueDescription()) {
3256
14/14
✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
✓ Branch 7 taken 174 times.
✓ Branch 10 taken 174 times.
✓ Branch 13 taken 174 times.
✓ Branch 16 taken 174 times.
✓ Branch 19 taken 174 times.
✓ Branch 22 taken 174 times.
✓ Branch 25 taken 174 times.
✓ Branch 28 taken 174 times.
✓ Branch 31 taken 174 times.
✓ Branch 35 taken 174 times.
✓ Branch 38 taken 174 times.
✓ Branch 41 taken 174 times.
174 LOG(Debug, "Trying query: " << queryEnvPeriod << ", " << freq->valueDescription() << ", " << timeSeriesName << ", " << upperKeyValue);
3257
3/3
✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
✓ Branch 7 taken 174 times.
174 ts = timeSeries(queryEnvPeriod, freq->valueDescription(), timeSeriesName, keyValue);
3258 }
3259 }
3260 232 }
3261
3262
5/5
✓ Branch 2 taken 643 times.
✓ Branch 5 taken 643 times.
✓ Branch 8 taken 643 times.
✓ Branch 11 taken 447 times.
✓ Branch 12 taken 196 times.
1276 } else if (!iEpRfNKv->timeSeries.values().empty()) {
3263
2/2
✓ Branch 1 taken 447 times.
✓ Branch 4 taken 447 times.
447 ts = iEpRfNKv->timeSeries;
3264 } else { // lazy caching
3265
2/2
✓ Branch 1 taken 196 times.
✓ Branch 4 taken 196 times.
196 DataDictionaryItem ddi = *iEpRfNKv;
3266
5/5
✓ Branch 1 taken 196 times.
✓ Branch 4 taken 196 times.
✓ Branch 7 taken 196 times.
✓ Branch 10 taken 196 times.
✓ Branch 13 taken 196 times.
196 LOG(Debug, ddi.envPeriod);
3267
5/5
✓ Branch 1 taken 196 times.
✓ Branch 4 taken 196 times.
✓ Branch 7 taken 196 times.
✓ Branch 10 taken 196 times.
✓ Branch 13 taken 196 times.
196 LOG(Debug, ddi.name);
3268
1/1
✓ Branch 1 taken 196 times.
196 ts = timeSeries(ddi);
3269
1/2
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
196 if (ts) {
3270
1/1
✓ Branch 1 taken 196 times.
196 ddi.timeSeries = *ts;
3271
1/1
✓ Branch 2 taken 196 times.
196 m_dataDictionary.get<envPeriodReportingFrequencyNameKeyValue>().replace(iEpRfNKv, ddi);
3272 }
3273 196 }
3274
2/2
✓ Branch 0 taken 1218 times.
✓ Branch 1 taken 58 times.
1276 if (ts) {
3275
5/5
✓ Branch 1 taken 1218 times.
✓ Branch 4 taken 1218 times.
✓ Branch 7 taken 1218 times.
✓ Branch 10 taken 1218 times.
✓ Branch 13 taken 1218 times.
1218 LOG(Debug, "Time series found");
3276 } else {
3277
5/5
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
✓ Branch 7 taken 58 times.
✓ Branch 10 taken 58 times.
✓ Branch 13 taken 58 times.
58 LOG(Debug, "No time series found");
3278 }
3279 2552 return ts;
3280 1276 }
3281
3282 1 SqlFileTimeSeriesQueryVector SqlFile_Impl::expandQuery(const SqlFileTimeSeriesQuery& query) {
3283
3284 1 SqlFileTimeSeriesQueryVector result;
3285 1 SqlFileTimeSeriesQueryVector temp1;
3286 1 SqlFileTimeSeriesQueryVector temp2;
3287
3288 // no work needed
3289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (query.m_vetted) {
3290 ✗ result.push_back(query);
3291 ✗ return result;
3292 }
3293
3294
1/1
✓ Branch 1 taken 1 time.
1 temp1 = expandEnvironment(query);
3295
3296 // build up temp2
3297
2/2
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
2 for (const SqlFileTimeSeriesQuery& q : temp1) {
3298
1/1
✓ Branch 1 taken 1 time.
1 SqlFileTimeSeriesQueryVector temp3 = expandReportingFrequency(q);
3299
1/1
✓ Branch 5 taken 1 time.
1 temp2.insert(temp2.end(), temp3.begin(), temp3.end());
3300 1 }
3301
3302 // build up temp1
3303 1 temp1.clear();
3304
2/2
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 time.
5 for (const SqlFileTimeSeriesQuery& q : temp2) {
3305
1/1
✓ Branch 1 taken 4 times.
4 SqlFileTimeSeriesQueryVector temp3 = expandTimeSeries(q);
3306
1/1
✓ Branch 5 taken 4 times.
4 temp1.insert(temp1.end(), temp3.begin(), temp3.end());
3307 4 }
3308
3309 // build up result
3310
2/2
✓ Branch 5 taken 50 times.
✓ Branch 6 taken 1 time.
51 for (const SqlFileTimeSeriesQuery& q : temp1) {
3311
1/1
✓ Branch 1 taken 50 times.
50 SqlFileTimeSeriesQueryVector temp3 = expandKeyValues(q);
3312
1/1
✓ Branch 5 taken 50 times.
50 result.insert(result.end(), temp3.begin(), temp3.end());
3313 50 }
3314
3315 // mark each query as vetted
3316
2/2
✓ Branch 4 taken 50 times.
✓ Branch 5 taken 1 time.
51 for (SqlFileTimeSeriesQuery& resultQuery : result) {
3317 50 resultQuery.m_vetted = true;
3318 }
3319
3320 1 return result;
3321 1 }
3322
3323 1 SqlFileTimeSeriesQueryVector SqlFile_Impl::expandEnvironment(const SqlFileTimeSeriesQuery& query) {
3324 1 SqlFileTimeSeriesQueryVector result;
3325
3326
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 EnvironmentIdentifier envId;
3327
1/1
✓ Branch 1 taken 1 time.
1 StringVector envNames = availableEnvPeriods();
3328 1 StringVector keepers;
3329
2/3
✓ Branch 1 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
2 if (query.environment()) {
3330 ✗ envId = query.environment().get();
3331 ✗ if (envId.type()) {
3332 ✗ EnvironmentType envType = envId.type().get();
3333 // specified by type--get all matching environment names
3334 ✗ for (const std::string& envName : envNames) {
3335 ✗ OptionalEnvironmentType oEnvType = environmentType(envName);
3336 ✗ if (oEnvType && (*oEnvType == envType)) {
3337 ✗ keepers.push_back(envName);
3338 }
3339 ✗ }
3340 } else {
3341 ✗ std::string envName = envId.name().get();
3342 // check validity of name
3343 ✗ auto it = std::find_if(envNames.cbegin(), envNames.cend(), [&envName](const auto& e) { return istringEqual(envName, e); });
3344 ✗ if (it != envNames.end()) {
3345 ✗ keepers.push_back(*it);
3346 }
3347 ✗ }
3348 } else {
3349 // keep all envNames
3350
1/1
✓ Branch 1 taken 1 time.
1 keepers = envNames;
3351 }
3352
3353 // initialize result queries
3354
1/1
✓ Branch 1 taken 1 time.
1 SqlFileTimeSeriesQuery wQuery(query);
3355
2/2
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
2 for (const std::string& envName : keepers) {
3356
1/1
✓ Branch 1 taken 1 time.
1 envId = EnvironmentIdentifier(envName);
3357
1/1
✓ Branch 1 taken 1 time.
1 wQuery.setEnvironment(envId);
3358
1/1
✓ Branch 1 taken 1 time.
1 result.push_back(wQuery);
3359 }
3360
3361 // check result queries for consistency
3362
1/1
✓ Branch 1 taken 1 time.
1 mf_makeConsistent(result);
3363
3364 2 return result;
3365 1 }
3366
3367 1 SqlFileTimeSeriesQueryVector SqlFile_Impl::expandReportingFrequency(const SqlFileTimeSeriesQuery& query) {
3368 1 SqlFileTimeSeriesQueryVector result;
3369
3370
2/3
✓ Branch 1 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
2 if (query.reportingFrequency()) {
3371 ✗ result.push_back(query);
3372 } else {
3373 1 ReportingFrequencySet rfSet;
3374 1 StringVector envNames;
3375 // get environment names
3376
2/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
2 if (query.environment()) {
3377
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 EnvironmentIdentifier envId = query.environment().get();
3378
2/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
2 if (envId.name()) {
3379
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 envNames.push_back(envId.name().get());
3380 } else {
3381 ✗ OS_ASSERT(envId.type());
3382 ✗ EnvironmentType envType = envId.type().get();
3383 ✗ for (const std::string& envName : availableEnvPeriods()) {
3384 ✗ OptionalEnvironmentType oEnvType = environmentType(envName);
3385 ✗ if (oEnvType && (*oEnvType == envType)) {
3386 ✗ envNames.push_back(envName);
3387 }
3388 ✗ }
3389 } // if-else
3390 1 } else {
3391 ✗ envNames = availableEnvPeriods();
3392 }
3393 // get reporting frequencies
3394
2/2
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
2 for (const std::string& envName : envNames) {
3395
1/1
✓ Branch 1 taken 1 time.
1 ReportingFrequencySet tempSet = availableReportingFrequencySet(*this, envName);
3396
1/1
✓ Branch 3 taken 1 time.
1 rfSet.insert(tempSet.begin(), tempSet.end());
3397 1 }
3398
3399 // make one query per rf
3400
2/2
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 time.
5 for (const ReportingFrequency& rf : rfSet) {
3401
1/1
✓ Branch 1 taken 4 times.
4 SqlFileTimeSeriesQuery wQuery(query);
3402
1/1
✓ Branch 1 taken 4 times.
4 wQuery.setReportingFrequency(rf);
3403
1/1
✓ Branch 1 taken 4 times.
4 result.push_back(wQuery);
3404 4 }
3405 1 }
3406
3407 // check result queries for consistency
3408
1/1
✓ Branch 1 taken 1 time.
1 mf_makeConsistent(result);
3409
3410 1 return result;
3411 ✗ }
3412
3413 4 SqlFileTimeSeriesQueryVector SqlFile_Impl::expandTimeSeries(const SqlFileTimeSeriesQuery& query) {
3414 4 SqlFileTimeSeriesQueryVector result;
3415
3416 4 StringVector tsNames;
3417
6/22
✓ Branch 1 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 4 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 4 times.
✓ Branch 24 taken 4 times.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 4 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
8 if (query.timeSeries() && query.timeSeries().get().name()) {
3418 ✗ if (query.timeSeries().get().name()) {
3419 ✗ tsNames.push_back(*(query.timeSeries().get().name()));
3420 }
3421 } else {
3422 // get candidate time series names
3423
13/29
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 4 times.
✓ Branch 22 taken 4 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 4 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 4 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 4 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 4 times.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
16 if (query.environment() && query.environment().get().name() && query.reportingFrequency()) {
3424
8/8
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 19 taken 4 times.
✓ Branch 22 taken 4 times.
4 tsNames = availableVariableNames(query.environment().get().name().get(), query.reportingFrequency().get().valueDescription());
3425 } else {
3426 // get all and let other function filter out
3427 ✗ tsNames = availableTimeSeries();
3428 }
3429 // filter by regex if applicable
3430
2/3
✓ Branch 1 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
8 if (query.timeSeries()) {
3431 ✗ OS_ASSERT(query.timeSeries().get().regex());
3432 ✗ boost::regex re = query.timeSeries().get().regex().get();
3433 ✗ for (auto it = tsNames.begin(); it != tsNames.end();) {
3434 ✗ if (!boost::regex_match(*it, re)) {
3435 ✗ it = tsNames.erase(it);
3436 ✗ continue;
3437 }
3438 ✗ ++it;
3439 }
3440 ✗ }
3441 }
3442
3443 // make one query per time series name
3444
2/2
✓ Branch 5 taken 50 times.
✓ Branch 6 taken 4 times.
54 for (const std::string& tsName : tsNames) {
3445
1/1
✓ Branch 1 taken 50 times.
50 SqlFileTimeSeriesQuery wQuery(query);
3446
1/1
✓ Branch 1 taken 50 times.
50 TimeSeriesIdentifier tsId(tsName);
3447
1/1
✓ Branch 1 taken 50 times.
50 wQuery.setTimeSeries(tsId);
3448
1/1
✓ Branch 1 taken 50 times.
50 result.push_back(wQuery);
3449 50 }
3450
3451 // check result queries for consistency
3452
1/1
✓ Branch 1 taken 4 times.
4 mf_makeConsistent(result);
3453
3454 8 return result;
3455 4 }
3456
3457 50 SqlFileTimeSeriesQueryVector SqlFile_Impl::expandKeyValues(const SqlFileTimeSeriesQuery& query) {
3458 50 SqlFileTimeSeriesQueryVector result;
3459
3460 // only "expand" regex
3461
1/1
✓ Branch 1 taken 50 times.
50 result.push_back(query);
3462
6/22
✓ Branch 1 taken 50 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 50 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 50 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 50 times.
✓ Branch 24 taken 50 times.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 50 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
100 if (query.keyValues() && query.keyValues().get().regex()) {
3463 // get available key value names
3464 ✗ StringVector kvNames;
3465 ✗ if (query.environment() && query.environment().get().name() && query.reportingFrequency() && query.timeSeries()
3466 ✗ && query.timeSeries().get().name()) {
3467 ✗ kvNames = availableKeyValues(query.environment().get().name().get(), query.reportingFrequency().get().valueDescription(),
3468 ✗ query.timeSeries().get().name().get());
3469 } else {
3470 ✗ LOG_AND_THROW("Not yet implemented.");
3471 }
3472 // check against regex
3473 ✗ boost::regex re = *(query.keyValues().get().regex());
3474 ✗ for (auto it = kvNames.begin(); it != kvNames.end();) {
3475 ✗ if (!boost::regex_match(*it, re)) {
3476 ✗ it = kvNames.erase(it);
3477 ✗ continue;
3478 }
3479 ✗ ++it;
3480 }
3481 ✗ if (kvNames.empty()) {
3482 ✗ result.clear();
3483 } else {
3484 // set names
3485 ✗ KeyValueIdentifier kvId(kvNames);
3486 ✗ result[0].setKeyValues(kvId);
3487 ✗ }
3488 ✗ }
3489
3490 // check result queries for consistency
3491
1/1
✓ Branch 1 taken 50 times.
50 mf_makeConsistent(result);
3492
3493 50 return result;
3494 ✗ }
3495
3496 ✗ TimeSeriesVector SqlFile_Impl::timeSeries(const SqlFileTimeSeriesQuery& query) {
3497 ✗ TimeSeriesVector result;
3498 ✗ SqlFileTimeSeriesQuery wquery(query);
3499 ✗ if (!wquery.m_vetted) {
3500 ✗ SqlFileTimeSeriesQueryVector expanded = expandQuery(query);
3501 ✗ if (expanded.size() == 1) {
3502 ✗ wquery = expanded[0];
3503 } else {
3504 ✗ if (expanded.empty()) {
3505 ✗ LOG(Info, "Unable to return timeSeries based on query: " << '\n'
3506 << query << ", because there are no matching timeSeries in SqlFile "
3507 << toString(path()) << ".");
3508 } else {
3509 ✗ OS_ASSERT(expanded.size() > 1);
3510 ✗ LOG(Info, "Unable to return timeSeries based on query: " << '\n'
3511 << query << ", because it expands to more than one (" << expanded.size()
3512 << ") query.");
3513 }
3514 ✗ return result;
3515 }
3516 ✗ }
3517
3518 ✗ OS_ASSERT(wquery.m_vetted);
3519 ✗ OS_ASSERT(wquery.environment());
3520 ✗ OS_ASSERT(!wquery.environment().get().type());
3521 ✗ OS_ASSERT(wquery.reportingFrequency());
3522 ✗ OS_ASSERT(wquery.timeSeries());
3523 ✗ OS_ASSERT(!wquery.timeSeries().get().regex());
3524 ✗ if (wquery.keyValues()) {
3525 ✗ OS_ASSERT(!wquery.keyValues().get().regex());
3526 }
3527
3528 // environment, reportingPeriod, and timeSeries will all be unique and explicit.
3529 // keyValues may or may not be explicit.
3530 // get all matching timeSeries and append to result.
3531 ✗ std::string envPeriod = *(wquery.environment().get().name());
3532 ✗ ReportingFrequency rf = *(wquery.reportingFrequency());
3533 ✗ std::string tsName = *(wquery.timeSeries().get().name());
3534 ✗ if (wquery.keyValues()) {
3535 ✗ for (const std::string& kvName : wquery.keyValues().get().names()) {
3536 ✗ OptionalTimeSeries ots = timeSeries(envPeriod, rf.valueDescription(), tsName, kvName);
3537 ✗ if (ots) {
3538 ✗ result.push_back(*ots);
3539 }
3540 ✗ }
3541 } else {
3542 ✗ result = timeSeries(envPeriod, rf.valueDescription(), tsName);
3543 }
3544
3545 ✗ return result;
3546 ✗ }
3547
3548 ✗ boost::optional<std::pair<DateTime, DateTime>> SqlFile_Impl::daylightSavingsPeriod() const {
3549 // first and last date for dst=1
3550 // sqlite3 does not have interface for first and last record in recordset
3551 // minimize recordset size and use group by and order by
3552 // TODO - unit test
3553
3554 ✗ boost::optional<std::pair<DateTime, DateTime>> dstPeriod;
3555 ✗ int startMonth = 0;
3556 ✗ int startDay = 0;
3557 ✗ int startHour = 0;
3558 ✗ int startMinute = 0;
3559 ✗ int endMonth = 0;
3560 ✗ int endDay = 0;
3561 ✗ int endHour = 0;
3562 ✗ int endMinute = 0;
3563
3564 ✗ if (m_db) {
3565
3566 sqlite3_stmt* sqlStmtPtr;
3567
3568 // first date time of dst
3569 ✗ std::string s = "select month, day, hour, minute from Time where dst=1 group by month order by month, day, hour, minute";
3570
3571 ✗ int code = sqlite3_prepare_v2(m_db, s.c_str(), -1, &sqlStmtPtr, nullptr);
3572
3573 ✗ code = sqlite3_step(sqlStmtPtr);
3574 ✗ if (code == SQLITE_ROW) {
3575 ✗ startMonth = sqlite3_column_int(sqlStmtPtr, 0);
3576 ✗ startDay = sqlite3_column_int(sqlStmtPtr, 1);
3577 ✗ startHour = sqlite3_column_int(sqlStmtPtr, 2);
3578 ✗ startMinute = sqlite3_column_int(sqlStmtPtr, 3);
3579 }
3580
3581 /// must finalize to prevent memory leaks
3582 ✗ sqlite3_finalize(sqlStmtPtr);
3583
3584 // last date time of dst
3585 ✗ s = "select month, day, hour, minute from Time where dst=1 group by month order by month desc, day desc, hour desc, minute desc";
3586
3587 ✗ code = sqlite3_prepare_v2(m_db, s.c_str(), -1, &sqlStmtPtr, nullptr);
3588
3589 ✗ code = sqlite3_step(sqlStmtPtr);
3590 ✗ if (code == SQLITE_ROW) {
3591 ✗ endMonth = sqlite3_column_int(sqlStmtPtr, 0);
3592 ✗ endDay = sqlite3_column_int(sqlStmtPtr, 1);
3593 ✗ endHour = sqlite3_column_int(sqlStmtPtr, 2);
3594 ✗ endMinute = sqlite3_column_int(sqlStmtPtr, 3);
3595 }
3596
3597 /// must finalize to prevent memory leaks
3598 ✗ sqlite3_finalize(sqlStmtPtr);
3599 ✗ }
3600
3601 // DLM: potential leap year problem
3602 // DLM: get standard time zone?
3603 ✗ DateTime dstStart(Date(openstudio::monthOfYear(startMonth), startDay), Time(startDay, startHour, startMinute, 0));
3604 ✗ DateTime dstEnd(Date(openstudio::monthOfYear(endMonth), endDay), Time(endDay, endHour, endMinute, 0));
3605
3606 ✗ dstPeriod->first = dstStart;
3607 ✗ dstPeriod->first = dstEnd;
3608 ✗ return dstPeriod;
3609 ✗ }
3610
3611 /// returns datadictionary of available timeseries
3612 ✗ DataDictionaryTable SqlFile_Impl::dataDictionary() const {
3613 ✗ return m_dataDictionary;
3614 }
3615
3616 /// Energy plus version number
3617 // DLM@20100511: can we query this?
3618 329 std::string SqlFile_Impl::energyPlusVersion() const {
3619 329 std::string result;
3620
1/2
✓ Branch 0 taken 329 times.
✗ Branch 1 not taken.
329 if (m_db) {
3621 sqlite3_stmt* sqlStmtPtr;
3622
1/1
✓ Branch 1 taken 329 times.
329 sqlite3_prepare_v2(m_db, "SELECT EnergyPlusVersion FROM Simulations", -1, &sqlStmtPtr, nullptr);
3623
1/1
✓ Branch 1 taken 329 times.
329 int code = sqlite3_step(sqlStmtPtr);
3624
2/2
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 8 times.
329 if (code == SQLITE_ROW) {
3625 // in 8.1 this is 'EnergyPlus-Windows-32 8.1.0.008, YMD=2014.11.08 22:49'
3626 // in 8.2 this is 'EnergyPlus, Version 8.2.0-8397c2e30b, YMD=2015.01.09 08:37'
3627 // radiance script is writing 'EnergyPlus, VERSION 8.2, (OpenStudio) YMD=2015.1.9 08:35:36'
3628
1/1
✓ Branch 1 taken 321 times.
321 boost::regex version_regex("\\d{1,}\\.\\d[\\.\\d]*");
3629
2/2
✓ Branch 1 taken 321 times.
✓ Branch 4 taken 321 times.
321 std::string version_line = columnText(sqlite3_column_text(sqlStmtPtr, 0));
3630
1/1
✓ Branch 1 taken 321 times.
321 boost::smatch version_match;
3631
3632
2/3
✓ Branch 1 taken 321 times.
✓ Branch 3 taken 321 times.
✗ Branch 4 not taken.
321 if (boost::regex_search(version_line, version_match, version_regex)) {
3633
2/2
✓ Branch 1 taken 321 times.
✓ Branch 4 taken 321 times.
321 result = version_match[0].str();
3634 }
3635 321 }
3636
1/1
✓ Branch 1 taken 329 times.
329 sqlite3_finalize(sqlStmtPtr);
3637 }
3638 329 return result;
3639 ✗ }
3640
3641 /// Energy Plus eplusout.sql file name
3642 ✗ std::string SqlFile_Impl::energyPlusSqliteFile() const {
3643 ✗ return m_sqliteFilename;
3644 }
3645
3646 /// get names of all available illuminance maps
3647 1 std::vector<std::string> SqlFile_Impl::illuminanceMapNames() const {
3648 1 std::vector<std::string> names;
3649
3650
1/1
✓ Branch 1 taken 1 time.
1 const std::string& s = "select MapName from daylightmaps";
3651
3652 sqlite3_stmt* sqlStmtPtr;
3653
3654
1/1
✓ Branch 2 taken 1 time.
1 int code = sqlite3_prepare_v2(m_db, s.c_str(), -1, &sqlStmtPtr, nullptr);
3655
1/1
✓ Branch 1 taken 1 time.
1 code = sqlite3_step(sqlStmtPtr);
3656
3657
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 while (code == SQLITE_ROW) {
3658
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 names.push_back(columnText(sqlite3_column_text(sqlStmtPtr, 0)));
3659
3660 // step to next row
3661
1/1
✓ Branch 1 taken 1 time.
1 code = sqlite3_step(sqlStmtPtr);
3662 }
3663
3664 /// must finalize to prevent memory leaks
3665
1/1
✓ Branch 1 taken 1 time.
1 sqlite3_finalize(sqlStmtPtr);
3666
3667 2 return names;
3668 1 }
3669
3670 /// get names of all available illuminance maps for the given environment period
3671 ✗ std::vector<std::string> SqlFile_Impl::illuminanceMapNames(const std::string& envPeriod) const {
3672
3673 ✗ std::vector<std::string> names;
3674
3675 ✗ if (auto _vec = execAndReturnVectorOfString("SELECT MapName FROM DaylightMaps WHERE Environment = ? COLLATE NOCASE",
3676 // Bind Args
3677 ✗ envPeriod)) {
3678 ✗ names = _vec.get();
3679 ✗ }
3680
3681 ✗ return names;
3682 ✗ }
3683
3684 /// reference point for map - form RefPtn=(x:y:illuminance)
3685 2 boost::optional<std::string> SqlFile_Impl::illuminanceMapRefPt(const std::string& name, int ptNum) const {
3686 2 boost::optional<std::string> refPt;
3687
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<int> mapIndex = illuminanceMapIndex(name);
3688
3689
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (mapIndex) {
3690
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 refPt = illuminanceMapRefPt(*mapIndex, ptNum);
3691 } else
3692 ✗ LOG(Error, "Unknown illuminance map '" << name << "'");
3693
3694 4 return refPt;
3695 ✗ }
3696
3697 2 boost::optional<std::string> SqlFile_Impl::illuminanceMapRefPt(int mapIndex, int ptNum) const {
3698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (ptNum <= 0) {
3699 ✗ LOG(Error, "illuminanceMapRefPt: ptNum must be > 0 (1-indexed)");
3700 ✗ return boost::none;
3701 }
3702
3703 2 boost::optional<std::string> refPt;
3704 sqlite3_stmt* sqlStmtPtr;
3705
3706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (m_illuminanceMapHasOnly2RefPts) {
3707 ✗ std::stringstream s;
3708 ✗ s << "SELECT ReferencePt" << ptNum << " FROM DaylightMaps WHERE MapNumber=" << mapIndex;
3709
3710 ✗ int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
3711 ✗ code = sqlite3_step(sqlStmtPtr);
3712
3713 ✗ if (code == SQLITE_ROW) {
3714 ✗ refPt = columnText(sqlite3_column_text(sqlStmtPtr, 0));
3715 }
3716
3717 ✗ } else {
3718
3719
1/1
✓ Branch 1 taken 2 times.
2 std::stringstream s;
3720
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 s << "SELECT ReferencePts FROM DaylightMaps WHERE MapNumber=" << mapIndex;
3721
3722
2/2
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
2 int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
3723
1/1
✓ Branch 1 taken 2 times.
2 code = sqlite3_step(sqlStmtPtr);
3724
3725
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (code == SQLITE_ROW) {
3726
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 std::string refPts = columnText(sqlite3_column_text(sqlStmtPtr, 0));
3727
1/1
✓ Branch 1 taken 2 times.
2 auto refPtsVec = openstudio::splitString(refPts, ',');
3728
3729 // Annoying that the parameters aren't unsigned here... Anyway, I **know** ptNum is > 0 since I tested for it above
3730
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (static_cast<size_t>(ptNum) > refPtsVec.size()) {
3731 ✗ LOG(Error, "illuminanceMapRefPt: ptNum=" << ptNum << " is greater than the number of reference points: " << refPtsVec.size());
3732 } else {
3733
1/1
✓ Branch 2 taken 2 times.
2 std::string refPtTrim = refPtsVec[ptNum - 1];
3734
1/1
✓ Branch 1 taken 2 times.
2 openstudio::ascii_trim(refPtTrim);
3735
1/1
✓ Branch 1 taken 2 times.
2 refPt = refPtTrim;
3736 2 }
3737 2 }
3738 2 }
3739
3740 /// must finalize to prevent memory leaks
3741
1/1
✓ Branch 1 taken 2 times.
2 sqlite3_finalize(sqlStmtPtr);
3742
3743 2 return refPt;
3744 2 }
3745
3746 /// minimum value of map
3747 1 boost::optional<double> SqlFile_Impl::illuminanceMapMinValue(const std::string& name) const {
3748 1 boost::optional<double> minValue;
3749
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<int> mapIndex = illuminanceMapIndex(name);
3750
3751
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (mapIndex) {
3752
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 minValue = illuminanceMapMinValue(*mapIndex);
3753 } else
3754 ✗ LOG(Error, "Unknown illuminance map '" << name << "'");
3755
3756 1 return minValue;
3757 }
3758
3759 /// minimum value of map
3760 1 boost::optional<double> SqlFile_Impl::illuminanceMapMinValue(int mapIndex) const {
3761 1 boost::optional<double> minValue;
3762
1/1
✓ Branch 1 taken 1 time.
1 std::stringstream s;
3763 s << "select min(d.Illuminance) from daylightmaphourlydata d inner join daylightmaphourlyreports r on d.HourlyReportIndex = "
3764 "r.HourlyReportIndex "
3765
1/1
✓ Branch 1 taken 1 time.
1 "where r.MapNumber="
3766
1/1
✓ Branch 1 taken 1 time.
1 << mapIndex;
3767
3768 sqlite3_stmt* sqlStmtPtr;
3769
3770
2/2
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
1 int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
3771
1/1
✓ Branch 1 taken 1 time.
1 code = sqlite3_step(sqlStmtPtr);
3772
3773
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (code == SQLITE_ROW) {
3774
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 minValue = sqlite3_column_double(sqlStmtPtr, 0);
3775 }
3776
3777 /// must finalize to prevent memory leaks
3778
1/1
✓ Branch 1 taken 1 time.
1 sqlite3_finalize(sqlStmtPtr);
3779
3780 1 return minValue;
3781 1 }
3782
3783 /// maximum value of map
3784 1 boost::optional<double> SqlFile_Impl::illuminanceMapMaxValue(const std::string& name) const {
3785 1 boost::optional<double> maxValue;
3786
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<int> mapIndex = illuminanceMapIndex(name);
3787
3788
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (mapIndex) {
3789
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 maxValue = illuminanceMapMaxValue(*mapIndex);
3790 } else
3791 ✗ LOG(Error, "Unknown illuminance map '" << name << "'");
3792
3793 1 return maxValue;
3794 }
3795
3796 /// maximum value of map
3797 1 boost::optional<double> SqlFile_Impl::illuminanceMapMaxValue(int mapIndex) const {
3798 1 boost::optional<double> maxValue;
3799
1/1
✓ Branch 1 taken 1 time.
1 std::stringstream s;
3800 s << "select max(d.Illuminance) from daylightmaphourlydata d inner join daylightmaphourlyreports r on d.HourlyReportIndex = "
3801 "r.HourlyReportIndex "
3802
1/1
✓ Branch 1 taken 1 time.
1 "where r.MapNumber="
3803
1/1
✓ Branch 1 taken 1 time.
1 << mapIndex;
3804
3805 sqlite3_stmt* sqlStmtPtr;
3806
3807
2/2
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
1 int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
3808
1/1
✓ Branch 1 taken 1 time.
1 code = sqlite3_step(sqlStmtPtr);
3809
3810
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (code == SQLITE_ROW) {
3811
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 maxValue = sqlite3_column_double(sqlStmtPtr, 0);
3812 }
3813
3814 /// must finalize to prevent memory leaks
3815
1/1
✓ Branch 1 taken 1 time.
1 sqlite3_finalize(sqlStmtPtr);
3816
3817 1 return maxValue;
3818 1 }
3819
3820 1 void SqlFile_Impl::illuminanceMapMaxValue(const std::string& name, double& minValue, double& maxValue) const {
3821
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<int> mapIndex = illuminanceMapIndex(name);
3822
3823
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (mapIndex) {
3824
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 illuminanceMapMaxValue(*mapIndex, minValue, maxValue);
3825 } else
3826 ✗ LOG(Error, "Unknown illuminance map '" << name << "'");
3827 1 }
3828
3829 /// minimum and maximum of map
3830 1 void SqlFile_Impl::illuminanceMapMaxValue(int mapIndex, double& minValue, double& maxValue) const {
3831
1/1
✓ Branch 1 taken 1 time.
1 std::stringstream s;
3832 s << "select min(d.Illuminance), max(d.Illuminance) from daylightmaphourlydata d inner join daylightmaphourlyreports r on d.HourlyReportIndex "
3833 "= "
3834
1/1
✓ Branch 1 taken 1 time.
1 "r.HourlyReportIndex where r.MapNumber="
3835
1/1
✓ Branch 1 taken 1 time.
1 << mapIndex;
3836
3837 sqlite3_stmt* sqlStmtPtr;
3838
3839
2/2
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
1 int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
3840
1/1
✓ Branch 1 taken 1 time.
1 code = sqlite3_step(sqlStmtPtr);
3841
3842
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (code == SQLITE_ROW) {
3843
1/1
✓ Branch 1 taken 1 time.
1 minValue = sqlite3_column_double(sqlStmtPtr, 0);
3844
1/1
✓ Branch 1 taken 1 time.
1 maxValue = sqlite3_column_double(sqlStmtPtr, 1);
3845 }
3846 /// must finalize to prevent memory leaks
3847
1/1
✓ Branch 1 taken 1 time.
1 sqlite3_finalize(sqlStmtPtr);
3848 1 }
3849
3850 /// get all zone names for specified illuminance map
3851 ✗ std::vector<std::string> SqlFile_Impl::illuminanceMapZoneNames(const std::string& name) const {
3852 ✗ std::vector<std::string> names;
3853 ✗ boost::optional<int> mapIndex = illuminanceMapIndex(name);
3854
3855 ✗ if (mapIndex) {
3856 ✗ names = illuminanceMapZoneNames(*mapIndex);
3857 } else
3858 ✗ LOG(Error, "Unknown illuminance map '" << name << "'");
3859
3860 ✗ return names;
3861 ✗ }
3862
3863 /// get all zone names for specified illuminance map
3864 ✗ std::vector<std::string> SqlFile_Impl::illuminanceMapZoneNames(int mapIndex) const {
3865 ✗ std::vector<std::string> names;
3866
3867 ✗ if (auto _vec = execAndReturnVectorOfString("SELECT ZoneName FROM Zones WHERE ZoneIndex in (SELECT Zone from DaylightMaps WHERE MapNumber = ?",
3868 // Bind Args
3869 ✗ mapIndex)) {
3870 ✗ names = _vec.get();
3871 ✗ }
3872
3873 ✗ return names;
3874 ✗ }
3875
3876 /// x position (m) of the illuminance map
3877 2 Vector SqlFile_Impl::illuminanceMapX(int hourlyReportIndex) const {
3878 2 std::vector<double> xv;
3879
1/1
✓ Branch 1 taken 2 times.
2 if (auto _vec = execAndReturnVectorOfDouble("SELECT X FROM DaylightMapHourlyData WHERE HourlyReportIndex = ? GROUP BY X",
3880 // Bind Args
3881
2/3
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
6 hourlyReportIndex)) {
3882
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 xv = _vec.get();
3883 2 }
3884
3885 // copy std::vector to Vector, will be sorted in ascending order
3886
1/1
✓ Branch 2 taken 2 times.
2 Vector x(xv.size());
3887
2/2
✓ Branch 1 taken 2 times.
✓ Branch 6 taken 2 times.
2 std::copy(xv.begin(), xv.end(), x.begin());
3888
3889 4 return x;
3890 2 }
3891
3892 /// x position (m) of the illuminance map
3893 1 Vector SqlFile_Impl::illuminanceMapX(const std::string& name, const DateTime& dateTime) const {
3894 // figure out map index
3895
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<int> mapIndex = illuminanceMapIndex(name);
3896
3897
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!mapIndex) {
3898 ✗ LOG(Error, "Unknown illuminance map '" << name << "'");
3899 ✗ return {};
3900 }
3901
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 boost::optional<int> timeIndex = illuminanceMapHourlyReportIndex(*mapIndex, dateTime);
3902
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!timeIndex) {
3903 ✗ LOG(Error, "Unknown date and time '" << dateTime << "'");
3904 ✗ return {};
3905 }
3906
3907
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 Vector x(illuminanceMapX(*timeIndex));
3908
3909
1/1
✓ Branch 1 taken 1 time.
1 return x;
3910 1 }
3911
3912 /// y position (m) of the illuminance map
3913 2 Vector SqlFile_Impl::illuminanceMapY(int hourlyReportIndex) const {
3914 2 std::vector<double> yv;
3915
3916
1/1
✓ Branch 1 taken 2 times.
2 if (auto _vec = execAndReturnVectorOfDouble("SELECT Y FROM DaylightMapHourlyData WHERE HourlyReportIndex = ? GROUP BY Y",
3917 // Bind Args
3918
2/3
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
6 hourlyReportIndex)) {
3919
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 yv = _vec.get();
3920 2 }
3921
3922 // copy std::vector to Vector, will be sorted in ascending order
3923
1/1
✓ Branch 2 taken 2 times.
2 Vector y(yv.size());
3924
2/2
✓ Branch 1 taken 2 times.
✓ Branch 6 taken 2 times.
2 std::copy(yv.begin(), yv.end(), y.begin());
3925
3926 4 return y;
3927 2 }
3928
3929 /// y position (m) of the illuminance map
3930 1 Vector SqlFile_Impl::illuminanceMapY(const std::string& name, const DateTime& dateTime) const {
3931 // figure out map index
3932
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<int> mapIndex = illuminanceMapIndex(name);
3933
3934
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!mapIndex) {
3935 ✗ LOG(Error, "Unknown illuminance map '" << name << "'");
3936 ✗ return {};
3937 }
3938
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 boost::optional<int> timeIndex = illuminanceMapHourlyReportIndex(*mapIndex, dateTime);
3939
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!timeIndex) {
3940 ✗ LOG(Error, "Unknown date and time '" << dateTime << "'");
3941 ✗ return {};
3942 }
3943
3944
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 Vector y(illuminanceMapY(*timeIndex));
3945
3946
1/1
✓ Branch 1 taken 1 time.
1 return y;
3947 1 }
3948
3949 ✗ std::vector<int> SqlFile_Impl::illuminanceMapHourlyReportIndices(const std::string& name) const {
3950 ✗ std::vector<int> reportIndices;
3951 // figure out map index
3952 ✗ boost::optional<int> mapIndex = illuminanceMapIndex(name);
3953 ✗ if (!mapIndex) {
3954 ✗ LOG(Error, "Unknown illuminance map '" << name << "'");
3955 ✗ return reportIndices;
3956 }
3957 ✗ reportIndices = illuminanceMapHourlyReportIndices(*mapIndex);
3958 ✗ return reportIndices;
3959 ✗ }
3960
3961 ✗ std::vector<int> SqlFile_Impl::illuminanceMapHourlyReportIndices(int mapIndex) const {
3962 ✗ std::vector<int> result;
3963
3964 ✗ if (auto _vec = execAndReturnVectorOfInt("SELECT HourlyReportIndex FROM DaylightMapHourlyReports WHERE MapNumber=?",
3965 // Bind Args
3966 ✗ mapIndex)) {
3967 ✗ result = _vec.get();
3968 ✗ }
3969
3970 ✗ return result;
3971 ✗ }
3972
3973 4 std::vector<std::pair<int, DateTime>> SqlFile_Impl::illuminanceMapHourlyReportIndicesDates(const std::string& name) const {
3974 4 std::vector<std::pair<int, DateTime>> reportIndicesDates;
3975 // figure out map index
3976
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<int> mapIndex = illuminanceMapIndex(name);
3977
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (!mapIndex) {
3978 ✗ LOG(Error, "Unknown illuminance map '" << name << "'");
3979 ✗ return reportIndicesDates;
3980 }
3981
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 reportIndicesDates = illuminanceMapHourlyReportIndicesDates(*mapIndex);
3982 4 return reportIndicesDates;
3983 ✗ }
3984
3985 4 std::vector<std::pair<int, DateTime>> SqlFile_Impl::illuminanceMapHourlyReportIndicesDates(int mapIndex) const {
3986 4 std::vector<std::pair<int, DateTime>> reportIndicesDates;
3987
1/1
✓ Branch 1 taken 4 times.
4 std::stringstream s;
3988
1/1
✓ Branch 1 taken 4 times.
4 s << "select HourlyReportIndex, ";
3989
2/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
4 if (hasIlluminanceMapYear()) {
3990
1/1
✓ Branch 1 taken 4 times.
4 s << "Year, ";
3991 }
3992
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 s << "Month, DayOfMonth, Hour from daylightmaphourlyreports where MapNumber=" << mapIndex;
3993
3994 sqlite3_stmt* sqlStmtPtr;
3995
3996
2/2
✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
4 int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
3997
1/1
✓ Branch 1 taken 4 times.
4 code = sqlite3_step(sqlStmtPtr);
3998
2/2
✓ Branch 0 taken 19040 times.
✓ Branch 1 taken 4 times.
19044 while (code == SQLITE_ROW) {
3999
1/1
✓ Branch 1 taken 19040 times.
19040 std::pair<int, DateTime> pair;
4000 19040 int b = 0;
4001
1/1
✓ Branch 1 taken 19040 times.
19040 pair.first = sqlite3_column_int(sqlStmtPtr, b++);
4002
4003 19040 boost::optional<unsigned> year;
4004
2/3
✓ Branch 1 taken 19040 times.
✓ Branch 3 taken 19040 times.
✗ Branch 4 not taken.
19040 if (hasIlluminanceMapYear()) {
4005
2/2
✓ Branch 1 taken 19040 times.
✓ Branch 4 taken 19040 times.
19040 year = sqlite3_column_int(sqlStmtPtr, b++);
4006 }
4007
4008
1/1
✓ Branch 1 taken 19040 times.
19040 unsigned month = sqlite3_column_int(sqlStmtPtr, b++);
4009
1/1
✓ Branch 1 taken 19040 times.
19040 unsigned day = sqlite3_column_int(sqlStmtPtr, b++);
4010
1/1
✓ Branch 1 taken 19040 times.
19040 unsigned hour = sqlite3_column_int(sqlStmtPtr, b++);
4011
4012 // Note JM 2019-03-14: E+ v8.9.0 added Year, but for IlluminanceMap only in 9.2.0
4013
4/7
✓ Branch 0 taken 19040 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 19040 times.
✓ Branch 6 taken 19040 times.
✓ Branch 9 taken 19040 times.
✗ Branch 12 not taken.
✗ Branch 15 not taken.
19040 openstudio::Date date = year ? Date(monthOfYear(month), day, *year) : Date(monthOfYear(month), day);
4014
3/3
✓ Branch 1 taken 19040 times.
✓ Branch 4 taken 19040 times.
✓ Branch 7 taken 19040 times.
19040 pair.second = DateTime(date, Time(0, hour, 0, 0));
4015
1/1
✓ Branch 1 taken 19040 times.
19040 reportIndicesDates.push_back(pair);
4016 // step to next row
4017
1/1
✓ Branch 1 taken 19040 times.
19040 code = sqlite3_step(sqlStmtPtr);
4018 }
4019
4020 /// must finalize to prevent memory leaks
4021
1/1
✓ Branch 1 taken 4 times.
4 sqlite3_finalize(sqlStmtPtr);
4022
4023 8 return reportIndicesDates;
4024 4 }
4025
4026 ✗ boost::optional<DateTime> SqlFile_Impl::illuminanceMapDate(int hourlyReportIndex) const {
4027 ✗ boost::optional<unsigned> year;
4028 ✗ unsigned month = 0;
4029 ✗ unsigned dayOfMonth = 0;
4030 ✗ unsigned hour = 0;
4031 ✗ std::stringstream s;
4032 ✗ s << "SELECT ";
4033 ✗ if (hasYear()) {
4034 ✗ s << "Year, ";
4035 }
4036 ✗ s << "Month, DayOfMonth, Hour from daylightmaphourlyreports where HourlyReportIndex=" << hourlyReportIndex;
4037
4038 sqlite3_stmt* sqlStmtPtr;
4039
4040 ✗ int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
4041 ✗ code = sqlite3_step(sqlStmtPtr);
4042 ✗ if (code == SQLITE_ROW) {
4043 ✗ int b = 0;
4044 ✗ if (hasYear()) {
4045 ✗ year = sqlite3_column_int(sqlStmtPtr, b++);
4046 }
4047 ✗ month = sqlite3_column_int(sqlStmtPtr, b++);
4048 ✗ dayOfMonth = sqlite3_column_int(sqlStmtPtr, b++);
4049 ✗ hour = sqlite3_column_int(sqlStmtPtr, b++);
4050 } else {
4051 ✗ LOG(Error, "Unknown hourly report index " << hourlyReportIndex);
4052 ✗ return DateTime();
4053 }
4054
4055 /// must finalize to prevent memory leaks
4056 ✗ sqlite3_finalize(sqlStmtPtr);
4057
4058 // Note JM 2019-03-14: Starting with E+ v8.9.0, we actually have Year in the SQL file
4059 // So if we can, we use the actual year, otherwise we initialze with defaults
4060 // and let the Date Ctor figure out the assumed year
4061 ✗ openstudio::Date date = year ? Date(monthOfYear(month), dayOfMonth, *year) : Date(monthOfYear(month), dayOfMonth);
4062
4063 // DLM: get standard time zone?
4064 ✗ return DateTime(date, Time(0, hour, 0, 0));
4065 ✗ }
4066
4067 3 boost::optional<int> SqlFile_Impl::illuminanceMapHourlyReportIndex(int mapIndex, const DateTime& dateTime) const {
4068 // E+ doesn't have a Year for this table
4069 // int year = dateTime.date().year();
4070
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 int monthOfYear = dateTime.date().monthOfYear().value();
4071
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 int dayOfMonth = dateTime.date().dayOfMonth();
4072
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 int hours = dateTime.time().hours();
4073 // EnergyPlus deals in a 00:00:01 -> 24:00:00 instead of
4074 // 00:00:00 -> 23:59:59 hrs that the real world uses, so
4075 // we are going to adjust for that, so we subtract an hour,
4076 // to get it back to the previous day, then we will replace
4077 // the hours with 24
4078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (hours == 0) {
4079 ✗ DateTime dt = dateTime - Time(0, 1);
4080 ✗ monthOfYear = dt.date().monthOfYear().value();
4081 ✗ dayOfMonth = dt.date().dayOfMonth();
4082 ✗ hours = 24;
4083 }
4084
4085
1/1
✓ Branch 1 taken 3 times.
3 std::stringstream s;
4086
1/1
✓ Branch 1 taken 3 times.
3 s << "select HourlyReportIndex from daylightmaphourlyreports where MapNumber='" << mapIndex
4087 << "'"
4088 // E+ doesn't have a Year for this table cf https://github.com/NREL/EnergyPlus/issues/7225
4089 // << " AND Year=" << year
4090
8/8
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
3 << " AND Month=" << monthOfYear << " AND DayOfMonth=" << dayOfMonth << " AND Hour=" << hours;
4091
4092 sqlite3_stmt* sqlStmtPtr;
4093
4094 3 boost::optional<int> timeIndex;
4095
2/2
✓ Branch 1 taken 3 times.
✓ Branch 5 taken 3 times.
3 int code = sqlite3_prepare_v2(m_db, s.str().c_str(), -1, &sqlStmtPtr, nullptr);
4096
1/1
✓ Branch 1 taken 3 times.
3 code = sqlite3_step(sqlStmtPtr);
4097
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (code == SQLITE_ROW) {
4098
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 timeIndex = sqlite3_column_int(sqlStmtPtr, 0);
4099 }
4100
4101 /// must finalize to prevent memory leaks
4102
1/1
✓ Branch 1 taken 3 times.
3 sqlite3_finalize(sqlStmtPtr);
4103
4104
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
3 if (!timeIndex) {
4105 ✗ LOG(Error, "Unknown date and time '" << dateTime << "'");
4106 }
4107 3 return timeIndex;
4108 3 }
4109
4110 /// value (lux) of the illuminance map at date and time
4111 /// value(i,j) is the illuminance at x(i), y(j)
4112 1 Matrix SqlFile_Impl::illuminanceMap(const std::string& name, const DateTime& dateTime) const {
4113 // figure out map index
4114
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<int> mapIndex = illuminanceMapIndex(name);
4115
4116
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!mapIndex) {
4117 ✗ LOG(Error, "Unknown illuminance map '" << name << "'");
4118 ✗ return {};
4119 }
4120
4121 // find the HourlyReportIndex
4122
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 boost::optional<int> timeIndex = illuminanceMapHourlyReportIndex(*mapIndex, dateTime);
4123
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!timeIndex) {
4124 ✗ LOG(Error, "Unknown date and time '" << dateTime << "'");
4125 ✗ return {};
4126 }
4127
4128
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 return illuminanceMap(*timeIndex);
4129 }
4130
4131 1 void SqlFile_Impl::illuminanceMap(int hourlyReportIndex, std::vector<double>& x, std::vector<double>& y, std::vector<double>& illuminance) const {
4132 1 double xVal(0.0);
4133 1 double yVal(0.0);
4134 1 double yValPrevious(0.0);
4135 1 double illuminanceVal(0.0);
4136 1 bool yValChanged = false;
4137
4138
1/1
✓ Branch 1 taken 1 time.
1 std::stringstream statement;
4139
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 statement << "select X,Y,Illuminance from daylightmaphourlydata where HourlyReportIndex=" << hourlyReportIndex << " order by Y asc, X asc";
4140
4141 sqlite3_stmt* sqlStmtPtr;
4142
4143
2/2
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
1 int code = sqlite3_prepare_v2(m_db, statement.str().c_str(), -1, &sqlStmtPtr, nullptr);
4144
1/1
✓ Branch 1 taken 1 time.
1 code = sqlite3_step(sqlStmtPtr);
4145
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (code == SQLITE_ROW) {
4146
1/1
✓ Branch 1 taken 1 time.
1 xVal = sqlite3_column_double(sqlStmtPtr, 0);
4147
1/1
✓ Branch 1 taken 1 time.
1 yVal = sqlite3_column_double(sqlStmtPtr, 1);
4148 1 yValPrevious = yVal;
4149
1/1
✓ Branch 1 taken 1 time.
1 illuminanceVal = sqlite3_column_double(sqlStmtPtr, 2);
4150
1/1
✓ Branch 1 taken 1 time.
1 x.push_back(xVal);
4151
1/1
✓ Branch 1 taken 1 time.
1 y.push_back(yVal);
4152
1/1
✓ Branch 1 taken 1 time.
1 illuminance.push_back(illuminanceVal);
4153 }
4154
1/1
✓ Branch 1 taken 1 time.
1 code = sqlite3_step(sqlStmtPtr);
4155
4156
3/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 1 time.
10 while ((code == SQLITE_ROW) && (!yValChanged)) {
4157
1/1
✓ Branch 1 taken 9 times.
9 xVal = sqlite3_column_double(sqlStmtPtr, 0);
4158
1/1
✓ Branch 1 taken 9 times.
9 yVal = sqlite3_column_double(sqlStmtPtr, 1);
4159
1/1
✓ Branch 1 taken 9 times.
9 illuminanceVal = sqlite3_column_double(sqlStmtPtr, 2);
4160
4161
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 8 times.
9 if (yVal != yValPrevious) {
4162
1/1
✓ Branch 1 taken 1 time.
1 y.push_back(yVal);
4163 1 yValPrevious = yVal;
4164 1 yValChanged = true;
4165 } else {
4166
1/1
✓ Branch 1 taken 8 times.
8 x.push_back(xVal);
4167 }
4168
4169
1/1
✓ Branch 1 taken 9 times.
9 illuminance.push_back(illuminanceVal);
4170
4171 // step to next row
4172
4173
1/1
✓ Branch 1 taken 9 times.
9 code = sqlite3_step(sqlStmtPtr);
4174 } // while
4175
4176
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 1 time.
72 while (code == SQLITE_ROW) {
4177
1/1
✓ Branch 1 taken 71 times.
71 yVal = sqlite3_column_double(sqlStmtPtr, 1);
4178
1/1
✓ Branch 1 taken 71 times.
71 illuminanceVal = sqlite3_column_double(sqlStmtPtr, 2);
4179
4180
1/1
✓ Branch 1 taken 71 times.
71 illuminance.push_back(illuminanceVal);
4181 // wrap columns at N
4182
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 64 times.
71 if (yVal != yValPrevious) {
4183
1/1
✓ Branch 1 taken 7 times.
7 y.push_back(yVal);
4184 7 yValPrevious = yVal;
4185 }
4186
4187 // step to next row
4188
1/1
✓ Branch 1 taken 71 times.
71 code = sqlite3_step(sqlStmtPtr);
4189 }
4190
4191 /// must finalize to prevent memory leaks
4192
1/1
✓ Branch 1 taken 1 time.
1 sqlite3_finalize(sqlStmtPtr);
4193 1 }
4194
4195 /// value (lux) of the illuminance map at hourlyReportIndex
4196 /// value(i,j) is the illuminance at x(i), y(j)
4197 1 Matrix SqlFile_Impl::illuminanceMap(int hourlyReportIndex) const {
4198
4199 /// loop over all points
4200
1/1
✓ Branch 1 taken 1 time.
1 Vector x = SqlFile_Impl::illuminanceMapX(hourlyReportIndex);
4201
1/1
✓ Branch 1 taken 1 time.
1 Vector y = SqlFile_Impl::illuminanceMapY(hourlyReportIndex);
4202
1/1
✓ Branch 1 taken 1 time.
1 unsigned M = x.size();
4203
1/1
✓ Branch 1 taken 1 time.
1 unsigned N = y.size();
4204
1/1
✓ Branch 1 taken 1 time.
1 Matrix illuminance(M, N, 0);
4205
4206 1 unsigned i = 0;
4207 1 unsigned j = 0;
4208
4209
1/1
✓ Branch 1 taken 1 time.
1 std::stringstream statement;
4210
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 statement << "select Illuminance from daylightmaphourlydata where HourlyReportIndex=" << hourlyReportIndex << " order by X asc, Y asc";
4211
4212 sqlite3_stmt* sqlStmtPtr;
4213
4214
2/2
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
1 int code = sqlite3_prepare_v2(m_db, statement.str().c_str(), -1, &sqlStmtPtr, nullptr);
4215
1/1
✓ Branch 1 taken 1 time.
1 code = sqlite3_step(sqlStmtPtr);
4216
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 1 time.
82 while (code == SQLITE_ROW) {
4217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if (i >= M) {
4218 ✗ LOG(Error, "Too much illuminance map data retrieved at time index " << hourlyReportIndex << " for map name = '" << hourlyReportIndex
4219 << "'. Size is " << M << "x" << N << ", current i is " << i
4220 << ", current j is " << j);
4221 ✗ break;
4222 }
4223
4224
2/2
✓ Branch 1 taken 81 times.
✓ Branch 4 taken 81 times.
81 illuminance(i, j) = sqlite3_column_double(sqlStmtPtr, 0);
4225
4226 // step to next row
4227
1/1
✓ Branch 1 taken 81 times.
81 code = sqlite3_step(sqlStmtPtr);
4228
4229 // wrap columns at N
4230 81 ++j;
4231
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 72 times.
81 if (j == N) {
4232 9 j = 0;
4233 9 ++i;
4234 }
4235 }
4236
4237 /// must finalize to prevent memory leaks
4238
1/1
✓ Branch 1 taken 1 time.
1 sqlite3_finalize(sqlStmtPtr);
4239
4240 2 return illuminance;
4241 1 }
4242
4243 // find the illuminance map index by name
4244 12 boost::optional<int> SqlFile_Impl::illuminanceMapIndex(const std::string& name) const {
4245 // TODO: haven't figured out how to bind properly to the LIKE statement, tried
4246 // LIKE ?
4247 // LIKE %?% => sqlite3_prepare_v2 fails
4248 // LIKE %%?%%
4249 // LIKE '%?%' (not recognized as a placeholder)
4250
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 const std::string& s = "SELECT MapNumber FROM DaylightMaps WHERE MapName LIKE '%" + name + "%'";
4251
1/1
✓ Branch 1 taken 12 times.
24 return execAndReturnFirstInt(s);
4252 12 }
4253
4254 56 void SqlFile_Impl::mf_makeConsistent(std::vector<SqlFileTimeSeriesQuery>& queries) {
4255 // make each query consistent, or delete it if there is no possibility of a matching TimeSeries
4256 // do not check name validity--only cross-validity
4257
2/2
✓ Branch 4 taken 105 times.
✓ Branch 5 taken 56 times.
161 for (auto queryIt = queries.begin(); queryIt < queries.end();) {
4258 // environment
4259 105 OptionalString envName;
4260
10/22
✓ Branch 2 taken 105 times.
✓ Branch 5 taken 105 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 105 times.
✓ Branch 12 taken 105 times.
✓ Branch 15 taken 105 times.
✓ Branch 18 taken 105 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 105 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 105 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 105 times.
✗ Branch 27 not taken.
✓ Branch 29 taken 105 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
315 if (queryIt->environment() && queryIt->environment()->name()) {
4261
3/3
✓ Branch 2 taken 105 times.
✓ Branch 5 taken 105 times.
✓ Branch 8 taken 105 times.
105 envName = queryIt->environment()->name();
4262 }
4263
4264 // reporting frequency
4265 105 OptionalReportingFrequency rf;
4266
3/3
✓ Branch 2 taken 105 times.
✓ Branch 5 taken 104 times.
✓ Branch 6 taken 1 time.
210 if (queryIt->reportingFrequency()) {
4267
1/1
✓ Branch 2 taken 104 times.
104 rf = queryIt->reportingFrequency();
4268 }
4269 105 ReportingFrequencySet rfSet;
4270
5/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 104 times.
✓ Branch 5 taken 1 time.
210 if (envName && rf) {
4271 // check compatibility
4272
2/2
✓ Branch 1 taken 104 times.
✓ Branch 4 taken 104 times.
104 rfSet = availableReportingFrequencySet(*this, *envName);
4273
3/4
✓ Branch 2 taken 104 times.
✓ Branch 5 taken 104 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 104 times.
104 if (rfSet.find(*rf) == rfSet.end()) {
4274 ✗ queryIt = queries.erase(queryIt);
4275 ✗ continue;
4276 }
4277 }
4278
4279 // time series
4280 105 OptionalString tsName;
4281
14/22
✓ Branch 2 taken 105 times.
✓ Branch 5 taken 100 times.
✓ Branch 6 taken 5 times.
✓ Branch 9 taken 100 times.
✓ Branch 12 taken 100 times.
✓ Branch 15 taken 100 times.
✓ Branch 18 taken 100 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 100 times.
✓ Branch 21 taken 5 times.
✓ Branch 23 taken 100 times.
✓ Branch 24 taken 5 times.
✓ Branch 26 taken 105 times.
✗ Branch 27 not taken.
✓ Branch 29 taken 100 times.
✓ Branch 30 taken 5 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
310 if (queryIt->timeSeries() && queryIt->timeSeries()->name()) {
4282
3/3
✓ Branch 2 taken 100 times.
✓ Branch 5 taken 100 times.
✓ Branch 8 taken 100 times.
100 tsName = queryIt->timeSeries()->name();
4283 }
4284 105 IStringSet tsSet;
4285 105 StringVector temp;
4286 105 StringVector envNames;
4287
5/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 5 times.
210 if (envName && tsName) {
4288
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if (rf) {
4289
4/4
✓ Branch 1 taken 100 times.
✓ Branch 4 taken 100 times.
✓ Branch 7 taken 100 times.
✓ Branch 10 taken 100 times.
100 temp = availableVariableNames(*envName, rf->valueDescription());
4290
1/1
✓ Branch 3 taken 100 times.
100 tsSet.insert(temp.begin(), temp.end());
4291 } else {
4292 ✗ rfSet = availableReportingFrequencySet(*this, *envName);
4293 ✗ for (const ReportingFrequency& rf : rfSet) {
4294 ✗ temp = availableVariableNames(*envName, rf.valueDescription());
4295 ✗ tsSet.insert(temp.begin(), temp.end());
4296 }
4297 }
4298
4/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
9 } else if (rf && tsName) {
4299 ✗ envNames = availableEnvPeriods();
4300 ✗ for (const std::string& envName : envNames) {
4301 ✗ temp = availableVariableNames(envName, rf->valueDescription());
4302 ✗ tsSet.insert(temp.begin(), temp.end());
4303 }
4304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 } else if (tsName) {
4305 ✗ temp = availableTimeSeries();
4306 ✗ tsSet.insert(temp.begin(), temp.end());
4307 }
4308
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
105 if (tsName) {
4309
3/4
✓ Branch 2 taken 100 times.
✓ Branch 5 taken 100 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 100 times.
100 if (tsSet.find(*tsName) == tsSet.end()) {
4310 ✗ queryIt = queries.erase(queryIt);
4311 ✗ continue;
4312 }
4313 }
4314
4315 // key values
4316 // for now, only check if tsName is specified
4317 105 StringVector keyValueNames;
4318 105 StringVector kvAvail;
4319 105 IStringSet keepers;
4320
9/24
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 5 times.
✓ Branch 5 taken 100 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 100 times.
✗ Branch 12 not taken.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 105 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 105 times.
✓ Branch 29 taken 100 times.
✓ Branch 30 taken 5 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 105 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
310 if (tsName && queryIt->keyValues() && !(queryIt->keyValues().get().regex())) {
4321 ✗ keyValueNames = queryIt->keyValues()->names();
4322 ✗ if (envName && rf) {
4323 ✗ kvAvail = availableKeyValues(*envName, rf->valueDescription(), *tsName);
4324 ✗ for (const std::string& kv : keyValueNames) {
4325 ✗ auto it = std::find_if(kvAvail.cbegin(), kvAvail.cend(), [&kv](const auto& k) { return istringEqual(kv, k); });
4326 ✗ if (it != kvAvail.end()) {
4327 ✗ keepers.insert(*it);
4328 }
4329 }
4330 ✗ } else if (envName) {
4331 ✗ OS_ASSERT(!rfSet.empty());
4332 ✗ for (const ReportingFrequency& rf : rfSet) {
4333 ✗ kvAvail = availableKeyValues(*envName, rf.valueDescription(), *tsName);
4334 ✗ for (const std::string& kv : keyValueNames) {
4335 ✗ auto it = std::find_if(kvAvail.cbegin(), kvAvail.cend(), [&kv](const auto& k) { return istringEqual(kv, k); });
4336 ✗ if (it != kvAvail.end()) {
4337 ✗ keepers.insert(*it);
4338 }
4339 }
4340 }
4341 ✗ } else if (rf) {
4342 ✗ OS_ASSERT(!envNames.empty());
4343 ✗ for (const std::string& envName : envNames) {
4344 ✗ kvAvail = availableKeyValues(envName, rf->valueDescription(), *tsName);
4345 ✗ for (const std::string& kv : keyValueNames) {
4346 ✗ auto it = std::find_if(kvAvail.cbegin(), kvAvail.cend(), [&kv](const auto& k) { return istringEqual(kv, k); });
4347 ✗ if (it != kvAvail.end()) {
4348 ✗ keepers.insert(*it);
4349 }
4350 }
4351 }
4352 } else {
4353 ✗ envNames = availableEnvPeriods();
4354 ✗ for (const std::string& envName : envNames) {
4355 ✗ rfSet = availableReportingFrequencySet(*this, envName);
4356 ✗ for (const ReportingFrequency& rf : rfSet) {
4357 ✗ kvAvail = availableKeyValues(envName, rf.valueDescription(), *tsName);
4358 ✗ for (const std::string& kv : keyValueNames) {
4359 ✗ auto it = std::find_if(kvAvail.cbegin(), kvAvail.cend(), [&kv](const auto& k) { return istringEqual(kv, k); });
4360 ✗ if (it != kvAvail.end()) {
4361 ✗ keepers.insert(*it);
4362 ✗ if (keepers.size() == keyValueNames.size()) {
4363 ✗ break;
4364 }
4365 }
4366 }
4367 ✗ if (keepers.size() == keyValueNames.size()) {
4368 ✗ break;
4369 }
4370 }
4371 ✗ if (keepers.size() == keyValueNames.size()) {
4372 ✗ break;
4373 }
4374 }
4375 }
4376 // set key values to keepers
4377 ✗ if (keepers.empty()) {
4378 ✗ queryIt = queries.erase(queryIt);
4379 ✗ continue;
4380 } else {
4381 ✗ KeyValueIdentifier kvId(StringVector(keepers.begin(), keepers.end()));
4382 ✗ queryIt->setKeyValues(kvId);
4383 ✗ }
4384 }
4385
4386 // check next query
4387 105 ++queryIt;
4388 105 } // for
4389 56 }
4390
4391 // NON-MEMBER HELPER FUNCTIONS
4392 105 ReportingFrequencySet availableReportingFrequencySet(SqlFile_Impl& sqlFileImpl, const std::string& envPeriod) {
4393 105 ReportingFrequencySet rfSet;
4394
1/1
✓ Branch 1 taken 105 times.
105 StringVector rfStrs = sqlFileImpl.availableReportingFrequencies(envPeriod);
4395
2/2
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 105 times.
525 for (const std::string& rfStr : rfStrs) {
4396
1/1
✓ Branch 1 taken 420 times.
420 OptionalReportingFrequency orf = sqlFileImpl.reportingFrequencyFromDB(rfStr);
4397
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if (orf) {
4398
2/2
✓ Branch 1 taken 420 times.
✓ Branch 4 taken 420 times.
420 rfSet.insert(*orf);
4399 }
4400 420 }
4401
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 5 not taken.
105 OS_ASSERT(rfSet.size() == rfStrs.size());
4402 210 return rfSet;
4403 105 }
4404 } // namespace detail
4405
4406 } // namespace openstudio
4407