Class: Roby::Coordination::Models::TaskFromAction
- Inherits:
-
TaskWithDependencies
- Object
- Task
- TaskWithDependencies
- Roby::Coordination::Models::TaskFromAction
- Defined in:
- lib/roby/coordination/models/task_from_action.rb
Overview
A representation of a state based on an action
Instance Attribute Summary collapse
-
#action ⇒ Roby::Actions::Action
The associated action.
Attributes inherited from TaskWithDependencies
Attributes inherited from Task
Instance Method Summary collapse
-
#action_coordination_model ⇒ nil, Base
Returns the action’s underlying coordination model if there is one.
-
#initialize(action) ⇒ TaskFromAction
constructor
A new instance of TaskFromAction.
-
#instanciate(plan, variables = Hash.new) ⇒ Object
Generates a task for this state in the given plan and returns it.
-
#rebind(coordination_model) ⇒ Object
Rebind this task to refer to a different action interface.
- #to_s ⇒ Object
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
#action ⇒ Roby::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_model ⇒ nil, Base
Returns the action’s underlying coordination model if there is one
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_s ⇒ Object
45 |
# File 'lib/roby/coordination/models/task_from_action.rb', line 45 def to_s; "action(#{action})[#{model}]" end |