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

"Add Meter" BCL measure error OS 2.1

asked 2017-05-24 00:53:27 -0500

PM's avatar

updated 2017-05-24 10:59:25 -0500

I just updated the OS 2.1.0 version and had a problem with AddMeter measure. I received an error everytime when run this "AddMeter" measure

image description

Please help. Thank you.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-05-24 13:58:33 -0500

PM's avatar

here is what I have changed from the measure.rb...but still having the same error..fail to run.image description image description

edit flag offensive delete link more

Comments

Should probably have updated the original question vs. making this an answer, but looks like I still see 'model.getMeters' vs. model.getOutputMeters'. At any rate I have published the updated Add Meter measure to BCL. May take a bit of time before it is indexed in search for app to see update. You will know you have the new one if it contains 'OutptMeters' in the text of measure.rb

David Goldwasser's avatar David Goldwasser  ( 2017-05-25 10:32:32 -0500 )edit

Thank you David...I learned now and will update the original question next time if I post a question again. Have a great weekend!

PM's avatar PM  ( 2017-05-26 12:23:06 -0500 )edit
2

answered 2017-05-24 10:54:22 -0500

updated 2017-05-24 11:12:07 -0500

You hit one of the rare model objects that changed from 1.x to 2.x. The 'Meter' object was changed to 'OutputMeter'. I have updated the measure and will try to push i to BCL this afternoon, but it is pretty short, so if you want to you can replace the run method of your measure.rb with this.

#use the built-in error checking 
if not runner.validateUserArguments(arguments(model), user_arguments)
  return false
end

#assign the user inputs to variables
meter_name = runner.getStringArgumentValue("meter_name",user_arguments)
reporting_frequency = runner.getStringArgumentValue("reporting_frequency",user_arguments)

#check the user_name for reasonableness
if meter_name == ""
  runner.registerError("No meter name was entered.")
  return false
end

meters = model.getOutputMeters
#reporting initial condition of model
runner.registerInitialCondition("The model started with #{meters.size} meter objects.")

#flag to add meter
add_flag = true

# OpenStudio doesn't like two meters of the same name, even if they have different reporting frequencies.
meters.each do |meter|
  if meter.name == meter_name
  runner.registerWarning("A meter named #{meter_name} already exists. One will not be added to the model.")
    if not meter.reportingFrequency == reporting_frequency
      meter.setReportingFrequency(reporting_frequency)
      runner.registerInfo("Changing reporting frequency of existing meter to #{reporting_frequency}.")
    end
  add_flag = false
  end
end

if add_flag
  meter = OpenStudio::Model::OutputMeter.new(model)
  meter.setName(meter_name)
  meter.setReportingFrequency(reporting_frequency)
  runner.registerInfo("Adding meter for #{meter.name} reporting #{reporting_frequency}")
end

meters = model.getOutputMeters
#reporting final condition of model
runner.registerFinalCondition("The model finished with #{meters.size} meter objects.")

return true
edit flag offensive delete link more

Comments

1

Ideally this measure would work in 1.x and 2.x. You could either add a version check or just try one name the rescue NameError and use the other one.

macumber's avatar macumber  ( 2017-05-24 10:59:07 -0500 )edit
1

@macumber, I updated the min version in the measure.xml so when it goes to BCL, it will only download for 2x versions of OpenStudio, but I could add version check in the measure so the same measure would work for 1x and 2x.

David Goldwasser's avatar David Goldwasser  ( 2017-05-24 11:10:36 -0500 )edit

Thank you David. I'll try to replace it with the one you have provided. Thanks again.

PM's avatar PM  ( 2017-05-24 12:39:41 -0500 )edit

Hi David, I have replaced the measure.rb with the one you have provided also did update the min version in the measure.xml to 2.0.0 but am still having the same error. Please advise. Thank you

PM's avatar PM  ( 2017-05-24 13:51:21 -0500 )edit

New version is on BCL may take little time for search to index so app can see update.

David Goldwasser's avatar David Goldwasser  ( 2017-05-25 10:33:28 -0500 )edit

Your Answer

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

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2017-05-24 00:53:27 -0500

Seen: 264 times

Last updated: May 24 '17