Class: Roby::Coordination::Models::FaultHandler::ReplaceBy
- Inherits:
-
ScriptInstruction
- Object
- ScriptInstruction
- Roby::Coordination::Models::FaultHandler::ReplaceBy
- Defined in:
- lib/roby/coordination/models/fault_handler.rb
Overview
Script element that implements the replacement part of #replace_by
Instance Attribute Summary collapse
-
#replacement_task ⇒ Object
readonly
Returns the value of attribute replacement_task.
Instance Method Summary collapse
- #execute(fault_handler) ⇒ Object
-
#initialize(replacement_task) ⇒ ReplaceBy
constructor
A new instance of ReplaceBy.
- #new(fault_handler) ⇒ Object
- #to_s ⇒ Object
Methods inherited from ScriptInstruction
Constructor Details
#initialize(replacement_task) ⇒ ReplaceBy
Returns a new instance of ReplaceBy.
81 82 83 84 85 |
# File 'lib/roby/coordination/models/fault_handler.rb', line 81 def initialize(replacement_task) super() @replacement_task = replacement_task end |
Instance Attribute Details
#replacement_task ⇒ Object (readonly)
Returns the value of attribute replacement_task.
79 80 81 |
# File 'lib/roby/coordination/models/fault_handler.rb', line 79 def replacement_task @replacement_task end |
Instance Method Details
#execute(fault_handler) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/roby/coordination/models/fault_handler.rb', line 91 def execute(fault_handler) response_task = fault_handler.root_task plan = response_task.plan replacement_task = self.replacement_task.resolve response_task.each_parent_object(Roby::TaskStructure::ErrorHandling) do |repaired_task| repaired_task_parents = repaired_task.each_parent_task.map do |parent_task| [parent_task, parent_task[repaired_task, Roby::TaskStructure::Dependency]] end plan.replace(repaired_task, replacement_task) repaired_task_parents.each do |parent_t, | parent_t.add_child repaired_task, end end true end |
#new(fault_handler) ⇒ Object
87 88 89 |
# File 'lib/roby/coordination/models/fault_handler.rb', line 87 def new(fault_handler) ReplaceBy.new(fault_handler.instance_for(replacement_task)) end |
#to_s ⇒ Object
108 109 110 |
# File 'lib/roby/coordination/models/fault_handler.rb', line 108 def to_s "start(#{task}, #{})" end |