Measures/m_4_example_4_halt_program_based_on_constraint/measure.rb
# define the arguments that the user will input
define the arguments that the user will input
define the arguments that the user will input
def arguments(model)
    args = OpenStudio::Measure::OSArgumentVector.new
	verbose_info_statements = OpenStudio::Ruleset::OSArgument::makeBoolArgument("verbose_info_statements", false)
	verbose_info_statements.setDisplayName("Check to allow measure to generate verbose runner.registerInfo statements.")
	verbose_info_statements.setDefaultValue(false)
	args << verbose_info_statements
    tz_handles = OpenStudio::StringVector.new
    tz_display_names = OpenStudio::StringVector.new
    tz_hash = {}
    model.getThermalZones.each do |tz|
      tz_hash[tz.name.to_s] = tz
    end
    tz_hash.sort.map do |tz_name, tz|
      if tz.thermostatSetpointDualSetpoint.is_initialized
        tstat = tz.thermostatSetpointDualSetpoint.get
        if tstat.heatingSetpointTemperatureSchedule.is_initialized || tstat.coolingSetpointTemperatureSchedule.is_initialized
          tz_handles << tz.handle.to_s
          tz_display_names << tz_name
        end
      end
    end
    building = model.getBuilding
    tz_handles << building.handle.to_s
    tz_display_names << '*All Thermal Zones*'    
    zones = OpenStudio::Measure::OSArgument.makeChoiceArgument('zones', tz_handles, tz_display_names, true)
    zones.setDisplayName('Choose Conditioned Thermal Zone(s) to apply EMS Fanger comfort model PMV graceful failure limits to. NOTE: The thermal zone must have People objects attached to it..')
    args << zones
    comfortWarnings = OpenStudio::Measure::OSArgument.makeBoolArgument('comfortWarnings', true)
    comfortWarnings.setDisplayName('Enable ASHRAE 55 Comfort Warnings?')
    comfortWarnings.setDefaultValue(false)
    args << comfortWarnings
    chs1 = OpenStudio::StringVector.new
    chs1 << 'ZoneAveraged'
    chs1 << 'SurfaceWeighted'
    meanRadiantCalcType = OpenStudio::Measure::OSArgument.makeChoiceArgument('meanRadiantCalcType', chs1, true)
    meanRadiantCalcType.setDisplayName('Mean Radiant Temperature Calculation Type.')
    meanRadiantCalcType.setDefaultValue('ZoneAveraged')
    args << meanRadiantCalcType
    schedule_args = model.getSchedules
    schedule_args_hash = {}
    schedule_args.each do |schedule_arg|
      schedule_args_hash[schedule_arg.name.to_s] = schedule_arg
    end
    fractional_schedule_handles = OpenStudio::StringVector.new
    fractional_schedule_display_names = OpenStudio::StringVector.new
    schedule_args_hash.sort.map do |key, value|
      next if value.scheduleTypeLimits.empty?
      if (value.scheduleTypeLimits.get.unitType == 'Dimensionless') && !value.scheduleTypeLimits.get.lowerLimitValue.empty? && !value.scheduleTypeLimits.get.upperLimitValue.empty?
        next if value.scheduleTypeLimits.get.lowerLimitValue.get != 0.0
        next if value.scheduleTypeLimits.get.upperLimitValue.get != 1.0
        fractional_schedule_handles << value.handle.to_s
        fractional_schedule_display_names << key
      end
    end
    work_efficiency_schedule = OpenStudio::Measure::OSArgument.makeChoiceArgument('work_efficiency_schedule', fractional_schedule_handles, fractional_schedule_display_names, true)
    work_efficiency_schedule.setDisplayName('Choose a Work Efficiency Schedule.')
    args << work_efficiency_schedule
    clothing_schedule_handles = OpenStudio::StringVector.new
    clothing_schedule_display_names = OpenStudio::StringVector.new
    schedule_args_hash.sort.map do |key,value|
      next if value.scheduleTypeLimits.empty?
      if value.scheduleTypeLimits.get.unitType == "ClothingInsulation"
        clothing_schedule_handles << value.handle.to_s
        clothing_schedule_display_names << key
      end
    end
    clothing_schedule = OpenStudio::Ruleset::OSArgument::makeChoiceArgument("clothing_schedule",clothing_schedule_handles, clothing_schedule_display_names,true)
    clothing_schedule.setDisplayName("Choose a Clothing Insulation Schedule.")
    if clothing_schedule_display_names.size > 0
      clothing_schedule.setDefaultValue(clothing_schedule_display_names[0]) 
    end
    args << clothing_schedule
    airVelocity_schedule_handles = OpenStudio::StringVector.new
    airVelocity_schedule_display_names = OpenStudio::StringVector.new
    schedule_args_hash.sort.map do |key, value|
      next if value.scheduleTypeLimits.empty?
      if value.scheduleTypeLimits.get.unitType == 'Velocity'
        airVelocity_schedule_handles << value.handle.to_s
        airVelocity_schedule_display_names << key
      end
    end
    air_velocity_schedule = OpenStudio::Measure::OSArgument.makeChoiceArgument('air_velocity_schedule', airVelocity_schedule_handles, airVelocity_schedule_display_names, true)
    air_velocity_schedule.setDisplayName('Choose an Air Velocity Schedule.')
    if !airVelocity_schedule_display_names.empty?
      air_velocity_schedule.setDefaultValue(airVelocity_schedule_display_names[0]) 
    end
    args << air_velocity_schedule
    chs2 = OpenStudio::StringVector.new
    chs2 << '60'
    chs2 << '30'
    chs2 << '15'
    chs2 << '10'
    chs2 << '6'
    model_time_step = OpenStudio::Measure::OSArgument.makeChoiceArgument('model_time_step', chs2, true)
    model_time_step.setDisplayName('Timestep to be used for model, in minutes.')
    model_time_step.setDefaultValue('15')
    args << model_time_step
    chs3 = OpenStudio::StringVector.new
    chs3 << '2'
    chs3 << '3'
    pmv_trend_length = OpenStudio::Measure::OSArgument.makeChoiceArgument('pmv_trend_length', chs3, true)
    pmv_trend_length.setDisplayName('Length of time to extend the Zone PMV calc, in hours.')
    pmv_trend_length.setDefaultValue('2')
    args << pmv_trend_length
    min_pmv_thresh = OpenStudio::Measure::OSArgument.makeDoubleArgument('min_pmv_thresh', true)
    min_pmv_thresh.setDisplayName('The minimum Fanger Model PMV that if below, will trigger a simulation halt.')
    min_pmv_thresh.setDefaultValue(1.3)
    args << min_pmv_thresh
    max_pmv_thresh = OpenStudio::Measure::OSArgument.makeDoubleArgument('max_pmv_thresh', true)
    max_pmv_thresh.setDisplayName('The maximum Fanger Model PMV that if above, will trigger a simulation halt.')
    max_pmv_thresh.setDefaultValue(2.5)
    args << max_pmv_thresh
    chs4 = OpenStudio::StringVector.new
    chs4 << 'None'
    chs4 << 'NotByUniqueKeyNames'
    chs4 << 'Verbose'
    internal_VariableAvailabilityDictionaryReporting = OpenStudio::Measure::OSArgument.makeChoiceArgument('internal_VariableAvailabilityDictionaryReporting', chs4, true)
    internal_VariableAvailabilityDictionaryReporting.setDisplayName('Level of output reporting related to the EMS internal variables that are available.')
    internal_VariableAvailabilityDictionaryReporting.setDefaultValue('None')
    args << internal_VariableAvailabilityDictionaryReporting
    chs5 = OpenStudio::StringVector.new
    chs5 << 'None'
    chs5 << 'ErrorsOnly'
    chs5 << 'Verbose'
    ems_RuntimeLanguageDebugOutputLevel = OpenStudio::Measure::OSArgument.makeChoiceArgument('ems_RuntimeLanguageDebugOutputLevel', chs5, true)
    ems_RuntimeLanguageDebugOutputLevel.setDisplayName('Level of output reporting related to the execution of EnergyPlus Runtime Language, written to .edd file.')
    ems_RuntimeLanguageDebugOutputLevel.setDefaultValue('None')
    args << ems_RuntimeLanguageDebugOutputLevel
    chs6 = OpenStudio::StringVector.new
    chs6 << 'None'
    chs6 << 'NotByUniqueKeyNames'
    chs6 << 'Verbose'
    actuator_AvailabilityDictionaryReporting = OpenStudio::Measure::OSArgument.makeChoiceArgument('actuator_AvailabilityDictionaryReporting', chs6, true)
    actuator_AvailabilityDictionaryReporting.setDisplayName('Level of output reporting related to the EMS actuators that are available.')
    actuator_AvailabilityDictionaryReporting.setDefaultValue('None')
    args << actuator_AvailabilityDictionaryReporting
    return args
  end
def arguments ( model ) args = OpenStudio :: Measure :: OSArgumentVector . new verbose_info_statements = OpenStudio :: Ruleset :: OSArgument :: makeBoolArgument ( "verbose_info_statements" , false ) verbose_info_statements . setDisplayName ( "Check to allow measure to generate verbose runner.registerInfo statements." ) verbose_info_statements . setDefaultValue ( false ) args << verbose_info_statements tz_handles = OpenStudio :: StringVector . new tz_display_names = OpenStudio :: StringVector . new tz_hash = { } model . getThermalZones . each do | tz | tz_hash [ tz . name . to_s ] = tz end tz_hash . sort . map do | tz_name , tz | if tz . thermostatSetpointDualSetpoint . is_initialized tstat = tz . thermostatSetpointDualSetpoint . get if tstat . heatingSetpointTemperatureSchedule . is_initialized || tstat . coolingSetpointTemperatureSchedule . is_initialized tz_handles << tz . handle . to_s tz_display_names << tz_name end end end building = model . getBuilding tz_handles << building . handle . to_s tz_display_names << '*All Thermal Zones*' zones = OpenStudio :: Measure :: OSArgument . makeChoiceArgument ( 'zones' , tz_handles , tz_display_names , true ) zones . setDisplayName ( 'Choose Conditioned Thermal Zone(s) to apply EMS Fanger comfort model PMV graceful failure limits to. NOTE: The thermal zone must have People objects attached to it..' ) args << zones comfortWarnings = OpenStudio :: Measure :: OSArgument . makeBoolArgument ( 'comfortWarnings' , true ) comfortWarnings . setDisplayName ( 'Enable ASHRAE 55 Comfort Warnings?' ) comfortWarnings . setDefaultValue ( false ) args << comfortWarnings chs1 = OpenStudio :: StringVector . new chs1 << 'ZoneAveraged' chs1 << 'SurfaceWeighted' meanRadiantCalcType = OpenStudio :: Measure :: OSArgument . makeChoiceArgument ( 'meanRadiantCalcType' , chs1 , true ) meanRadiantCalcType . setDisplayName ( 'Mean Radiant Temperature Calculation Type.' ) meanRadiantCalcType . setDefaultValue ( 'ZoneAveraged' ) args << meanRadiantCalcType schedule_args = model . getSchedules schedule_args_hash = { } schedule_args . each do | schedule_arg | schedule_args_hash [ schedule_arg . name . to_s ] = schedule_arg end fractional_schedule_handles = OpenStudio :: StringVector . new fractional_schedule_display_names = OpenStudio :: StringVector . new schedule_args_hash . sort . map do | key , value | next if value . scheduleTypeLimits . empty? if ( value . scheduleTypeLimits . get . unitType == 'Dimensionless' ) && ! value . scheduleTypeLimits . get . lowerLimitValue . empty? && ! value . scheduleTypeLimits . get . upperLimitValue . empty? next if value . scheduleTypeLimits . get . lowerLimitValue . get != 0.0 next if value . scheduleTypeLimits . get . upperLimitValue . get != 1.0 fractional_schedule_handles << value . handle . to_s fractional_schedule_display_names << key end end work_efficiency_schedule = OpenStudio :: Measure :: OSArgument . makeChoiceArgument ( 'work_efficiency_schedule' , fractional_schedule_handles , fractional_schedule_display_names , true ) work_efficiency_schedule . setDisplayName ( 'Choose a Work Efficiency Schedule.' ) args << work_efficiency_schedule clothing_schedule_handles = OpenStudio :: StringVector . new clothing_schedule_display_names = OpenStudio :: StringVector . new schedule_args_hash . sort . map do | key , value | next if value . scheduleTypeLimits . empty? if value . scheduleTypeLimits . get . unitType == "ClothingInsulation" clothing_schedule_handles << value . handle . to_s clothing_schedule_display_names << key end end clothing_schedule = OpenStudio :: Ruleset :: OSArgument :: makeChoiceArgument ( "clothing_schedule" , clothing_schedule_handles , clothing_schedule_display_names , true ) clothing_schedule . setDisplayName ( "Choose a Clothing Insulation Schedule." ) if clothing_schedule_display_names . size > 0 clothing_schedule . setDefaultValue ( clothing_schedule_display_names [ 0 ] ) end args << clothing_schedule airVelocity_schedule_handles = OpenStudio :: StringVector . new airVelocity_schedule_display_names = OpenStudio :: StringVector . new schedule_args_hash . sort . map do | key , value | next if value . scheduleTypeLimits . empty? if value . scheduleTypeLimits . get . unitType == 'Velocity' airVelocity_schedule_handles << value . handle . to_s airVelocity_schedule_display_names << key end end air_velocity_schedule = OpenStudio :: Measure :: OSArgument . makeChoiceArgument ( 'air_velocity_schedule' , airVelocity_schedule_handles , airVelocity_schedule_display_names , true ) air_velocity_schedule . setDisplayName ( 'Choose an Air Velocity Schedule.' ) if ! airVelocity_schedule_display_names . empty? air_velocity_schedule . setDefaultValue ( airVelocity_schedule_display_names [ 0 ] ) end args << air_velocity_schedule chs2 = OpenStudio :: StringVector . new chs2 << '60' chs2 << '30' chs2 << '15' chs2 << '10' chs2 << '6' model_time_step = OpenStudio :: Measure :: OSArgument . makeChoiceArgument ( 'model_time_step' , chs2 , true ) model_time_step . setDisplayName ( 'Timestep to be used for model, in minutes.' ) model_time_step . setDefaultValue ( '15' ) args << model_time_step chs3 = OpenStudio :: StringVector . new chs3 << '2' chs3 << '3' pmv_trend_length = OpenStudio :: Measure :: OSArgument . makeChoiceArgument ( 'pmv_trend_length' , chs3 , true ) pmv_trend_length . setDisplayName ( 'Length of time to extend the Zone PMV calc, in hours.' ) pmv_trend_length . setDefaultValue ( '2' ) args << pmv_trend_length min_pmv_thresh = OpenStudio :: Measure :: OSArgument . makeDoubleArgument ( 'min_pmv_thresh' , true ) min_pmv_thresh . setDisplayName ( 'The minimum Fanger Model PMV that if below, will trigger a simulation halt.' ) min_pmv_thresh . setDefaultValue ( 1.3 ) args << min_pmv_thresh max_pmv_thresh = OpenStudio :: Measure :: OSArgument . makeDoubleArgument ( 'max_pmv_thresh' , true ) max_pmv_thresh . setDisplayName ( 'The maximum Fanger Model PMV that if above, will trigger a simulation halt.' ) max_pmv_thresh . setDefaultValue ( 2.5 ) args << max_pmv_thresh chs4 = OpenStudio :: StringVector . new chs4 << 'None' chs4 << 'NotByUniqueKeyNames' chs4 << 'Verbose' internal_VariableAvailabilityDictionaryReporting = OpenStudio :: Measure :: OSArgument . makeChoiceArgument ( 'internal_VariableAvailabilityDictionaryReporting' , chs4 , true ) internal_VariableAvailabilityDictionaryReporting . setDisplayName ( 'Level of output reporting related to the EMS internal variables that are available.' ) internal_VariableAvailabilityDictionaryReporting . setDefaultValue ( 'None' ) args << internal_VariableAvailabilityDictionaryReporting chs5 = OpenStudio :: StringVector . new chs5 << 'None' chs5 << 'ErrorsOnly' chs5 << 'Verbose' ems_RuntimeLanguageDebugOutputLevel = OpenStudio :: Measure :: OSArgument . makeChoiceArgument ( 'ems_RuntimeLanguageDebugOutputLevel' , chs5 , true ) ems_RuntimeLanguageDebugOutputLevel . setDisplayName ( 'Level of output reporting related to the execution of EnergyPlus Runtime Language, written to .edd file.' ) ems_RuntimeLanguageDebugOutputLevel . setDefaultValue ( 'None' ) args << ems_RuntimeLanguageDebugOutputLevel chs6 = OpenStudio :: StringVector . new chs6 << 'None' chs6 << 'NotByUniqueKeyNames' chs6 << 'Verbose' actuator_AvailabilityDictionaryReporting = OpenStudio :: Measure :: OSArgument . makeChoiceArgument ( 'actuator_AvailabilityDictionaryReporting' , chs6 , true ) actuator_AvailabilityDictionaryReporting . setDisplayName ( 'Level of output reporting related to the EMS actuators that are available.' ) actuator_AvailabilityDictionaryReporting . setDefaultValue ( 'None' ) args << actuator_AvailabilityDictionaryReporting return args end
define the arguments that the user will input
define the arguments that the user will input
# Add a check box for specifying verbose info statements # Choice List Argument - Select <conditioned> thermal zone to apply PMV criteria to  # declare necessary variables for proper scope # put thermal zone names into a hash # looping through a sorted hash of zones # add building to string vector with zones # make an argument for zones # make a bool argument for ASHRAE 55 Comfort Warnings # make a choice argument for Mean Radiant Temperature Calculation Type # putting raw schedules and names into hash # populate choice argument for fractional schedules # looping through sorted hash of schedules to find fractional schedules # make a choice schedule for Work Efficiency Schedule #populate choice argument for clothing insulation schedules #looping through sorted hash of schedules to find clothing insulation schedules #make a choice argument for Clothing Insulation Schedule Name #normally I don't default model choice list, but since often there might be just one I decided to default this. # populate choice argument for air velocity schedules # looping through sorted hash of schedules to find air velocity schedules # make a choice argument for Air Velocity Schedule Name # normally I don't default model choice list, but since often there might be just one I decided to default this. # make a choice argument for Model Timestep # make a choice argument for number of hours to trend the Zone PMV before comparing to threshold # Populate double precision argument for the Minimum Fanger PMV Value to trigger a graceful failure (program halt)  # Populate double precision value for the Maximum Fanger PMV Value to trigger a graceful failure (program halt)  # make a choice argument for setting InternalVariableAvailabilityDictionaryReporting value # make a choice argument for setting EMSRuntimeLanguageDebugOutputLevel value # make a choice argument for setting ActuatorAvailabilityDictionaryReportingvalue
model
<not_specific>