Class: RunXml
- Inherits:
-
Object
- Object
- RunXml
- Defined in:
- lib/openstudio/workflow/jobs/run_xml/run_xml.rb
Overview
This actually belongs as another class that gets added as a state dynamically
Instance Method Summary collapse
-
#initialize(directory, logger, time_logger, adapter, options = {}) ⇒ RunXml
constructor
RunXml.
- #perform ⇒ Object
Constructor Details
#initialize(directory, logger, time_logger, adapter, options = {}) ⇒ RunXml
RunXml
25 26 27 28 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 |
# File 'lib/openstudio/workflow/jobs/run_xml/run_xml.rb', line 25 def initialize(directory, logger, time_logger, adapter, = {}) defaults = { use_monthly_reports: false, analysis_root_path: '.', xml_library_file: 'xml_runner.rb' } @options = defaults.merge() @directory = directory # TODO: there is a base number of arguments that each job will need including @run_directory. abstract it out. @run_directory = "#{@directory}/run" @adapter = adapter @results = {} @logger = logger @time_logger = time_logger @logger.info "#{self.class} passed the following options #{@options}" # initialize instance variables that are needed in the perform section @weather_filename = nil @weather_directory = File.(File.join(@options[:analysis_root_path], 'weather')) @logger.info "Weather directory is: #{@weather_directory}" @model_xml = nil @model = nil @model_idf = nil @analysis_json = nil # TODO: rename datapoint_json to just datapoint @datapoint_json = nil @output_attributes = {} @report_measures = [] @measure_type_lookup = { openstudio_measure: 'RubyMeasure', energyplus_measure: 'EnergyPlusMeasure', reporting_measure: 'ReportingMeasure' } end |
Instance Method Details
#perform ⇒ Object
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 |
# File 'lib/openstudio/workflow/jobs/run_xml/run_xml.rb', line 56 def perform @logger.info "Calling #{__method__} in the #{self.class} class" @logger.info "Current directory is #{@directory}" @logger.info 'Retrieving datapoint and problem' @datapoint_json = @adapter.get_datapoint(@directory, @options) @analysis_json = @adapter.get_problem(@directory, @options) if @analysis_json && @analysis_json[:analysis] @model_xml = load_xml_model @weather_filename = load_weather_file begin apply_xml_measures rescue => e = "Exception during 'apply_xml_measure' with #{e.}, #{e.backtrace.join("\n")}" raise end # @logger.debug "XML measure output attributes JSON is #{@output_attributes}" File.open("#{@run_directory}/measure_attributes_xml.json", 'w') do |f| f << JSON.pretty_generate(@output_attributes) end end create_osm_from_xml @results end |