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).
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.
6 7 8 |
# File 'lib/arduino/incoming_handler.rb', line 6 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
49 50 51 |
# File 'lib/arduino/incoming_handler.rb', line 49 def busy(gcode) bot.status[:busy] = 1 end |
#done(gcode) ⇒ Object
45 46 47 |
# File 'lib/arduino/incoming_handler.rb', line 45 def done(gcode) bot.status[:busy] = 0 end |
#execute(gcode) ⇒ Object
10 11 12 13 14 |
# File 'lib/arduino/incoming_handler.rb', line 10 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
41 42 43 |
# File 'lib/arduino/incoming_handler.rb', line 41 def idle(gcode) bot.status[:busy] = 0 end |
#received(gcode) ⇒ Object
37 38 39 |
# File 'lib/arduino/incoming_handler.rb', line 37 def received(gcode) bot.status[:busy] = 1 end |
#report_current_position(gcode) ⇒ Object
28 29 30 |
# File 'lib/arduino/incoming_handler.rb', line 28 def report_current_position(gcode) bot.status.gcode_update(gcode) end |
#report_parameter_value(gcode) ⇒ Object
20 21 22 |
# File 'lib/arduino/incoming_handler.rb', line 20 def report_parameter_value(gcode) bot.status.set_pin(gcode.value_of(:P), gcode.value_of(:V)) end |
#report_software_version(gcode) ⇒ Object
53 54 55 |
# File 'lib/arduino/incoming_handler.rb', line 53 def report_software_version(gcode) nil # Don't need the info right now. end |
#report_status_value(gcode) ⇒ Object
32 33 34 35 |
# File 'lib/arduino/incoming_handler.rb', line 32 def report_status_value(gcode) # TODO: Verfiy the accuracy of this code. CC: @timevww bot.status.set_pin(gcode.value_of(:P), gcode.value_of(:V)) end |
#reporting_end_stops(gcode) ⇒ Object
24 25 26 |
# File 'lib/arduino/incoming_handler.rb', line 24 def reporting_end_stops(gcode) bot.status.gcode_update(gcode) end |
#unknown(gcode) ⇒ Object
16 17 18 |
# File 'lib/arduino/incoming_handler.rb', line 16 def unknown(gcode) bot.log "Don't know how to parse incoming GCode: #{gcode}" end |