class OroGen::Spec::TaskDeployment
The instances of this class hold the deployment-specific information needed for a task.
Constants
- ActivityDefinition
Attributes
If this task is deployed with a slave activity, this is the master task @return [TaskDeployment]
Overrides the default minimal trigger latency for this particular task
The task name as specified by the user
The deployed operations, as OperationDeployment instances
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.
The deployed ports, as PortDeployment instances
The deployed properties, as PropertyDeployment instances
If this task is the master of other tasks deployed as slave activities, they are listed here @return [Array<TaskDeployment>]
The TaskContext model used to define this task
Overrides the default expected trigger latency for this particular task
Public Class Methods
# 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
# File lib/orogen/spec/deployment.rb, line 422 def activity_setup(&block) @activity_setup = block end
# File lib/orogen/spec/deployment.rb, line 426 def activity_xml(&block) @activity_xml = block end
Backward compatibility only. Use task_model instead.
# File lib/orogen/spec/deployment.rb, line 122 def context; task_model end
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
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
# File lib/orogen/spec/deployment.rb, line 275 def fd_driven? activity_type.name == 'FileDescriptorActivity' end
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
# File lib/orogen/spec/deployment.rb, line 150 def initialize_copy(old) super @slaves = slaves.dup end
# File lib/orogen/spec/deployment.rb, line 466 def inspect to_s end
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
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
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
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
# File lib/orogen/spec/deployment.rb, line 271 def periodic? activity_type.name == 'Triggered' && period != 0 end
The Project object this task is part of
# File lib/orogen/spec/deployment.rb, line 238 def project; task_model.project end
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
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
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
# File lib/orogen/spec/deployment.rb, line 263 def sequential? activity_type.name == 'Sequential' end
# File lib/orogen/spec/deployment.rb, line 279 def slave? activity_type.name == 'SlaveActivity' end
# 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
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
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
# File lib/orogen/spec/deployment.rb, line 463 def to_s "#<#{self.class} name=#{name} model=#{task_model}>" end
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
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
# File lib/orogen/spec/deployment.rb, line 267 def triggered? activity_type.name == 'Triggered' && period == 0 end