Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
1

argument in reporting measure

asked 2016-02-09 13:17:05 -0600

ngkhanh's avatar

updated 2017-01-31 17:22:38 -0600

I get fault with this code :

def arguments()      
   args = OpenStudio::Ruleset::OSArgumentVector.new
   all_scheds = model.getSchedules
    sched_name_vec = OpenStudio::StringVector.new
    all_scheds.each do |sched|
    sched_name_vec << sched.name.get
    end
    sched_name = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('Occupancy Schedule',sched_name_vec,false)
    sched_name.setDisplayName("Choose Occupancy Schedule")
    args << sched_name
    return args
  end #end the arguments method

  # return a vector of IdfObject's to request EnergyPlus objects needed by the run method
  def energyPlusOutputRequests(runner, user_arguments)
    super(runner, user_arguments)

    result = OpenStudio::IdfObjectVector.new

    # use the built-in error checking
    if !runner.validateUserArguments(arguments(), user_arguments)
      return result
    end
    request = OpenStudio::IdfObject.load("Output:Table:SummaryReports,AllSummaryAndSizingPeriod;").get
    result << request
    request = OpenStudio::IdfObject.load("Output:Table:TimeBins,*,Zone Air Temperature,14,2,8,,Temperature;").get
    result << request
    return result
  end

It gets undefined variable or method for model while i want to get all schedule as choices for my argument in a reporting measure. How to configure argument in reporting measure ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2016-02-09 14:02:44 -0600

updated 2017-01-11 00:55:17 -0600

It just doesn't know what your model is.

Check out the Mesure Writing Guide, there's a "reporting measure" section that should prove most interesting.

If your case, you currently cannot access it in the arguments method.

If you wanted to do something in the run method, you could do this:

model = runner.lastOpenStudioModel
if model.empty?
  runner.registerError("Cannot find last model.")
  return false
end
model = model.get

# then "model" is actually initialized and you can get your schedules
model.getSchedules...

You can see the function signatures for these in ReportingMeasure.hpp.

Note: this used to be called ReportingUserScript before OS 2.0.0.

edit flag offensive delete link more

Comments

2

Julian is correct and his code would work in the run method (the runner is passed to run) but would not currently work in the arguments method (the runner is not passed to the arguments method).

macumber's avatar macumber  ( 2016-02-09 14:06:28 -0600 )edit

Can you just pass it to the arguments method? Or do you mean "in the current version of OS"?

Julien Marrec's avatar Julien Marrec  ( 2016-02-09 14:10:25 -0600 )edit

The function signatures for the reporting measures can be found here. That shows the arguments that will be passed in to the methods when OpenStudio runs your measure.

macumber's avatar macumber  ( 2016-02-09 14:13:44 -0600 )edit

@macumber : so am i able to read model/workspace input Argument method in Reporting measure ? If answer is "yes", i would like to see an example of code.

ngkhanh's avatar ngkhanh  ( 2016-02-09 14:50:25 -0600 )edit
2

The answer is currently no. If you want to report values for a particular node or something like that you can pass in a string that you can use to find the right object during the run method.

macumber's avatar macumber  ( 2016-02-10 10:26:38 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2016-02-09 13:17:05 -0600

Seen: 276 times

Last updated: Jan 31 '17