Exception: Syskit::TaskAllocationFailed

Inherits:
SpecError show all
Defined in:
lib/syskit/exceptions.rb

Overview

Exception raised when we could not find concrete implementations for abstract tasks that are in the plan

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine, still_abstract) ⇒ TaskAllocationFailed

Creates a new TaskAllocationFailed exception for the given tasks.

tasks is a mapping from the abstract tasks to the possible candidate implementation for these tasks, i.e.

t => [model0, model1, ...]


295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/syskit/exceptions.rb', line 295

def initialize(engine, still_abstract)
    @abstract_tasks = Hash.new

    still_abstract.each do |task|
        if task.placeholder?
            component_models = Syskit::Component.each_submodel.to_a
            per_service_candidates = task.proxied_data_service_models.map do |m|
                component_models.find_all do |component_m|
                    !component_m.abstract? &&
                        !component_m.private_specialization? &&
                        component_m.fullfills?(m)
                end.to_set
            end
            candidates = per_service_candidates.inject { |a, b| a & b } || Set.new
        else
            candidates = task.plan.find_local_tasks(task.concrete_model).not_abstract.to_set
        end

        parents = task.
            enum_for(:each_parent_object, Roby::TaskStructure::Dependency).
            map do |parent_task|
                options = parent_task[task,
                    Roby::TaskStructure::Dependency]
                [options[:roles], parent_task]
            end
        abstract_tasks[task] = [parents, candidates]
    end
end

Instance Attribute Details

#abstract_tasksObject (readonly)

A task to [parents, candidates] mapping for the failed allocations



286
287
288
# File 'lib/syskit/exceptions.rb', line 286

def abstract_tasks
  @abstract_tasks
end

Instance Method Details

#pretty_print(pp) ⇒ Object



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/syskit/exceptions.rb', line 324

def pretty_print(pp)
    pp.text "cannot find a concrete implementation for #{abstract_tasks.size} task(s)"

    abstract_tasks.each do |task, (parents, candidates)|
        pp.breakable
        pp.text "#{task.to_s.gsub(/Syskit::/, '')}"
        pp.nest(2) do
            pp.breakable
            if candidates
                if candidates.empty?
                    pp.text "no candidates"
                else
                    pp.text "#{candidates.size} candidates"
                    pp.nest(2) do
                        pp.breakable
                        pp.seplist(candidates) do |c_task|
                            pp.text "#{c_task.short_name}"
                        end
                    end
                end
            end
            pp.breakable
            pp.seplist(parents) do |parent|
                role, parent = parent
                pp.text "child #{role.to_a.first} of #{parent.to_s.gsub(/Syskit::/, '')}"
            end
        end
    end
end