Class: Syskit::Coordination::DataMonitoringTable
- Inherits:
-
Roby::Coordination::Base
- Object
- Roby::Coordination::Base
- Syskit::Coordination::DataMonitoringTable
- Extended by:
- Models::DataMonitoringTable
- Defined in:
- lib/syskit/coordination/data_monitoring_table.rb
Overview
Definition of a data monitoring table
Instance Attribute Summary collapse
-
#monitors ⇒ Array<DataMonitor>
readonly
List of instanciated data monitors.
Instance Method Summary collapse
-
#initialize(root_task, arguments = Hash.new, options = Hash.new) ⇒ DataMonitoringTable
constructor
A new instance of DataMonitoringTable.
-
#poll ⇒ Object
Checks all the monitors for new data, and issue the related errors if their predicate triggers.
-
#ready? ⇒ Boolean
Checks whether the table is attached to all its data sources.
-
#remove! ⇒ void
Untie this table from the task it is currently attached to.
-
#resolve_monitors ⇒ Object
Instanciates all data monitor registered on this table's models and stores the new monitors in #monitors.
Methods included from Models::DataMonitoringTable
all_attachment_point, all_monitor, apply_block, attach_to, attachment_point, each_attachment_point, each_monitor, find_monitor, find_through_method_missing, has_through_method_missing?, monitor, validate_monitors
Constructor Details
#initialize(root_task, arguments = Hash.new, options = Hash.new) ⇒ DataMonitoringTable
Returns a new instance of DataMonitoringTable
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/syskit/coordination/data_monitoring_table.rb', line 55 def initialize(root_task, arguments = Hash.new, = Hash.new) super(root_task, arguments, ) , _ = Kernel. , :on_replace => :drop @poll_id = root_task.poll() do poll end @monitors = Array.new @monitors_resolved = false resolve_monitors end |
Instance Attribute Details
#monitors ⇒ Array<DataMonitor> (readonly)
Returns list of instanciated data monitors
52 53 54 |
# File 'lib/syskit/coordination/data_monitoring_table.rb', line 52 def monitors @monitors end |
Instance Method Details
#poll ⇒ Object
Checks all the monitors for new data, and issue the related errors if their predicate triggers
96 97 98 99 100 |
# File 'lib/syskit/coordination/data_monitoring_table.rb', line 96 def poll monitors.each do |m| m.poll(instance_for(model.root).resolve) end end |
#ready? ⇒ Boolean
Checks whether the table is attached to all its data sources
103 104 105 |
# File 'lib/syskit/coordination/data_monitoring_table.rb', line 103 def ready? @monitors_resolved && monitors.all?(&:ready?) end |
#remove! ⇒ void
This method returns an undefined value.
Untie this table from the task it is currently attached to
It CANNOT be reused afterwards
70 71 72 |
# File 'lib/syskit/coordination/data_monitoring_table.rb', line 70 def remove! root_task.remove_poll_handler(@poll_id) end |
#resolve_monitors ⇒ Object
Instanciates all data monitor registered on this table's models and stores the new monitors in #monitors
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/syskit/coordination/data_monitoring_table.rb', line 76 def resolve_monitors model.each_task do |coordination_task_model| if coordination_task_model.respond_to?(:instanciate) root_task.depends_on(task_instance = coordination_task_model.instanciate(root_task.plan)) bind_coordination_task_to_instance( instance_for(coordination_task_model), task_instance, on_replace: :copy) end end monitors_m = model.each_monitor.to_a model.validate_monitors(monitors_m) root_task.execute do @monitors_resolved = true monitors.concat(monitors_m.map { |m| m.bind(self) }) end end |