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.



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

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

Instance Attribute Details

#actionRoby::Actions::Action

The associated action



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

def action
  @action
end

Instance Method Details

#action_coordination_modelnil, Base

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

Returns:



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

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

#instanciate(plan, variables = Hash.new) ⇒ Object

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



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

def instanciate(plan, variables = Hash.new)
    arguments = action.arguments.map_value do |key, 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



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

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



45
# File 'lib/roby/coordination/models/task_from_action.rb', line 45

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