Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
4

OpenStudio Reporting with Ruby Scripts

asked 2015-03-09 09:02:04 -0600

dpud12 gravatar image

updated 2017-08-05 13:27:26 -0600

I am using the RunAllOSMs.rb Ruby script from the example script files to run an OpenStudio file from the command line. When I do this, the OpenStuido post process Report.xml file is generated, however when I open up OpenStudio after the simulation completes, the OpenStudio Report is not visible. Is there a way that the OpenStudio Report can be shown after running an OSM from the command line?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2015-03-09 09:59:28 -0600

Good question. The report you see out of the OpenStudio application after a simulation is just a reporting measure that we put in the workflow even if the user doesn't request it. That does not happen with the RunAllOSMs example.

If you want to see that report then you can add code for that measure to be run. If you look at the ruby script in the "tests" folder of the measure you an see what that code looks like. Here is a link to the reporting measures on BCL. The default one is named "Standard Reports".

Here is part of the code, it should result in an HTML file. For reference below is the code from the test.

def test_StandardReports

  assert(File.exist?(modelPath()))
  assert(File.exist?(sqlPath()))

  # create an instance of the measure
  measure = StandardReports.new

  # create an instance of a runner
  runner = OpenStudio::Ruleset::OSRunner.new

  # get arguments and test that they are what we are expecting
  arguments = measure.arguments()
  assert_equal(0, arguments.size)

  # set up runner, this will happen automatically when measure is run in PAT
  runner.setLastOpenStudioModelPath(OpenStudio::Path.new(modelPath))
  runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sqlPath))

  # set argument values to good values and run the measure
  argument_map = OpenStudio::Ruleset::OSArgumentMap.new
  measure.run(runner, argument_map)
  result = runner.result
  show_output(result)
  assert(result.value.valueName == "Success")
  assert(result.warnings.size == 0)
  #assert(result.info.size == 1)

  assert(File.exist?(reportPath()))

end
edit flag offensive delete link more

Comments

We really need to clean up the examples around this. Basically, you want to add the reporting measure to the end of the workflow.

This example shows how to use a RubyJobBuilder to add a measure to a Workflow.

You can get the location of the built in reporting measure with this.

macumber gravatar image macumber  ( 2015-03-09 10:49:36 -0600 )edit

@David Thanks for your help, since the Standard Report test file runs a simulation if the sql file does not yet exist, I was able to eliminate the RunAllOSM code from the workflow entirely (since I am only running one model). @macumber I will try to use the JobBuilder in the next iteration, thanks for the insight.

dpud12 gravatar image dpud12  ( 2015-03-10 09:11:58 -0600 )edit

Also, FYI there is a typo in the RunAllOSMs code, line 65 should read:

filenames = Dir.glob(osmDir.to_s + "/**/*.osm")

instead of

filenames = Dir.glob(osmDir.to_s + "./**/*.osm")
dpud12 gravatar image dpud12  ( 2015-03-10 09:14:31 -0600 )edit
0

answered 2015-03-09 09:58:16 -0600

You can open thereport.html files in any web browser.

edit flag offensive delete link more

Comments

@aparker, I think the example he is using pre-dates measures and even OpenStudio app, I don't think it makes the report.html.

David Goldwasser gravatar image David Goldwasser  ( 2015-03-09 10:15:55 -0600 )edit

Oddly enough, the report.html file only opens for me on Google Chrome, not Internet Explorer

dpud12 gravatar image dpud12  ( 2015-03-10 09:16:35 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Question Tools

1 follower

Stats

Asked: 2015-03-09 09:02:04 -0600

Seen: 394 times

Last updated: Mar 09 '15