class Orocos::Async::Log::OutputPort
Attributes
task[R]
Public Class Methods
new(async_task,port,options=Hash.new)
click to toggle source
Calls superclass method
Orocos::Async::ObjectBase.new
# File lib/orocos/async/log/ports.rb, line 66 def initialize(async_task,port,options=Hash.new) @options ||= options @readers ||= Array.new @task = async_task super(port.name,async_task.event_loop) # do not queue reachable event no listeners are registered so far disable_emitting do reachable! port end @on_raw_data = port.on_raw_data do |sample, _| emit_raw_data sample end @on_raw_data.disable @on_data = port.on_data do |sample, _| emit_data sample end @on_data.disable end
Public Instance Methods
last_sample()
click to toggle source
# File lib/orocos/async/log/ports.rb, line 99 def last_sample @delegator_obj.read end
on_data(policy = Hash.new,&block)
click to toggle source
# File lib/orocos/async/log/ports.rb, line 152 def on_data(policy = Hash.new,&block) @options = if policy.empty? @options elsif @options.empty? && !@global_reader policy elsif @options == policy @options else Orocos.warn "Log::OutputPort #{full_name} cannot emit :data with different policies." Orocos.warn "The current policy is: #{@options}." Orocos.warn "Ignoring policy: #{policy}." @options end on_event :data,&block end
period()
click to toggle source
# File lib/orocos/async/log/ports.rb, line 140 def period if @options.has_key?(:period) @options[:period] else OutputReader.default_period end end
period=(value)
click to toggle source
# File lib/orocos/async/log/ports.rb, line 148 def period=(value) @options[:period] = value end
raw_last_sample()
click to toggle source
# File lib/orocos/async/log/ports.rb, line 103 def raw_last_sample @delegator_obj.raw_read end
reader(options = Hash.new,&block)
click to toggle source
# File lib/orocos/async/log/ports.rb, line 130 def reader(options = Hash.new,&block) if block orig_reader(policy) do |reader| block.call OutputReader.new(self,reader,options) end else OutputReader.new(self,orig_reader(policy),options) end end
really_add_listener(listener)
click to toggle source
Calls superclass method
Orocos::Async::ObjectBase#really_add_listener
# File lib/orocos/async/log/ports.rb, line 107 def really_add_listener(listener) return super unless listener.use_last_value? if listener.event == :data sample = last_sample if sample event_loop.once do listener.call sample end end @on_data.enable elsif listener.event == :raw_data sample = raw_last_sample if sample event_loop.once do listener.call sample end end @on_raw_data.enable end super end
to_async(options=Hash.new)
click to toggle source
# File lib/orocos/async/log/ports.rb, line 91 def to_async(options=Hash.new) self end
to_proxy(options=Hash.new)
click to toggle source
# File lib/orocos/async/log/ports.rb, line 95 def to_proxy(options=Hash.new) task.to_proxy(options).port(name).wait end
type?()
click to toggle source
# File lib/orocos/async/log/ports.rb, line 87 def type? true end