Class: Syskit::LiveProperty

Inherits:
Property show all
Defined in:
lib/syskit/live_property.rb

Overview

Syskit-side representation of the property of an actual live task

Instance Attribute Summary collapse

Attributes inherited from Property

#log_metadata, #log_stream, #name, #remote_value, #type, #value

Instance Method Summary collapse

Methods inherited from Property

#clear_value, #has_value?, #raw_read, #read, #update_log, #update_log_metadata, #update_remote_value

Constructor Details

#initialize(task_context, name, type) ⇒ LiveProperty

Returns a new instance of LiveProperty



18
19
20
21
22
# File 'lib/syskit/live_property.rb', line 18

def initialize(task_context, name, type)
    super(name, type)
    @task_context = task_context
    @remote_property = nil
end

Instance Attribute Details

#remote_propertyObject

The remote property

It is used as a cache mechanism, and should never be used directly. It is initialized and accessed by the API on TaskContext



11
12
13
# File 'lib/syskit/live_property.rb', line 11

def remote_property
  @remote_property
end

#task_contextObject (readonly)

The underlying task context



5
6
7
# File 'lib/syskit/live_property.rb', line 5

def task_context
  @task_context
end

Instance Method Details

#logged?Boolean

Whether this property is being logged

Returns:

  • (Boolean)


14
15
16
# File 'lib/syskit/live_property.rb', line 14

def logged?
    !!log_stream
end

#needs_commit?Boolean

Whether this property needs to be written on the remote side

Returns:

  • (Boolean)


25
26
27
# File 'lib/syskit/live_property.rb', line 25

def needs_commit?
    @value && (!@remote_value || (@value != @remote_value))
end

#raw_write(value, _timestap = nil) ⇒ Object

Update this property with a Typelib object

The object's type and value will not be checked



46
47
48
49
# File 'lib/syskit/live_property.rb', line 46

def raw_write(value, _timestap = nil)
    super
    task_context.queue_property_update_if_needed
end

#write(value, _timestamp = nil) ⇒ Object

Request updating this property with the given value

The property will be updated only at the task's configuration time, or when TaskContext#commit_properties is called.

Parameters:

  • value (Typelib::Type, Object)

    the property value

  • _timestamp (Time) (defaults to: nil)

    ignored, for compatibility with Orocos::Property



37
38
39
40
41
# File 'lib/syskit/live_property.rb', line 37

def write(value, _timestamp = nil)
    if task_context.would_use_property_update?
        super
    end
end