lib/measures/tbd/measure.rb
# define what happens when the measure is run
define what happens when the measure is run
define what happens when the measure is run
def run(user_model, runner, user_arguments)
    super(user_model, runner, user_arguments)
    load_tbd_json = runner.getBoolArgumentValue("load_tbd_json", user_arguments)
    option = runner.getStringArgumentValue("option", user_arguments)
    alter = runner.getBoolArgumentValue("alter_model", user_arguments)
    write_tbd_json = runner.getBoolArgumentValue("write_tbd_json", user_arguments)
    gen_UA = runner.getBoolArgumentValue("gen_UA_report", user_arguments)
    ua_ref = runner.getStringArgumentValue("ua_reference", user_arguments)
    gen_kiva = runner.getBoolArgumentValue("gen_kiva", user_arguments)
    gen_kiva_force = runner.getBoolArgumentValue("gen_kiva_force", user_arguments)
    return false unless runner.validateUserArguments(arguments(user_model), user_arguments)
    TBD.clean!
    io_path = nil
    if load_tbd_json
      io_path = runner.workflow.findFile('tbd.json')
      if io_path.empty?
        TBD.log(TBD::FATAL, "Can't find 'tbd.json' - simulation halted")
        return exitTBD(runner)
      else
        io_path = io_path.get.to_s
      end
    end
    if gen_kiva_force
      gen_kiva = true
      user_model.getSurfaces.each do |s|
        next unless s.isGroundSurface
        construction = s.construction.get
        s.setOutsideBoundaryCondition("Foundation")
        s.setConstruction(construction)
      end
    end
    seed = runner.workflow.seedFile
    seed = File.basename(seed.get.to_s) unless seed.empty?
    seed = "OpenStudio model" if seed.empty? || seed == "temp_measure_manager.osm"
    if alter == false
      model = OpenStudio::Model::Model.new
      model.addObjects(user_model.toIdfFile.objects)
    else
      model = user_model
    end
    io, surfaces = processTBD(model, option, io_path, nil, gen_UA, ua_ref, gen_kiva)
    t = heatingTemperatureSetpoints?(model)
    t = coolingTemperatureSetpoints?(model) || t
    return exitTBD(model, runner, gen_UA, ua_ref, t, write_tbd_json, io, surfaces, seed)
  end
def run ( user_model , runner , user_arguments ) super ( user_model , runner , user_arguments ) load_tbd_json = runner . getBoolArgumentValue ( "load_tbd_json" , user_arguments ) option = runner . getStringArgumentValue ( "option" , user_arguments ) alter = runner . getBoolArgumentValue ( "alter_model" , user_arguments ) write_tbd_json = runner . getBoolArgumentValue ( "write_tbd_json" , user_arguments ) gen_UA = runner . getBoolArgumentValue ( "gen_UA_report" , user_arguments ) ua_ref = runner . getStringArgumentValue ( "ua_reference" , user_arguments ) gen_kiva = runner . getBoolArgumentValue ( "gen_kiva" , user_arguments ) gen_kiva_force = runner . getBoolArgumentValue ( "gen_kiva_force" , user_arguments ) return false unless runner . validateUserArguments ( arguments ( user_model ) , user_arguments ) TBD . clean! io_path = nil if load_tbd_json io_path = runner . workflow . findFile ( 'tbd.json' ) if io_path . empty? TBD . log ( TBD :: FATAL , "Can't find 'tbd.json' - simulation halted" ) return exitTBD ( runner ) else io_path = io_path . get . to_s end end if gen_kiva_force gen_kiva = true user_model . getSurfaces . each do | s | next unless s . isGroundSurface construction = s . construction . get s . setOutsideBoundaryCondition ( "Foundation" ) s . setConstruction ( construction ) end end seed = runner . workflow . seedFile seed = File . basename ( seed . get . to_s ) unless seed . empty? seed = "OpenStudio model" if seed . empty? || seed == "temp_measure_manager.osm" if alter == false model = OpenStudio :: Model :: Model . new model . addObjects ( user_model . toIdfFile . objects ) else model = user_model end io , surfaces = processTBD ( model , option , io_path , nil , gen_UA , ua_ref , gen_kiva ) t = heatingTemperatureSetpoints? ( model ) t = coolingTemperatureSetpoints? ( model ) || t return exitTBD ( model , runner , gen_UA , ua_ref , t , write_tbd_json , io , surfaces , seed ) end
define what happens when the measure is run
define what happens when the measure is run
# assign the user inputs to variables # use the built-in error checking # TBD.log(TBD::INFO, "Using inputs from #{io_path}")  # for debugging # runner.registerInfo("Using inputs from #{io_path}") # for debugging # Process all ground-facing surfaces as foundation-facing. # Clone model.
user_model
runner
user_arguments