Class: Syskit::ActualDataFlowGraph

Inherits:
ConnectionGraph show all
Defined in:
lib/syskit/actual_data_flow_graph.rb

Overview

The graph that represents the connections on the actual ports

I.e. this is the set of connections that really exist between our components

Instance Attribute Summary collapse

Attributes inherited from ConnectionGraph

#name

Instance Method Summary collapse

Methods inherited from ConnectionGraph

#add_edge, #connected?, #each_in_connection, #each_out_connection, #freeze_edge_info, #has_in_connections?, #has_out_connections?, #merge_info, #remove_connections

Constructor Details

#initializeActualDataFlowGraph

Returns a new instance of ActualDataFlowGraph



14
15
16
17
# File 'lib/syskit/actual_data_flow_graph.rb', line 14

def initialize(*)
    super
    @static_info = Hash.new
end

Instance Attribute Details

#static_infoHash<(Orocos::TaskContext,String),Boolean> (readonly)

Information about which ports are static and which are not. This information is critical during disconnection to force reconfiguration of the associated tasks

Returns:

  • (Hash<(Orocos::TaskContext,String),Boolean>)


12
13
14
# File 'lib/syskit/actual_data_flow_graph.rb', line 12

def static_info
  @static_info
end

Instance Method Details

#add_connections(source_task, sink_task, mappings) ⇒ Object

Registers a connection between two tasks

Each element in the connection mappings represent one connection. It is of the form

[source_port_name, sink_port_name] => [policy, source_static, sink_static]

where policy is a connection policy hash, and source_static/sink_static are booleans indicating whether the source (resp. sink) ports are static per Port#static?.

Parameters:

  • source_task (Orocos::TaskContext)

    the task of the source port

  • sink_task (Orocos::TaskContext)

    the task of the sink port

  • mappings (Hash)

    the connections themselves

Options Hash (mappings):

  • force_update (Boolean) — default: false

    whether the method should raise if the connection tries to be updated with a new incompatible policy, or whether it should be updated

Raises:

  • (Roby::ModelViolation)

    if the connection already exists with an incompatible policy



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/syskit/actual_data_flow_graph.rb', line 41

def add_connections(source_task, sink_task, mappings) # :nodoc:
    force_update = mappings.delete(:force_update)
    mappings = mappings.map_value do |(source_port, sink_port), info|
        if info.size != 3
            raise ArgumentError, "ActualDataFlowGraph#add_connections expects the mappings to be of the form (source_port,sink_port) => [policy, source_static, sink_static]"
        end
        policy, source_static, sink_static = *info
        static_info[[source_task, source_port]] = source_static
        static_info[[sink_task, sink_port]] = sink_static
        policy
    end
    if !force_update || !has_edge?(source_task, sink_task)
        super(source_task, sink_task, mappings)
    else
        set_edge_info(source_task, sink_task,
                      edge_info(source_task, sink_task).merge(mappings))
    end
end

#static?(task, port) ⇒ Boolean

Whether the given port is static (per Port#static?

Parameters:

  • task (Orocos::TaskContext)
  • port (String)

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)

    if the (task, port) pair is not registered



65
66
67
68
69
# File 'lib/syskit/actual_data_flow_graph.rb', line 65

def static?(task, port)
    static_info.fetch([task, port])
rescue KeyError
    raise ArgumentError, "no port #{port} on a task called #{task} is registered on #{self}"
end