Class: OroGen::Spec::TaskDeployment
- Inherits:
-
Object
- Object
- OroGen::Spec::TaskDeployment
- Defined in:
- lib/orogen/spec/deployment.rb
Overview
The instances of this class hold the deployment-specific information needed for a task.
Defined Under Namespace
Classes: ActivityDefinition
Instance Attribute Summary collapse
-
#master ⇒ TaskDeployment
If this task is deployed with a slave activity, this is the master task.
-
#minimal_trigger_latency ⇒ Object
Returns the minimal latency between the time the task gets triggered (for instance because of data on an input event port), and the time updateHook() is actually called, based on its scheduler and priority.
-
#name ⇒ Object
The task name as specified by the user.
-
#operations ⇒ Object
readonly
The deployed operations, as OperationDeployment instances.
-
#period ⇒ Object
readonly
Returns the task period, or nil if the task is not periodic.
-
#ports ⇒ Object
readonly
The deployed ports, as PortDeployment instances.
-
#properties ⇒ Object
readonly
The deployed properties, as PropertyDeployment instances.
-
#slaves ⇒ Array<TaskDeployment>
readonly
If this task is the master of other tasks deployed as slave activities, they are listed here.
-
#task_model ⇒ Object
readonly
The TaskContext model used to define this task.
-
#worstcase_trigger_latency ⇒ Object
Returns the expected (average) latency between the time the task gets triggered (for instance because of data on an input event port), and the time updateHook() is actually called, based on its scheduler and priority.
Instance Method Summary collapse
- #activity_setup(&block) ⇒ Object
- #activity_xml(&block) ⇒ Object
-
#context ⇒ Object
Backward compatibility only.
-
#disable_overruns_control ⇒ Object
Do no check for overruns.
-
#fd_driven ⇒ Object
Makes this task's activity driven by a file descriptor.
- #fd_driven? ⇒ Boolean
-
#highest_priority ⇒ Object
Make this task as being of the highest priority allowed by the underlying OS.
-
#initialize(name, task_model) ⇒ TaskDeployment
constructor
A new instance of TaskDeployment.
- #initialize_copy(old) ⇒ Object
- #inspect ⇒ Object
-
#irq_driven ⇒ Object
Makes this task's activity driven by events on an IRQ line.
-
#lowest_priority ⇒ Object
Make this task as being of the lowest priority allowed by the underlying OS.
-
#method_missing(m, *args) ⇒ Object
:nodoc:.
-
#non_realtime ⇒ Object
Marks this task as being part of the non-realtime scheduling class (the default).
-
#periodic(value) ⇒ Object
call-seq: periodic(period_in_seconds) -> self.
- #periodic? ⇒ Boolean
-
#pretty_print(pp) ⇒ Object
:nodoc:.
-
#project ⇒ Object
The Project object this task is part of.
-
#realtime ⇒ Object
Marks this task as being part of the realtime scheduling class.
-
#realtime? ⇒ Boolean
True if this task should be deployed using a realtime scheduler, and false otherwise.
-
#sequential ⇒ Object
Marks this task as being “sequential”.
- #sequential? ⇒ Boolean
- #slave? ⇒ Boolean
- #slave_of(master) ⇒ Object
-
#start ⇒ Object
Call to make the deployer start this task when the task context is launched.
-
#start? ⇒ Boolean
True if this task should be started when the task context is started.
- #to_s ⇒ Object
-
#trigger_port?(port) ⇒ Boolean
Returns true if
port
is a trigger for this task. -
#triggered ⇒ Object
Marks this task as being explicitely triggered (the default).
- #triggered? ⇒ Boolean
Constructor Details
#initialize(name, task_model) ⇒ TaskDeployment
Returns a new instance of TaskDeployment
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
:nodoc:
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/orogen/spec/deployment.rb', line 480 def method_missing(m, *args) # :nodoc: name = m.to_s if name =~ /=$/ setter = true name = $` end { :properties => PropertyDeployment, :ports => PortDeployment, :operations => OperationDeployment }.each do |collection_name, klass| if obj = send(collection_name).find { |el| el.name == name.to_s } if setter if args.size != 1 raise ArgumentError, "wrong number of arguments for #{name}=: expected 1 got #{args.size}" end obj.set args[0] return args[0] else if !args.empty? raise ArgumentError, "wrong number of arguments for #{name}: expected 1 got #{args.size}" end return obj end end end return super end |
Instance Attribute Details
#master ⇒ TaskDeployment
If this task is deployed with a slave activity, this is the master task
144 145 146 |
# File 'lib/orogen/spec/deployment.rb', line 144 def master @master end |
#minimal_trigger_latency ⇒ Object
Returns the minimal latency between the time the task gets triggered (for instance because of data on an input event port), and the time updateHook() is actually called, based on its scheduler and priority. All tasks will return a value (even non-periodic ones).
Default values are set in the DEFAULT_RT_MINIMAL_TRIGGER_LATENCY and DEFAULT_NONRT_MINIMAL_TRIGGER_LATENCY constants. They can be overriden by setting the minimal_trigger_latency property
135 136 137 |
# File 'lib/orogen/spec/deployment.rb', line 135 def minimal_trigger_latency @minimal_trigger_latency end |
#name ⇒ Object
The task name as specified by the user
118 119 120 |
# File 'lib/orogen/spec/deployment.rb', line 118 def name @name end |
#operations ⇒ Object (readonly)
The deployed operations, as OperationDeployment instances
129 130 131 |
# File 'lib/orogen/spec/deployment.rb', line 129 def operations @operations end |
#period ⇒ Object (readonly)
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.
317 318 319 |
# File 'lib/orogen/spec/deployment.rb', line 317 def period @period end |
#ports ⇒ Object (readonly)
The deployed ports, as PortDeployment instances
127 128 129 |
# File 'lib/orogen/spec/deployment.rb', line 127 def ports @ports end |
#properties ⇒ Object (readonly)
The deployed properties, as PropertyDeployment instances
125 126 127 |
# File 'lib/orogen/spec/deployment.rb', line 125 def properties @properties end |
#slaves ⇒ Array<TaskDeployment> (readonly)
If this task is the master of other tasks deployed as slave activities, they are listed here
148 149 150 |
# File 'lib/orogen/spec/deployment.rb', line 148 def slaves @slaves end |
#task_model ⇒ Object (readonly)
The TaskContext model used to define this task
120 121 122 |
# File 'lib/orogen/spec/deployment.rb', line 120 def task_model @task_model end |
#worstcase_trigger_latency ⇒ Object
Returns the expected (average) latency between the time the task gets triggered (for instance because of data on an input event port), and the time updateHook() is actually called, based on its scheduler and priority. All tasks will return a value (even non-periodic ones).
Default values are set in the DEFAULT_RT_WORSTCASE_TRIGGER_LATENCY and DEFAULT_NONRT_WORSTCASE_TRIGGER_LATENCY constants. They can be overriden by setting the worstcase_trigger_latency property
140 141 142 |
# File 'lib/orogen/spec/deployment.rb', line 140 def worstcase_trigger_latency @worstcase_trigger_latency end |
Instance Method Details
#activity_setup(&block) ⇒ Object
422 423 424 |
# File 'lib/orogen/spec/deployment.rb', line 422 def activity_setup(&block) @activity_setup = block end |
#activity_xml(&block) ⇒ Object
426 427 428 |
# File 'lib/orogen/spec/deployment.rb', line 426 def activity_xml(&block) @activity_xml = block end |
#context ⇒ Object
Backward compatibility only. Use #task_model instead.
122 |
# File 'lib/orogen/spec/deployment.rb', line 122 def context; task_model end |
#disable_overruns_control ⇒ Object
Do no check for overruns. Valid for periodic tasks. See #max_overruns for a more precise description.
441 |
# File 'lib/orogen/spec/deployment.rb', line 441 def disable_overruns_control; @max_overruns = -1; self end |
#fd_driven ⇒ Object
Makes this task's activity driven by a file descriptor. The underlying task context must be a subclass of FileDescriptorActivity::Provider
285 286 287 288 289 290 291 292 293 294 295 296 |
# 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? ⇒ Boolean
275 276 277 |
# File 'lib/orogen/spec/deployment.rb', line 275 def fd_driven? activity_type.name == 'FileDescriptorActivity' end |
#highest_priority ⇒ Object
Make this task as being of the highest priority allowed by the underlying OS
222 |
# File 'lib/orogen/spec/deployment.rb', line 222 def highest_priority; @priority = :highest; self end |
#initialize_copy(old) ⇒ Object
150 151 152 153 |
# File 'lib/orogen/spec/deployment.rb', line 150 def initialize_copy(old) super @slaves = slaves.dup end |
#inspect ⇒ Object
466 467 468 |
# File 'lib/orogen/spec/deployment.rb', line 466 def inspect to_s end |
#irq_driven ⇒ Object
Makes this task's activity driven by events on an IRQ line. The underlying task context must be a subclass of IRQActivity::Provider
301 302 303 304 305 306 307 308 309 310 311 312 |
# 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 ⇒ Object
Make this task as being of the lowest priority allowed by the underlying OS
225 |
# File 'lib/orogen/spec/deployment.rb', line 225 def lowest_priority; @priority = :lowest; self end |
#non_realtime ⇒ Object
Marks this task as being part of the non-realtime scheduling class (the default)
461 |
# File 'lib/orogen/spec/deployment.rb', line 461 def non_realtime; @realtime = false; self end |
#periodic(value) ⇒ Object
call-seq:
periodic(period_in_seconds) -> self
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.
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# 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? ⇒ Boolean
271 272 273 |
# File 'lib/orogen/spec/deployment.rb', line 271 def periodic? activity_type.name == 'Triggered' && period != 0 end |
#pretty_print(pp) ⇒ Object
:nodoc:
470 471 472 473 474 475 476 477 478 |
# File 'lib/orogen/spec/deployment.rb', line 470 def pretty_print(pp) # :nodoc: pp.text "#{name}[#{task_model.name}]" pp.nest(2) do pp.breakable pp.text "activity: #{@activity_type.name}, prio=#{@priority}" pp.breakable pp.text "scheduler: #{@realtime ? 'realtime' : 'non realtime'}" end end |
#project ⇒ Object
The Project object this task is part of
238 |
# File 'lib/orogen/spec/deployment.rb', line 238 def project; task_model.project end |
#realtime ⇒ Object
Marks this task as being part of the realtime scheduling class
458 |
# File 'lib/orogen/spec/deployment.rb', line 458 def realtime; @realtime = true; self end |
#realtime? ⇒ Boolean
True if this task should be deployed using a realtime scheduler, and false otherwise
456 |
# File 'lib/orogen/spec/deployment.rb', line 456 def realtime?; @realtime end |
#sequential ⇒ Object
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.
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
# 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? ⇒ Boolean
263 264 265 |
# File 'lib/orogen/spec/deployment.rb', line 263 def sequential? activity_type.name == 'Sequential' end |
#slave? ⇒ Boolean
279 280 281 |
# File 'lib/orogen/spec/deployment.rb', line 279 def slave? activity_type.name == 'SlaveActivity' end |
#slave_of(master) ⇒ Object
408 409 410 411 412 413 414 415 416 417 418 419 420 |
# 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 ⇒ Object
Call to make the deployer start this task when the task context is launched
432 |
# File 'lib/orogen/spec/deployment.rb', line 432 def start; @start = true; self end |
#start? ⇒ Boolean
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)
437 |
# File 'lib/orogen/spec/deployment.rb', line 437 def start?; !!@start end |
#to_s ⇒ Object
463 464 465 |
# File 'lib/orogen/spec/deployment.rb', line 463 def to_s "#<#{self.class} name=#{name} model=#{task_model}>" end |
#trigger_port?(port) ⇒ Boolean
Returns true if port
is a trigger for this task
320 321 322 323 |
# File 'lib/orogen/spec/deployment.rb', line 320 def trigger_port?(port) port.trigger_port? && activity_type.name != 'Periodic' end |
#triggered ⇒ Object
Marks this task as being explicitely triggered (the default). To make it periodic, call #period with the required period
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
# 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? ⇒ Boolean
267 268 269 |
# File 'lib/orogen/spec/deployment.rb', line 267 def triggered? activity_type.name == 'Triggered' && period == 0 end |