Class: EnableDemandControlledVentilation
- Inherits:
-
OpenStudio::Measure::ModelMeasure
- Object
- OpenStudio::Measure::ModelMeasure
- EnableDemandControlledVentilation
- Defined in:
- lib/measures/EnableDemandControlledVentilation/measure.rb
Overview
start the measure
Instance Method Summary collapse
-
#arguments(model) ⇒ Object
define the arguments that the user will input.
-
#name ⇒ Object
define the name that a user will see, this method may be deprecated as the display name in PAT comes from the name field in measure.xml.
-
#neat_numbers(number, roundto = 2) ⇒ Object
short def to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001).
-
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is cop.
Instance Method Details
#arguments(model) ⇒ Object
define the arguments that the user will input
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/measures/EnableDemandControlledVentilation/measure.rb', line 26 def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new # make choice argument economizer control type choices = OpenStudio::StringVector.new choices << 'EnableDCV' choices << 'DisableDCV' choices << 'NoChange' dcv_type = OpenStudio::Measure::OSArgument.makeChoiceArgument('dcv_type', choices, true) dcv_type.setDisplayName('DCV Type') args << dcv_type return args end |
#name ⇒ Object
define the name that a user will see, this method may be deprecated as the display name in PAT comes from the name field in measure.xml
21 22 23 |
# File 'lib/measures/EnableDemandControlledVentilation/measure.rb', line 21 def name return 'Enable Demand Controlled Ventilation' end |
#neat_numbers(number, roundto = 2) ⇒ Object
short def to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001). The definition be called through this measure
61 62 63 64 65 66 67 68 69 |
# File 'lib/measures/EnableDemandControlledVentilation/measure.rb', line 61 def neat_numbers(number, roundto = 2) # round to 0 or 2) if roundto == 2 number = format '%.2f', number else number = number.round end # regex to add commas number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\1,').reverse end |
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is cop
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/measures/EnableDemandControlledVentilation/measure.rb', line 42 def run(model, runner, user_arguments) super(model, runner, user_arguments) # use the built-in error checking if !runner.validateUserArguments(arguments(model), user_arguments) return false end # assign the user inputs to variables dcv_type = runner.getStringArgumentValue('dcv_type', user_arguments) # Note if dcv_type == NoChange # and register as N/A if dcv_type == 'NoChange' runner.registerAsNotApplicable('N/A - User requested No Change in economizer operation.') return true end # short def to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001). The definition be called through this measure def neat_numbers(number, roundto = 2) # round to 0 or 2) if roundto == 2 number = format '%.2f', number else number = number.round end # regex to add commas number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\1,').reverse end # info for initial condition air_loops_changed = [] # loop through air loops model.getAirLoopHVACs.each do |air_loop| # find AirLoopHVACOutdoorAirSystem on loop air_loop.supplyComponents.each do |supply_component| hVACComponent = supply_component.to_AirLoopHVACOutdoorAirSystem if !hVACComponent.empty? hVACComponent = hVACComponent.get # get ControllerOutdoorAir controller_oa = hVACComponent.getControllerOutdoorAir # get ControllerMechanicalVentilation controller_mv = controller_oa.controllerMechanicalVentilation if dcv_type == 'EnableDCV' # check if demand control is enabled, if not, then enable it if controller_mv.demandControlledVentilation == true runner.registerInfo("#{air_loop.name} already has DCV enabled.") else controller_mv.setDemandControlledVentilation(true) runner.registerInfo("Enabling DCV for #{air_loop.name}.") air_loops_changed << air_loop end elsif dcv_type == 'DisableDCV' # check if demand control is disabled, if not, then disabled it if controller_mv.demandControlledVentilation == false runner.registerInfo("#{air_loop.name} already has DCV disabled.") else controller_mv.setDemandControlledVentilation(false) runner.registerInfo("Disabling DCV for #{air_loop.name}.") air_loops_changed << air_loop end end end end end # Report N/A if none of the air loops were changed if air_loops_changed.empty? runner.registerAsNotApplicable('No air loops had DCV enabled or disabled.') return true end # Report final condition of model runner.registerFinalCondition("#{air_loops_changed.size} air loops now have demand controlled ventilation enabled.") return true end |