class Syskit::ConnectionGraph

Represents the actual connection graph between task context proxies. Its vertices are instances of Orocos::TaskContext, and edges are mappings from [source_port_name, sink_port_name] pairs to the connection policy between these ports.

Syskit::ActualDataFlow is the actual global graph instance in which the overall system connections are maintained in practice. Its vertices are Orocos::TaskContext and the edge information a mapping of the form

(source_port_name, sink_port_name) => policy

Syskit::RequiredDataFlow is the graph instance that manages concrete connections between Syskit::TaskContext (i.e. where all the forwarding through compositions has been removed). It is updated as needed by {Runtime::ConnectionManagement#update_required_dataflow_graph}. Its vertices are Syskit::TaskContext instances and the edge information a mapping of the form

(source_port_name, sink_port_name) => policy

Syskit::Flows::DataFlow is the flow graph that is generated by the engine. Its vertices are Syskit::Component, it contains “virtual” connections (connections between composition ports and task ports). The edge information is of the form

(source_port_name, sink_port_name) => policy

Since compositions are still in this graph, source_port_name and sink_port_name can be either outputs or inputs. In all the other graphs, they are guaranteed to be output ports resp. input ports.

Attributes

name[RW]

Needed for Roby's marshalling (so that we can dump the connection graph as a constant)

Public Instance Methods

add_edge(source_task, sink_task, mappings) click to toggle source
Calls superclass method
# File lib/syskit/connection_graph.rb, line 71
def add_edge(source_task, sink_task, mappings)
    if mappings.empty?
        raise ArgumentError, "the connection set is empty"
    end
    super
end
connected?(source_task, source_port, sink_task, sink_port) click to toggle source

Tests if there is a connection between source_task:source_port and sink_task:sink_port

# File lib/syskit/connection_graph.rb, line 60
def connected?(source_task, source_port, sink_task, sink_port)
    if !has_edge?(source_task, sink_task)
        return false
    end
    edge_info(source_task, sink_task).has_key?([source_port, sink_port])
end
each_in_connection(task, port = nil) { |source_task, source_port, sink_port, policy| ... } click to toggle source

Yield or enumerates incoming connections

@param [Component] component the component whose connections we want

to enumerate

@param [#name,String,nil] port if non-nil, the port for

which we want to enumerate the connections (in which case
the sink_port yield parameter is guaranteed to be this name).
Otherwise, all ports are enumerated.

@yield each connections @yieldparam [Syskit::TaskContext] source_task the source task in

the connection

@yieldparam [String] source_port the source port name on source_task @yieldparam [String] sink_port the sink port name on self. If

the port argument is non-nil, it is guaranteed to be the
same.

@yieldparam [Hash] policy the connection policy

@see each_concrete_input_connection each_concrete_output_connection

each_output_connection
# File lib/syskit/connection_graph.rb, line 127
def each_in_connection(task, port = nil)
    return enum_for(__method__, task, port) if !block_given?
    if port.respond_to? :name
        port = port.name
    end

    each_in_neighbour(task) do |source_task|
        edge_info(source_task, task).each do |(source_port, sink_port), policy|
            if !port || (sink_port == port)
                yield(source_task, source_port, sink_port, policy)
            end
        end
    end
end
each_out_connection(task, port = nil) { |source_port, sink_port, sink_task, policy| ... } click to toggle source

Yield or enumerates the connections that exist from the output ports of self.

@param [Component] source_task the task whose connections are being

enumerated

@param [#name,String,nil] port if non-nil, the port for

which we want to enumerate the connections (in which case
the source_port yield parameter is guaranteed to be this name).
Otherwise, all ports are enumerated.

@yield each connections @yieldparam [String] source_port the source port name on self. If

the port argument is non-nil, it is guaranteed to be the
same.

@yieldparam [String] sink_port the sink port name on sink_task. @yieldparam [Syskit::Component] sink_task the sink task in

the connection

@yieldparam [Hash] policy the connection policy

# File lib/syskit/connection_graph.rb, line 161
def each_out_connection(task, port = nil)
    return enum_for(__method__, task, port) if !block_given?
    if port.respond_to? :name
        port = port.name
    end

    each_out_neighbour(task) do |sink_task|
        edge_info(task, sink_task).each do |(source_port, sink_port), policy|
            if !port || (port == source_port)
                yield(source_port, sink_port, sink_task, policy)
            end
        end
    end
    self
end
has_in_connections?(task, port) click to toggle source

Tests if port, which has to be an input port, is connected

# File lib/syskit/connection_graph.rb, line 49
def has_in_connections?(task, port)
    each_in_neighbour(task) do |parent_task|
        if edge_info(parent_task, task).each_key.any? { |_, target_port| target_port == port }
            return true
        end
    end
    false
end
has_out_connections?(task, port) click to toggle source

Tests if port, which has to be an output port, is connected

# File lib/syskit/connection_graph.rb, line 39
def has_out_connections?(task, port)
    each_out_neighbour(task) do |child_task|
        if edge_info(task, child_task).each_key.any? { |source_port, _| source_port == port }
            return true
        end
    end
    false
end
merge_info(source, sink, current_mappings, additional_mappings) click to toggle source
# File lib/syskit/connection_graph.rb, line 78
def merge_info(source, sink, current_mappings, additional_mappings)
    current_mappings.merge(additional_mappings) do |k, v1, v2|
        if v1 != v2
            raise ArgumentError, "cannot override policy information by default: trying to override the policy between #{source} and #{sink} from #{k}: #{v1} to #{k}: #{v2}"
        end
        v1
    end
end