NREL / OpenStudio

OpenStudio is a cross-platform collection of software tools to support whole building energy modeling using EnergyPlus and advanced daylight analysis using Radiance.
https://www.openstudio.net/
Other
484 stars 185 forks source link

Issue with runner.lastEnergyPlusSqlFile #5147

Closed jmarrec closed 2 months ago

jmarrec commented 2 months ago

Issue overview

Current Behavior

In measure testing:

-sqlFile = OpenStudio::SqlFile.new(OpenStudio::Path.new(sql_path(test_name))) # Works
+sqlFile = runner.lastEnergyPlusSqlFile.get # Fails
 hours = sqlFile.hoursSimulated
 refute_empty(hours)
 assert_equal(8760.0, hours.get)
OpenStudioResults_Test#test_example_model_si:
RuntimeError: Error creating prepared statement: SELECT Value FROM TabularDataWithStrings
                                  WHERE ReportName='InputVerificationandResultsSummary'
                                  AND ReportForString='Entire Facility'
                                  AND TableName='General'
                                  AND RowName='Hours Simulated'
                                  AND Units='hrs' with error code 21, extended code 21, errmsg: bad parameter or other API misuse
    OpenStudioResults_Test.rb:263:in `hoursSimulated'
    OpenStudioResults_Test.rb:263:in `test_example_model_si

Expected Behavior

Steps to Reproduce

Possible Solution

Pretty sure it's because "sql_file.close" is at the end of the measure template...

Details

Environment

Some additional details about your environment for this issue (if relevant):

Context

jmarrec commented 2 months ago

Yep, it's becaue sql_file.close

This fixes it.

    sqlFile = runner.lastEnergyPlusSqlFile.get
    if !sqlFile.connectionOpen
      sqlFile.reopen
    end

I'll adjust the templates