module Orocos::PortBase
Constants
- D_DIFFERENT_HOSTS
- D_SAME_HOST
- D_SAME_PROCESS
- D_UNKNOWN
Attributes
model[R]
The port's model @return [OroGen::Spec::Port,nil] the port model
name[R]
The port name
orocos_type_name[R]
The port's type name as used by the RTT
task[R]
The task this port is part of
type[R]
The port's type as a Typelib::Type object
Public Class Methods
new(task, name, orocos_type_name, model)
click to toggle source
Calls superclass method
# File lib/orocos/ports_base.rb, line 17 def initialize(task, name, orocos_type_name, model) @task = task @name = name @orocos_type_name = orocos_type_name @model = model ensure_type_available(:fallback_to_null_type => true) if model @max_sizes = model.max_sizes.dup else @max_sizes = Hash.new end @max_sizes.merge!(Orocos.max_sizes_for(type)) super() if defined? super end
Public Instance Methods
==(other)
click to toggle source
True if self and other represent the same port
# File lib/orocos/ports_base.rb, line 59 def ==(other) return false if !other.kind_of?(PortBase) other.task == self.task && other.name == self.name end
distance_to(input_port)
click to toggle source
How “far” from the given input port this port is
@return one of the D_ constants
# File lib/orocos/ports_base.rb, line 43 def distance_to(input_port) if !task.process || !input_port.task.process return D_UNKNOWN elsif task.process == input_port.task.process return D_SAME_PROCESS elsif task.process.host_id == input_port.task.process.host_id return D_SAME_HOST else return D_DIFFERENT_HOSTS end end
ensure_type_available(options = Hash.new)
click to toggle source
# File lib/orocos/ports_base.rb, line 64 def ensure_type_available(options = Hash.new) if !type || type.null? @type = Orocos.find_type_by_orocos_type_name(orocos_type_name, options) end end
full_name()
click to toggle source
The port full name. It is task_name.port_name
# File lib/orocos/ports_base.rb, line 8 def full_name; "#{task.name}.#{name}" end
log_metadata()
click to toggle source
# File lib/orocos/ports_base.rb, line 76 def log_metadata metadata = Hash['rock_task_model' => (task.model.name || ''), 'rock_task_name' => task.name, 'rock_task_object_name' => name, 'rock_stream_type' => 'port', 'rock_orocos_type_name' => orocos_type_name] if Orocos.logger_guess_timestamp_field? # see if we can find a time field in the type, which # would qualify as being used as the default time stamp if @type.respond_to? :each_field @type.each_field do |name, type| if type.name == "/base/Time" metadata['rock_timestamp_field'] = name break end end else # TODO what about if the type is a base::Time itself end end metadata end
max_marshalling_size()
click to toggle source
Returns the maximum marshalled size of a sample from this port, as marshalled by typelib
If the type contains variable-size containers, the result is dependent on the values given to max_sizes. If not enough is known, this method will return nil.
# File lib/orocos/ports_base.rb, line 143 def max_marshalling_size OroGen::Spec::OutputPort.compute_max_marshalling_size(type, max_sizes) end
new_sample()
click to toggle source
Returns a new object of this port's type
# File lib/orocos/ports_base.rb, line 71 def new_sample ensure_type_available @type.new end
to_s()
click to toggle source
# File lib/orocos/ports_base.rb, line 54 def to_s "#{full_name}" end