Module: Syskit::ComBus
- Defined in:
- lib/syskit/data_service.rb
Overview
Module that represents the communication busses in the task models. It defines the methods that are available on task instances. For methods that are added to the task models, see ComBus::ClassExtension
Instance Method Summary collapse
-
#attach(task) ⇒ Object
Attaches the given task to the communication bus.
- #each_attached_device {|device| ... } ⇒ Object
-
#each_com_bus_device {|the| ... } ⇒ void
Enumerates the communication busses this task is a driver for.
- #each_declared_attached_device {|device| ... } ⇒ Object
Instance Method Details
#attach(task) ⇒ Object
Attaches the given task to the communication bus
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/syskit/data_service.rb', line 173 def attach(task) model.each_com_bus_driver_service do |combus_srv| combus_m = combus_srv.model # Do we have a device for this bus ? next if !(combus = find_device_attached_to(combus_srv)) task.each_master_device do |dev| next if !dev.attached_to?(combus) client_in_srv = dev.combus_client_in_srv client_out_srv = dev.combus_client_out_srv if !combus_m.lazy_dispatch? if !(bus_srv = find_data_service(dev.name)) raise ArgumentError, "combus task #{self} was expected to have a service named #{dev.name} to connect to the device of the same name, but has none" end else bus_srv = combus.require_dynamic_service_for_device(self, dev) end if dev.client_to_bus? client_out_srv.bind(task).connect_to bus_srv end if dev.bus_to_client? bus_srv.connect_to client_in_srv.bind(task) end end end end |
#each_attached_device {|device| ... } ⇒ Object
Enumerates all the devices that are attached to this communication bus for which a corresponding Syskit::Component instance has been attached to self using #attach
163 164 165 166 167 168 169 170 |
# File 'lib/syskit/data_service.rb', line 163 def each_attached_device return enum_for(:each_attached_device) if !block_given? each_declared_attached_device do |dev| if find_data_service(dev.name) yield(dev) end end end |
#each_com_bus_device {|the| ... } ⇒ void
This method returns an undefined value.
Enumerates the communication busses this task is a driver for
132 133 134 135 136 137 |
# File 'lib/syskit/data_service.rb', line 132 def each_com_bus_device return enum_for(:each_com_bus_device) if !block_given? each_master_device do |device| yield(device) if device.kind_of?(Robot::ComBus) end end |
#each_declared_attached_device {|device| ... } ⇒ Object
Enumerates all the devices that are attached to the underlying communication busses, regardless of whether a corresponding Syskit::Component instance has been associated with self using #attach
147 148 149 150 151 152 153 154 |
# File 'lib/syskit/data_service.rb', line 147 def each_declared_attached_device return enum_for(:each_declared_attached_device) if !block_given? each_com_bus_device do |combus| combus.each_attached_device do |dev| yield(dev) end end end |