@@ -76,16 +76,16 @@ def initialize(base_xml, ns)
7676
7777 @measures = [ ]
7878 @contacts = [ ]
79- @systems_map = { }
8079
8180 # TODO: Go under Report
8281 @utility_name = nil
8382 @utility_meter_numbers = [ ]
8483 @metering_configuration = nil
8584 @spaces_excluded_from_gross_floor_area = nil
8685
87- @load_system = nil
8886 @hvac_systems = nil
87+ @lighting_systems = nil
88+ @load_systems = nil
8989
9090 # reading the xml
9191 read_xml
@@ -213,8 +213,7 @@ def read_and_create_initial_systems
213213
214214 init_hvac_systems ( systems_xml . elements [ "#{ @ns } :HVACSystems" ] )
215215 init_lighting_systems ( systems_xml . elements [ "#{ @ns } :LightingSystem" ] )
216- # TODO: we aren't reading this from file... Which type of System is this? Plugloads? ProcessLoads?
217- @load_system = LoadsSystem . new
216+ init_load_systems ( systems_xml . elements [ "#{ @ns } :PlugLoads" ] ) # PlugLoad, not ProcessLoad
218217
219218 end
220219
@@ -248,6 +247,21 @@ def init_lighting_systems(lighting_system_xmls)
248247 end
249248 end
250249
250+ def init_load_systems ( loads_system_xmls )
251+ # if theres no loads_system_xmls, use a default
252+ if loads_system_xmls . nil? || !loads_system_xmls . has_elements?
253+ loads_system_xml = @g . add_plug_load_to_facility ( @base_xml )
254+ @load_systems = [ BuildingSync ::LoadsSystem . new ( loads_system_xml , @ns ) ]
255+
256+ # else, use the lighting_system_xmls
257+ else
258+ @load_systems = [ ]
259+ loads_system_xmls . elements . each do |lighting_system_xml |
260+ @load_systems << BuildingSync ::LoadsSystem . new ( lighting_system_xml , @ns )
261+ end
262+ end
263+ end
264+
251265 # @see BuildingSync::Report.add_cb_modeled
252266 def add_cb_modeled ( id = 'Scenario-Baseline' )
253267 @report . add_cb_modeled ( id )
@@ -264,13 +278,13 @@ def add_blank_lighting_system(premise_id, premise_type, lighting_system_id = 'Li
264278 @g . add_linked_premise ( lighting_system_xml , premise_id , premise_type )
265279
266280 # Create a new array if doesn't yet exist
267- if ! @systems_map . key? ( 'LightingSystems' )
268- @systems_map [ 'LightingSystems' ] = [ ]
281+ if @lighting_systems . nil?
282+ @lighting_systems = [ ]
269283 end
270284
271285 # Create new lighting system and add to array
272286 new_system = BuildingSync ::LightingSystemType . new ( lighting_system_xml , @ns )
273- @systems_map [ 'LightingSystems' ] << new_system
287+ @lighting_systems << new_system
274288 return new_system
275289 end
276290
@@ -324,13 +338,17 @@ def create_building_systems(main_output_dir:, zone_hash: nil, hvac_delivery_type
324338
325339 # add internal loads to space types
326340 if add_space_type_loads
327- @load_system . add_internal_loads ( model , open_studio_system_standard , template , @site . get_building_sections , remove_objects )
341+ @load_systems . each do |load_system |
342+ load_system . add_internal_loads ( model , open_studio_system_standard , template , @site . get_building_sections , remove_objects )
343+ end
328344 new_occupancy_peak = @site . get_peak_occupancy
329345 new_occupancy_peak . each do |id , occupancy_peak |
330346 floor_area = @site . get_floor_area [ id ]
331347 if occupancy_peak && floor_area && floor_area > 0.0
332348 puts "new peak occupancy value found: absolute occupancy: #{ occupancy_peak } occupancy per area: #{ occupancy_peak . to_f / floor_area . to_f } and area: #{ floor_area } m2"
333- @load_system . adjust_occupancy_peak ( model , occupancy_peak , floor_area , @site . get_space_types_from_hash ( id ) )
349+ @load_systems . each do |load_system |
350+ load_system . adjust_occupancy_peak ( model , occupancy_peak , floor_area , @site . get_space_types_from_hash ( id ) )
351+ end
334352 end
335353 end
336354 end
@@ -363,13 +381,15 @@ def create_building_systems(main_output_dir:, zone_hash: nil, hvac_delivery_type
363381
364382 # add elevators (returns ElectricEquipment object)
365383 if add_elevators
366- @load_system . add_elevator ( model , open_studio_system_standard )
384+ @load_systems . each do |load_system |
385+ load_system . add_elevator ( model , open_studio_system_standard )
386+ end
367387 end
368388
369389 # add exterior lights (returns a hash where key is lighting type and value is exteriorLights object)
370390 if add_exterior_lights
371- if !@systems_map [ 'LightingSystems' ] . nil?
372- @systems_map [ 'LightingSystems' ] . each do |lighting_system |
391+ if !@lighting_systems . nil?
392+ @lighting_systems . each do |lighting_system |
373393 lighting_system . add_exterior_lights ( model , open_studio_system_standard , onsite_parking_fraction , exterior_lighting_zone , remove_objects )
374394 end
375395 else
@@ -460,6 +480,6 @@ def prepare_final_xml
460480 @site . prepare_final_xml
461481 end
462482
463- attr_reader :systems_map , : site, :report , :measures , :contacts
483+ attr_reader :site , :report , :measures , :contacts , :hvac_systems , :lighting_systems , :load_systems
464484 end
465485end
0 commit comments