Class: Honeybee::DaylightingControl

Inherits:
ModelObject show all
Defined in:
lib/honeybee/load/daylight.rb,
lib/to_openstudio/load/daylight.rb,
lib/from_openstudio/load/daylight.rb

Instance Attribute Summary

Attributes inherited from ModelObject

#errors, #openstudio_object, #warnings

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ModelObject

#allowable_types, clean_identifier, clean_name, #initialize, #method_missing, read_from_disk, truncate

Constructor Details

This class inherits a constructor from Honeybee::ModelObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Honeybee::ModelObject

Class Method Details

.from_load(load) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/from_openstudio/load/daylight.rb', line 38

def self.from_load(load)
    # create an empty hash
    hash = {}
    hash[:type] = 'DaylightingControl'
    # set hash values from OpenStudio Object
    unless load.displayName.empty?
        hash[:display_name] = (load.displayName.get).force_encoding("UTF-8")
    end
    hash[:illuminance_setpoint] = load.illuminanceSetpoint
    # TODO: set control fraction property
    hash[:min_power_input] = load.minimumInputPowerFractionforContinuousDimmingControl
    hash[:min_light_output] = load.minimumLightOutputFractionforContinuousDimmingControl
    # TODO: set off at minimum property
    hash[:sensor_position] = []
    hash[:sensor_position] << load.positionXCoordinate
    hash[:sensor_position] << load.positionYCoordinate
    hash[:sensor_position] << load.positionZCoordinate
    
    hash 
end

Instance Method Details

#defaultsObject



37
38
39
# File 'lib/honeybee/load/daylight.rb', line 37

def defaults
  @@schema[:components][:schemas][:DaylightingControl][:properties]
end

#find_existing_openstudio_object(openstudio_model, parent_space_name) ⇒ Object



39
40
41
42
43
44
# File 'lib/to_openstudio/load/daylight.rb', line 39

def find_existing_openstudio_object(openstudio_model, parent_space_name)
  dl_cntrl_name = parent_space_name + '_Daylighting'
  model_dl_cntrl = openstudio_model.getDaylightingControlByName(dl_cntrl_name)
  return model_dl_cntrl.get unless model_dl_cntrl.empty?
  nil
end

#to_openstudio(openstudio_model, parent_zone, parent_space) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/to_openstudio/load/daylight.rb', line 46

def to_openstudio(openstudio_model, parent_zone, parent_space)
  # create daylighting control openstudio object and set identifier
  os_dl_control = OpenStudio::Model::DaylightingControl.new(openstudio_model)
  space_name = parent_space.name
  unless space_name.empty?
    os_dl_control.setName(parent_space.name.get + '_Daylighting')
  end
  os_dl_control.setSpace(parent_space)
  parent_zone.setPrimaryDaylightingControl(os_dl_control)

  # assign the position of the sensor point
  os_dl_control.setPositionXCoordinate(@hash[:sensor_position][0])
  os_dl_control.setPositionYCoordinate(@hash[:sensor_position][1])
  os_dl_control.setPositionZCoordinate(@hash[:sensor_position][2])

  # assign the illuminance setpoint if it exists
  if @hash[:illuminance_setpoint]
    os_dl_control.setIlluminanceSetpoint(@hash[:illuminance_setpoint])
  else
    os_dl_control.setIlluminanceSetpoint(defaults[:illuminance_setpoint][:default])
  end

  # assign power fraction if it exists
  if @hash[:min_power_input]
    os_dl_control.setMinimumInputPowerFractionforContinuousDimmingControl(@hash[:min_power_input])
  else
    os_dl_control.setMinimumInputPowerFractionforContinuousDimmingControl(defaults[:min_power_input][:default])
  end

  # assign light output fraction if it exists
  if @hash[:min_light_output]
    os_dl_control.setMinimumLightOutputFractionforContinuousDimmingControl(@hash[:min_light_output])
  else
    os_dl_control.setMinimumLightOutputFractionforContinuousDimmingControl(defaults[:min_light_output][:default])
  end

  # set whether the lights go off when they reach their minimum
  if @hash[:off_at_minimum]
    os_dl_control.setLightingControlType('Continuous/Off')
  else
    os_dl_control.setLightingControlType('Continuous')
  end

  # set the fraction of the zone lights that are dimmed
  if @hash[:control_fraction]
    parent_zone.setFractionofZoneControlledbyPrimaryDaylightingControl(@hash[:control_fraction])
  else
    parent_zone.setFractionofZoneControlledbyPrimaryDaylightingControl(defaults[:control_fraction][:default])
  end

  os_dl_control
end