3

Method to check the OpenStudio version?

With the advent of OpenStudio 2.x, my existing measure content needs to support both v1.x and v2.x. How can I tell which version of OpenStudio my measure is running on, from within a measure?

rpg777's avatar
7k
rpg777
asked 2016-10-05 11:46:52 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2017-08-05 13:33:05 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

3

Currently, OpenStudio can report the model version, but there is not a definitive method or test for which version of the OpenStudio codebase (1.x or 2.x) a measure is currently running within. The following crude method was added to the Radiance measure to provide a more definitive OS-version test; while both OS versions are extant, you may want to implement something like this to maintain backward compatibility in your own measures as well:

def got_2x
    v2 = true
    begin 
      got_workflow = OpenStudio::WorkflowJSON # i can haz wofkflow gem?
    rescue NameError
      v2 = false
      return v2
    end
    return v2
end

e.g.

if !got_2x
  # find EnergyPlus with 1.x Runmanager
  co = OpenStudio::Runmanager::ConfigOptions.new 
  co.fastFindEnergyPlus
else 
  require 'openstudio-workflow' #OS2.x only
  epp = OpenStudio::getEnergyPlusExecutable() # yeah, you know me
end

You get the idea.

rpg777's avatar
7k
rpg777
answered 2016-10-05 11:56:34 -0500, updated 2016-10-05 12:06:02 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments