Class: EnableOccupancyDrivenLighting
- Inherits:
-
OpenStudio::Measure::ModelMeasure
- Object
- OpenStudio::Measure::ModelMeasure
- EnableOccupancyDrivenLighting
- Defined in:
- lib/measures/enable_occupancy_driven_lighting/measure.rb
Overview
start the measure
Instance Method Summary collapse
-
#arguments(model) ⇒ Object
define the arguments that the user will input.
-
#description ⇒ Object
human readable description.
-
#modeler_description ⇒ Object
human readable description of modeling approach.
-
#name ⇒ Object
human readable name.
-
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run.
- #run_osw(osw_path) ⇒ Object
Instance Method Details
#arguments(model) ⇒ Object
define the arguments that the user will input
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/measures/enable_occupancy_driven_lighting/measure.rb', line 30 def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new minutes_delay = OpenStudio::Measure::OSArgument.makeIntegerArgument('minutes_delay', false) minutes_delay.setDisplayName('Number of minutes of delay for turning off lights') minutes_delay.setDefaultValue(15) args << minutes_delay run_output_path = OpenStudio::Measure::OSArgument.makeStringArgument('run_output_path', false) run_output_path.setDisplayName('Alternative output path for pre-run') run_output_path.setDescription("If not specified, write to the ./generated_files directory") run_output_path.setDefaultValue("") args << run_output_path return args end |
#description ⇒ Object
human readable description
20 21 22 |
# File 'lib/measures/enable_occupancy_driven_lighting/measure.rb', line 20 def description return 'This measure applies occupancy-driven lighting.' end |
#modeler_description ⇒ Object
human readable description of modeling approach
25 26 27 |
# File 'lib/measures/enable_occupancy_driven_lighting/measure.rb', line 25 def modeler_description return 'Replace this text with an explanation for the energy modeler specifically. It should explain how the measure is modeled, including any requirements about how the baseline model must be set up, major assumptions, citations of references to applicable modeling resources, etc. The energy modeler should be able to read this description and understand what changes the measure is making to the model and why these changes are being made. Because the Modeler Description is written for an expert audience, using common abbreviations for brevity is good practice.' end |
#name ⇒ Object
human readable name
14 15 16 17 |
# File 'lib/measures/enable_occupancy_driven_lighting/measure.rb', line 14 def name # Measure name should be the title case of the class name. return 'Enable occupancy-driven lighting' end |
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run
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 |
# File 'lib/measures/enable_occupancy_driven_lighting/measure.rb', line 48 def run(model, runner, user_arguments) super(model, runner, user_arguments) def run_osw(osw_path) cli_path = OpenStudio.getOpenStudioCLI cmd = "\"#{cli_path}\" run -w \"#{osw_path}\"" puts cmd system(cmd) end # use the built-in error checking if !runner.validateUserArguments(arguments(model), user_arguments) return false end run_output_path = runner.getStringArgumentValue('run_output_path', user_arguments).to_s if run_output_path.empty? run_output_path = runner.workflow.filePaths[0].to_s end runner.registerInfo("Pre-run output path: #{run_output_path}") Dir.mkdir(run_output_path) unless File.exist?(run_output_path) prerun_dir = File.join(run_output_path, 'pre-run') Dir.mkdir(prerun_dir) unless File.exist?(prerun_dir) prerun_osw_path = File.join(prerun_dir, 'sizing.osm') model.save(prerun_osw_path, true) # true is overwrite outputVariable = OpenStudio::Model::OutputVariable.new("People Occupant Count", model) outputVariable.setReportingFrequency("timestep") outputVariable.setKeyValue("*") runner.registerInfo("Adding output variable for #{outputVariable.variableName} reporting at each timestep.") if File.exist?(model.weatherFile.get.path.get.to_s) epw_path = model.weatherFile.get.path.get else epw_path = File.join(File.dirname(__FILE__), 'USA_NY_Buffalo.Niagara.Intl.AP.725280_TMY3.epw') end osw = {} osw["weather_file"] = epw_path osw["seed_file"] = prerun_osw_path # output_measure_input = { # "measure_dir_name": "Add Output Variable", # "arguments": {"variable_name": "People Occupant Count", "reporting_frequency": "timestep", "key_value": "*"} # } # osw["steps"] = [output_measure_input] osw_path = File.join(prerun_dir, "pre-run.osw") File.open(osw_path, 'w') do |f| f << JSON.pretty_generate(osw) end run_osw(osw_path) sleep(1) if File.exist?(File.join(prerun_dir, "run", "eplusout.csv")) runner.registerInfo("Occupant schedules generated!") end return true end |
#run_osw(osw_path) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/measures/enable_occupancy_driven_lighting/measure.rb', line 51 def run_osw(osw_path) cli_path = OpenStudio.getOpenStudioCLI cmd = "\"#{cli_path}\" run -w \"#{osw_path}\"" puts cmd system(cmd) end |