lib/measures/create_parametric_schedules/measure.rb in openstudio-model-articulation-0.9.0 vs lib/measures/create_parametric_schedules/measure.rb in openstudio-model-articulation-0.10.0

- old
+ new

@@ -6,20 +6,15 @@ # see the URL below for information on how to write OpenStudio measures # http://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/ 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' +# load openstudio-standards gem +require 'openstudio-standards' # start the measure class CreateParametricSchedules < OpenStudio::Measure::ModelMeasure - # resource file modules - include OsLib_HelperMethods - include OsLib_Schedules # human readable name def name return 'Create Parametric Schedules' end @@ -494,11 +489,12 @@ # define what happens when the measure is run def run(model, runner, user_arguments) super(model, runner, user_arguments) # assign the user inputs to variables - args = OsLib_HelperMethods.createRunVariables(runner, model, user_arguments, arguments(model)) + args = runner.getArgumentValues(arguments(model), user_arguments) + args = Hash[args.collect{ |k, v| [k.to_s, v] }] if !args then return false end # create array from argument, clean up and check if measure should alter model valid_building_names = [] args['valid_building_names'].split(',').each do |name| @@ -508,11 +504,12 @@ runner.registerAsNotApplicable("#{model.getBuilding.name} isn't listed as building to apply measure to. Model won't be altered") return true end # look at upstream measure for 'hoo_per_week' argument - hoo_per_week_from_osw = OsLib_HelperMethods.check_upstream_measure_for_arg(runner, 'hoo_per_week') + hoo_per_week_from_osw = runner.getPastStepValuesForName('hoo_per_week') + hoo_per_week_from_osw = hoo_per_week_from_osw.collect{ |k, v| Hash[:measure_name => k, :value => v] }.first if !hoo_per_week_from_osw.empty? if !hoo_per_week_from_osw.empty? runner.registerInfo("Replacing argument named 'hoo_per_week' from current measure with a value of #{hoo_per_week_from_osw[:value]} from #{hoo_per_week_from_osw[:measure_name]}.") args['hoo_per_week'] = hoo_per_week_from_osw[:value].to_f end @@ -714,11 +711,11 @@ options = { 'name' => ruleset_name, 'winter_design_day' => winter_design_day, 'summer_design_day' => summer_design_day, 'default_day' => default_day, 'rules' => rules } - hoo_sch = OsLib_Schedules.createComplexSchedule(model, options) + hoo_sch = OpenstudioStandards::Schedules.create_complex_schedule(model, options) default_schedule_set.setHoursofOperationSchedule(hoo_sch) # create activity schedule # todo - save this from model or add user argument ruleset_name = 'Parametric Activity Schedule' @@ -729,11 +726,11 @@ options = { 'name' => ruleset_name, 'winter_design_day' => winter_design_day, 'summer_design_day' => summer_design_day, 'default_day' => default_day, 'rules' => rules } - activity_sch = OsLib_Schedules.createComplexSchedule(model, options) + activity_sch = OpenstudioStandards::Schedules.create_complex_schedule(model, options) default_schedule_set.setPeopleActivityLevelSchedule(activity_sch) # generate and apply lighting schedule using hours of operation schedule and parametric inputs ruleset_name = 'Parametric Lighting Schedule' hash = process_hash(runner, args['lighting_profiles'], args, profile_override, ruleset_name) @@ -748,11 +745,11 @@ 'winter_design_day' => winter_design_day, 'summer_design_day' => summer_design_day, 'default_day' => default_day, 'rules' => rules } - lighting_sch = OsLib_Schedules.createComplexSchedule(model, options) + lighting_sch = OpenstudioStandards::Schedules.create_complex_schedule(model, options) lighting_sch.setComment(args['lighting_profiles']) default_schedule_set.setLightingSchedule(lighting_sch) # generate and apply electric_equipment schedule using hours of operation schedule and parametric inputs ruleset_name = 'Parametric Electric Equipment Schedule' @@ -767,11 +764,11 @@ options = { 'name' => ruleset_name, 'winter_design_day' => winter_design_day, 'summer_design_day' => summer_design_day, 'default_day' => default_day, 'rules' => rules } - electric_equipment_sch = OsLib_Schedules.createComplexSchedule(model, options) + electric_equipment_sch = OpenstudioStandards::Schedules.create_complex_schedule(model, options) electric_equipment_sch.setComment(args['electric_equipment_profiles']) default_schedule_set.setElectricEquipmentSchedule(electric_equipment_sch) # generate and apply gas_equipment schedule using hours of operation schedule and parametric inputs ruleset_name = 'Parametric Gas Equipment Schedule' @@ -786,11 +783,11 @@ options = { 'name' => ruleset_name, 'winter_design_day' => winter_design_day, 'summer_design_day' => summer_design_day, 'default_day' => default_day, 'rules' => rules } - gas_equipment_sch = OsLib_Schedules.createComplexSchedule(model, options) + gas_equipment_sch = OpenstudioStandards::Schedules.create_complex_schedule(model, options) gas_equipment_sch.setComment(args['gas_equipment_profiles']) default_schedule_set.setGasEquipmentSchedule(gas_equipment_sch) # generate and apply occupancy schedule using hours of operation schedule and parametric inputs ruleset_name = 'Parametric Occupancy Schedule' @@ -805,11 +802,11 @@ options = { 'name' => ruleset_name, 'winter_design_day' => winter_design_day, 'summer_design_day' => summer_design_day, 'default_day' => default_day, 'rules' => rules } - occupancy_sch = OsLib_Schedules.createComplexSchedule(model, options) + occupancy_sch = OpenstudioStandards::Schedules.create_complex_schedule(model, options) occupancy_sch.setComment(args['occupancy_profiles']) default_schedule_set.setNumberofPeopleSchedule(occupancy_sch) # generate and apply infiltration schedule using hours of operation schedule and parametric inputs ruleset_name = 'Parametric Infiltration Schedule' @@ -824,11 +821,11 @@ options = { 'name' => ruleset_name, 'winter_design_day' => winter_design_day, 'summer_design_day' => summer_design_day, 'default_day' => default_day, 'rules' => rules } - infiltration_sch = OsLib_Schedules.createComplexSchedule(model, options) + infiltration_sch = OpenstudioStandards::Schedules.create_complex_schedule(model, options) infiltration_sch.setComment(args['infiltration_profiles']) default_schedule_set.setInfiltrationSchedule(infiltration_sch) # generate and apply hvac_availability schedule using hours of operation schedule and parametric inputs ruleset_name = 'Parametric HVAC Availability Schedule' @@ -843,11 +840,11 @@ options = { 'name' => ruleset_name, 'winter_design_day' => winter_design_day, 'summer_design_day' => summer_design_day, 'default_day' => default_day, 'rules' => rules } - hvac_availability_sch = OsLib_Schedules.createComplexSchedule(model, options) + hvac_availability_sch = OpenstudioStandards::Schedules.create_complex_schedule(model, options) hvac_availability_sch.setComment(args['hvac_availability_profiles']) # apply HVAC schedules # todo - measure currently only replaces AirLoopHVAC.setAvailabilitySchedule) air_loops_to_alter.each do |air_loop| @@ -878,11 +875,11 @@ options = { 'name' => ruleset_name, 'winter_design_day' => winter_design_day, 'summer_design_day' => summer_design_day, 'default_day' => default_day, 'rules' => rules } - heating_setpoint_sch = OsLib_Schedules.createComplexSchedule(model, options) + heating_setpoint_sch = OpenstudioStandards::Schedules.create_complex_schedule(model, options) # generate and apply cooling_setpoint schedule using hours of operation schedule and parametric inputs ruleset_name = 'Parametric Cooling Setpoint Schedule' # clg setpoints @@ -906,11 +903,11 @@ options = { 'name' => ruleset_name, 'winter_design_day' => winter_design_day, 'summer_design_day' => summer_design_day, 'default_day' => default_day, 'rules' => rules } - cooling_setpoint_sch = OsLib_Schedules.createComplexSchedule(model, options) + cooling_setpoint_sch = OpenstudioStandards::Schedules.create_complex_schedule(model, options) # apply heating and cooling setpoint schedules thermostats_to_alter.each do |thermostat| thermostat.setHeatingSchedule(heating_setpoint_sch) thermostat.setCoolingSchedule(cooling_setpoint_sch) @@ -929,10 +926,10 @@ options = { 'name' => ruleset_name, 'winter_design_day' => winter_design_day, 'summer_design_day' => summer_design_day, 'default_day' => default_day, 'rules' => rules } - swh_sch = OsLib_Schedules.createComplexSchedule(model, options) + swh_sch = OpenstudioStandards::Schedules.create_complex_schedule(model, options) swh_sch.setComment(args['swh_profiles']) water_use_equipment_to_alter.each do |water_use_equipment| water_use_equipment.setFlowRateFractionSchedule(swh_sch) end