class Elemac::Sensor::Ph

Constants

ADC1
ADC2
ADC_OFFSET
CALIBR_49
CALIBR_7
CALIBR_DATE
CALIBR_FLAGS
ELZERO
PH_DATA_SIZE
PH_OFFSET
REMINDER
SLOPE

Public Instance Methods

adc() click to toggle source
# File lib/elemac/sensor/ph.rb, line 85
def adc
        # depending on current ph 0 or 1, get adc value
        adc_address = (@index - 4) == 0 ? ADC1 : ADC2
        prop = Property.new(offset: ADC_OFFSET, address: ADC1, type: :short)
        get_data(prop.to_s)
end
calibr_49() click to toggle source

TODO: chyba nie sprowadza dobrych wartosci dla ph9 (218) - wyswietla tyle co w 4

# File lib/elemac/sensor/ph.rb, line 37
def calibr_49
        prop = Property.new(offset: get_ph_offset, address: CALIBR_49, type: :short)
        get_data(prop.to_s)
end
calibr_7() click to toggle source
# File lib/elemac/sensor/ph.rb, line 31
def calibr_7
        prop = Property.new(offset: get_ph_offset, address: CALIBR_7, type: :short)
        get_data(prop.to_s)
end
calibr_date() click to toggle source
# File lib/elemac/sensor/ph.rb, line 47
def calibr_date
        prop = Property.new(offset: get_ph_offset, address: CALIBR_DATE, type: :int)
        Converter.long_to_date(get_data(prop.to_s))
end
calibr_flags() click to toggle source
# File lib/elemac/sensor/ph.rb, line 42
def calibr_flags
        prop = Property.new(offset: get_ph_offset, address: CALIBR_FLAGS, type: :char)
        get_data(prop.to_s)
end
calibr_status() click to toggle source
# File lib/elemac/sensor/ph.rb, line 77
def calibr_status
        Converter.ph_reminder(calibr_flags, calibr_date, reminder)
end
elzero() click to toggle source
# File lib/elemac/sensor/ph.rb, line 67
def elzero
        prop = Property.new(offset: get_ph_offset, address: ELZERO, type: :short)
        get_data(prop.to_s)
end
get_ph_offset() click to toggle source

-4 poniewaz index sensora jest 4 lub 5 dla ph, a dane offsetowe do kalibracji moga przyjmowac index 0 lub 1 wyłącznie co odpowiada indeksowi 0 lub 1 w zaleznosci od czujnika

# File lib/elemac/sensor/ph.rb, line 25
def get_ph_offset
        index = (@index - 4)
        throw "Bad offset. Can be only 0 or 1. #{index} given." unless (0..1).cover?(index)
        PH_OFFSET + (index * PH_DATA_SIZE)
end
inspect() click to toggle source
Calls superclass method Elemac::Sensor::Default#inspect
# File lib/elemac/sensor/ph.rb, line 92
def inspect
        super
        puts "ADC\t\t#{adc}"
        puts "CALIBR 7\t#{calibr_7}"
        puts "CALIBR 49\t#{calibr_49}"
        puts "PH9 ENABLED\t#{ph_9_enabled}"
        puts "CALIBR_FLAGS\t#{calibr_flags} (#{(calibr_flags & 7).to_s(2)})"
        puts "CALIBR_DATE\t#{calibr_date}"
        puts "SLOPE\t\t#{slope}"
        puts "SLOPE mV/pH\t#{slope_mv_ph}"
        puts "ELZERO\t\t#{elzero}"
        puts "REMINDER\t#{reminder}"
        puts "STATUS\t\t#{calibr_status}"
end
ph_9_enabled() click to toggle source
# File lib/elemac/sensor/ph.rb, line 81
def ph_9_enabled
        Converter.ph_9_enabled(calibr_flags)
end
reminder() click to toggle source
# File lib/elemac/sensor/ph.rb, line 72
def reminder
        prop = Property.new(offset: get_ph_offset, address: REMINDER, type: :char)
        get_data(prop.to_s)
end
slope() click to toggle source

a warning should be shown when this value is > 22240

# File lib/elemac/sensor/ph.rb, line 53
def slope
        prop = Property.new(offset: get_ph_offset, address: SLOPE, type: :short)
        get_data(prop.to_s)
end
slope_mv_ph() click to toggle source
# File lib/elemac/sensor/ph.rb, line 58
def slope_mv_ph
        current_slope = slope
        if current_slope == 0
                0
        else
                1638400.0 / current_slope * (625.0 / 128.0) / 11.9090900421143
        end
end