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
- #idle(gcode) ⇒ Object
-
#initialize(bot) ⇒ IncomingHandler
constructor
A new instance of IncomingHandler.
- #received(gcode) ⇒ Object
- #report_current_position(gcode) ⇒ Object
- #report_parameter_value(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
51 52 53 |
# File 'lib/arduino/incoming_handler.rb', line 51 def busy(gcode) bot.status[:busy] = 1 end |
#done(gcode) ⇒ Object
47 48 49 |
# File 'lib/arduino/incoming_handler.rb', line 47 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 |
#idle(gcode) ⇒ Object
43 44 45 |
# File 'lib/arduino/incoming_handler.rb', line 43 def idle(gcode) bot.status[:busy] = 0 end |
#received(gcode) ⇒ Object
39 40 41 |
# File 'lib/arduino/incoming_handler.rb', line 39 def received(gcode) bot.status[:busy] = 1 end |
#report_current_position(gcode) ⇒ Object
31 32 33 |
# File 'lib/arduino/incoming_handler.rb', line 31 def report_current_position(gcode) bot.status.gcode_update(gcode) end |
#report_parameter_value(gcode) ⇒ Object
22 23 24 25 |
# File 'lib/arduino/incoming_handler.rb', line 22 def report_parameter_value(gcode) # This is not correct. We need to store pin values in an array somewhere. bot.status.gcode_update(gcode) end |
#report_software_version(gcode) ⇒ Object
55 56 57 |
# File 'lib/arduino/incoming_handler.rb', line 55 def report_software_version(gcode) nil # Don't need the info right now. end |
#report_status_value(gcode) ⇒ Object
35 36 37 |
# File 'lib/arduino/incoming_handler.rb', line 35 def report_status_value(gcode) bot.status.gcode_update(gcode) end |
#reporting_end_stops(gcode) ⇒ Object
27 28 29 |
# File 'lib/arduino/incoming_handler.rb', line 27 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 |