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

OpenStudio measure writing, do generic methods exist for all AirTerminal ObjectTypes?

asked 2021-12-14 11:00:16 -0500

pow_skier's avatar

updated 2021-12-14 13:48:26 -0500

Does the SDK have a generic class with methods that work on all AirTerminal ObjectTypes?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2021-12-14 13:46:42 -0500

updated 2021-12-14 13:51:01 -0500

ThermalZone::airLoopHVACTerminal returns an HVACComponent class, which is the 'generic' class that all AirTerminal object types inherit from (AirTerminalDualDuct types inherit from Mixer, not StraightComponent). Once you get the HVACObject, you need to 'cast' it to the proper base type in order to access the specific terminal class methods. e.g.:

terminal = thermal_zone.airLoopHVACTerminal
if terminal.is_initialized
  terminal = terminal.get # this gets the HVACComponent
end
# cast to AirTerminalSingleDuctVAVReheat class
if terminal.to_AirTerminalSingleDuctVAVReheat.is_initialized
  terminal = terminal.to_AirTerminalSingleDuctVAVReheat.get 
end
terminal.setMaximumAirFlowRate(rate)
edit flag offensive delete link more

Comments

Good Morning Eric and Luis thank you for the responses. This solved my blockage and I added in some if tests to address the ambiguity of what kind of terminal might get pulled depending on what the seed model has and it is working. Regards and a hearty thank you.

pow_skier's avatar pow_skier  ( 2021-12-15 09:06:50 -0500 )edit
2

To avoid the casting, try Julian's to_actual_objectmethod. https://unmethours.com/question/17616...

MatthewSteen's avatar MatthewSteen  ( 2021-12-15 09:28:52 -0500 )edit
0

answered 2021-12-14 13:12:26 -0500

pow_skier's avatar

It seems like maybe the StraightComponentStraightComponent is the answer to my question.

But the use case I am struggling with is after doing terminal = thermal_zone.airLoopHVACTerminal.get including doing .empty? check before hand, when using an object method like .setMaximumAirFlowRate it returns a hash error on the Terminal object. It seems like the ambiguity on what kind of Terminal might be the issue but any pointers would be very much appreciated. Thank you.

edit flag offensive delete link more

Comments

Eric's answer is what you need to do.

Luis Lara's avatar Luis Lara  ( 2021-12-14 23:11:39 -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: 2021-12-14 11:00:16 -0500

Seen: 149 times

Last updated: Dec 15 '21