class Orocos::Async::PortProxy
Public Class Methods
new(task_proxy,port_name,options=Hash.new)
click to toggle source
Calls superclass method
Orocos::Async::ObjectBase.new
# File lib/orocos/async/task_context_proxy.rb, line 162 def initialize(task_proxy,port_name,options=Hash.new) super(port_name,task_proxy.event_loop) @task_proxy = task_proxy @type = options.delete(:type) @options = options @raw_last_sample = nil end
Public Instance Methods
full_name()
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 178 def full_name "#{@task_proxy.name}.#{name}" end
input?()
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 208 def input? if !valid_delegator? true elsif @delegator_obj.respond_to?(:writer) true else false end end
last_sample()
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 278 def last_sample if @raw_last_sample Typelib.to_ruby(@raw_last_sample) end end
new_sample()
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 192 def new_sample type.new end
on_data(policy = Hash.new) { |to_ruby(sample,type)| ... }
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 307 def on_data(policy = Hash.new,&block) on_raw_data policy do |sample| yield Typelib::to_ruby(sample,type) end end
on_raw_data(policy = Hash.new,&block)
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 313 def on_raw_data(policy = Hash.new,&block) raise RuntimeError , "Port #{name} is not an output port" if !output? @options = if policy.empty? @options elsif @options.empty? && !valid_delegator? policy elsif @options == policy @options else Orocos.warn "Changing global reader policy for #{full_name} from #{@options} to #{policy}" @delegator_obj.options = policy policy end on_event :raw_data,&block end
output?()
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 218 def output? if !valid_delegator? true elsif @delegator_obj.respond_to?(:reader) true else false end end
period()
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 264 def period if @options.has_key? :period @options[:period] else nil end end
period=(period)
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 272 def period=(period) raise RuntimeError, "Port #{name} is not an output port" if !output? @options[:period] = period @delegator_obj.period = period if valid_delegator? end
raw_last_sample()
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 284 def raw_last_sample @raw_last_sample end
reachable!(port,options = Hash.new)
click to toggle source
Calls superclass method
Orocos::Async::ObjectBase#reachable!
# File lib/orocos/async/task_context_proxy.rb, line 232 def reachable!(port,options = Hash.new) raise ArgumentError, "port must not be kind of PortProxy" if port.is_a? PortProxy if @type && @type != port.type && @type.name != port.orocos_type_name raise RuntimeError, "the given type #{@type} for port #{port.full_name} differes from the real type name #{port.type}" end remove_proxy_event(@delegator_obj,@delegator_obj.event_names) if valid_delegator? super(port,options) proxy_event(@delegator_obj,@delegator_obj.event_names-[:reachable]) @type = port.type #check which port we have if port.respond_to?(:reader) @raw_last_sample = port.raw_last_sample elsif number_of_listeners(:data) != 0 raise RuntimeError, "Port #{name} is an input port but callbacks for on_data are registered" end rescue Orocos::NotFound unreachable! end
reachable?()
click to toggle source
Calls superclass method
Orocos::Async::ObjectBase#reachable?
# File lib/orocos/async/task_context_proxy.rb, line 228 def reachable? super && @delegator_obj.reachable? end
really_add_listener(listener)
click to toggle source
Calls superclass method
Orocos::Async::ObjectBase#really_add_listener
# File lib/orocos/async/task_context_proxy.rb, line 288 def really_add_listener(listener) return super unless listener.use_last_value? if listener.event == :data if sample = last_sample event_loop.once do listener.call sample end end elsif listener.event == :raw_data if sample = raw_last_sample event_loop.once do listener.call sample end end end super end
sub_port(subfield)
click to toggle source
returns a sub port for the given subfield
# File lib/orocos/async/task_context_proxy.rb, line 259 def sub_port(subfield) raise RuntimeError , "Port #{name} is not an output port" if !output? SubPortProxy.new(self,subfield) end
task()
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 204 def task @task_proxy end
to_async(options=Hash.new)
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 196 def to_async(options=Hash.new) task.to_async(options).port(self.name) end
to_proxy(options=Hash.new)
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 200 def to_proxy(options=Hash.new) self end
to_s()
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 170 def to_s "#<Orocos::Async::PortProxy #{full_name}[#{type.name}]>" end
type()
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 182 def type raise Orocos::NotFound, "#{self} is not reachable" unless @type @type end
type?()
click to toggle source
returns true if the proxy stored the type
# File lib/orocos/async/task_context_proxy.rb, line 188 def type? !!@type end
type_name()
click to toggle source
# File lib/orocos/async/task_context_proxy.rb, line 174 def type_name type.name end
unreachable!(options = Hash.new)
click to toggle source
Calls superclass method
Orocos::Async::ObjectBase#unreachable!
# File lib/orocos/async/task_context_proxy.rb, line 253 def unreachable!(options = Hash.new) remove_proxy_event(@delegator_obj,@delegator_obj.event_names) if valid_delegator? super(options) end