class Fluent::ArduinoOutput

Constants

DATA_BITS
PARITY
PIN_NUMBER
STOP_BITS

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_arduino.rb, line 37
def configure(conf)
  super

  if @device_type != "led"
    raise Fluent::ConfigError, "this use type is led only"
  end

  @sw = true
  @serial = SerialPort.new(@port, @baud_rate, DATA_BITS, STOP_BITS, PARITY)
end
emit(tag, es, chain) click to toggle source
# File lib/fluent/plugin/out_arduino.rb, line 56
def emit(tag, es, chain)
  es.each do |time, record|
    v = record[@key].strip
    if v == @value and @sw == true
      @serial.write(PIN_NUMBER[@pin.to_s].downcase)
      @sw = !@sw
    elsif v == @value and @sw == false
      @serial.write(PIN_NUMBER[@pin.to_s].upcase)
      @sw = !@sw
    end
  end
  chain.next
end
shutdown() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_arduino.rb, line 52
def shutdown
  super
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_arduino.rb, line 48
def start
  super
end