clases/clase_011_EjemploProyectoFinal_FInal_FInal/osm/CVentanas_004/measures/add_output_variable/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(model, runner, user_arguments)
    super(model, runner, user_arguments)
    if !runner.validateUserArguments(arguments(model), user_arguments)
      return false
    end
    variable_name = runner.getStringArgumentValue('variable_name', user_arguments)
    reporting_frequency = runner.getStringArgumentValue('reporting_frequency', user_arguments)
    key_value = runner.getStringArgumentValue('key_value', user_arguments)
    if variable_name == ''
      runner.registerError('No variable name was entered.')
      return false
    end
    if key_value == ''
      runner.registerInfo("Blank key isn't valid. Changing key to *")
      key_value == '*'
    end
    outputVariables = model.getOutputVariables
    starting_spaces = model.getSpaces
    runner.registerInitialCondition("The model started with #{outputVariables.size} output variable objects.")
    outputVariable = OpenStudio::Model::OutputVariable.new(variable_name, model)
    outputVariable.setReportingFrequency(reporting_frequency)
    outputVariable.setKeyValue(key_value)
    runner.registerInfo("Adding output variable for #{outputVariable.variableName} reporting #{reporting_frequency}.")
    runner.registerInfo("Key value for variable is #{outputVariable.keyValue}.")
    outputVariables = model.getOutputVariables
    finishing_spaces = model.getSpaces
    runner.registerFinalCondition("The model finished with #{outputVariables.size} output variable objects.")
    return true
  end
def run ( model , runner , user_arguments ) super ( model , runner , user_arguments ) if ! runner . validateUserArguments ( arguments ( model ) , user_arguments ) return false end variable_name = runner . getStringArgumentValue ( 'variable_name' , user_arguments ) reporting_frequency = runner . getStringArgumentValue ( 'reporting_frequency' , user_arguments ) key_value = runner . getStringArgumentValue ( 'key_value' , user_arguments ) if variable_name == '' runner . registerError ( 'No variable name was entered.' ) return false end if key_value == '' runner . registerInfo ( "Blank key isn't valid. Changing key to *" ) key_value == '*' end outputVariables = model . getOutputVariables starting_spaces = model . getSpaces runner . registerInitialCondition ( "The model started with #{outputVariables.size} output variable objects." ) outputVariable = OpenStudio :: Model :: OutputVariable . new ( variable_name , model ) outputVariable . setReportingFrequency ( reporting_frequency ) outputVariable . setKeyValue ( key_value ) runner . registerInfo ( "Adding output variable for #{outputVariable.variableName} reporting #{reporting_frequency}." ) runner . registerInfo ( "Key value for variable is #{outputVariable.keyValue}." ) outputVariables = model . getOutputVariables finishing_spaces = model . getSpaces runner . registerFinalCondition ( "The model finished with #{outputVariables.size} output variable objects." ) return true end
define what happens when the measure is run
define what happens when the measure is run
# use the built-in error checking # assign the user inputs to variables # check the user_name for reasonableness # check the user_name for reasonableness # reporting initial condition of model # reporting final condition of model
model
<not_specific>
runner
<not_specific>
user_arguments
<not_specific>