Class: Elemac::Light

Inherits:
Object
  • Object
show all
Defined in:
lib/elemac/light.rb

Constant Summary collapse

SUNRISE =
92
SUNSET =
94
DAY_BREAK_START =
160
DAY_BREAK_END =
162
NIGHT_BREAK_START =
164
NIGHT_BREAK_END =
166
DAYLIGHT_SAVE =
360
LAMP_POWER_ON_DELAY =
91
OFFSET =
0

Instance Method Summary collapse

Constructor Details

#initialize(device:) ⇒ Light

Returns a new instance of Light.



16
17
18
# File 'lib/elemac/light.rb', line 16

def initialize(device:)
  @device = device
end

Instance Method Details

#day_break_endObject



39
40
41
42
# File 'lib/elemac/light.rb', line 39

def day_break_end
  prop = Property.new(offset: get_offset, address: DAY_BREAK_END, type: :short)
  Converter.int_to_hour(get_data(prop.to_s))
end

#day_break_startObject



34
35
36
37
# File 'lib/elemac/light.rb', line 34

def day_break_start
  prop = Property.new(offset: get_offset, address: DAY_BREAK_START, type: :short)
  Converter.int_to_hour(get_data(prop.to_s))
end

#get_offsetObject



20
21
22
# File 'lib/elemac/light.rb', line 20

def get_offset
  OFFSET
end

#inspectObject



59
60
61
62
63
64
65
66
67
# File 'lib/elemac/light.rb', line 59

def inspect
  puts "SUNRISE:\t#{sunrise}"
  puts "D-BREAK START:\t#{day_break_start}"
  puts "D-BREAK END:\t#{day_break_end}"
  puts "SUNSET:\t\t#{sunset}"
  puts "N-BREAK START:\t#{night_break_start}"
  puts "N-BREAK END:\t#{night_break_end}"
  puts "HQI DELAY:\t#{light_power_on_delay}"
end

#light_power_on_delayObject



54
55
56
57
# File 'lib/elemac/light.rb', line 54

def light_power_on_delay
  prop = Property.new(offset: get_offset, address: LAMP_POWER_ON_DELAY, type: :char)
  get_data(prop.to_s)
end

#night_break_endObject



49
50
51
52
# File 'lib/elemac/light.rb', line 49

def night_break_end
  prop = Property.new(offset: get_offset, address: NIGHT_BREAK_END, type: :short)
  Converter.int_to_hour(get_data(prop.to_s))
end

#night_break_startObject



44
45
46
47
# File 'lib/elemac/light.rb', line 44

def night_break_start
  prop = Property.new(offset: get_offset, address: NIGHT_BREAK_START, type: :short)
  Converter.int_to_hour(get_data(prop.to_s))
end

#sunriseObject



24
25
26
27
# File 'lib/elemac/light.rb', line 24

def sunrise
  prop = Property.new(offset: get_offset, address: SUNRISE, type: :short)
  Converter.int_to_hour(get_data(prop.to_s))
end

#sunsetObject



29
30
31
32
# File 'lib/elemac/light.rb', line 29

def sunset
  prop = Property.new(offset: get_offset, address: SUNSET, type: :short)
  Converter.int_to_hour(get_data(prop.to_s))
end