3

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

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

pow_skier's avatar
290
pow_skier
asked 2021-12-14 11:00:16 -0500
shorowit's avatar
11.8k
shorowit
updated 2021-12-14 13:48:26 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

3

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)
ericringold's avatar
10.6k
ericringold
answered 2021-12-14 13:46:42 -0500, updated 2021-12-14 13:51:01 -0500
edit flag offensive 0 remove flag delete link

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
add a comment see more comments
0

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.

pow_skier's avatar
290
pow_skier
answered 2021-12-14 13:12:26 -0500
edit flag offensive 0 remove flag delete link

Comments

Eric's answer is what you need to do.

Luis Lara's avatar Luis Lara (2021-12-14 23:11:39 -0500) edit
add a comment see more comments