OpenStudio DaylightControl: redundancy between Space and Thermal Zone
Relationship between objects
I'm writing a measure to add a daylighting control to a zone/space. I'm not sure I understand the relationship between DaylightControl, Space and ThermalZone.
OS:Daylighting:Control,
{Handle_of_Daylight_Control}, !- Handle
{Handle_of_Space}, !- Space Name
OS:Space,
{Handle_of_Space}, !- Handle
[...]
{Handle_of_ThermalZone}, !- Thermal Zone Name
OS:ThermalZone,
{Handle_of_ThermalZone}, !- Handle
[...]
{Handle_of_Daylight_Control}, !- Primary Daylighting Control Name
[...]
Using my awesome MSPaint skills, I can see it looks redundant, doesn't it?
Even more confusing, I can see the OS:ThermalZone object has a method
openstudio::model::ThermalZone::setPrimaryDaylightingControl ( const DaylightingControl & daylightingControl )
But if you use it by itself (not caring about space), it doesn't assign anything to the ThermalZone.
Looking at DaylightingControl Class Reference, it seems it does belong to a Space, not a thermal zone. So why do we need the the daylightControl handle in the OS:ThermalZone object?
So, what am I missing there?
Further problem
Looking at a measure called "Add Daylight Sensor at the Center of Spaces with a Specified Space Type Assigned", what's used is:
sensor = OpenStudio::Model::DaylightingControl.new(model)
...
sensor.setSpace(space)
First, I didn't find anywhere in the documentation the setSpace
method. Where can I find it?
Second, I'm having a problem. I initially wrote the measure asking the user to select the ThermalZone for which he wants a daylight control, considering that I knew in E+ it was linked to a zone (spaces don't exists anyways...). Is that a bad idea?
If not a truly awful idea right from the start, is it bad to just use
#Get first space linked to the ThermalZone we selected
zone_space = zone.spaces[0]
#Assign sensor to space
sensor.setSpace(zone_space)
Do I also need to do this in addition?
# Assign the sensor as a Primary Daylightlighting Control to the Thermal Zone
zone.setPrimaryDaylightingControl(sensor)
Note: my measure works the way I want to, using both sensor.setSpace and zone.setPrimary... etc. (code here).
I'm mostly asking because I'm trying to understand more about measures and how to write them... I keep bumping into stuff like this, I'm wondering if I'm really bad at using the reference guide or if it's confusing for everyone, and I get the feeling my code isn't exactly 'DRY' (do not repeat yourself) nor clean.