class OroGen::Spec::TaskDeployment

The instances of this class hold the deployment-specific information needed for a task.

Constants

ActivityDefinition

Attributes

master[RW]

If this task is deployed with a slave activity, this is the master task @return [TaskDeployment]

minimal_trigger_latency[RW]

Overrides the default minimal trigger latency for this particular task

See #minimal_trigger_latency

name[RW]

The task name as specified by the user

operations[R]

The deployed operations, as OperationDeployment instances

period[R]

Returns the task period, or nil if the task is not periodic. Call periodic to define a periodic task and one of the other triggering methods otherwise.

ports[R]

The deployed ports, as PortDeployment instances

properties[R]

The deployed properties, as PropertyDeployment instances

slaves[R]

If this task is the master of other tasks deployed as slave activities, they are listed here @return [Array<TaskDeployment>]

task_model[R]

The TaskContext model used to define this task

worstcase_trigger_latency[RW]

Overrides the default expected trigger latency for this particular task

See #worstcase_trigger_latency

Public Class Methods

new(name, task_model) click to toggle source
# File lib/orogen/spec/deployment.rb, line 197
def initialize(name, task_model)
    @name     = name
    @task_model  = task_model
    @realtime = false
    @priority = :lowest
    @max_overruns = -1
    @master = nil
    @slaves = Array.new
    if task_model.default_activity
        send(*task_model.default_activity)
        @explicit_activity = task_model.required_activity?
    end

    { :properties  => PropertyDeployment,
        :ports    => PortDeployment,
        :operations => OperationDeployment }.each do |collection_name, klass|
            deployed_objects = task_model.send("all_#{collection_name}").map do |obj|
                klass.new(self, obj)
            end
            instance_variable_set "@#{collection_name}", deployed_objects
        end
end

Public Instance Methods

activity_setup(&block) click to toggle source
# File lib/orogen/spec/deployment.rb, line 422
def activity_setup(&block)
    @activity_setup = block
end
activity_xml(&block) click to toggle source
# File lib/orogen/spec/deployment.rb, line 426
def activity_xml(&block)
    @activity_xml = block
end
context() click to toggle source

Backward compatibility only. Use task_model instead.

# File lib/orogen/spec/deployment.rb, line 122
def context; task_model end
disable_overruns_control() click to toggle source

Do no check for overruns. Valid for periodic tasks. See max_overruns for a more precise description.

# File lib/orogen/spec/deployment.rb, line 441
def disable_overruns_control; @max_overruns = -1; self end
fd_driven() click to toggle source

Makes this task's activity driven by a file descriptor. The underlying task context must be a subclass of FileDescriptorActivity::Provider

# File lib/orogen/spec/deployment.rb, line 285
            def fd_driven
                activity_type 'FileDescriptorActivity', 'RTT::extras::FileDescriptorActivity', 'rtt/extras/FileDescriptorActivity.hpp'
                activity_xml do
                    result = <<-EOD
<struct name="#{name}" type="FileDescriptorActivity">
    <simple name="Priority" type="short"><value>#{rtt_priority}</value></simple>
    <simple name="Scheduler" type="string"><value>#{rtt_scheduler}</value></simple>
</struct>
                    EOD
                end
                self
            end
fd_driven?() click to toggle source
# File lib/orogen/spec/deployment.rb, line 275
def fd_driven?
    activity_type.name == 'FileDescriptorActivity'
end
highest_priority() click to toggle source

Make this task as being of the highest priority allowed by the underlying OS

# File lib/orogen/spec/deployment.rb, line 222
def highest_priority; @priority = :highest; self end
initialize_copy(old) click to toggle source
Calls superclass method
# File lib/orogen/spec/deployment.rb, line 150
def initialize_copy(old)
    super
    @slaves = slaves.dup
end
inspect() click to toggle source
# File lib/orogen/spec/deployment.rb, line 466
def inspect
    to_s
end
irq_driven() click to toggle source

Makes this task's activity driven by events on an IRQ line. The underlying task context must be a subclass of IRQActivity::Provider

# File lib/orogen/spec/deployment.rb, line 301
            def irq_driven
                activity_type 'IRQActivity', 'RTT::extras::IRQActivity', 'rtt/extras/IRQActivity.hpp'
                activity_xml do
                    result = <<-EOD
<struct name="#{name}" type="IRQActivity">
    <simple name="Priority" type="short"><value>#{rtt_priority}</value></simple>
    <simple name="Scheduler" type="string"><value>#{rtt_scheduler}</value></simple>
</struct>
                    EOD
                end
                self
            end
lowest_priority() click to toggle source

Make this task as being of the lowest priority allowed by the underlying OS

# File lib/orogen/spec/deployment.rb, line 225
def lowest_priority;  @priority = :lowest; self end
non_realtime() click to toggle source

Marks this task as being part of the non-realtime scheduling class (the default)

# File lib/orogen/spec/deployment.rb, line 461
def non_realtime; @realtime = false; self end
periodic(period_in_seconds) → self click to toggle source

Sets this task as being periodic. Call period to return the current task's period (or nil if the task is not periodic), and one of the other triggering methods if you want a different activity type.

# File lib/orogen/spec/deployment.rb, line 332
            def periodic(value)
                activity_type 'Periodic', 'RTT::Activity', 'rtt/Activity.hpp'
                activity_setup do
                   result = <<-EOD
#{activity_type.class_name}* activity_#{name} = new #{activity_type.class_name}(
    #{rtt_scheduler},
    #{rtt_priority},
    #{period},
    task_#{name}->engine(),
    "#{name}");
RTT::os::Thread* thread_#{name} =
    dynamic_cast<RTT::os::Thread*>(activity_#{name}->thread());
thread_#{name}->setMaxOverrun(#{max_overruns});
                   EOD
                end
                activity_xml do
                    result = <<-EOD
<struct name="#{name}" type="Activity">
    <simple name="Period" type="double"><value>#{period}</value></simple>
    <simple name="Priority" type="short"><value>#{rtt_priority}</value></simple>
    <simple name="Scheduler" type="string"><value>#{rtt_scheduler}</value></simple>
</struct>
                    EOD
                end

                @period = Float(value)
                self
            end
periodic?() click to toggle source
# File lib/orogen/spec/deployment.rb, line 271
def periodic?
    activity_type.name == 'Triggered' && period != 0
end
project() click to toggle source

The Project object this task is part of

# File lib/orogen/spec/deployment.rb, line 238
def project; task_model.project end
realtime() click to toggle source

Marks this task as being part of the realtime scheduling class

# File lib/orogen/spec/deployment.rb, line 458
def realtime; @realtime = true; self end
realtime?() click to toggle source

True if this task should be deployed using a realtime scheduler, and false otherwise

# File lib/orogen/spec/deployment.rb, line 456
def realtime?; @realtime end
sequential() click to toggle source

Marks this task as being “sequential”. Sequential tasks are thread-less, and are triggered by the task context that is calling step() on them, or – in the case of port-driven tasks – by the task context that wrote on their read ports.

# File lib/orogen/spec/deployment.rb, line 392
            def sequential
                activity_type 'Sequential', 'RTT::extras::SequentialActivity', 'rtt/extras/SequentialActivity.hpp'
                activity_setup do
                    result = <<-EOD
#{activity_type.class_name}* activity_#{name} = new #{activity_type.class_name}(task_#{name}->engine());
                    EOD
                end
                activity_xml do
                    <<-EOD
<struct name="#{name}" type="SequentialActivity" />
                    EOD
                end

                self
            end
sequential?() click to toggle source
# File lib/orogen/spec/deployment.rb, line 263
def sequential?
    activity_type.name == 'Sequential'
end
slave?() click to toggle source
# File lib/orogen/spec/deployment.rb, line 279
def slave?
    activity_type.name == 'SlaveActivity'
end
slave_of(master) click to toggle source
# File lib/orogen/spec/deployment.rb, line 408
            def slave_of(master)
                activity_type 'SlaveActivity', 'RTT::extras::SlaveActivity', 'rtt/extras/SlaveActivity.hpp'
                self.master = master
                master.slaves << self
                activity_setup do
                    <<-EOD
#{activity_type.class_name}* activity_#{name} = new #{activity_type.class_name}(activity_#{master.name},task_#{name}->engine());
                    EOD
                end
                activity_xml do
                    "<struct name=\"#{name}\" type=\"SlaveActivity\" />"
                end
            end
start() click to toggle source

Call to make the deployer start this task when the task context is launched

# File lib/orogen/spec/deployment.rb, line 432
def start; @start = true; self end
start?() click to toggle source

True if this task should be started when the task context is started. Note that the deployer must honor the initial_state of the underlying task context (i.e. call configure() if initial_state is PreOperational)

# File lib/orogen/spec/deployment.rb, line 437
def start?; !!@start end
to_s() click to toggle source
# File lib/orogen/spec/deployment.rb, line 463
def to_s
    "#<#{self.class} name=#{name} model=#{task_model}>"
end
trigger_port?(port) click to toggle source

Returns true if port is a trigger for this task

# File lib/orogen/spec/deployment.rb, line 320
def trigger_port?(port)
    port.trigger_port? &&
        activity_type.name != 'Periodic'
end
triggered() click to toggle source

Marks this task as being explicitely triggered (the default). To make it periodic, call period with the required period

# File lib/orogen/spec/deployment.rb, line 363
            def triggered
                activity_type 'Triggered', 'RTT::Activity', 'rtt/Activity.hpp'
                activity_setup do
                   result = <<-EOD
#{activity_type.class_name}* activity_#{name} = new #{activity_type.class_name}(
    #{rtt_scheduler},
    #{rtt_priority},
    0,
    task_#{name}->engine(),
    "#{name}");
                   EOD
                end
                activity_xml do
                    result = <<-EOD
<struct name="#{name}" type="Activity">
    <simple name="Period" type="double"><value>0</value></simple>
    <simple name="Priority" type="short"><value>#{rtt_priority}</value></simple>
    <simple name="Scheduler" type="string"><value>#{rtt_scheduler}</value></simple>
</struct>
                    EOD
                end
                @period = 0
                self
            end
triggered?() click to toggle source
# File lib/orogen/spec/deployment.rb, line 267
def triggered?
    activity_type.name == 'Triggered' && period == 0
end