Class: RunTranslation
- Inherits:
-
OpenStudio::Workflow::Job
- Object
- OpenStudio::Workflow::Job
- RunTranslation
- Includes:
- OpenStudio::Workflow::Util::Model
- Defined in:
- lib/openstudio/workflow/jobs/run_translation.rb
Overview
Run the initialization job to validate the directory and initialize the adapters.
Instance Method Summary collapse
-
#initialize(input_adapter, output_adapter, registry, options = {}) ⇒ RunTranslation
constructor
A new instance of RunTranslation.
- #perform ⇒ Object
Methods included from OpenStudio::Workflow::Util::Model
#load_idf, #load_osm, #save_idf, #save_osm, #translate_to_energyplus
Constructor Details
#initialize(input_adapter, output_adapter, registry, options = {}) ⇒ RunTranslation
Returns a new instance of RunTranslation.
25 26 27 |
# File 'lib/openstudio/workflow/jobs/run_translation.rb', line 25 def initialize(input_adapter, output_adapter, registry, = {}) super end |
Instance Method Details
#perform ⇒ Object
29 30 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 |
# File 'lib/openstudio/workflow/jobs/run_translation.rb', line 29 def perform @logger.debug "Calling #{__method__} in the #{self.class} class" # skip if halted if @registry[:runner].halted @logger.info 'Workflow halted, skipping OSM to IDF translation' @registry.register(:model_idf) { OpenStudio::Workspace.new } # This allows model arguments to still be calculated return nil end # Ensure that the run directory is created FileUtils.mkdir_p(@registry[:run_dir]) # Copy in the weather file defined in the registry, or alternately in the options if @registry[:wf] @logger.info "Weather file for EnergyPlus simulation is #{@registry[:wf]}" FileUtils.copy(@registry[:wf], "#{@registry[:run_dir]}/in.epw") @registry.register(:wf) { "#{@registry[:run_dir]}/in.epw" } else @logger.warn "EPW file not found or not sent to #{self.class}" end # Translate the OSM to an IDF @logger.info 'Beginning the translation to IDF' @registry[:time_logger].start('Translating to EnergyPlus') if @registry[:time_logger] model_idf = translate_to_energyplus @registry[:model], @logger @registry[:time_logger].stop('Translating to EnergyPlus') if @registry[:time_logger] @registry.register(:model_idf) { model_idf } @logger.info 'Successfully translated to IDF' # Save the generated IDF file if the :debug option is true return nil unless @options[:debug] @registry[:time_logger].start('Saving IDF') if @registry[:time_logger] idf_name = save_idf(@registry[:model_idf], @registry[:root_dir]) @registry[:time_logger].stop('Saving IDF') if @registry[:time_logger] @logger.debug "Saved IDF as #{idf_name}" nil end |