Class: RunOpenStudioMeasures

Inherits:
OpenStudio::Workflow::Job show all
Includes:
OpenStudio::Workflow::Util::Measure, OpenStudio::Workflow::Util::Model
Defined in:
lib/openstudio/workflow/jobs/run_os_measures.rb

Overview

Run any OpenStudio measures contained in the OSW

Instance Method Summary collapse

Methods included from OpenStudio::Workflow::Util::Model

#load_idf, #load_osm, #save_idf, #save_osm, #translate_to_energyplus

Methods included from OpenStudio::Workflow::Util::Measure

#add_result_measure_info, #apply_arguments, #apply_arguments_2, #apply_measure, #apply_measures, #validate_measures

Constructor Details

#initialize(input_adapter, output_adapter, registry, options = {}) ⇒ RunOpenStudioMeasures

Returns a new instance of RunOpenStudioMeasures.



27
28
29
# File 'lib/openstudio/workflow/jobs/run_os_measures.rb', line 27

def initialize(input_adapter, output_adapter, registry, options = {})
  super
end

Instance Method Details

#performObject



31
32
33
34
35
36
37
38
39
40
41
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
# File 'lib/openstudio/workflow/jobs/run_os_measures.rb', line 31

def perform
  @logger.debug "Calling #{__method__} in the #{self.class} class"
  
  # set weather file
  if @registry[:wf] && @registry[:model]
    epwFile = OpenStudio::EpwFile.load(@registry[:wf])
    if !epwFile.empty?
      OpenStudio::Model::WeatherFile.setWeatherFile(@registry[:model], epwFile.get)
    else
      @logger.warn "Could not load weather file from '#{weather_full_path.to_s}'"
    end
  end
    
  # Ensure output_attributes is initialized in the registry
  @registry.register(:output_attributes) { {} } unless @registry[:output_attributes]

  # Execute the OpenStudio measures
  @options[:output_adapter] = @output_adapter
  @logger.info 'Beginning to execute OpenStudio measures.'
  apply_measures('ModelMeasure'.to_MeasureType, @registry, @options)
  @logger.info('Finished applying OpenStudio measures.')

  # Send the measure output attributes to the output adapter
  @logger.debug 'Communicating measure output attributes to the output adapter'
  @output_adapter.communicate_measure_attributes @registry[:output_attributes]

  # save the final OSM
  save_osm(@registry[:model], @registry[:run_dir])

  # Save the OSM if the :debug option is true
  return nil unless @options[:debug]
  @registry[:time_logger].start('Saving OSM') if @registry[:time_logger]
  osm_name = save_osm(@registry[:model], @registry[:root_dir])
  @registry[:time_logger].stop('Saving OSM') if @registry[:time_logger]
  @logger.debug "Saved model as #{osm_name}"

  nil
end