module Orocos::InputPortBase
Generic implementation of some methods for all input-port-like objects
For reader to work, the mixed-in class must provide a writer_class singleton method, and must be able to connect to an input port
Public Instance Methods
For convenience, automatically reverts the connection direction
# File lib/orocos/ports_base.rb, line 154 def connect_to(other, policy = Hash.new) if other.respond_to?(:writer) # This is also an input port ! raise ArgumentError, "cannot connect #{self} with #{other}, as they are both inputs" end other.connect_to(self, policy) end
This method is part of the connection protocol
Whenever an output is connected to an input, if the receiver object cannot resolve the connection, it calls resolve_connection_from on its target
@param source the source object in the connection that is being
created
@raise [ArgumentError] if the connection cannot be created
# File lib/orocos/ports_base.rb, line 198 def resolve_connection_from(source, policy = Hash.new) raise ArgumentError, "I don't know how to connect #{source} to #{self}" end
This method is part of the connection protocol
Whenever an output is disconnected from an input, if the receiver object cannot resolve the connection, it calls resolve_disconnection_from on its target
@param source the source object in the connection that is being
destroyed
@raise [ArgumentError] if the connection cannot be undone (or if it
could not exist in the first place)
# File lib/orocos/ports_base.rb, line 212 def resolve_disconnection_from(source) raise ArgumentError, "I don't know how to disconnect #{source} to #{self}" end
Writes one sample with a default policy.
While convenient, this is quite ressource consuming, as each time one will need to create a new connection between the ruby interpreter and the remote component.
Use writer if you need to write on the same port repeatedly.
# File lib/orocos/ports_base.rb, line 185 def write(sample) writer.write(sample) end
Returns a InputWriter object that allows you to write data to the remote input port.
# File lib/orocos/ports_base.rb, line 163 def writer(distance: PortBase::D_UNKNOWN, **policy) ensure_type_available writer = Orocos.ruby_task_access do Orocos.ruby_task.create_output_port( self.class.transient_local_port_name(full_name), orocos_type_name, permanent: false, class: self.class.writer_class) end writer.port = self writer.policy = policy writer.connect_to(self, distance: distance, **policy) writer end