class Syskit::Models::DeviceModel

Metamodel for all devices

Public Instance Methods

apply_device_configuration_extensions(device_instance) click to toggle source

Applies the configuration extensions declaredwith extend_device_configuration to the provided class

# File lib/syskit/models/data_service.rb, line 358
def apply_device_configuration_extensions(device_instance)
    if device_configuration_module
        device_instance.extend(device_configuration_module)
    end
end
default_driver() click to toggle source
# File lib/syskit/models/data_service.rb, line 385
def default_driver
    tasks = find_all_drivers
    if tasks.size > 1
        raise Ambiguous, "#{tasks.map(&:to_s).join(", ")} can all handle '#{self}'"
    elsif tasks.empty?
        raise ArgumentError, "no task can handle devices of type '#{self}'"
    end
    tasks.first
end
extend_device_configuration(&block) click to toggle source

Requires that the given block is used to add methods to the device configuration objects.

I.e. if a device type is defined with

device_type('Hokuyo').
   extend_device_configuration do
       def enable_remanence_values; @remanence = true; self end
       def remanence_values_enabled?; @remanence end
   end

Then the methods are made available on the corresponding MasterDeviceInstance instances:

Robot.devices do
  device(Devices::Hokuyo).
    enable_remanence_values
end
# File lib/syskit/models/data_service.rb, line 348
def extend_device_configuration(&block)
    if block
        self.device_configuration_module ||= Module.new
        device_configuration_module.class_eval(&block)
    end
    self
end
find_all_drivers() click to toggle source
# File lib/syskit/models/data_service.rb, line 376
def find_all_drivers
    # Since we want to drive a particular device, we actually need a
    # concrete task model. So, search for one.
    #
    # Get all task models that implement this device
    Syskit::Component.each_submodel.
        find_all { |t| t.fullfills?(self) && !t.abstract? }
end
provides(service_model, new_port_mappings = Hash.new) click to toggle source
# File lib/syskit/models/data_service.rb, line 364
def provides(service_model, new_port_mappings = Hash.new)
    super

    # If the provided model has a device_configuration_module,
    # include it in our own
    if service_model.respond_to?(:device_configuration_module) &&
        service_model.device_configuration_module
        self.device_configuration_module ||= Module.new
        self.device_configuration_module.include(service_model.device_configuration_module)
    end
end
setup_submodel(submodel, options = Hash.new, &block) click to toggle source
Calls superclass method
# File lib/syskit/models/data_service.rb, line 320
def setup_submodel(submodel, options = Hash.new, &block)
    super
    if device_configuration_module
        submodel.device_configuration_module = Module.new
        submodel.device_configuration_module.include(device_configuration_module)
    end
end