Class: Roby::ExecutionEngine::PropagationInfo Private

Inherits:
Struct
  • Object
show all
Defined in:
lib/roby/execution_engine.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Gathering of all the errors that happened during an event processing loop and were not handled

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(called_generators = Set.new, emitted_events = Set.new, kill_tasks = Set.new, fatal_errors = [], nonfatal_errors = [], free_events_errors = [], handled_errors = [], inhibited_errors = [], framework_errors = []) ⇒ PropagationInfo

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PropagationInfo.



1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
# File 'lib/roby/execution_engine.rb', line 1568

def initialize(called_generators = Set.new,
               emitted_events = Set.new,
               kill_tasks = Set.new,
               fatal_errors = [],
               nonfatal_errors = [],
               free_events_errors = [],
               handled_errors = [],
               inhibited_errors = [],
               framework_errors = [])

    self.called_generators  = called_generators.to_set
    self.emitted_events     = emitted_events.to_set
    self.kill_tasks         = kill_tasks.to_set
    self.fatal_errors       = fatal_errors
    self.nonfatal_errors    = nonfatal_errors
    self.free_events_errors = free_events_errors
    self.handled_errors     = handled_errors
    self.inhibited_errors   = inhibited_errors
    self.framework_errors = framework_errors
end

Instance Attribute Details

#called_generatorsObject

Returns the value of attribute called_generators

Returns:

  • (Object)

    the current value of called_generators



1563
1564
1565
# File 'lib/roby/execution_engine.rb', line 1563

def called_generators
  @called_generators
end

#emitted_eventsObject

Returns the value of attribute emitted_events

Returns:

  • (Object)

    the current value of emitted_events



1563
1564
1565
# File 'lib/roby/execution_engine.rb', line 1563

def emitted_events
  @emitted_events
end

#fatal_errorsObject

Returns the value of attribute fatal_errors

Returns:

  • (Object)

    the current value of fatal_errors



1563
1564
1565
# File 'lib/roby/execution_engine.rb', line 1563

def fatal_errors
  @fatal_errors
end

#framework_errorsObject

Returns the value of attribute framework_errors

Returns:

  • (Object)

    the current value of framework_errors



1563
1564
1565
# File 'lib/roby/execution_engine.rb', line 1563

def framework_errors
  @framework_errors
end

#free_events_errorsObject

Returns the value of attribute free_events_errors

Returns:

  • (Object)

    the current value of free_events_errors



1563
1564
1565
# File 'lib/roby/execution_engine.rb', line 1563

def free_events_errors
  @free_events_errors
end

#handled_errorsObject

Returns the value of attribute handled_errors

Returns:

  • (Object)

    the current value of handled_errors



1563
1564
1565
# File 'lib/roby/execution_engine.rb', line 1563

def handled_errors
  @handled_errors
end

#inhibited_errorsObject

Returns the value of attribute inhibited_errors

Returns:

  • (Object)

    the current value of inhibited_errors



1563
1564
1565
# File 'lib/roby/execution_engine.rb', line 1563

def inhibited_errors
  @inhibited_errors
end

#kill_tasksObject

Returns the value of attribute kill_tasks

Returns:

  • (Object)

    the current value of kill_tasks



1563
1564
1565
# File 'lib/roby/execution_engine.rb', line 1563

def kill_tasks
  @kill_tasks
end

#nonfatal_errorsObject

Returns the value of attribute nonfatal_errors

Returns:

  • (Object)

    the current value of nonfatal_errors



1563
1564
1565
# File 'lib/roby/execution_engine.rb', line 1563

def nonfatal_errors
  @nonfatal_errors
end

Instance Method Details

#add_event_emission(event) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1605
1606
1607
# File 'lib/roby/execution_engine.rb', line 1605

def add_event_emission(event)
    emitted_events << event
end

#add_framework_errors(errors) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1678
1679
1680
# File 'lib/roby/execution_engine.rb', line 1678

def add_framework_errors(errors)
    framework_errors.concat(errors)
end

#add_generator_call(generator) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1601
1602
1603
# File 'lib/roby/execution_engine.rb', line 1601

def add_generator_call(generator)
    called_generators << generator
end

#each_called_generator(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1609
1610
1611
# File 'lib/roby/execution_engine.rb', line 1609

def each_called_generator(&block)
    called_generators.each(&block)
end

#each_emitted_event(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1617
1618
1619
# File 'lib/roby/execution_engine.rb', line 1617

def each_emitted_event(&block)
    emitted_events.each(&block)
end

#each_fatal_error(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1630
1631
1632
# File 'lib/roby/execution_engine.rb', line 1630

def each_fatal_error(&block)
    fatal_errors.each(&block)
end

#each_framework_error(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1670
1671
1672
# File 'lib/roby/execution_engine.rb', line 1670

def each_framework_error(&block)
    framework_errors.each(&block)
end

#each_free_events_errors(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1646
1647
1648
# File 'lib/roby/execution_engine.rb', line 1646

def each_free_events_errors(&block)
    free_events_errors.each(&block)
end

#each_handled_error(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1654
1655
1656
# File 'lib/roby/execution_engine.rb', line 1654

def each_handled_error(&block)
    handled_errors.each(&block)
end

#each_inhibited_error(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1662
1663
1664
# File 'lib/roby/execution_engine.rb', line 1662

def each_inhibited_error(&block)
    inhibited_errors.each(&block)
end

#each_nonfatal_error(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1638
1639
1640
# File 'lib/roby/execution_engine.rb', line 1638

def each_nonfatal_error(&block)
    nonfatal_errors.each(&block)
end

#exceptionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the exception objects registered in this result object



1626
1627
1628
# File 'lib/roby/execution_engine.rb', line 1626

def exceptions
    fatal_errors.map(&:first) + nonfatal_errors.map(&:first) + free_events_errors.map(&:first)
end

#has_called_generators?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


1613
1614
1615
# File 'lib/roby/execution_engine.rb', line 1613

def has_called_generators?
    !called_generators.empty?
end

#has_emitted_events?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


1621
1622
1623
# File 'lib/roby/execution_engine.rb', line 1621

def has_emitted_events?
    !emitted_events.empty?
end

#has_fatal_errors?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


1634
1635
1636
# File 'lib/roby/execution_engine.rb', line 1634

def has_fatal_errors?
    !fatal_errors.empty?
end

#has_framework_errors?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


1674
1675
1676
# File 'lib/roby/execution_engine.rb', line 1674

def has_framework_errors?
    !framework_errors.empty?
end

#has_free_events_errors?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


1650
1651
1652
# File 'lib/roby/execution_engine.rb', line 1650

def has_free_events_errors?
    !free_events_errors.empty?
end

#has_handled_errors?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


1658
1659
1660
# File 'lib/roby/execution_engine.rb', line 1658

def has_handled_errors?
    !handled_errors.empty?
end

#has_inhibited_errors?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


1666
1667
1668
# File 'lib/roby/execution_engine.rb', line 1666

def has_inhibited_errors?
    !inhibited_errors.empty?
end

#has_nonfatal_errors?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


1642
1643
1644
# File 'lib/roby/execution_engine.rb', line 1642

def has_nonfatal_errors?
    !nonfatal_errors.empty?
end

#merge(results) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
# File 'lib/roby/execution_engine.rb', line 1589

def merge(results)
    self.called_generators.merge(results.called_generators)
    self.emitted_events.merge(results.emitted_events)
    self.kill_tasks.merge(results.kill_tasks)
    self.fatal_errors.concat(results.fatal_errors)
    self.nonfatal_errors.concat(results.nonfatal_errors)
    self.free_events_errors.concat(results.free_events_errors)
    self.handled_errors.concat(results.handled_errors)
    self.inhibited_errors.concat(results.inhibited_errors)
    self.framework_errors.concat(results.framework_errors)
end

#pp_emitted_events(pp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
# File 'lib/roby/execution_engine.rb', line 1727

def pp_emitted_events(pp)
    return if emitted_events.empty?

    pp.text "received #{emitted_events.size} events:"
    by_task =
        emitted_events
        .group_by { |ev| ev.task if ev.respond_to?(:task) }

    by_task.each do |task, events|
        next unless task

        pp.nest(2) do
            pp.breakable
            pp_task_events(pp, task, events)
        end
    end

    by_task[nil]&.each do |event|
        pp.breakable
        pp_event(pp, event)
    end
end

#pp_event(pp, event) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1764
1765
1766
1767
# File 'lib/roby/execution_engine.rb', line 1764

def pp_event(pp, event)
    time_s = Roby.format_time(event.time)
    pp.text "event '#{event}' emitted at [#{time_s} @#{event.propagation_id}]"
end

#pp_task_events(pp, task, events) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
# File 'lib/roby/execution_engine.rb', line 1750

def pp_task_events(pp, task, events)
    pp.text "From "
    task.pretty_print(pp)

    pp.nest(2) do
        events.each do |ev|
            pp.breakable
            time_s = Roby.format_time(ev.time)
            pp.text "event '#{ev.symbol}' emitted at [#{time_s} " \
                    "@#{ev.propagation_id}]"
        end
    end
end

#pretty_print(pp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
# File 'lib/roby/execution_engine.rb', line 1682

def pretty_print(pp)
    pp_emitted_events(pp)

    exceptions = self.exceptions
    unless exceptions.empty?
        pp.breakable unless emitted_events.empty?
        pp.text "#{exceptions.size} unhandled exceptions:"
        pp.nest(2) do
            exceptions.map do |e|
                pp.breakable
                e.pretty_print(pp)
            end
        end
    end
    unless handled_errors.empty?
        pp.breakable if !emitted_events.empty? || !exceptions.empty?
        pp.text "#{handled_errors.size} handled exceptions:"
        pp.nest(2) do
            handled_errors.each do |e, handled_by|
                pp.breakable
                e.pretty_print(pp)
                pp.breakable
                pp.text "Handled by:"
                pp.nest(2) do
                    handled_by.each do |t|
                        pp.breakable
                        t.pretty_print(pp)
                    end
                end
            end
        end
    end
    unless framework_errors.empty?
        pp.breakable if !emitted_events.empty? || !exceptions.empty? || !handled_errors.empty?
        pp.text "#{framework_errors.size} framework errors"
        pp.nest(2) do
            framework_errors.each do |e, source|
                pp.breakable
                pp.text "from #{source}: "
                e.pretty_print(pp)
            end
        end
    end
end