Class: Artoo::Master

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/artoo/master.rb

Overview

The Artoo::Master class is a registered supervisor class to keep track of all the running robots

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Celluloid

#timers

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

#robotsObject (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_workObject



43
44
45
# File 'lib/artoo/master.rb', line 43

def continue_work
  robots.each {|r| r.async.continue_work}
end

#pause_workObject



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_workObject



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_workObject



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