diff --git a/lib/roby/coordination/base.rb b/lib/roby/coordination/base.rb index 7f239b45d..63ffadf59 100644 --- a/lib/roby/coordination/base.rb +++ b/lib/roby/coordination/base.rb @@ -70,6 +70,11 @@ def initialize(root_task = nil, arguments = Hash.new, options = Hash.new) attach_fault_response_tables_to(new_task) end end + + #We register ourself at the rreffering roby task to + #get a access to us. + root_task.register_coordination_object(self) + end end diff --git a/lib/roby/task.rb b/lib/roby/task.rb index 73b9f1cfc..cbcbfc8ab 100644 --- a/lib/roby/task.rb +++ b/lib/roby/task.rb @@ -185,6 +185,7 @@ def initialize(arguments = Hash.new) #:yields: task_object @poll_handlers = [] @execute_handlers = [] + @coordination_objects = [] yield(self) if block_given? @@ -664,9 +665,6 @@ def emitting_event(event, context) # :nodoc: if finished? && !event.terminal? raise EmissionFailed.new(nil, event), "#{self}.emit(#{event.symbol}, #{context}) called by #{plan.engine.propagation_sources.to_a} but the task has finished. Task has been terminated by #{event(:stop).history.first.sources}." - elsif pending? && event.symbol != :start - raise EmissionFailed.new(nil, event), - "#{self}.emit(#{event.symbol}, #{context}) called by #{plan.engine.propagation_sources.to_a} but the task has never been started" elsif running? && event.symbol == :start raise EmissionFailed.new(nil, event), "#{self}.emit(#{event.symbol}, #{context}) called by #{plan.engine.propagation_sources.to_a} but the task is already running. Task has been started by #{event(:start).history.first.sources}." @@ -705,7 +703,15 @@ def fired_event(event) # # It is only much more efficient attr_reader :failure_event - + + # Reference to the coordinating task if this Roby::Task is handled by a coordination + # object like Statemachiens or ActionScripts + attr_reader :coordination_objects + + def register_coordination_object(object) + coordination_objects << object + end + # Call to update the task status because of +event+ def update_task_status(event) # :nodoc: if event.success?