Class: FB::IncomingHandler
- Inherits:
-
Object
- Object
- FB::IncomingHandler
- Defined in:
- lib/arduino/incoming_handler.rb
Overview
Handles Gcode that was sent by the ARDUINO to the RASPBERRY PI.
Instance Attribute Summary collapse
-
#bot ⇒ Object
readonly
Returns the value of attribute bot.
Instance Method Summary collapse
- #busy(gcode) ⇒ Object
- #debug_message ⇒ 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_end_stops(gcode) ⇒ Object
-
#report_parameter_value(gcode) ⇒ Object
Called when the Ardunio is reporting the status of a parameter.
- #report_pin_value(gcode) ⇒ Object
- #report_software_version(gcode) ⇒ Object
- #report_status_value(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
57 58 59 |
# File 'lib/arduino/incoming_handler.rb', line 57 def busy(gcode) bot.status[:busy] = 1 end |
#debug_message ⇒ Object
65 66 67 |
# File 'lib/arduino/incoming_handler.rb', line 65 def (*) nil # Squelch debug messages. end |
#done(gcode) ⇒ Object
53 54 55 |
# File 'lib/arduino/incoming_handler.rb', line 53 def done(gcode) bot.status[:busy] = 0 end |
#execute(gcode) ⇒ Object
10 11 12 13 14 15 16 17 |
# 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) ⇒ Object
49 50 51 |
# File 'lib/arduino/incoming_handler.rb', line 49 def idle(gcode) bot.status[:busy] = 0 end |
#received(gcode) ⇒ Object
45 46 47 |
# File 'lib/arduino/incoming_handler.rb', line 45 def received(gcode) bot.status[:busy] = 1 end |
#report_current_position(gcode) ⇒ Object
36 37 38 |
# File 'lib/arduino/incoming_handler.rb', line 36 def report_current_position(gcode) bot.status.gcode_update(gcode) end |
#report_end_stops(gcode) ⇒ Object
32 33 34 |
# File 'lib/arduino/incoming_handler.rb', line 32 def report_end_stops(gcode) bot.status.gcode_update(gcode) end |
#report_parameter_value(gcode) ⇒ Object
Called when the Ardunio is reporting the status of a parameter.
24 25 26 |
# 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) ⇒ Object
28 29 30 |
# 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) ⇒ Object
61 62 63 |
# 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) ⇒ Object
40 41 42 43 |
# 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) ⇒ Object
19 20 21 |
# File 'lib/arduino/incoming_handler.rb', line 19 def unknown(gcode) bot.log "Don't know how to parse incoming GCode: #{gcode}" end |