Class: FB::IncomingHandler
- Inherits:
-
Object
- Object
- FB::IncomingHandler
- Defined in:
- lib/arduino/incoming_handler.rb
Overview
Handles Gcode that moves from the Arduino to the Pi (Arduino -> Pi).
Defined Under Namespace
Classes: UnhandledGcode
Instance Attribute Summary collapse
-
#bot ⇒ Object
readonly
Returns the value of attribute bot.
Instance Method Summary collapse
- #busy(gcode) ⇒ Object
- #done(gcode) ⇒ Object
- #execute(gcode) ⇒ Object
-
#initialize(bot) ⇒ IncomingHandler
constructor
A new instance of IncomingHandler.
- #received(gcode) ⇒ Object
- #report_current_position(gcode) ⇒ Object
- #report_software_version(gcode) ⇒ Object
- #report_status_value(gcode) ⇒ Object
- #reporting_end_stops(gcode) ⇒ Object
- #unknown(gcode) ⇒ Object
Constructor Details
#initialize(bot) ⇒ IncomingHandler
Returns a new instance of IncomingHandler.
8 9 10 |
# File 'lib/arduino/incoming_handler.rb', line 8 def initialize(bot) @bot = bot end |
Instance Attribute Details
#bot ⇒ Object (readonly)
Returns the value of attribute bot.
4 5 6 |
# File 'lib/arduino/incoming_handler.rb', line 4 def bot @bot end |
Instance Method Details
#busy(gcode) ⇒ Object
38 39 40 |
# File 'lib/arduino/incoming_handler.rb', line 38 def busy(gcode) bot.status[:busy] = 1 end |
#done(gcode) ⇒ Object
34 35 36 |
# File 'lib/arduino/incoming_handler.rb', line 34 def done(gcode) bot.status[:busy] = 0 end |
#execute(gcode) ⇒ Object
12 13 14 15 16 |
# File 'lib/arduino/incoming_handler.rb', line 12 def execute(gcode) self.send(gcode.name, gcode) rescue NoMethodError bot.log "#{gcode.name} is a valid GCode, but no input handler method exists" end |
#received(gcode) ⇒ Object
22 23 24 |
# File 'lib/arduino/incoming_handler.rb', line 22 def received(gcode) bot.status[:busy] = 1 end |
#report_current_position(gcode) ⇒ Object
30 31 32 |
# File 'lib/arduino/incoming_handler.rb', line 30 def report_current_position(gcode) bot.status.gcode_update(gcode) end |
#report_software_version(gcode) ⇒ Object
46 47 48 |
# File 'lib/arduino/incoming_handler.rb', line 46 def report_software_version(gcode) nil # Don't need the info right now. end |
#report_status_value(gcode) ⇒ Object
42 43 44 |
# File 'lib/arduino/incoming_handler.rb', line 42 def report_status_value(gcode) bot.status.gcode_update(gcode) end |
#reporting_end_stops(gcode) ⇒ Object
26 27 28 |
# File 'lib/arduino/incoming_handler.rb', line 26 def reporting_end_stops(gcode) bot.status.gcode_update(gcode) end |
#unknown(gcode) ⇒ Object
18 19 20 |
# File 'lib/arduino/incoming_handler.rb', line 18 def unknown(gcode) bot.log "Don't know how to parse incoming GCode: #{gcode}" end |