class Orocos::Log::Property
Simulated Property based on a configuration log file It is automatically replayed if at least one OutputPort of the task is replayed
Attributes
The property/attribute name
dedicated stream for simulating the port
The underlying TaskContext instance
true –> this property shall be replayed
The attribute type, as a subclass of Typelib::Type
Public Class Methods
# File lib/orocos/log/task_context.rb, line 513 def initialize(task, stream) if !stream.respond_to?(:name) || !stream.respond_to?(:type) || !stream.respond_to?(:typename) || !stream.respond_to?(:metadata) raise "Cannot create Property out of #{stream.class}" end @stream = stream @name = stream.name.to_s.match(/\.(.*$)/) raise 'Stream name does not follow the convention TASKNAME.PROPERTYNAME' if @name == nil @name = @name[1] @type = stream.type @task = task @current_data = nil @type_name = stream.typename @notify_blocks =[] end
Public Instance Methods
returns true if Log::Replay is aligned
# File lib/orocos/log/task_context.rb, line 535 def aligned? task.log_replay.aligned? end
# File lib/orocos/log/task_context.rb, line 539 def doc? false end
Give the full name for this property. It is the stream name.
# File lib/orocos/log/task_context.rb, line 596 def full_name stream.name end
returns the metadata associated with the underlying stream
# File lib/orocos/log/task_context.rb, line 605 def metadata stream.metadata end
# File lib/orocos/log/task_context.rb, line 578 def new_sample type.new end
registers a code block which will be called when the property changes
# File lib/orocos/log/task_context.rb, line 574 def notify(&block) @notify_blocks << block end
Returns the number of samples for the property.
# File lib/orocos/log/task_context.rb, line 591 def number_of_samples return @stream.size end
registers a code block which will be called when the property changes
# File lib/orocos/log/task_context.rb, line 565 def on_change(&block) self.tracked = true notify do block.call(read) end end
# File lib/orocos/log/task_context.rb, line 582 def orocos_type_name if metadata && metadata.has_key?(:rock_orocos_type_name) metadata[:rock_orocos_type_name] else type_name end end
# File lib/orocos/log/task_context.rb, line 555 def raw_read if @sample_info && !@current_data stream, position = *@sample_info @current_data = stream.read_one_raw_data_sample(position) end @current_data end
Read the current value of the property/attribute
# File lib/orocos/log/task_context.rb, line 549 def read if sample = raw_read Typelib.to_ruby(sample) end end
If set to true the port is replayed.
# File lib/orocos/log/task_context.rb, line 529 def tracked=(value) raise "can not track property #{stream.name} after the replay has started" if !used? && aligned? @tracked = value end
# File lib/orocos/log/task_context.rb, line 543 def update(sample_info) @current_data = nil @sample_info = sample_info end
# File lib/orocos/log/task_context.rb, line 609 def used? tracked end