class Syskit::Property

Syskit-side representation of a property

Writing on such an object does not write on the task. The write is performed either at configuration time, or when commit_properties is called

Attributes

log_metadata[R]

The metadata for the log stream

log_stream[RW]

The stream on which this property is logged @return [nil,#write]

name[R]

This property's name

@return [String]

remote_value[R]

The value of this property on the component side

@return [Typelib::Type]

type[R]

This property's type

@return [String]

value[R]

The value that would be applied on this property next time Syskit::TaskContext#commit_properties is called

@return [Typelib::Type]

Public Class Methods

new(name, type) click to toggle source
# File lib/syskit/property.rb, line 41
def initialize(name, type)
    @name  = name
    @type  = type
    @remote_value = nil
    @value = nil
    @log_stream = nil
    @log_metadata = Hash.new
end

Public Instance Methods

clear_value() click to toggle source

Remove the current value

This will in effect ensure that the property won't get written

# File lib/syskit/property.rb, line 108
def clear_value
    @value = nil
end
has_value?() click to toggle source

Whether a value has been set with {#write}

# File lib/syskit/property.rb, line 51
def has_value?
    !!@value
end
logged?() click to toggle source

Whether this property is being logged

# File lib/syskit/property.rb, line 37
def logged?
    !!log_stream
end
raw_read() click to toggle source

Read the current Syskit-side value of this property as a Typelib object

This is not necessarily the value on the component side

# File lib/syskit/property.rb, line 79
def raw_read
    @value
end
raw_write(value, _timestap = nil) click to toggle source

Update this property with a Typelib object

The object's type and value will not be checked

# File lib/syskit/property.rb, line 98
def raw_write(value, _timestap = nil)
    if value.class != type
        raise ArgumentError, "expected a typelib value of type #{type}, but got #{value.class}"
    end
    @value = value
end
read() click to toggle source

Read the current Syskit-side value of this property

This is not necessarily the value on the component side

# File lib/syskit/property.rb, line 71
def read
    Typelib.to_ruby(@value)
end
update_log(timestamp = Time.now, value = self.remote_value) click to toggle source

Update the log stream with the currently none remote value

# File lib/syskit/property.rb, line 113
def update_log(timestamp = Time.now, value = self.remote_value)
    if logged?
        log_stream.write(timestamp, timestamp, value)
    end
end
update_log_metadata(metadata) click to toggle source

Add metadata to {#log_metadata}

# File lib/syskit/property.rb, line 56
def update_log_metadata(metadata)
    log_metadata.merge!(metadata)
end
update_remote_value(value) click to toggle source

Update the known value for the property on the node side

@param [Object] value a valid value for the property. It will be

converted to the propertie's own type
# File lib/syskit/property.rb, line 64
def update_remote_value(value)
    @remote_value = Typelib.from_ruby(value, type).dup
end
write(value, _timestamp = nil) click to toggle source

Request updating this property with the given value

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

@param [Typelib::Type,Object] value the property value @param [Time] _timestamp ignored, for compatibility with

{Orocos::Property}
# File lib/syskit/property.rb, line 91
def write(value, _timestamp = nil)
    raw_write(Typelib.from_ruby(value, type))
end