module Orocos::RobyPlugin::ComponentModel

Definition of model-level methods for the Component models. See the documentation of Model for an explanation of this.

Attributes

data_services[R]

The data services that are provided by this particular component model, as a hash mapping the source name to the corresponding DataService instance. This only includes new sources that have been added at this level of the component hierarchy, not the ones that have already been added to the model parents.

See also #provides

Public Instance Methods

as(service_model) click to toggle source

Returns a view of this component as a producer of the given model

This will fail if multiple services offer service_model. In this case, one would have to first explicitely select the service and only then call #as on the returned ProvidedDataService object

# File lib/orocos/roby/component.rb, line 470
def as(service_model)
    srv = find_service_from_type(service_model)
    return srv.as(service_model)
end
each_data_service { |service_name, service| } click to toggle source

Enumerates all the data services that are provided by this component model, as pairs of source name and DataService instances. Unlike #data_services, it enumerates both the sources added at this level of the model hierarchy and the ones that are provided by the model’s parents.

See also #provides

# File lib/orocos/roby/component.rb, line 305
            
each_input_port(&block) click to toggle source

Enumerates this component’s input ports

# File lib/orocos/roby/component.rb, line 361
def each_input_port(&block)
    return [].each(&block) if !respond_to?(:orogen_spec)
    orogen_spec.each_input_port(&block)
end
each_output_port(&block) click to toggle source

Enumerates this component’s output ports

# File lib/orocos/roby/component.rb, line 355
def each_output_port(&block)
    return [].each(&block) if !respond_to?(:orogen_spec)
    orogen_spec.each_output_port(&block)
end
each_port(&block) click to toggle source

Enumerates all of this component’s ports

# File lib/orocos/roby/component.rb, line 367
def each_port(&block)
    return [].each(&block) if !respond_to?(:orogen_spec)
    orogen_spec.each_port(&block)
end
find_data_service(name) → service click to toggle source

Returns the DataService instance that has the given name, or nil if there is none.

See also #provides

# File lib/orocos/roby/component.rb, line 317
            
find_input_port(name) click to toggle source

Returns the input port with the given name, or nil if it does not exist.

# File lib/orocos/roby/component.rb, line 349
def find_input_port(name)
    return if !respond_to?(:orogen_spec)
    orogen_spec.find_input_port(name)
end
find_output_port(name) click to toggle source

Returns the output port with the given name, or nil if it does not exist.

# File lib/orocos/roby/component.rb, line 342
def find_output_port(name)
    return if !respond_to?(:orogen_spec)
    orogen_spec.find_output_port(name)
end
find_port(name) click to toggle source

Returns the port object that maps to the given name, or nil if it does not exist.

# File lib/orocos/roby/component.rb, line 331
def find_port(name)
    name = name.to_str
    find_output_port(name) || find_input_port(name)
end
has_dynamic_input_port?(name, type = nil) click to toggle source

True if name could be a dynamic input port name.

Dynamic input ports are declared on the task models using the #dynamic_input_port statement, e.g.:

data_service do
    dynamic_input_port /name_pattern\w+/, "/std/string"
end

One can then match if a given string (name) matches one of the dynamic input port declarations using this predicate.

# File lib/orocos/roby/component.rb, line 419
def has_dynamic_input_port?(name, type = nil)
    return if !respond_to?(:orogen_spec)
    orogen_spec.has_dynamic_input_port?(name, type)
end
has_dynamic_output_port?(name, type = nil) click to toggle source

True if name could be a dynamic output port name.

Dynamic output ports are declared on the task models using the #dynamic_output_port statement, e.g.:

data_service do
    dynamic_output_port /name_pattern\w+/, "/std/string"
end

One can then match if a given string (name) matches one of the dynamic output port declarations using this predicate.

# File lib/orocos/roby/component.rb, line 403
def has_dynamic_output_port?(name, type = nil)
    return if !respond_to?(:orogen_spec)
    orogen_spec.has_dynamic_output_port?(name, type)
end
has_input_port?(name, including_dynamic = true) click to toggle source

Returns true if name is a valid input port name for instances of self. If including_dynamic is set to false, only static ports will be considered

# File lib/orocos/roby/component.rb, line 385
def has_input_port?(name, including_dynamic = true)
    return true if find_input_port(name)
    if including_dynamic
        has_dynamic_input_port?(name)
    end
end
has_output_port?(name, including_dynamic = true) click to toggle source

Returns true if name is a valid output port name for instances of self. If including_dynamic is set to false, only static ports will be considered

# File lib/orocos/roby/component.rb, line 375
def has_output_port?(name, including_dynamic = true)
    return true if find_output_port(name)
    if including_dynamic
        has_dynamic_output_port?(name)
    end
end
has_port?(name) click to toggle source
# File lib/orocos/roby/component.rb, line 336
def has_port?(name)
    has_input_port?(name) || has_output_port?(name)
end
instanciate(engine, context, arguments = Hash.new) click to toggle source

Generic instanciation of a component.

It creates a new task from the component model using Orocos::RobyPlugin::Component.new, adds it to the engine’s plan and returns it.

# File lib/orocos/roby/component.rb, line 428
def instanciate(engine, context, arguments = Hash.new)
    task_arguments, instanciate_arguments = Kernel.
        filter_options arguments, :task_arguments => Hash.new
    engine.plan.add(task = new(task_arguments[:task_arguments]))
    task.robot = engine.robot
    task
end
port_mappings_for_task() click to toggle source

Defined to be compatible, in port mapping code, with the data services

# File lib/orocos/roby/component.rb, line 476
def port_mappings_for_task
   Hash.new { |h,k| k }
end
use_conf(*spec, &block) click to toggle source

@deprecated

# File lib/orocos/roby/component.rb, line 449
def use_conf(*spec, &block)
    with_conf(*spec, &block)
end
with_arguments(*spec, &block) click to toggle source

This returns an InstanciatedComponent object that can be used in other #use statements in the deployment spec

For instance,

add(Cmp::CorridorServoing).
    use(Cmp::Odometry.with_arguments('special_behaviour' => true))
# File lib/orocos/roby/component.rb, line 444
def with_arguments(*spec, &block)
    Engine.create_instanciated_component(nil, nil, self).with_arguments(*spec, &block)
end
with_conf(*spec, &block) click to toggle source

This returns an InstanciatedComponent object that can be used in other #use statements in the deployment spec

For instance,

add(Cmp::CorridorServoing).
    use(Cmp::Odometry.use_conf('special_conf'))
# File lib/orocos/roby/component.rb, line 461
def with_conf(*spec, &block)
    Engine.create_instanciated_component(nil, nil, self).with_conf(*spec, &block)
end