lib/measures/create_parametric_schedules/measure.rb in openstudio-model-articulation-0.5.0 vs lib/measures/create_parametric_schedules/measure.rb in openstudio-model-articulation-0.6.0

- old
+ new

@@ -39,11 +39,11 @@ require 'json' # load OpenStudio measure libraries from openstudio-extension gem require 'openstudio-extension' require 'openstudio/extension/core/os_lib_helper_methods' -require 'openstudio/extension/core/os_lib_schedules.rb' +require 'openstudio/extension/core/os_lib_schedules' # start the measure class CreateParametricSchedules < OpenStudio::Measure::ModelMeasure # resource file modules include OsLib_HelperMethods @@ -204,11 +204,11 @@ occupancy_profiles = OpenStudio::Measure::OSArgument.makeStringArgument('occupancy_profiles', true) occupancy_profiles.setDisplayName('Occupancy Profiles') occupancy_profiles.setDefaultValue(string.join(', ')) args << occupancy_profiles - # note: infiltration, setpoints, and hvac availability follow the same time parameters but use different values + # NOTE: infiltration, setpoints, and hvac availability follow the same time parameters but use different values # Make argument for infiltration_profiles string = [] string << ':default => [[start,1],[start,0.25],[end+vac*0.35,0.25],[end+vac*0.35,1]]' string << ':saturday => [[start,1],[start,0.25],[end+vac*0.25,0.25],[end+vac*0.25,1]]' @@ -334,17 +334,18 @@ end # day_type specific gsub temp_array.each_with_index do |string, i| day_type = string.split('=>').first.delete(':') - if day_type == 'default' + case day_type + when 'default' hoo_start = args['hoo_start_wkdy'] hoo_end = args['hoo_end_wkdy'] - elsif day_type == 'saturday' + when 'saturday' hoo_start = args['hoo_start_sat'] hoo_end = args['hoo_end_sat'] - elsif day_type == 'sunday' + when 'sunday' hoo_start = args['hoo_start_sun'] hoo_end = args['hoo_end_sun'] end if hoo_end >= hoo_start @@ -362,11 +363,11 @@ # re-assemble and convert to hash final_string = temp_array.join(']], :') hash = eval("{#{final_string}}").to_hash - rescue SyntaxError => se + rescue SyntaxError => e runner.registerError("{#{final_string}} could not be converted to a hash.") return false end # continue to process hash and interpolate values @@ -476,11 +477,11 @@ items_to_remove << i else time_values_used << time_value_pair[0] end end - items_to_remove.reverse.each do |i| + items_to_remove.reverse_each do |i| time_value_pairs.delete_at(i) end # if time is > 24 shift to front of array and adjust value rotate_steps = 0 @@ -498,15 +499,16 @@ if time_value_pairs.last[0] != 24.0 time_value_pairs << [24.0, time_value_pairs.first[1]] end # add on text needed for createComplexSchedule - if day_type == :saturday + case day_type + when :saturday time_value_pairs.insert(0, 'Sat') time_value_pairs.insert(0, '1/1-12/31') time_value_pairs.insert(0, 'Saturday') - elsif day_type == :sunday + when :sunday time_value_pairs.insert(0, 'Sun') time_value_pairs.insert(0, '1/1-12/31') time_value_pairs.insert(0, 'Sunday') else # weekday time_value_pairs.insert(0, 'Default') @@ -621,10 +623,11 @@ if args['standards_space_type'] != '' next if !space_type.standardsSpaceType.is_initialized next if space_type.standardsSpaceType.get != args['standards_space_type'] end next if space_type.spaces.empty? + space_types_to_alter << space_type end # create shared deafult schedule set default_schedule_set = OpenStudio::Model::DefaultScheduleSet.new(model) @@ -644,10 +647,11 @@ # don't have to remove HVAC and setpoint schedules, they will be replaced individually # remove schedule sets. model.getDefaultScheduleSets.each do |sch_set| next if sch_set == default_schedule_set + sch_set.remove end # assign default schedule set to building level model.getBuilding.setDefaultScheduleSet(default_schedule_set) @@ -701,10 +705,11 @@ # add water use equipment not assigned to space if requested if args['alter_swh_wo_space'] model.getWaterUseEquipments.each do |water_use_equipment| next if water_use_equipment.space.is_initialized + water_use_equipment_to_alter << water_use_equipment end end end @@ -858,10 +863,10 @@ # generate and apply hvac_availability schedule using hours of operation schedule and parametric inputs ruleset_name = 'Parametric HVAC Availability Schedule' hash = process_hash(runner, args['hvac_availability_profiles'], args, profile_override, ruleset_name) if !hash then runner.registerError("Failed to generate #{ruleset_name}"); return false end winter_design_day = [[24, 1]] # TODO: - confirm proper value - summer_design_day = [[24, 1]] # todo - confirm proper value + summer_design_day = [[24, 1]] # TODO: - confirm proper value default_day = hash[:default] rules = [] rules << hash[:saturday] rules << hash[:sunday] options = { 'name' => ruleset_name,