class Elemac::Output::Default

Constants

DATA_SIZE
DAY_1_START
DAY_1_STOP
DAY_2_START
DAY_2_STOP
DAY_3_START
DAY_3_STOP
DIMMABLE_FLAG
MODE
NEGATIVE_FLAG
OFFSET
PAUSE
POWER_FLAG
PRESENT_FLAG
TIMER
TIMER_ON_FLAG
TYPE
VOLTAGE_FLAG
WORK

Public Class Methods

new(device:, index: 0) click to toggle source
# File lib/elemac/output/default.rb, line 25
def initialize(device:, index: 0)
        @device = device
        @index = index
        @voltage = 0
        @dimmable = false
        @dim_value = 0
end

Public Instance Methods

board_dimmable() click to toggle source
# File lib/elemac/output/default.rb, line 51
def board_dimmable
        type & DIMMABLE_FLAG != 0
end
board_present() click to toggle source
# File lib/elemac/output/default.rb, line 55
def board_present
        type & 128 != 0
end
board_voltage() click to toggle source
# File lib/elemac/output/default.rb, line 59
def board_voltage
        val = (type & VOLTAGE_FLAG) >> 1
        case(val)
        when 0
                230
        when 1
                12
        when 2
                5
        when 3
                3
        else
                0
        end
end
dimmable() click to toggle source
# File lib/elemac/output/default.rb, line 83
def dimmable
        @dimmable
end
get_offset() click to toggle source
# File lib/elemac/output/default.rb, line 33
def get_offset
        throw "Bad offset. Can be only 0..25. #{@index} given." unless (0..25).cover?(@index)
        OFFSET + (@index * DATA_SIZE)
end
inspect() click to toggle source
# File lib/elemac/output/default.rb, line 87
def inspect
        puts "NAME:\t\t#{name}"
        puts "TYPE:\t\t#{type}"
        puts "POWERED:\t#{powered}"
        puts "TIMER:\t\t#{timer_on}"
        puts "NEGATIVE:\t#{negative}"
        puts "BRD_PRESENT:\t#{board_present}"
        puts "BRD_VOLTAGE:\t#{board_voltage}"
        puts "BRD_DIMMABLE:\t#{board_dimmable}"             
end
name() click to toggle source
# File lib/elemac/output/default.rb, line 38
def name
        (@index + 'A'.ord).chr
end
negative() click to toggle source
# File lib/elemac/output/default.rb, line 75
def negative
        type & NEGATIVE_FLAG != 0
end
powered() click to toggle source
# File lib/elemac/output/default.rb, line 47
def powered
        type & POWER_FLAG != 0
end
timer_on() click to toggle source
# File lib/elemac/output/default.rb, line 79
def timer_on
        type & TIMER_ON_FLAG != 0
end
type() click to toggle source
# File lib/elemac/output/default.rb, line 42
def type
        prop = Property.new(offset: get_offset, address: TYPE, type: :short)
        get_data(prop.to_s)
end

Private Instance Methods

get_data(address) click to toggle source
# File lib/elemac/output/default.rb, line 99
def get_data(address)
        @device.request_data(address)
end