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
The metadata for the log stream
The stream on which this property is logged @return [nil,#write]
This property's name
@return [String]
The value of this property on the component side
@return [Typelib::Type]
This property's type
@return [String]
The value that would be applied on this property next time Syskit::TaskContext#commit_properties is called
@return [Typelib::Type]
Public Class Methods
# 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
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
Whether a value has been set with {#write}
# File lib/syskit/property.rb, line 51 def has_value? !!@value end
Whether this property is being logged
# File lib/syskit/property.rb, line 37 def logged? !!log_stream end
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
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 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 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
Add metadata to {#log_metadata}
# File lib/syskit/property.rb, line 56 def update_log_metadata(metadata) log_metadata.merge!(metadata) end
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
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