Skip to content

Commit

Permalink
Make convertArguments generic so we can use in resstock.
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-robertson committed Nov 4, 2024
1 parent 2f31f5b commit 6e3bb51
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 40 deletions.
42 changes: 8 additions & 34 deletions BuildResidentialHPXML/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5133,40 +5133,6 @@ def makeArgument(name:,
return args
end

# TODO
def convertArgumentValues(arguments_model, args)
args.each do |name, value|
if value == Constants::Auto
args.delete(name)
next
end

arg = arguments_model.find { |a| name == a.name.to_sym }
type = arg.type

if type == 'Choice'.to_OSArgumentType
choices = arg.choiceValues
if choices.include?(Constants::Auto)
if value.downcase.to_s == 'true'
args[name] = true
elsif value.downcase.to_s == 'false'
args[name] = false
end
end
elsif type == 'String'.to_OSArgumentType
begin
args[name] = Integer(value)
rescue
begin
args[name] = Float(value)
rescue
end
end
end
end
return args
end

# TODO
def defaultOptionalArgumentValues(args)
# these were previously required arguments with default values set
Expand All @@ -5187,9 +5153,17 @@ def defaultOptionalArgumentValues(args)
args[:neighbor_left_distance] = 10.0 if args[:neighbor_left_distance].nil?
args[:neighbor_right_distance] = 10.0 if args[:neighbor_right_distance].nil?
args[:overhangs_front_depth] = 0 if args[:overhangs_front_depth].nil?
args[:overhangs_front_distance_to_top_of_window] = 0 if args[:overhangs_front_distance_to_top_of_window].nil?
args[:overhangs_front_distance_to_bottom_of_window] = 4 if args[:overhangs_front_distance_to_bottom_of_window].nil?
args[:overhangs_back_depth] = 0 if args[:overhangs_back_depth].nil?
args[:overhangs_back_distance_to_top_of_window] = 0 if args[:overhangs_back_distance_to_top_of_window].nil?
args[:overhangs_back_distance_to_bottom_of_window] = 4 if args[:overhangs_back_distance_to_bottom_of_window].nil?
args[:overhangs_left_depth] = 0 if args[:overhangs_left_depth].nil?
args[:overhangs_left_distance_to_top_of_window] = 0 if args[:overhangs_left_distance_to_top_of_window].nil?
args[:overhangs_left_distance_to_bottom_of_window] = 4 if args[:overhangs_left_distance_to_bottom_of_window].nil?
args[:overhangs_right_depth] = 0 if args[:overhangs_right_depth].nil?
args[:overhangs_right_distance_to_top_of_window] = 0 if args[:overhangs_right_distance_to_top_of_window].nil?
args[:overhangs_right_distance_to_bottom_of_window] = 4 if args[:overhangs_right_distance_to_bottom_of_window].nil?
args[:skylight_ufactor] = 0.33 if args[:skylight_ufactor].nil?
args[:skylight_shgc] = 0.45 if args[:skylight_shgc].nil?
args[:heating_system_2_type] = Constants::None if args[:heating_system_2_type].nil?
Expand Down
6 changes: 3 additions & 3 deletions BuildResidentialHPXML/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>build_residential_hpxml</name>
<uid>a13a8983-2b01-4930-8af2-42030b6e4233</uid>
<version_id>f395b10d-1835-4a9c-a974-84f065590fb2</version_id>
<version_modified>2024-11-04T17:29:08Z</version_modified>
<version_id>1f5d4f80-84aa-4782-a014-a377a70ea0d2</version_id>
<version_modified>2024-11-04T18:08:10Z</version_modified>
<xml_checksum>2C38F48B</xml_checksum>
<class_name>BuildResidentialHPXML</class_name>
<display_name>HPXML Builder</display_name>
Expand Down Expand Up @@ -7628,7 +7628,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>4DE55017</checksum>
<checksum>44646A2C</checksum>
</file>
<file>
<filename>constants.rb</filename>
Expand Down
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>5ba92132-b948-4d22-ba2f-2b01e874ee21</version_id>
<version_modified>2024-11-01T16:22:35Z</version_modified>
<version_id>67aeb4d4-239a-428c-b4d5-3f56a8404f3d</version_id>
<version_modified>2024-11-04T18:08: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>F335EDC8</checksum>
<checksum>B5131E34</checksum>
</file>
<file>
<filename>minitest_helper.rb</filename>
Expand Down
34 changes: 34 additions & 0 deletions HPXMLtoOpenStudio/resources/meta_measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -624,3 +624,37 @@ def is_integer?
return true
end
end

# TODO
def convertArgumentValues(arguments_model, args, delete_auto = true)
args.each do |name, value|
if delete_auto && value == Constants::Auto
args.delete(name)
next
end

arg = arguments_model.find { |a| name == a.name.to_sym }
type = arg.type

if type == 'Choice'.to_OSArgumentType
choices = arg.choiceValues
if choices.include?(Constants::Auto)
if value.downcase.to_s == 'true'
args[name] = true
elsif value.downcase.to_s == 'false'
args[name] = false
end
end
elsif type == 'String'.to_OSArgumentType
begin
args[name] = Integer(value)
rescue
begin
args[name] = Float(value)
rescue
end
end
end
end
return args
end

0 comments on commit 6e3bb51

Please sign in to comment.