Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/NREL/OpenStudio-HPXML int…
Browse files Browse the repository at this point in the history
…o ghp-two-speed-var-speed
  • Loading branch information
yzhou601 committed Jan 10, 2025
2 parents 7facd88 + 0111ed5 commit b1512e2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
6 changes: 3 additions & 3 deletions HPXMLtoOpenStudio/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.1</schema_version>
<name>hpxm_lto_openstudio</name>
<uid>b1543b30-9465-45ff-ba04-1d1f85e763bc</uid>
<version_id>2923f17a-1485-4128-903f-cf3ea4a903d5</version_id>
<version_modified>2025-01-10T20:23:40Z</version_modified>
<version_id>5c0b6313-0c89-4943-99cf-f9e2e85a45e6</version_id>
<version_modified>2025-01-10T20:25:12Z</version_modified>
<xml_checksum>D8922A73</xml_checksum>
<class_name>HPXMLtoOpenStudio</class_name>
<display_name>HPXML to OpenStudio Translator</display_name>
Expand Down Expand Up @@ -429,7 +429,7 @@
<filename>meta_measure.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>377E6136</checksum>
<checksum>D11644B9</checksum>
</file>
<file>
<filename>minitest_helper.rb</filename>
Expand Down
26 changes: 20 additions & 6 deletions HPXMLtoOpenStudio/resources/meta_measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>] 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
Expand Down Expand Up @@ -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<String>] 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
Expand Down Expand Up @@ -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
Expand All @@ -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<String>] 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<String>] 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
Expand Down Expand Up @@ -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<String>] 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)
Expand Down

0 comments on commit b1512e2

Please sign in to comment.