Class: Orocos::Log::Property
- Inherits:
-
InterfaceObject
- Object
- InterfaceObject
- Orocos::Log::Property
- Defined in:
- lib/orocos/log/task_context.rb
Overview
Simulated Property based on a configuration log file It is automatically replayed if at least one OutputPort of the task is replayed
Instance Attribute Summary collapse
-
#task ⇒ Object
readonly
The underlying TaskContext instance.
-
#tracked ⇒ Object
true –> this property shall be replayed.
Attributes inherited from InterfaceObject
#name, #stream, #type, #type_name
Instance Method Summary collapse
-
#aligned? ⇒ Boolean
returns true if Log::Replay is aligned.
- #doc? ⇒ Boolean
-
#full_name ⇒ Object
Give the full name for this property.
-
#initialize(task, stream) ⇒ Property
constructor
A new instance of Property.
-
#metadata ⇒ Object
returns the metadata associated with the underlying stream.
- #new_sample ⇒ Object
-
#notify(&block) ⇒ Object
registers a code block which will be called when the property changes.
-
#number_of_samples ⇒ Object
Returns the number of samples for the property.
-
#on_change(&block) ⇒ Object
registers a code block which will be called when the property changes.
- #orocos_type_name ⇒ Object
-
#pretty_print(pp) ⇒ Object
:nodoc:.
- #raw_read ⇒ Object
-
#read ⇒ Object
Read the current value of the property/attribute.
- #update(sample_info) ⇒ Object
- #used? ⇒ Boolean
Methods inherited from InterfaceObject
#guess_object_name, #guess_orocos_type_name
Constructor Details
#initialize(task, stream) ⇒ Property
Returns a new instance of Property
540 541 542 543 544 545 546 |
# File 'lib/orocos/log/task_context.rb', line 540 def initialize(task, stream) super(stream) @task = task @current_data = nil @notify_blocks =[] end |
Instance Attribute Details
#task ⇒ Object (readonly)
The underlying TaskContext instance
538 539 540 |
# File 'lib/orocos/log/task_context.rb', line 538 def task @task end |
#tracked ⇒ Object
true –> this property shall be replayed
536 537 538 |
# File 'lib/orocos/log/task_context.rb', line 536 def tracked @tracked end |
Instance Method Details
#aligned? ⇒ Boolean
returns true if Log::Replay is aligned
555 556 557 |
# File 'lib/orocos/log/task_context.rb', line 555 def aligned? task.log_replay.aligned? end |
#doc? ⇒ Boolean
559 560 561 |
# File 'lib/orocos/log/task_context.rb', line 559 def doc? false end |
#full_name ⇒ Object
Give the full name for this property. It is the stream name.
616 617 618 |
# File 'lib/orocos/log/task_context.rb', line 616 def full_name stream.name end |
#metadata ⇒ Object
returns the metadata associated with the underlying stream
625 626 627 |
# File 'lib/orocos/log/task_context.rb', line 625 def stream. end |
#new_sample ⇒ Object
598 599 600 |
# File 'lib/orocos/log/task_context.rb', line 598 def new_sample type.new end |
#notify(&block) ⇒ Object
registers a code block which will be called when the property changes
594 595 596 |
# File 'lib/orocos/log/task_context.rb', line 594 def notify(&block) @notify_blocks << block end |
#number_of_samples ⇒ Object
Returns the number of samples for the property.
611 612 613 |
# File 'lib/orocos/log/task_context.rb', line 611 def number_of_samples return @stream.size end |
#on_change(&block) ⇒ Object
registers a code block which will be called when the property changes
585 586 587 588 589 590 |
# File 'lib/orocos/log/task_context.rb', line 585 def on_change(&block) self.tracked = true notify do block.call(read) end end |
#orocos_type_name ⇒ Object
602 603 604 605 606 607 608 |
# File 'lib/orocos/log/task_context.rb', line 602 def orocos_type_name if && .has_key?(:rock_orocos_type_name) [:rock_orocos_type_name] else type_name end end |
#pretty_print(pp) ⇒ Object
:nodoc:
620 621 622 |
# File 'lib/orocos/log/task_context.rb', line 620 def pretty_print(pp) # :nodoc: pp.text "property #{name} (#{type.name})" end |
#raw_read ⇒ Object
575 576 577 578 579 580 581 |
# File 'lib/orocos/log/task_context.rb', line 575 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 ⇒ Object
Read the current value of the property/attribute
569 570 571 572 573 |
# File 'lib/orocos/log/task_context.rb', line 569 def read if sample = raw_read Typelib.to_ruby(sample) end end |
#update(sample_info) ⇒ Object
563 564 565 566 |
# File 'lib/orocos/log/task_context.rb', line 563 def update(sample_info) @current_data = nil @sample_info = sample_info end |
#used? ⇒ Boolean
629 630 631 |
# File 'lib/orocos/log/task_context.rb', line 629 def used? tracked end |