Class: AddOutputVariable
- Inherits:
-
OpenStudio::Measure::ModelMeasure
- Object
- OpenStudio::Measure::ModelMeasure
- AddOutputVariable
- Defined in:
- lib/measures/AddOutputVariable/measure.rb
Overview
start the measure
Instance Method Summary collapse
-
#arguments(model) ⇒ Object
define the arguments that the user will input.
-
#description ⇒ Object
human readable description.
-
#modeler_description ⇒ Object
human readable description of modeling approach.
-
#name ⇒ Object
define the name that a user will see, this method may be deprecated as the display name in PAT comes from the name field in measure.xml.
-
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run.
Instance Method Details
#arguments(model) ⇒ Object
define the arguments that the user will input
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 |
# File 'lib/measures/AddOutputVariable/measure.rb', line 31 def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new # make an argument for the variable name variable_name = OpenStudio::Measure::OSArgument.makeStringArgument('variable_name', true) variable_name.setDisplayName('Enter Variable Name') args << variable_name # make an argument for the electric tariff reporting_frequency_chs = OpenStudio::StringVector.new reporting_frequency_chs << 'detailed' reporting_frequency_chs << 'timestep' reporting_frequency_chs << 'hourly' reporting_frequency_chs << 'daily' reporting_frequency_chs << 'monthly' reporting_frequency_chs << 'runperiod' reporting_frequency = OpenStudio::Measure::OSArgument.makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true) reporting_frequency.setDisplayName('Reporting Frequency') reporting_frequency.setDefaultValue('hourly') args << reporting_frequency # make an argument for the key_value key_value = OpenStudio::Measure::OSArgument.makeStringArgument('key_value', true) key_value.setDisplayName('Enter Key Name') key_value.setDescription('Enter * for all objects or the full name of a specific object to.') key_value.setDefaultValue('*') args << key_value return args end |
#description ⇒ Object
human readable description
21 22 23 |
# File 'lib/measures/AddOutputVariable/measure.rb', line 21 def description return 'This measure adds an output variable at the requested reporting frequency.' end |
#modeler_description ⇒ Object
human readable description of modeling approach
26 27 28 |
# File 'lib/measures/AddOutputVariable/measure.rb', line 26 def modeler_description return 'The measure just passes in the string and does not validate that it is a proper variable name. It is up to the user to know this or to look at the .rdd file from a previous simulation run.' end |
#name ⇒ Object
define the name that a user will see, this method may be deprecated as the display name in PAT comes from the name field in measure.xml
16 17 18 |
# File 'lib/measures/AddOutputVariable/measure.rb', line 16 def name return 'Add Output Variable' end |
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/measures/AddOutputVariable/measure.rb', line 63 def run(model, runner, user_arguments) super(model, runner, user_arguments) # use the built-in error checking if !runner.validateUserArguments(arguments(model), user_arguments) return false end # assign the user inputs to variables variable_name = runner.getStringArgumentValue('variable_name', user_arguments) reporting_frequency = runner.getStringArgumentValue('reporting_frequency', user_arguments) key_value = runner.getStringArgumentValue('key_value', user_arguments) # check the user_name for reasonableness if variable_name == '' runner.registerError('No variable name was entered.') return false end # check the user_name for reasonableness if key_value == '' runner.registerInfo("Blank key isn't valid. Changing key to *") key_value == '*' end outputVariables = model.getOutputVariables # reporting initial condition of model 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 # reporting final condition of model finishing_spaces = model.getSpaces runner.registerFinalCondition("The model finished with #{outputVariables.size} output variable objects.") return true end |