Class: Syskit::Models::DeviceModel
- Inherits:
-
DataServiceModel
- Object
- Roby::Models::TaskServiceModel
- DataServiceModel
- Syskit::Models::DeviceModel
- Defined in:
- lib/syskit/models/data_service.rb
Overview
Metamodel for all devices
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from DataServiceModel
#orogen_model, #rw port_mappings
Instance Method Summary collapse
-
#apply_device_configuration_extensions(device_instance) ⇒ Object
Applies the configuration extensions declaredwith #extend_device_configuration to the provided class.
- #default_driver ⇒ Object
-
#extend_device_configuration(&block) ⇒ Object
Requires that the given block is used to add methods to the device configuration objects.
- #find_all_drivers ⇒ Object
- #provides(service_model, new_port_mappings = Hash.new) ⇒ Object
- #setup_submodel(submodel, options = Hash.new, &block) ⇒ Object
Methods inherited from DataServiceModel
#apply_block, #as_plan, #bind, #clear_model, #connected?, #create_placeholder_task, #create_proxy_task, #each_fullfilled_model, #each_required_model, #if_already_present, #initialize, #instanciate, new_permanent_root, #placeholder?, #placeholder_model, #port_mappings_for, #pretty_print, #provides?, #proxy_task_model, #resolve, #to_component_model, #to_dot, #try_bind, #try_resolve
Methods included from PortAccess
#each_input_port, #each_output_port, #each_port, #find_input_port, #find_output_port, #find_port, #find_through_method_missing, #has_dynamic_input_port?, #has_dynamic_output_port?, #has_input_port?, #has_output_port?, #has_port?, #has_through_method_missing?, #port_by_name
Methods included from Base
#dependency_injection_names, #pretty_print, #short_name, #to_instance_requirements, #to_s
Constructor Details
This class inherits a constructor from Syskit::Models::DataServiceModel
Instance Method Details
#apply_device_configuration_extensions(device_instance) ⇒ Object
Applies the configuration extensions declaredwith #extend_device_configuration to the provided class
404 405 406 407 408 |
# File 'lib/syskit/models/data_service.rb', line 404 def apply_device_configuration_extensions(device_instance) if device_configuration_module device_instance.extend(device_configuration_module) end end |
#default_driver ⇒ Object
431 432 433 434 435 436 437 438 439 |
# File 'lib/syskit/models/data_service.rb', line 431 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) ⇒ Object
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
394 395 396 397 398 399 400 |
# File 'lib/syskit/models/data_service.rb', line 394 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 ⇒ Object
422 423 424 425 426 427 428 429 |
# File 'lib/syskit/models/data_service.rb', line 422 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) ⇒ Object
410 411 412 413 414 415 416 417 418 419 420 |
# File 'lib/syskit/models/data_service.rb', line 410 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) ⇒ Object
366 367 368 369 370 371 372 |
# File 'lib/syskit/models/data_service.rb', line 366 def setup_submodel(submodel, = Hash.new, &block) super if device_configuration_module submodel.device_configuration_module = Module.new submodel.device_configuration_module.include(device_configuration_module) end end |