Class: Syskit::Robot::ComBus

Inherits:
MasterDeviceInstance show all
Defined in:
lib/syskit/robot/communication_bus.rb

Overview

This class represents a communication bus on the robot, i.e. a device that multiplexes and demultiplexes I/O for device modules

Constant Summary

Constants inherited from MasterDeviceInstance

MasterDeviceInstance::KNOWN_PARAMETERS

Instance Attribute Summary collapse

Attributes inherited from MasterDeviceInstance

#com_busses, #combus_client_in_srv, #combus_client_out_srv, #configuration, #configuration_block, #device_model, #driver_model, #name, #requirements, #robot, #slaves

Instance Method Summary collapse

Methods inherited from MasterDeviceInstance

#==, #advanced, #advanced=, #advanced?, #arguments, #as_plan, #attach_to, #attached_to?, #bus_to_client?, #client_to_bus?, #device_id, #droby_dump, #each_fullfilled_model, #each_slave, #find_combus_client_srv, #find_through_method_missing, #full_name, #has_slave?, #has_through_method_missing?, #model, #prefer_deployed_tasks, #pretty_print, #short_name, #slave, #to_action_model, #to_instance_requirements, #to_s, #use, #use_conf, #use_deployments, #with_arguments, #with_conf

Methods inherited from DeviceInstance

#doc, #period, #to_action

Constructor Details

#initialize(robot, name, device_model, options, driver_model, task_arguments) ⇒ ComBus

Returns a new instance of ComBus



8
9
10
11
12
# File 'lib/syskit/robot/communication_bus.rb', line 8

def initialize(robot, name, device_model, options,
               driver_model, task_arguments)
    super
    @attached_devices = Set.new
end

Instance Attribute Details

#attached_devicesObject (readonly)

Returns the value of attribute attached_devices



6
7
8
# File 'lib/syskit/robot/communication_bus.rb', line 6

def attached_devices
  @attached_devices
end

Instance Method Details

#device(type_name, options = Hash.new) ⇒ Object

Used by the #through call to override com_bus specification.



48
49
50
51
52
# File 'lib/syskit/robot/communication_bus.rb', line 48

def device(type_name, options = Hash.new)
    device = robot.device(type_name, options)
    device.attach_to(self)
    device
end

#each_attached_deviceObject



43
44
45
# File 'lib/syskit/robot/communication_bus.rb', line 43

def each_attached_device
    attached_devices.each { |dev| yield(dev) }
end

#instanciate(plan, context = DependencyInjectionContext.new, **options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/syskit/robot/communication_bus.rb', line 14

def instanciate(plan, context = DependencyInjectionContext.new, **options)
    service = super
    task = service.to_task
    if !device_model.lazy_dispatch?
        each_attached_device do |dev|
            require_dynamic_service_for_device(task, dev)
        end
    end
    service
end

#require_dynamic_service_for_device(combus_task, device) ⇒ BoundDataService

Create the dynamic service on the combus driver task that is necessary to connect to the given device

Parameters:

  • combus_task (Component)

    the driver task for self

  • device (Device)

    the device that should be interfaced through the service

Returns:



33
34
35
36
37
# File 'lib/syskit/robot/communication_bus.rb', line 33

def require_dynamic_service_for_device(combus_task, device)
    combus_task.require_dynamic_service(
        device_model.dynamic_service_name,
        as: device.name, bus_to_client: device.bus_to_client?, client_to_bus: device.client_to_bus?)
end

#through(&block) ⇒ Object



39
40
41
# File 'lib/syskit/robot/communication_bus.rb', line 39

def through(&block)
    instance_eval(&block)
end