Class: Roby::Log::NotificationsDisplay
- Inherits:
-
Qt::TextBrowser
- Object
- Qt::TextBrowser
- Roby::Log::NotificationsDisplay
show all
- Includes:
- DataDisplay
- Defined in:
- lib/roby/log/notifications.rb
Constant Summary
collapse
- STYLESHEET =
" h1 { font-size: large; }\n h1 { margin-bottom: 3px; }\n h2 { font-size: medium; }\n .time { \n margin-right: 10px; \n }\n\n div.info {\n color: black;\n margin-top: 20px;\n border-top: thin solid black;\n }\n div.info h1 { margin-top: 0; background-color: #5FB86A; }\n div.warn { \n color: black;\n margin-top: 20px;\n border-top: thin solid black; \n }\n div.warn h1 { margin-top: 0; background-color: #B8AC5F; }\n div.error { \n color: black;\n margin-top: 20px;\n border-top: thin solid black; \n }\n div.error h1 { margin-top: 0; background-color: #B8937D; }\n"
Instance Attribute Summary collapse
Attributes included from DataDisplay
#config_ui, #decoder, #main
Instance Method Summary
collapse
-
#added_mission(time, task) ⇒ Object
-
#clear ⇒ Object
-
#failed_task(time, task, history) ⇒ Object
-
#fatal_exception(time, error, tasks) ⇒ Object
-
#finalized_pending(time, task) ⇒ Object
-
#handled_exception(time, error, tasks) ⇒ Object
-
#initialize ⇒ NotificationsDisplay
constructor
A new instance of NotificationsDisplay.
-
#overly_long_call(time, duration, task, event_name, context) ⇒ Object
-
#removed_mission(time, task) ⇒ Object
-
#render_error(error, tasks) ⇒ Object
-
#render_event(kind, time, title) ⇒ Object
-
#render_history(history) ⇒ Object
-
#render_task(task) ⇒ Object
#splat?, #stream=
Constructor Details
Returns a new instance of NotificationsDisplay.
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/roby/log/notifications.rb', line 138
def initialize
super()
resize(500, 600)
@main = self
@document = Qt::TextDocument.new
self.document = document
document.setDefaultStyleSheet(STYLESHEET)
end
|
Instance Attribute Details
Returns the value of attribute document.
107
108
109
|
# File 'lib/roby/log/notifications.rb', line 107
def document
@document
end
|
Returns the value of attribute text.
108
109
110
|
# File 'lib/roby/log/notifications.rb', line 108
def text
@text
end
|
Instance Method Details
#added_mission(time, task) ⇒ Object
193
194
195
196
197
|
# File 'lib/roby/log/notifications.rb', line 193
def added_mission(time, task)
render_event("info", time, "New mission") do
render_task(task)
end
end
|
184
185
186
|
# File 'lib/roby/log/notifications.rb', line 184
def clear
document.clear
end
|
#failed_task(time, task, history) ⇒ Object
229
230
231
232
233
234
|
# File 'lib/roby/log/notifications.rb', line 229
def failed_task(time, task, history)
render_event("warn", time, "Failed task") do
render_task(task)
render_history(history)
end
end
|
#fatal_exception(time, error, tasks) ⇒ Object
219
220
221
222
223
|
# File 'lib/roby/log/notifications.rb', line 219
def fatal_exception(time, error, tasks)
render_event("error", time, "Fatal exception") do
render_error(error, tasks)
end
end
|
#finalized_pending(time, task) ⇒ Object
188
189
190
191
192
|
# File 'lib/roby/log/notifications.rb', line 188
def finalized_pending(time, task)
render_event("warn", time, "Finalized pending task") do
render_task(task)
end
end
|
#handled_exception(time, error, tasks) ⇒ Object
224
225
226
227
228
|
# File 'lib/roby/log/notifications.rb', line 224
def handled_exception(time, error, tasks)
render_event("warn", time, "Handled exception") do
render_error(error, tasks)
end
end
|
#overly_long_call(time, duration, task, event_name, context) ⇒ Object
235
236
237
238
239
240
|
# File 'lib/roby/log/notifications.rb', line 235
def overly_long_call(time, duration, task, event_name, context)
render_event("warn", time, "Overly long call: ") do
text << "Call of #{event_name}(#{context}) lasted #{Integer(duration * 1000)}ms in<br>"
render_task(task)
end
end
|
#removed_mission(time, task) ⇒ Object
198
199
200
201
202
|
# File 'lib/roby/log/notifications.rb', line 198
def removed_mission(time, task)
render_event("info", time, "Removed mission") do
render_task(task)
end
end
|
#render_error(error, tasks) ⇒ Object
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
# File 'lib/roby/log/notifications.rb', line 203
def render_error(error, tasks)
error = Qt.escape(error.to_s)
error = error.split("\n").map do |line|
line.gsub(/^\s+/) { " " * $&.size }
end.join("<br>")
text << error
text << "<h2>Involved tasks</h2>"
text << "<ul>"
tasks.each do |t|
text << "<li>"
render_task(t)
text << "</li>"
end
end
|
#render_event(kind, time, title) ⇒ Object
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/roby/log/notifications.rb', line 150
def render_event(kind, time, title)
@text = ""
text << "\n<div class=#{kind}>\n <h1><span class=\"time\">#{time.to_hms}</span> #{title}</h1>\n "
yield
ensure
text << "\n</div>"
insertHtml(text)
verticalScrollBar.value = verticalScrollBar.maximum
end
|
#render_history(history) ⇒ Object
176
177
178
179
180
181
182
|
# File 'lib/roby/log/notifications.rb', line 176
def render_history(history)
text << "<ul class=\"history\">\n"
history.each do |generator, id, time, context|
text << "<li>#{time.to_hms} #{generator.symbol} [#{context}]</li>"
end
text << "</ul>"
end
|
#render_task(task) ⇒ Object
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/roby/log/notifications.rb', line 161
def render_task(task)
remote_siblings = "{ " << task.remote_siblings.map { |peer, id| id.to_s(peer) }.join(", ") << " }"
text << "<div class=\"task\">
#{task.model.ancestors.first.first}#{remote_siblings}\n "
unless task.arguments.empty?
text << "<ul class=\"task-arguments\">\n "
task.arguments.each do |key, value|
text << " <li>#{key}: #{value}<li>\n"
end
text << " </ul>\n"
end
text << "</div>"
end
|