class Elemac::Sensor::Default
Constants
- ALARM_HIGH
- ALARM_LOW
- DATA_SIZE
- DAY_HIGH
- DAY_LOW
- FLAGS
- FLAG_ALARM_HIGH
- FLAG_ALARM_LOW
- FLAG_LOWER
- FLAG_PRESENT
- FLAG_RISE
- HYSTERESIS
- MEASURMENT
- NIGHT_HIGH
- NIGHT_LOW
- OFFSET
Public Class Methods
new(device:, index: 0, divider: 1.0)
click to toggle source
# File lib/elemac/sensor/default.rb, line 23 def initialize(device:, index: 0, divider: 1.0) throw 'Index has to be in range 0-5' if !(0..5).cover?(index) @device = device @index = index @offset = get_offset @divider = divider end
Public Instance Methods
alarm_high()
click to toggle source
# File lib/elemac/sensor/default.rb, line 59 def alarm_high prop = Property.new(offset: get_offset, address: ALARM_HIGH, type: :short) get_data(prop.to_s) / @divider end
alarm_low()
click to toggle source
# File lib/elemac/sensor/default.rb, line 63 def alarm_low prop = Property.new(offset: get_offset, address: ALARM_LOW, type: :short) get_data(prop.to_s) / @divider end
day_high()
click to toggle source
# File lib/elemac/sensor/default.rb, line 43 def day_high prop = Property.new(offset: get_offset, address: DAY_HIGH, type: :short) get_data(prop.to_s) / @divider end
day_low()
click to toggle source
# File lib/elemac/sensor/default.rb, line 47 def day_low prop = Property.new(offset: get_offset, address: DAY_LOW, type: :short) get_data(prop.to_s) / @divider end
flag_alarm_high()
click to toggle source
# File lib/elemac/sensor/default.rb, line 82 def flag_alarm_high return false unless flag_present flags & FLAG_ALARM_HIGH != 0 end
flag_alarm_low()
click to toggle source
# File lib/elemac/sensor/default.rb, line 86 def flag_alarm_low return false unless flag_present flags & FLAG_ALARM_LOW != 0 end
flag_lower()
click to toggle source
# File lib/elemac/sensor/default.rb, line 78 def flag_lower return false unless flag_present flags & FLAG_LOWER != 0 end
flag_present()
click to toggle source
# File lib/elemac/sensor/default.rb, line 71 def flag_present flags & FLAG_PRESENT != 0 end
flag_rise()
click to toggle source
# File lib/elemac/sensor/default.rb, line 74 def flag_rise return false unless flag_present flags & FLAG_RISE != 0 end
flags()
click to toggle source
# File lib/elemac/sensor/default.rb, line 67 def flags prop = Property.new(offset: get_offset, address: FLAGS, type: :short) get_data(prop.to_s) end
get_offset()
click to toggle source
# File lib/elemac/sensor/default.rb, line 30 def get_offset # this does not include rh sensor yet throw "Bad offset. Can be only 0,1,2,3 for TEMP or 4,5 for PH. #{@index} given." unless (0..5).cover?(@index) OFFSET + (@index * DATA_SIZE) end
hysteresis()
click to toggle source
# File lib/elemac/sensor/default.rb, line 39 def hysteresis prop = Property.new(offset: get_offset, address: HYSTERESIS, type: :char) get_data(prop.to_s) / @divider end
inspect()
click to toggle source
# File lib/elemac/sensor/default.rb, line 91 def inspect puts "MEASURMENT\t#{value}" puts "HYSTERESIS\t#{hysteresis}" puts "DAY LOW\t\t#{day_low}" puts "DAY HIGH\t#{day_high}" puts "NIGHT LOW\t#{night_low}" puts "NIGHT HIGH\t#{night_high}" puts "ALARM LOW\t#{alarm_low}" puts "ALARM HIGH\t#{alarm_high}" puts "FLAGS:\t\t#{flags} (#{flags.to_s(2)})" puts "F_PRESENT:\t#{flag_present}" puts "F_RISE:\t\t#{flag_rise}" puts "F_LOWER:\t#{flag_lower}" puts "F_ALARM_H:\t#{flag_alarm_high}" puts "F_ALARM_L:\t#{flag_alarm_low}" end
night_high()
click to toggle source
# File lib/elemac/sensor/default.rb, line 51 def night_high prop = Property.new(offset: get_offset, address: NIGHT_HIGH, type: :short) get_data(prop.to_s) / @divider end
night_low()
click to toggle source
# File lib/elemac/sensor/default.rb, line 55 def night_low prop = Property.new(offset: get_offset, address: NIGHT_LOW, type: :short) get_data(prop.to_s) / @divider end
value()
click to toggle source
# File lib/elemac/sensor/default.rb, line 35 def value prop = Property.new(offset: get_offset, address: MEASURMENT, type: :short) get_data(prop.to_s) / @divider end
Private Instance Methods
get_data(address)
click to toggle source
# File lib/elemac/sensor/default.rb, line 109 def get_data(address) @device.request_data(address) end