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.