Class: BTAP::Measures::OSMeasures::TemplateModelMeasure

Inherits:
BTAPModelUserScript
  • Object
show all
Defined in:
lib/openstudio-standards/btap/measures.rb

Overview

Measure Template simplified.

Instance Attribute Summary

Attributes inherited from BTAPModelUserScript

#argument_array, #argument_array_of_arrays, #file

Instance Method Summary collapse

Methods inherited from BTAPModelUserScript

#argument_getter, #argument_setter, #generate_ruby_macro

Instance Method Details

#arguments(model) ⇒ Object



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/openstudio-standards/btap/measures.rb', line 301

def arguments(model)

  #bool
  @argument_array << OSMArgument.bool(variable_name,display_name,required,default_value)
  #string
  @argument_array << OSMArgument.string(variable_name,display_name,required,default_value)
  #integer
  @argument_array << OSMArgument.integer(variable_name,display_name,required,default_value,min_value,max_value)
  #float
  @argument_array << OSMArgument.float(variable_name,display_name,required,default_value,min_value,max_value)
  #Choice
  @argument_array << OSMArgument.choice(variable_name,display_name,required,default_value,string_choice_array)
  #Workspace choice (using zones as an example)
  @argument_array << OSMArgument.wschoice(variable_name,display_name,required,default_value,string_choice_array)
  args = super(model,@argument_array)
  return args
end

#nameObject



297
298
299
# File 'lib/openstudio-standards/btap/measures.rb', line 297

def name
  "BTAPTempModelMeasure"
end

#run(model, runner, user_arguments) ⇒ Object



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/openstudio-standards/btap/measures.rb', line 319

def run(model, runner, user_arguments)
  #IF and E+ measure replace model with workspace as the argument
  #Boilerplate start
  parent_method_is_true = super(model, runner, user_arguments)


  #Start measure changes based on model.
  puts @boolean_argument_name
  puts @string_argument_name
  puts @integer_argument_name
  puts @float_argument_name
  puts @choice_argument_name
  puts @ws_choice_argument_name




  #Do your stuff here!
  #Here are some logging methods for reference.
  #      runner.registerInitialCondition("Model initial condition (for example number of floors.")
  #      runner.registerInfo("Use this for information to user.")
  #      runner.registerWarning("Use this for warnings to user.")
  #      runner.registerError("Use this for fatal error message to user. Will not continue. Return a false.") ; return false
  #      runner.registerAsNotApplicable("Measure not applicable because XYZ. Return a true and will continue with other chained measures."); return true
  #      runner.registerFinalCondition("Model ended with # of floors for example")
  #      runner.registerFinalCondition("Indicate what was changed.")


  #If everything went well..
  return  true ? parent_method_is_true  : false
end

#set_user_arguments_and_apply(model, argument_values, runner) ⇒ Object

For manually running script via an IDE or a command line. Using the template above as an example.….

argument_values = [

     ["boolean_argument_name",    true          ],
     ["string_argument_name",     "some string" ],
     ["integer_argument_name",    1             ],
     ["float_argument_name",      0.001         ],
     ["choice_argument_name",     "choice1"     ],
     ["ws_choice_argument_name",  "zone1"       ],
     ["path_argument_name",       OpenStudio::Path.new(File.dirname(__FILE__))]
  ]


364
365
366
# File 'lib/openstudio-standards/btap/measures.rb', line 364

def set_user_arguments_and_apply(model,argument_values,runner)
  self.run(model, runner, super(model,argument_values,runner) )
end