Class: RuntimeDisplay

Inherits:
Qt::MainWindow
  • Object
show all
Defined in:
lib/roby/log/gui/runtime.rb

Constant Summary collapse

DISPLAY_MINIMUM_DURATION =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(broadcast, port, period) ⇒ RuntimeDisplay

Returns a new instance of RuntimeDisplay.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/roby/log/gui/runtime.rb', line 60

def initialize(broadcast, port, period)
  super()

  # Create the vertical layout for this window
  central_widget = Qt::Widget.new(self)
  self.central_widget = central_widget
  layout = Qt::VBoxLayout.new(central_widget)
  layout.spacing = 6
  layout.margin  = 0

  # add GUI for the data streams and display setup
  @streams = Array.new
  @streams_model  = RemoteStreamListModel.new(streams)
  displays_holder = Qt::Widget.new(central_widget)
  layout.add_widget displays_holder
  @ui_displays = Ui_DataDisplays.new
  ui_displays.setupUi(displays_holder)
  ui_displays.streams.model = streams_model
  ui_displays.add_stream.enabled = false
  ui_displays.remove_stream.enabled = false
  connect(ui_displays.display_add, SIGNAL("clicked()"), self, SLOT("add_display()"))

  # Set up the stream discovery
  Roby::Log::Server.enable_discovery(broadcast, port, period)

  # This timer is used to call Thread.pass ... of course needed or Ruby
  # threads won't be woken up
  Thread.current.priority = -1

  @threads_timer = Qt::Timer.new(self)
  connect(@threads_timer, SIGNAL('timeout()')) do
 Thread.pass
  end
  @threads_timer.start(50)

  @display_timer = Qt::Timer.new(self)
  connect(@display_timer, SIGNAL('timeout()')) do
 streams.each do |s|
    s.synchronize do
  s.display
    end
 end
  end
  @display_timer.start(5000)

  sleep(0.5)
  streams_model.update

  @discovery_timer = Qt::Timer.new(self)
  connect(@discovery_timer, SIGNAL('timeout()')) do
 streams_model.update
  end
  @discovery_timer.start(Integer(period * 1000))
end

Instance Attribute Details

#streamsObject (readonly)

Returns the value of attribute streams.



55
56
57
# File 'lib/roby/log/gui/runtime.rb', line 55

def streams
  @streams
end

#streams_modelObject (readonly)

Returns the value of attribute streams_model.



56
57
58
# File 'lib/roby/log/gui/runtime.rb', line 56

def streams_model
  @streams_model
end

#ui_displaysObject (readonly)

Returns the value of attribute ui_displays.



53
54
55
# File 'lib/roby/log/gui/runtime.rb', line 53

def ui_displays
  @ui_displays
end

Instance Method Details

#add_display(kind = nil) ⇒ Object



115
116
117
# File 'lib/roby/log/gui/runtime.rb', line 115

def add_display(kind = nil)
  ui_displays.add_display(streams_model, kind)
end