Class: Orocos::OutputReader

Inherits:
RubyTasks::LocalInputPort show all
Defined in:
lib/orocos/output_reader.rb

Overview

Local input port that is specifically designed to read to another task's output port

Constant Summary

Constants inherited from Port

Port::CONNECTION_POLICY_OPTIONS, Port::DEFAULT_CONNECTION_POLICY, Port::MQ_RTT_DEFAULT_QUEUE_LENGTH

Constants included from PortBase

PortBase::D_DIFFERENT_HOSTS, PortBase::D_SAME_HOST, PortBase::D_SAME_PROCESS, PortBase::D_UNKNOWN

Instance Attribute Summary collapse

Attributes included from PortBase

#model, #name, #orocos_type_name, #task, #type

Instance Method Summary collapse

Methods inherited from RubyTasks::LocalInputPort

#clear, #connected?, #do_clear, #do_read, #raw_read, #raw_read_new, #raw_read_with_result, #read_new_raw, #read_raw, #read_with_result, #remove

Methods inherited from InputPort

#initialize, #pretty_print, #subscribe_to_ros, #to_async, #to_proxy, #unsubscribe_from_ros, writer_class

Methods included from InputPortBase

#connect_to, #resolve_connection_from, #resolve_disconnection_from, #write, #writer

Methods inherited from Port

#connected?, #create_stream, #default_ros_topic_name, #disconnect_all, #do_create_stream, #do_disconnect_all, #do_disconnect_from, #do_remove_stream, #doc, #doc?, #handle_mq_transport, prepare_policy, #pretty_print, #refine_exceptions, #remove_stream, #to_orocos_port, transient_local_port_name, transport_name, #type_name, validate_policy

Methods included from PortBase

#==, #distance_to, #ensure_type_available, #full_name, #initialize, #log_metadata, #max_marshalling_size, #max_sizes, #new_sample, #to_s

Constructor Details

This class inherits a constructor from Orocos::InputPort

Instance Attribute Details

#policyObject

The policy of the connection



8
9
10
# File 'lib/orocos/output_reader.rb', line 8

def policy
  @policy
end

#portObject

The port this object is reading from



5
6
7
# File 'lib/orocos/output_reader.rb', line 5

def port
  @port
end

Instance Method Details

#disconnectObject

Disconnects this port from the port it is reading



61
62
63
# File 'lib/orocos/output_reader.rb', line 61

def disconnect
    disconnect_all
end

#read(sample = nil) ⇒ Object

Reads a sample on the associated output port. Returns a value as soon as a sample has ever been written to the port since the data reader has been created

This is only possible if the remote deployment has been started by this Ruby instance

Raises:



31
32
33
34
35
36
37
38
39
40
# File 'lib/orocos/output_reader.rb', line 31

def read(sample = nil)
    if !policy[:pull]
        Orocos.allow_blocking_calls do
            # Non-pull readers are non-blocking
            super
        end
    else
        super
    end
end

#read_helper(sample, copy_old_data) ⇒ Object

Helper method for #read and #read_new

This is overloaded in OutputReader to raise CORBA::ComError if the process supporting the remote task is known to be dead



14
15
16
17
18
19
20
21
22
# File 'lib/orocos/output_reader.rb', line 14

def read_helper(sample, copy_old_data)
	    if process = port.task.process
		if !process.alive?
		    disconnect_all
		    raise CORBA::ComError, "remote end is dead"
		end
	    end
    super
end

#read_new(sample = nil) ⇒ Object

Reads a sample on the associated output port, and returns nil if no new data is available

This is only possible if the remote deployment has been started by this Ruby instance

Raises:

See Also:



49
50
51
52
53
54
55
56
57
58
# File 'lib/orocos/output_reader.rb', line 49

def read_new(sample = nil)
    if !policy[:pull]
        Orocos.allow_blocking_calls do
            # Non-pull readers are non-blocking
            super
        end
    else
        super
    end
end