Class: Orocos::Async::Log::AttributeBase
- Inherits:
-
ObjectBase
- Object
- ObjectBase
- Orocos::Async::Log::AttributeBase
- Extended by:
- ObjectBase::Periodic::ClassMethods, Utilrb::EventLoop::Forwardable
- Includes:
- ObjectBase::Periodic
- Defined in:
- lib/orocos/async/log/attributes.rb
Instance Attribute Summary collapse
-
#raw_last_sample ⇒ Object
readonly
Returns the value of attribute raw_last_sample.
Attributes included from ObjectBase::Periodic::ClassMethods
Attributes inherited from ObjectBase
#emitting, #event_loop, #name, #options, #pending_adds
Instance Method Summary collapse
-
#initialize(async_task, attribute, options = Hash.new) ⇒ AttributeBase
constructor
A new instance of AttributeBase.
- #last_sample ⇒ Object
- #really_add_listener(listener) ⇒ Object
- #type? ⇒ Boolean
Methods included from ObjectBase::Periodic
#default_period, #period, #period=
Methods inherited from ObjectBase
#add_listener, define_event, define_events, #disable_emitting, #event, event_names, #event_names, #invalidate_delegator!, #listener?, #listeners, #number_of_listeners, #on_event, #proxy_event, #reachable!, #reachable?, #remove_all_listeners, #remove_listener, #remove_proxy_event, #unreachable!, #valid_delegator?, valid_event?, #valid_event?, validate_event, #validate_event, #wait
Constructor Details
#initialize(async_task, attribute, options = Hash.new) ⇒ AttributeBase
Returns a new instance of AttributeBase
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/orocos/async/log/attributes.rb', line 12 def initialize(async_task,attribute,=Hash.new) super(attribute.name,async_task.event_loop) @task = async_task @raw_last_sample = attribute.raw_read # do not queue reachable event no listeners are registered so far disable_emitting do reachable!(attribute) end attribute.notify do @raw_last_sample = attribute.raw_read emit_raw_change @raw_last_sample emit_change Typelib.to_ruby(@raw_last_sample) end end |
Instance Attribute Details
#raw_last_sample ⇒ Object (readonly)
Returns the value of attribute raw_last_sample
10 11 12 |
# File 'lib/orocos/async/log/attributes.rb', line 10 def raw_last_sample @raw_last_sample end |
Instance Method Details
#last_sample ⇒ Object
27 28 29 30 31 |
# File 'lib/orocos/async/log/attributes.rb', line 27 def last_sample if @raw_last_sample Typelib.to_ruby(@raw_last_sample) end end |
#really_add_listener(listener) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/orocos/async/log/attributes.rb', line 33 def really_add_listener(listener) return super unless listener.use_last_value? if listener.event == :change && @raw_last_sample event_loop.once{listener.call(Typelib.to_ruby(@raw_last_sample))} elsif listener.event == :raw_change && @raw_last_sample event_loop.once{listener.call(@raw_last_sample)} end super end |
#type? ⇒ Boolean
44 45 46 |
# File 'lib/orocos/async/log/attributes.rb', line 44 def type? true end |