Class: Roby::Coordination::FaultResponseTable
- Inherits:
-
Actions::Interface
- Object
- Actions::Interface
- Roby::Coordination::FaultResponseTable
- Extended by:
- Models::FaultResponseTable
- Defined in:
- lib/roby/coordination/fault_response_table.rb
Overview
A way to organize response to faults (a.k.a. Roby exceptions)
Fault response tables are defined as subclasses of this class, e.g.
The fault response description is [an action script](ActionScript). It is represented by a FaultHandlingTask that is added when a fault response triggers.
When a Models::FaultResponseTable#on_fault declaration matches an exception, the table will create a FaultHandlingTask task and attach it to a task in the plan. The task it attaches it to depends on statements that extend the action script:
* locate_on_missions: the fault response will be assigned to the
downmost missions which are affected by the fault.
* locate_on_actions: the fault response will be assigned to the
downmost actions which are affected by the fault. This is the
default.
* locate_on_origins: the fault response will be assigned to the fault
origin
The task on which the fault response is attached is stopped. The exception that caused the response is inhibited while the response is running.
By default, once the fault response is finished, the plan will resume normal exception processing. I.e., it is the fault response’s responsibility to fix the exception(s) in the plan. This default can be changed by adding the ‘restart’ statement in the action script. In this case, the mission or task that was assigned to the fault handler will be restarted once the fault handler script terminates. It can optionally be given a number of allowed restarts (to avoid infinite loops) as well as a timeout (to reset the counter if the fault did not occur for a certain length of time)
And can then be attached to plans within an action interface:
Instance Attribute Summary collapse
-
#arguments ⇒ {Symbol=>Object}
readonly
Assigned table arguments.
Attributes inherited from Actions::Interface
Instance Method Summary collapse
-
#attach_to(plan) ⇒ void
Hook called when this table is attached to a given plan.
-
#find_all_matching_handlers(exception) ⇒ Array<Models::FaultHandler>
Returns the handlers that are defined for a particular exception.
-
#initialize(plan, arguments = {}) ⇒ FaultResponseTable
constructor
A new instance of FaultResponseTable.
-
#removed! ⇒ void
Called when this table has been removed from the plan it was attached to.
Methods included from Models::FaultResponseTable
each_task, fault_handler, method_missing, on_fault, respond_to_missing?
Methods included from Models::Arguments
#argument, #validate_arguments
Methods included from Actions::Models::Interface
Methods included from Actions::Models::InterfaceBase
#action_script, #action_state_machine, #added_method_action_check_arity, #clear_model, #create_and_register_coordination_action, #create_coordination_action, #create_coordination_model, #create_default_action_return_type, #describe, #each_action, #fault_response_table, #find_action_by_name, #find_all_actions_by_type, #method_added, #method_missing, #promote_registered_action, #register_action, #register_action!, #register_added_method_as_action, #registered_action, #require_current_description, #respond_to_missing?, #state_machine, #use_fault_response_table, #use_library
Methods inherited from Actions::Interface
#action_script, #action_state_machine, #model
Methods included from DRoby::Identifiable
Methods included from DRoby::V5::ModelDumper
#droby_dump, #droby_marshallable?
Constructor Details
#initialize(plan, arguments = {}) ⇒ FaultResponseTable
Returns a new instance of FaultResponseTable.
68 69 70 71 72 73 |
# File 'lib/roby/coordination/fault_response_table.rb', line 68 def initialize(plan, arguments = {}) # Argument massaging must be done before we call super(), as # super() will attach the table on the plan @arguments = model.validate_arguments(arguments) super(plan) end |
Instance Attribute Details
#arguments ⇒ {Symbol=>Object} (readonly)
Returns assigned table arguments.
66 67 68 |
# File 'lib/roby/coordination/fault_response_table.rb', line 66 def arguments @arguments end |
Instance Method Details
#attach_to(plan) ⇒ void
This method returns an undefined value.
Hook called when this table is attached to a given plan
This is a hook, so one can inject code here by defining a attach_to method on a module and prepending the module on the FaultResponseTable class. Do not forget to call super in the hook method.
84 |
# File 'lib/roby/coordination/fault_response_table.rb', line 84 def attach_to(plan); end |
#find_all_matching_handlers(exception) ⇒ Array<Models::FaultHandler>
Returns the handlers that are defined for a particular exception
91 92 93 |
# File 'lib/roby/coordination/fault_response_table.rb', line 91 def find_all_matching_handlers(exception) model.find_all_matching_handlers(exception) end |
#removed! ⇒ void
This method returns an undefined value.
Called when this table has been removed from the plan it was attached to
It cannot be reused afterwards
It calls super if it is defined, so it is possible to use it as a hook by defining a module that defines removed! and prepend it in the FaultResponseTable class. Don’t forget to call super in the hook .
106 |
# File 'lib/roby/coordination/fault_response_table.rb', line 106 def removed!; end |