Module: Roby::Coordination::Script
Overview
Common logic for script-based coordination models
Defined Under Namespace
Modules: Models
Classes: BlockExecute, PollUntil, TimedOut, TimeoutStart, TimeoutStop
Constant Summary
collapse
- DeadInstruction =
Models::Script::DeadInstruction
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#current_instruction ⇒ Object
Returns the value of attribute current_instruction.
131
132
133
|
# File 'lib/roby/coordination/script.rb', line 131
def current_instruction
@current_instruction
end
|
#instructions ⇒ Object
Returns the value of attribute instructions.
133
134
135
|
# File 'lib/roby/coordination/script.rb', line 133
def instructions
@instructions
end
|
Instance Method Details
#dependency_options_for(toplevel, task, roles) ⇒ Object
154
155
156
157
158
159
160
|
# File 'lib/roby/coordination/script.rb', line 154
def dependency_options_for(toplevel, task, roles)
options = super
if current_instruction.respond_to?(:task) && current_instruction.task == task
options = options.merge(current_instruction.dependency_options)
end
options
end
|
#finished? ⇒ Boolean
195
196
197
|
# File 'lib/roby/coordination/script.rb', line 195
def finished?
instructions.empty? && !@current_instruction
end
|
#jump_to(target) ⇒ Object
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
# File 'lib/roby/coordination/script.rb', line 180
def jump_to(target)
if current_instruction != target && !instructions.find { |ins| ins == target }
raise ArgumentError, "#{target} is not an instruction in #{self}"
end
if current_instruction != target
current_instruction.cancel
end
while instructions.first != target
instructions.shift
end
step
end
|
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/roby/coordination/script.rb', line 135
def prepare
@instructions = Array.new
resolve_instructions
@current_instruction = nil
root_task.stop_event.on do |context|
current_instruction.cancel if current_instruction
instructions.each do |ins|
ins.cancel
end
end
end
|
#resolve_instructions ⇒ Object
148
149
150
151
152
|
# File 'lib/roby/coordination/script.rb', line 148
def resolve_instructions
model.instructions.each do |ins|
instructions << instance_for(ins)
end
end
|
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/roby/coordination/script.rb', line 162
def step
if current_instruction && !current_instruction.disabled?
return
end
while @current_instruction = instructions.shift
if !current_instruction.disabled?
if !current_instruction.execute(self)
break
end
end
end
rescue LocalizedError => e
raise e
rescue Exception => e
raise CodeError.new(e, root_task), e.message, e.backtrace
end
|