Class: Artoo::Master
Overview
The Artoo::Master class is a registered supervisor class to keep track of all the running robots
Instance Attribute Summary collapse
-
#robots ⇒ Object
readonly
Returns the value of attribute robots.
Instance Method Summary collapse
- #continue_work ⇒ Object
-
#initialize(bots) ⇒ Master
constructor
A new instance of Master.
- #pause_work ⇒ Object
- #robot(name) ⇒ Object
- #robot_connection(robot_id, connection_id) ⇒ Object
- #robot_connections(name) ⇒ Object
- #robot_device(name, device_id) ⇒ Object
- #robot_devices(name) ⇒ Object
- #start_work ⇒ Object
- #stop_work ⇒ Object
Methods included from Celluloid
Constructor Details
#initialize(bots) ⇒ Master
Returns a new instance of Master.
8 9 10 |
# File 'lib/artoo/master.rb', line 8 def initialize(bots) @robots = bots end |
Instance Attribute Details
#robots ⇒ Object (readonly)
Returns the value of attribute robots.
6 7 8 |
# File 'lib/artoo/master.rb', line 6 def robots @robots end |
Instance Method Details
#continue_work ⇒ Object
43 44 45 |
# File 'lib/artoo/master.rb', line 43 def continue_work robots.each {|r| r.async.continue_work} end |
#pause_work ⇒ Object
36 37 38 39 40 41 |
# File 'lib/artoo/master.rb', line 36 def pause_work robots.each {|r| Logger.info "pausing #{r.name}" r.async.pause_work } end |
#robot(name) ⇒ Object
12 13 14 |
# File 'lib/artoo/master.rb', line 12 def robot(name) robots.find {|r| r.name == name} end |
#robot_connection(robot_id, connection_id) ⇒ Object
28 29 30 |
# File 'lib/artoo/master.rb', line 28 def robot_connection(robot_id, connection_id) robot_connections(robot_id)[connection_id.intern] end |
#robot_connections(name) ⇒ Object
24 25 26 |
# File 'lib/artoo/master.rb', line 24 def robot_connections(name) robot(name).connections end |
#robot_device(name, device_id) ⇒ Object
20 21 22 |
# File 'lib/artoo/master.rb', line 20 def robot_device(name, device_id) robot_devices(name)[device_id.intern] end |
#robot_devices(name) ⇒ Object
16 17 18 |
# File 'lib/artoo/master.rb', line 16 def robot_devices(name) robot(name).devices end |
#start_work ⇒ Object
32 33 34 |
# File 'lib/artoo/master.rb', line 32 def start_work robots.each {|r| r.async.work} unless Artoo::Robot.is_running? end |
#stop_work ⇒ Object
47 48 49 |
# File 'lib/artoo/master.rb', line 47 def stop_work #robots.each {|r| r.async.stop_work} unless !Artoo::Robot.is_running? end |