class BTAPModelMeasure

start the measure

Attributes

use_json_package[RW]
use_string_double[RW]

Public Class Methods

new() click to toggle source

Use the constructor to set global variables

Calls superclass method
# File lib/openstudio-standards/utilities/template_measure/measure.rb, line 29
def initialize
  super()
  # Set to true if you want to package the arguments as json.
  @use_json_package = false
  # Set to true if you want to want to allow strings and doubles in stringdouble types. Set to false to force to use doubles. The latter is used for certain
  # continuous optimization algorithms. You may have to re-examine your input in PAT as this fundamentally changes the measure.
  @use_string_double = true

  # Put in this array of hashes all the input variables that you need in your measure. Your choice of types are Sting, Double,
  # StringDouble, and Choice. Optional fields are valid strings, max_double_value, and min_double_value. This will
  # create all the variables, validate the ranges and types you need,  and make them available in the 'run' method as a hash after
  # you run 'arguments = validate_and_get_arguments_in_hash(model, runner, user_arguments)'
  @measure_interface_detailed = [
    {
      'name' => 'a_string_argument',
      'type' => 'String',
      'display_name' => 'A String Argument (string)',
      'default_value' => 'The Default Value',
      'is_required' => true
    },
    {
      'name' => 'a_double_argument',
      'type' => 'Double',
      'display_name' => 'A Double numeric Argument (double)',
      'default_value' => 0,
      'max_double_value' => 100.0,
      'min_double_value' => 0.0,
      'is_required' => true
    },
    {
      'name' => 'a_string_double_argument',
      'type' => 'StringDouble',
      'display_name' => 'A String Double numeric Argument (double)',
      'default_value' => 23.0,
      'max_double_value' => 100.0,
      'min_double_value' => 0.0,
      'valid_strings' => ['Baseline', 'NA'],
      'is_required' => true
    },
    {
      'name' => 'a_choice_argument',
      'type' => 'Choice',
      'display_name' => 'A Choice String Argument ',
      'default_value' => 'choice_1',
      'choices' => ['choice_1', 'choice_2'],
      'is_required' => true
    },
    {
      'name' => 'a_bool_argument',
      'type' => 'Bool',
      'display_name' => 'A Boolean Argument ',
      'default_value' => false,
      'is_required' => true
    }
  ]
end

Public Instance Methods

description() click to toggle source

human readable description

# File lib/openstudio-standards/utilities/template_measure/measure.rb, line 19
def description
  return 'This template measure is used to ensure consistency in detailed BTAP measures.'
end
modeler_description() click to toggle source

human readable description of modeling approach

# File lib/openstudio-standards/utilities/template_measure/measure.rb, line 24
def modeler_description
  return 'This template measure is used to ensure consistency in BTAP measures.'
end
name() click to toggle source

human readable name

# File lib/openstudio-standards/utilities/template_measure/measure.rb, line 11
def name
  # BEFORE YOU DO anything.. please generate a new <uid>224561f4-8ccc-4f60-8118-34b85359d6f7</uid> and add this to the measure.xml file
  # You can generate a new UUID using the ruby command
  # ruby -e 'require "securerandom";  puts SecureRandom.uuid '
  return 'BTAPTemplateMeasure'
end
run(model, runner, user_arguments) click to toggle source

define what happens when the measure is run

Calls superclass method
# File lib/openstudio-standards/utilities/template_measure/measure.rb, line 87
def run(model, runner, user_arguments)
  # Runs parent run method.
  super(model, runner, user_arguments)
  # Gets arguments from interfaced and puts them in a hash with there display name. This also does a check on ranges to
  # ensure that the values inputted are valid based on your @measure_interface array of hashes.
  arguments = validate_and_get_arguments_in_hash(model, runner, user_arguments)
  # puts JSON.pretty_generate(arguments)
  return false if arguments == false

  # You can now access the input argument by the name.
  # arguments['a_string_argument']
  # arguments['a_double_argument']
  # etc......
  # So write your measure code here!

  # Do something.
  return true
end