class FB::IncomingHandler

Handles Gcode that was sent by the ARDUINO to the RASPBERRY PI.

Attributes

bot[R]

Public Class Methods

new(bot) click to toggle source
# File lib/arduino/incoming_handler.rb, line 6
def initialize(bot)
  @bot = bot
end

Public Instance Methods

busy(gcode) click to toggle source
# File lib/arduino/incoming_handler.rb, line 57
def busy(gcode)
  bot.status[:busy] = 1
end
debug_message(*) click to toggle source
# File lib/arduino/incoming_handler.rb, line 65
def debug_message(*)
  nil # Squelch debug messages.
end
done(gcode) click to toggle source
# File lib/arduino/incoming_handler.rb, line 53
def done(gcode)
  bot.status[:busy] = 0
end
execute(gcode) click to toggle source
# File lib/arduino/incoming_handler.rb, line 10
def execute(gcode)
  name = gcode.name
  if respond_to?(name)
    self.send(name, gcode)
  else
    bot.log "#{gcode.name} is a valid GCode, but no input handler method exists"
  end
end
idle(gcode) click to toggle source
# File lib/arduino/incoming_handler.rb, line 49
def idle(gcode)
  bot.status[:busy] = 0
end
received(gcode) click to toggle source
# File lib/arduino/incoming_handler.rb, line 45
def received(gcode)
  bot.status[:busy] = 1
end
report_current_position(gcode) click to toggle source
# File lib/arduino/incoming_handler.rb, line 36
def report_current_position(gcode)
  bot.status.gcode_update(gcode)
end
report_end_stops(gcode) click to toggle source
# File lib/arduino/incoming_handler.rb, line 32
def report_end_stops(gcode)
  bot.status.gcode_update(gcode)
end
report_parameter_value(gcode) click to toggle source

Called when the Ardunio is reporting the status of a parameter.

# File lib/arduino/incoming_handler.rb, line 24
def report_parameter_value(gcode)
  bot.status.set_parameter(gcode.value_of(:P), gcode.value_of(:V))
end
report_pin_value(gcode) click to toggle source
# File lib/arduino/incoming_handler.rb, line 28
def report_pin_value(gcode)
  bot.status.set_pin(gcode.value_of(:P), gcode.value_of(:V))
end
report_software_version(gcode) click to toggle source
# File lib/arduino/incoming_handler.rb, line 61
def report_software_version(gcode)
  nil # Don't need the info right now.
end
report_status_value(gcode) click to toggle source
# File lib/arduino/incoming_handler.rb, line 40
def report_status_value(gcode)
  # TODO: Verfiy the accuracy of this code. CC: @timevww
  bot.status.set(gcode.value_of(:P), gcode.value_of(:V))
end
unknown(gcode) click to toggle source
# File lib/arduino/incoming_handler.rb, line 19
def unknown(gcode)
  bot.log "Don't know how to parse incoming GCode: #{gcode}"
end