diff --git a/HPXMLtoOpenStudio/measure.xml b/HPXMLtoOpenStudio/measure.xml index 1558e95f1f..536e8b1774 100644 --- a/HPXMLtoOpenStudio/measure.xml +++ b/HPXMLtoOpenStudio/measure.xml @@ -3,8 +3,8 @@ 3.1 hpxm_lto_openstudio b1543b30-9465-45ff-ba04-1d1f85e763bc - 2923f17a-1485-4128-903f-cf3ea4a903d5 - 2025-01-10T20:23:40Z + 5c0b6313-0c89-4943-99cf-f9e2e85a45e6 + 2025-01-10T20:25:12Z D8922A73 HPXMLtoOpenStudio HPXML to OpenStudio Translator @@ -429,7 +429,7 @@ meta_measure.rb rb resource - 377E6136 + D11644B9 minitest_helper.rb diff --git a/HPXMLtoOpenStudio/resources/meta_measure.rb b/HPXMLtoOpenStudio/resources/meta_measure.rb index e3647eb04e..88609eb9f8 100644 --- a/HPXMLtoOpenStudio/resources/meta_measure.rb +++ b/HPXMLtoOpenStudio/resources/meta_measure.rb @@ -13,7 +13,7 @@ # # @param rundir [String] The run directory containing all simulation output files # @param measures [Hash] Map of OpenStudio-HPXML measure directory name => List of measure argument hashes -# @param measures_dir [String] Parent directory path of all OpenStudio-HPXML measures +# @param measures_dir [String or Array] Parent directory path(s) of all OpenStudio-HPXML measures # @param debug [Boolean] If true, reports info statements from the runner results # @param run_measures_only [Boolean] True applies only OpenStudio Model measures, skipping IDF generation and the simulation # @param skip_simulation [Boolean] True applies the OpenStudio Model measures and generates the IDF, but skips the simulation @@ -177,7 +177,7 @@ def run_hpxml_workflow(rundir, measures, measures_dir, debug: false, run_measure # Apply OpenStudio measures and arguments (i.e., "run" method) corresponding to a provided Hash. # Optionally, save an OpenStudio Workflow based on the provided Hash. # -# @param measures_dir [String] Parent directory path of all OpenStudio-HPXML measures +# @param measures_dir [String or Array] Parent directory path(s) of all OpenStudio-HPXML measures # @param measures [Hash] Map of OpenStudio-HPXML measure directory name => List of measure argument hashes # @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings # @param model [OpenStudio::Model::Model] OpenStudio Model object @@ -211,8 +211,7 @@ def apply_measures(measures_dir, measures, runner, model, show_measure_calls = t # Call each measure in the specified order measures.keys.each do |measure_subdir| # Gather measure arguments and call measure - full_measure_path = File.join(measures_dir, measure_subdir, 'measure.rb') - check_file_exists(full_measure_path, runner) + full_measure_path = get_full_measure_path(measures_dir, measure_subdir, runner) measure = get_measure_instance(full_measure_path) measures[measure_subdir].each do |args| next unless measure_type == measure.class.superclass.name.to_s @@ -231,9 +230,24 @@ def apply_measures(measures_dir, measures, runner, model, show_measure_calls = t return true end +# Get the full path to a measure.rb file given the measure directory name(s). +# +# @param measures_dir [String or Array] Parent directory path(s) of all OpenStudio-HPXML measures +# @param measure_name [String] Name of the OpenStudio measure directory +# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings +# @return [String] Full path to the measure.rb file +def get_full_measure_path(measures_dir, measure_name, runner) + measures_dirs = measures_dir.is_a?(Array) ? measures_dir : [measures_dir] + measures_dirs.each do |dir| + full_measure_path = File.join(dir, measure_name, 'measure.rb') + return full_measure_path if File.exist?(full_measure_path) + end + register_error("Cannot find measure #{measure_name} in any of the measures_dirs: #{measures_dirs.join(', ')}.", runner) +end + # Apply OpenStudio measures and arguments (i.e., "energyPlusOutputRequests" method) corresponding to a provided Hash. # -# @param measures_dir [String] Parent directory path of all OpenStudio-HPXML measures +# @param measures_dir [String or Array] Parent directory path(s) of all OpenStudio-HPXML measures # @param measures [Hash] Map of OpenStudio-HPXML measure directory name => List of measure argument hashes # @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings # @param model [OpenStudio::Model::Model] OpenStudio Model object @@ -264,7 +278,7 @@ def apply_energyplus_output_requests(measures_dir, measures, runner, model, work # Register an info statement to the OpenStudio Runner about calling measures with arguments. # # @param measure_args [Hash] Map of provided measure arguments to values -# @param measures_dir [String] Parent directory path of all OpenStudio-HPXML measures +# @param measures_dir [String or Array] Parent directory path(s) of all OpenStudio-HPXML measures # @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings # @return [nil] def print_measure_call(measure_args, measure_dir, runner)