class Syskit::Coordination::DataMonitoringTable
Definition of a data monitoring table
@example Define a data monitoring table that attaches to all tasks of a given type
module Asguard data_monitoring_table 'TrajectoryFollowing' do attach_to ControlLoop.specialized_on 'controller' => TrajectoryFollower::Task monitor('pose', pose_child.pose_samples_port). trigger_on do |pose| # Verify that pose is within reasonable bounds of trajectory end. raise_exception end # Later, in an action interface file class Main < Roby::Actions::Interface use_data_monitoring_table Asguard::TrajectoryFollowing end end
@example Define a standalone monitoring subsystem
module Asguard class LowLevelMonitor < Syskit::Composition add BatteryStatusSrv, :as => 'battery_provider' data_monitoring_table do monitor('battery_level', battery_provider_child.battery_status_port). trigger_on do |battery_status| battery_status.level < Robot.battery_required_to_reach_base end. raise_exception end end end # Later, in a profile definition define 'low_level_monitor', Asguard::LowLevelMonitor.use(battery_dev)
@example Use a data monitoring table in a fault response table
module Asguard fault_response_table 'Safing' do use_data_monitoring_table LowLevelMonitor on_fault battery_level_monitor do go_recharge end end end
Attributes
monitors[R]
@return [Array<DataMonitor>] list of instanciated data monitors
Public Class Methods
new(root_task, arguments = Hash.new, options = Hash.new)
click to toggle source
(see Roby::Coordination::Base)
Calls superclass method
# File lib/syskit/coordination/data_monitoring_table.rb, line 55 def initialize(root_task, arguments = Hash.new, options = Hash.new) super(root_task, arguments, options) options, _ = Kernel.filter_options options, :on_replace => :drop @poll_id = root_task.poll(options) do poll end @monitors = Array.new @monitors_resolved = false resolve_monitors end
Public Instance Methods
poll()
click to toggle source
Checks all the monitors for new data, and issue the related errors if their predicate triggers
# 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?()
click to toggle source
Checks whether the table is attached to all its data sources
# File lib/syskit/coordination/data_monitoring_table.rb, line 103 def ready? @monitors_resolved && monitors.all?(&:ready?) end
remove!()
click to toggle source
Untie this table from the task it is currently attached to
It CANNOT be reused afterwards @return [void]
# File lib/syskit/coordination/data_monitoring_table.rb, line 70 def remove! root_task.remove_poll_handler(@poll_id) end
resolve_monitors()
click to toggle source
Instanciates all data monitor registered on this table's models and stores the new monitors in {#monitors}
# 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