Module: Roby::Coordination::Models::FaultResponseTable

Includes:
Actions::Models::Interface, Arguments
Included in:
FaultResponseTable
Defined in:
lib/roby/coordination/models/fault_response_table.rb

Overview

Definition of the metamodel for Coordination::FaultResponseTable

Defined Under Namespace

Classes: Action

Instance Method Summary collapse

Methods included from Arguments

#argument, #validate_arguments

Methods included from Actions::Models::Interface

#promote_registered_action

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, #promote_registered_action, #register_action, #register_action!, #register_added_method_as_action, #registered_action, #require_current_description, #state_machine, #use_fault_response_table, #use_library

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



68
69
70
71
72
73
74
75
76
# File 'lib/roby/coordination/models/fault_response_table.rb', line 68

def method_missing(m, *args, &block)
    if Queries::ExecutionExceptionMatcher.method_defined?(m)
        matcher = Queries::ExecutionExceptionMatcher.new
        matcher.send(m, *args, &block)
        matcher
    else
        super
    end
end

Instance Method Details

#each_taskObject



53
54
55
56
57
58
59
60
61
62
# File 'lib/roby/coordination/models/fault_response_table.rb', line 53

def each_task
    return enum_for(:each_task) unless block_given?

    super
    each_fault_handler do |handler|
        if task = handler.replacement
            yield(task)
        end
    end
end

#fault_handlerFaultHandler

The set of defined fault handlers

Returns:



14
# File 'lib/roby/coordination/models/fault_response_table.rb', line 14

inherited_attribute("fault_handler", "fault_handlers") { [] }

#find_all_matching_handlers(exception) ⇒ Object



16
17
18
19
20
# File 'lib/roby/coordination/models/fault_response_table.rb', line 16

def find_all_matching_handlers(exception)
    each_fault_handler.find_all do |h|
        h.execution_exception_matcher === exception
    end
end

#on_fault(exception_matcher, &block) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/roby/coordination/models/fault_response_table.rb', line 40

def on_fault(exception_matcher, &block)
    exception_matcher = exception_matcher.to_execution_exception_matcher
    action_model = Action.new(self)
    each_argument do |_, arg|
        action_model.required_arg(arg.name)
    end
    action_model, handler =
        create_coordination_action(action_model, Coordination::FaultHandler, &block)
    handler.execution_exception_matcher(exception_matcher)
    fault_handlers << handler
    handler
end

#respond_to_missing?(m, include_private) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/roby/coordination/models/fault_response_table.rb', line 64

def respond_to_missing?(m, include_private)
    Queries::ExecutionExceptionMatcher.method_defined?(m) || super
end