class Roby::Interface::Async::UIConnector
Creates a connection between a Syskit job and a Qt-based GUI
A job is a placeholder for an action with some arguments set. It is created by {Interface#connect_to_ui}. More than one job can exist based on a given action (as long as they differ by their arguments), but a given job can be started by the GUI
only once.
@example represent an action with some argument(s) set
action = <name_of_action>!(x: 10)
@example start a job from an action when a button is pressed
connect widget, SIGNAL('clicked()'), START(action)
@example allow a job to be restarted (otherwise an existing job must be manually killed first)
connect widget, SIGNAL('clicked()'), START(action), restart: true
@example kill the job when a button is pressed
connect widget, SIGNAL('clicked()'), KILL(action)
@example call a block with a job monitoring object when its state changes
connect PROGRESS(job) do |action| # 'action' is an ActionMonitor end
@example set an action's argument from a signal (by default, requires the user to press the 'start' button afterwards)
connect widget, SIGNAL('textChanged(QString)'), ARGUMENT(action,:z), getter: ->(z) { Integer(z) }
@example set an action's argument from a signal, and restart the action right away
connect widget, SIGNAL('textChanged(QString)'), ARGUMENT(action,:z), getter: ->(z) { Integer(z) }, auto_apply: true
Constants
- ActionConnector
Attributes
Public Class Methods
# File lib/roby/interface/async/ui_connector.rb, line 107 def initialize(interface, widget) @interface = interface @widget = widget end
Public Instance Methods
# File lib/roby/interface/async/ui_connector.rb, line 158 def ARGUMENT(action, argument_name) SetArgumentCommand.new(self, action, argument_name) end
# File lib/roby/interface/async/ui_connector.rb, line 146 def DROP(action) DropCommand.new(self, action) end
# File lib/roby/interface/async/ui_connector.rb, line 150 def KILL(action) KillCommand.new(self, action) end
# File lib/roby/interface/async/ui_connector.rb, line 154 def PROGRESS(action) ProgressMonitorCommand.new(self, action) end
# File lib/roby/interface/async/ui_connector.rb, line 142 def START(action) StartCommand.new(self, action) end
# File lib/roby/interface/async/ui_connector.rb, line 120 def connect(*args, &block) if args.first.kind_of?(Qt::Widget) # Signature from a widget's signal to Syskit widget = args.shift signal = args.shift action = args.shift action.options = args.shift || Hash.new if widget.respond_to?(:to_widget) widget = widget.to_widget end widget.connect(signal) do |*args| action.run(*args) end else # Signature from syskit to a block action = args.shift action.options = args.shift action.callback = block action.connect end end
# File lib/roby/interface/async/ui_connector.rb, line 166 def method_missing(m, *args, &block) if m =~ /!$/ ActionMonitor.new(interface, m.to_s[0..-2], *args) elsif widget.respond_to?(m) widget.public_send(m, *args, &block) else super end end
# File lib/roby/interface/async/ui_connector.rb, line 112 def on_reachable(&block) interface.on_reachable(&block) end
# File lib/roby/interface/async/ui_connector.rb, line 116 def on_unreachable(&block) interface.on_unreachable(&block) end
# File lib/roby/interface/async/ui_connector.rb, line 162 def respond_to_missing?(m, include_private = false) (m =~ /!$/) || widget.respond_to?(m) end
# File lib/roby/interface/async/ui_connector.rb, line 176 def to_widget widget end