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 = {}) ⇒ 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.
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
#action ⇒ Roby::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_model ⇒ nil, Base
Returns the action’s underlying coordination model if there is one
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_s ⇒ Object
47 48 49 |
# File 'lib/roby/coordination/models/task_from_action.rb', line 47 def to_s "action(#{action})[#{model}]" end |