Class: Roby::Coordination::Models::TaskFromAction

Inherits:
TaskWithDependencies show all
Defined in:
lib/roby/coordination/models/task_from_action.rb

Overview

A representation of a state based on an action

Instance Attribute Summary collapse

Attributes inherited from TaskWithDependencies

#dependencies

Attributes inherited from Task

#model, #name

Instance Method Summary collapse

Methods inherited from TaskWithDependencies

#depends_on, #find_child_model, #initialize_copy, #map_tasks

Methods inherited from Task

#can_resolve_child_models?, #find_child, #find_child_model, #find_event, #find_through_method_missing, #has_child?, #has_event?, #has_through_method_missing?, #map_tasks, #new, #setup_instanciated_task, #to_coordination_task

Constructor Details

#initialize(action) ⇒ TaskFromAction

Returns a new instance of TaskFromAction.



12
13
14
15
# File 'lib/roby/coordination/models/task_from_action.rb', line 12

def initialize(action)
    @action = action
    super(action.model.returned_type)
end

Instance Attribute Details

#actionRoby::Actions::Action

The associated action



10
11
12
# File 'lib/roby/coordination/models/task_from_action.rb', line 10

def action
  @action
end

Instance Method Details

#action_coordination_modelnil, Base

Returns the action’s underlying coordination model if there is one

Returns:



41
42
43
44
45
# File 'lib/roby/coordination/models/task_from_action.rb', line 41

def action_coordination_model
    if action.model.respond_to?(:coordination_model)
        action.model.coordination_model
    end
end

#instanciate(plan, variables = {}) ⇒ Object

Generates a task for this state in the given plan and returns it



27
28
29
30
31
32
33
34
35
36
# File 'lib/roby/coordination/models/task_from_action.rb', line 27

def instanciate(plan, variables = {})
    arguments = action.arguments.transform_values do |value|
        if value.respond_to?(:evaluate)
            value.evaluate(variables)
        else
            value
        end
    end
    action.as_plan(**arguments)
end

#rebind(coordination_model) ⇒ Object

Rebind this task to refer to a different action interface



18
19
20
21
22
23
# File 'lib/roby/coordination/models/task_from_action.rb', line 18

def rebind(coordination_model)
    result = super
    result.action = action.rebind(coordination_model.action_interface)
    result.model  = result.action.model.returned_type
    result
end

#to_sObject



47
48
49
# File 'lib/roby/coordination/models/task_from_action.rb', line 47

def to_s
    "action(#{action})[#{model}]"
end