Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues in the resources/measure test #135

Merged
merged 5 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,22 @@ namespace :unit_tests do
if File.exist?(RESOURCE_MEASURETESTS_PATH)
# load test files from file.
full_file_list = FileList.new(File.readlines(RESOURCE_MEASURETESTS_PATH).map(&:chomp))
full_file_list.select! { |item| item.include?('rb')}
full_file_list.select! { |item| item.include?('rb') && File.exist?(item) }
p full_file_list
end
t.test_files = full_file_list
t.test_files = full_file_list.select do |file|
begin
# Try to load the file to check for syntax errors
load file
true
rescue Exception => e
puts "Error in #{file}: #{e.message}"
Minitest::Reporters.reporter.report_error(file, e)
false
end
end
p(full_file_list)
t.verbose = false
t.warning = false
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'minitest/autorun'
require_relative '../measure.rb'
require 'fileutils'
require_relative '../../../../test/helpers/minitest_helper'

class AdjustOccupancyScheduleTest < Minitest::Test
# def setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
require 'minitest/autorun'
require_relative '../measure.rb'
require 'fileutils'
require_relative '../../../../test/helpers/minitest_helper'

class AddHVACSystemTest < MiniTest::Unit::TestCase
class AddHVACSystemTest < Minitest::Test
def test_add_hvac_systems
# Get the original working directory
start_dir = Dir.pwd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
require 'fileutils'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'


# only necessary to include here if annual simulation request and the measure doesn't require openstudio-standards
# require 'openstudio-standards'
Expand Down Expand Up @@ -239,7 +241,7 @@ def test_models
argument_map['changeovertemp'] = changeovertemp

# set arguments: apply measure
apply_measure = arguments[2].clone
apply_measure = arguments[2].clone
assert(apply_measure.setValue(true))
argument_map['apply_measure'] = apply_measure

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
require 'fileutils'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'


# only necessary to include here if annual simulation request and the measure doesn't require openstudio-standards
# require 'openstudio-standards'
Expand Down Expand Up @@ -257,7 +259,7 @@ def test_models
argument_map['damper_pos'] = damper_pos

# set arguments: apply measure
apply_measure = arguments[5].clone
apply_measure = arguments[5].clone
assert(apply_measure.setValue(true))
argument_map['apply_measure'] = apply_measure

Expand Down
40 changes: 23 additions & 17 deletions resources/measures/hvac_nighttime_oa_controls/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def run(model, runner, user_arguments)

# # report final condition of model
# runner.registerFinalCondition("The building finished with #{model.getSpaces.size} spaces.")

template = 'ComStock 90.1-2013'
std = Standard.build(template)

Expand Down Expand Up @@ -159,22 +159,28 @@ def run(model, runner, user_arguments)
li_unitary_systems.sort.each do |air_loop_hvac|

# change night OA schedule to match hvac operation schedule for no night OA
# Schedule to control whether or not unit ventilates at night - clone hvac availability schedule
next unless air_loop_hvac.availabilitySchedule.clone.to_ScheduleRuleset.is_initialized
air_loop_vent_sch = air_loop_hvac.availabilitySchedule.clone.to_ScheduleRuleset.get
air_loop_vent_sch.setName("#{air_loop_hvac.name}_night_novent_schedule")
next unless air_loop_hvac.airLoopHVACOutdoorAirSystem.is_initialized
air_loop_oa_system = air_loop_hvac.airLoopHVACOutdoorAirSystem.get.getControllerOutdoorAir
next unless air_loop_oa_system.minimumOutdoorAirSchedule.is_initialized
air_loop_oa_system.setMinimumOutdoorAirSchedule(air_loop_vent_sch)
oa_schd_op_count += 1
end

# change fan operation schedule to new clone of hvac operation schedule to ensure night cycling of fans (removing any constant schedules)
# Schedule to control whether or not unit ventilates at night - clone hvac availability schedule
next unless air_loop_hvac.availabilitySchedule.to_ScheduleRuleset.is_initialized
air_loop_fan_sch = air_loop_hvac.availabilitySchedule.clone.to_ScheduleRuleset.get
air_loop_fan_sch.setName("#{air_loop_hvac.name}_night_fancycle_schedule")
# Schedule to control whether or not unit ventilates at night - clone hvac availability schedule
next unless air_loop_hvac.availabilitySchedule.clone.to_ScheduleRuleset.is_initialized

air_loop_vent_sch = air_loop_hvac.availabilitySchedule.clone.to_ScheduleRuleset.get
air_loop_vent_sch.setName("#{air_loop_hvac.name}_night_novent_schedule")

next unless air_loop_hvac.airLoopHVACOutdoorAirSystem.is_initialized

air_loop_oa_system = air_loop_hvac.airLoopHVACOutdoorAirSystem.get.getControllerOutdoorAir

next unless air_loop_oa_system.minimumOutdoorAirSchedule.is_initialized

air_loop_oa_system.setMinimumOutdoorAirSchedule(air_loop_vent_sch)
oa_schd_op_count += 1
end

# change fan operation schedule to new clone of hvac operation schedule to ensure night cycling of fans (removing any constant schedules)
# Schedule to control whether or not unit ventilates at night - clone hvac availability schedule
next unless air_loop_hvac.availabilitySchedule.to_ScheduleRuleset.is_initialized

air_loop_fan_sch = air_loop_hvac.availabilitySchedule.clone.to_ScheduleRuleset.get
air_loop_fan_sch.setName("#{air_loop_hvac.name}_night_fancycle_schedule")
# Schedule to control the airloop fan operation schedule
air_loop_hvac.supplyComponents.each do |component|
obj_type = component.iddObjectType.valueName.to_s
Expand Down
18 changes: 13 additions & 5 deletions resources/measures/hvac_nighttime_oa_controls/measure.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.1</schema_version>
<error>/App/Comstock/resources/measures/hvac_nighttime_oa_controls/measure.rb:180: Invalid next</error>
<name>new_measure</name>
<uid>e6960929-a4a7-4447-8dc6-d9dfc6b92765</uid>
<version_id>10ce1645-8cc4-4cf1-b166-08225bff1811</version_id>
<version_modified>2023-12-06T17:53:33Z</version_modified>
<xml_checksum>00000000</xml_checksum>
<version_id>45b31a96-bf2e-4d1b-bf92-98e12cc4ef66</version_id>
<version_modified>2024-03-07T19:16:12Z</version_modified>
<xml_checksum>B3180F38</xml_checksum>
<class_name>NewMeasure</class_name>
<display_name>New Measure</display_name>
<description>Replace this text with an explanation of what the measure does in terms that can be understood by a general building professional audience (building owners, architects, engineers, contractors, etc.). This description will be used to create reports aimed at convincing the owner and/or design team to implement the measure in the actual building design. For this reason, the description may include details about how the measure would be implemented, along with explanations of qualitative benefits associated with the measure. It is good practice to include citations in the measure if the description is taken from a known source or if specific benefits are listed.</description>
Expand Down Expand Up @@ -64,6 +65,12 @@
<usage_type>license</usage_type>
<checksum>CD7F5672</checksum>
</file>
<file>
<filename>README.md</filename>
<filetype>md</filetype>
<usage_type>readme</usage_type>
<checksum>01DF739F</checksum>
</file>
<file>
<filename>README.md.erb</filename>
<filetype>erb</filetype>
Expand All @@ -80,11 +87,12 @@
<version>
<software_program>OpenStudio</software_program>
<identifier>3.6.1</identifier>
<min_compatible>3.6.1</min_compatible>
</version>
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>FE47D144</checksum>
<checksum>A62EED52</checksum>
</file>
<file>
<filename>example_model.osm</filename>
Expand All @@ -96,7 +104,7 @@
<filename>new_measure_test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>576EDB23</checksum>
<checksum>E90B7467</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
require 'minitest/autorun'
require_relative '../measure.rb'
require 'fileutils'
require_relative '../../../../test/helpers/minitest_helper'


class NewMeasureTest < Minitest::Test
# def setup
Expand Down
Loading