Class: Syskit::Property
Overview
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
Direct Known Subclasses
Instance Attribute Summary collapse
-
#log_metadata ⇒ Object
readonly
The metadata for the log stream.
-
#log_stream ⇒ nil, #write
The stream on which this property is logged.
-
#name ⇒ String
readonly
This property's name.
-
#remote_value ⇒ Typelib::Type
readonly
The value of this property on the component side.
-
#type ⇒ String
readonly
This property's type.
-
#value ⇒ Typelib::Type
readonly
The value that would be applied on this property next time TaskContext#commit_properties is called.
Instance Method Summary collapse
-
#clear_value ⇒ Object
Remove the current value.
-
#has_value? ⇒ Boolean
Whether a value has been set with #write.
-
#initialize(name, type) ⇒ Property
constructor
A new instance of Property.
-
#logged? ⇒ Boolean
Whether this property is being logged.
-
#raw_read ⇒ Object
Read the current Syskit-side value of this property as a Typelib object.
-
#raw_write(value, _timestap = nil) ⇒ Object
Update this property with a Typelib object.
-
#read ⇒ Object
Read the current Syskit-side value of this property.
-
#update_log(timestamp = Time.now, value = self.remote_value) ⇒ Object
Update the log stream with the currently none remote value.
-
#update_log_metadata(metadata) ⇒ Object
Add metadata to #log_metadata.
-
#update_remote_value(value) ⇒ Object
Update the known value for the property on the node side.
-
#write(value, _timestamp = nil) ⇒ Object
Request updating this property with the given value.
Constructor Details
#initialize(name, type) ⇒ Property
Returns a new instance of Property
41 42 43 44 45 46 47 48 |
# 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 |
Instance Attribute Details
#log_metadata ⇒ Object (readonly)
The metadata for the log stream
30 31 32 |
# File 'lib/syskit/property.rb', line 30 def @log_metadata end |
#log_stream ⇒ nil, #write
The stream on which this property is logged
34 35 36 |
# File 'lib/syskit/property.rb', line 34 def log_stream @log_stream end |
#name ⇒ String (readonly)
This property's name
11 12 13 |
# File 'lib/syskit/property.rb', line 11 def name @name end |
#remote_value ⇒ Typelib::Type (readonly)
The value of this property on the component side
21 22 23 |
# File 'lib/syskit/property.rb', line 21 def remote_value @remote_value end |
#type ⇒ String (readonly)
This property's type
16 17 18 |
# File 'lib/syskit/property.rb', line 16 def type @type end |
#value ⇒ Typelib::Type (readonly)
The value that would be applied on this property next time TaskContext#commit_properties is called
27 28 29 |
# File 'lib/syskit/property.rb', line 27 def value @value end |
Instance Method Details
#clear_value ⇒ Object
Remove the current value
This will in effect ensure that the property won't get written
108 109 110 |
# File 'lib/syskit/property.rb', line 108 def clear_value @value = nil end |
#has_value? ⇒ Boolean
Whether a value has been set with #write
51 52 53 |
# File 'lib/syskit/property.rb', line 51 def has_value? !!@value end |
#logged? ⇒ Boolean
Whether this property is being logged
37 38 39 |
# File 'lib/syskit/property.rb', line 37 def logged? !!log_stream end |
#raw_read ⇒ Object
Read the current Syskit-side value of this property as a Typelib object
This is not necessarily the value on the component side
79 80 81 |
# File 'lib/syskit/property.rb', line 79 def raw_read @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
98 99 100 101 102 103 |
# 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 ⇒ Object
Read the current Syskit-side value of this property
This is not necessarily the value on the component side
71 72 73 |
# File 'lib/syskit/property.rb', line 71 def read Typelib.to_ruby(@value) end |
#update_log(timestamp = Time.now, value = self.remote_value) ⇒ Object
Update the log stream with the currently none remote value
113 114 115 116 117 |
# File 'lib/syskit/property.rb', line 113 def update_log( = Time.now, value = self.remote_value) if logged? log_stream.write(, , value) end end |
#update_log_metadata(metadata) ⇒ Object
Add metadata to #log_metadata
56 57 58 |
# File 'lib/syskit/property.rb', line 56 def () .merge!() end |
#update_remote_value(value) ⇒ Object
Update the known value for the property on the node side
64 65 66 |
# 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) ⇒ 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.
91 92 93 |
# File 'lib/syskit/property.rb', line 91 def write(value, = nil) raw_write(Typelib.from_ruby(value, type)) end |