module Syskit::Models::PortAccess

Mixin used to define common methods to enumerate ports on objects that have an attribute orogen_model of type Orocos::Spec::TaskContext

Public Instance Methods

each_input_port() { |ports ||= input_port| ... } click to toggle source

Enumerates this component's input ports

# File lib/syskit/models/port_access.rb, line 67
def each_input_port
    return enum_for(:each_input_port) if !block_given?
    orogen_model.each_input_port do |p|
        yield(ports[p.name] ||= InputPort.new(self, p))
    end
end
each_output_port() { |ports ||= output_port| ... } click to toggle source

Enumerates this component's output ports

# File lib/syskit/models/port_access.rb, line 59
def each_output_port
    return enum_for(:each_output_port) if !block_given?
    orogen_model.each_output_port do |p|
        yield(ports[p.name] ||= OutputPort.new(self, p))
    end
end
each_port(&block) click to toggle source

Enumerates all of this component's ports

# File lib/syskit/models/port_access.rb, line 52
def each_port(&block)
    return enum_for(:each_port) if !block_given?
    each_output_port(&block)
    each_input_port(&block)
end
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/syskit/models/port_access.rb, line 44
def find_input_port(name)
    name = name.to_str
    if port_model = orogen_model.find_input_port(name)
        ports[name] ||= InputPort.new(self, port_model)
    end
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/syskit/models/port_access.rb, line 35
def find_output_port(name)
    name = name.to_str
    if port_model = orogen_model.find_output_port(name)
        ports[name] ||= OutputPort.new(self, port_model)
    end
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/syskit/models/port_access.rb, line 21
def find_port(name)
    name = name.to_str
    find_output_port(name) || find_input_port(name)
end
find_through_method_missing(m, args) click to toggle source
Calls superclass method
# File lib/syskit/models/port_access.rb, line 14
def find_through_method_missing(m, args)
    MetaRuby::DSLs.find_through_method_missing(
        self, m, args, '_port' => :find_port) || super
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/syskit/models/port_access.rb, line 128
def has_dynamic_input_port?(name, type = nil)
    if type
        type = Roby.app.default_loader.opaque_type_for(type)
    end
    orogen_model.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/syskit/models/port_access.rb, line 110
def has_dynamic_output_port?(name, type = nil)
    if type
        type = Roby.app.default_loader.opaque_type_for(type)
    end
    orogen_model.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/syskit/models/port_access.rb, line 92
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/syskit/models/port_access.rb, line 82
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/syskit/models/port_access.rb, line 74
def has_port?(name)
    name = name.to_str
    has_input_port?(name) || has_output_port?(name)
end
has_through_method_missing?(m) click to toggle source
Calls superclass method
# File lib/syskit/models/port_access.rb, line 10
def has_through_method_missing?(m)
    MetaRuby::DSLs.has_through_method_missing?(
        self, m, '_port' => :has_port?) || super
end
port_by_name(name) click to toggle source
# File lib/syskit/models/port_access.rb, line 26
def port_by_name(name)
    if p = find_port(name)
        p
    else raise ArgumentError, "#{self} has no port called #{name}, known ports are: #{each_port.map(&:name).sort.join(", ")}"
    end
end