class Orocos::AttributeBase

This class represents both RTT attributes and properties

Attributes

log_port[RW]

If set, this is an input port object in which new values set from within Ruby are sent

log_stream[RW]

If set, this is a Pocolog::DataStream object in which new values set from within Ruby are set

name[R]

The property/attribute name

orocos_type_name[R]

The type name as registered in the orocos type system

task[R]

The underlying TaskContext instance

type[R]

The attribute type, as a subclass of Typelib::Type

Public Class Methods

new(task, name, orocos_type_name) click to toggle source
# File lib/orocos/task_context.rb, line 38
def initialize(task, name, orocos_type_name)
    @task, @name = task, name
    @orocos_type_name = orocos_type_name
    @type =
        begin
            Orocos.typelib_type_for(orocos_type_name)
        rescue Typelib::NotFound
            Orocos.load_typekit_for(orocos_type_name)
            Orocos.typelib_type_for(orocos_type_name)
        end

    @type_name = type.name
end

Public Instance Methods

doc() click to toggle source
# File lib/orocos/task_context.rb, line 104
def doc
    property = task.model.find_property(name)
    property.doc if property
end
doc?() click to toggle source
# File lib/orocos/task_context.rb, line 100
def doc?
    (doc && !doc.empty?)
end
log_current_value(timestamp = Time.now) click to toggle source

Write the current value of the property or attribute to #log_stream

# File lib/orocos/task_context.rb, line 79
def log_current_value(timestamp = Time.now)
    log_value(read)
end
log_metadata() click to toggle source
# File lib/orocos/task_context.rb, line 52
def log_metadata
    Hash['rock_task_model' => task.model.name,
        'rock_task_name' => task.name,
        'rock_task_object_name' => name,
        'rock_orocos_type_name' => orocos_type_name]
end
log_value(value, timestamp = Time.now) click to toggle source
# File lib/orocos/task_context.rb, line 83
def log_value(value, timestamp = Time.now)
    if log_stream
        log_stream.write(timestamp, timestamp, value)
    end
    if log_port
        log_port.write(value)
    end
end
new_sample() click to toggle source
# File lib/orocos/task_context.rb, line 92
def new_sample
    type.new
end
raw_read() click to toggle source
# File lib/orocos/task_context.rb, line 59
def raw_read
    value = type.new
    do_read(@orocos_type_name, value)
    value
end
read() click to toggle source

Read the current value of the property/attribute

# File lib/orocos/task_context.rb, line 66
def read
    Typelib.to_ruby(raw_read)
end
write(value, timestamp = Time.now) click to toggle source

Sets a new value for the property/attribute

# File lib/orocos/task_context.rb, line 71
def write(value, timestamp = Time.now)
    value = Typelib.from_ruby(value, type)
    do_write(@orocos_type_name, value)
    log_value(value, timestamp)
    value
end