Module: Orocos::OutputPortBase

Included in:
OutputPort, ROS::OutputTopic
Defined in:
lib/orocos/ports_base.rb

Overview

Generic functionality for all output objects

For #reader to work, the mixed-in class must provide a reader_class singleton method, and must be able to connect to an input port

It also implements the fallback calls for the connection / disconnection protocol. Any 'output port' class must call this generic implementation when it does not know how to connect to / disconnect from the argument it has been given. The 'input port' classes that can handle specialized connection schemes must then implement #resolve_connection_from and #resolve_disconnection_from to implement them. These methods are called by the default implementation of #connect_to and #disconnect_from.

Instance Method Summary collapse

Instance Method Details

#connect_to(sink, policy = Hash.new) ⇒ Object

Generic implementation of #connect_to

It calls #resolve_connection_from, as a fallback for out.connect_to(in) calls where 'out' does not know how to handle 'in'


231
232
233
# File 'lib/orocos/ports_base.rb', line 231

def connect_to(sink, policy = Hash.new)
    sink.resolve_connection_from(self, policy)
end

#disconnect_from(sink) ⇒ Object

Generic implementation of #disconnect_from

It calls #resolve_connection_from, as a fallback for out.connect_to(in) calls where 'out' does not know how to handle 'in'


239
240
241
# File 'lib/orocos/ports_base.rb', line 239

def disconnect_from(sink)
    sink.resolve_disconnection_from(self)
end

#reader(policy = Hash.new) ⇒ Object

Returns an OutputReader object that is connected to that port

The policy dictates how data should flow between the port and the reader object. See #prepare_policy


214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/orocos/ports_base.rb', line 214

def reader(policy = Hash.new)
    ensure_type_available
    reader = Orocos.ruby_task.create_input_port(
        self.class.transient_local_port_name(full_name),
        orocos_type_name,
        :permanent => false,
        :class => self.class.reader_class)
    reader.port = self
    reader.policy = policy
    connect_to(reader, policy)
    reader
end