Home | Trees | Indices | Help |
---|
|
1 # Software License Agreement (BSD License) 2 # 3 # Copyright (c) 2012, Fraunhofer FKIE/US, Alexander Tiderko 4 # All rights reserved. 5 # 6 # Redistribution and use in source and binary forms, with or without 7 # modification, are permitted provided that the following conditions 8 # are met: 9 # 10 # * Redistributions of source code must retain the above copyright 11 # notice, this list of conditions and the following disclaimer. 12 # * Redistributions in binary form must reproduce the above 13 # copyright notice, this list of conditions and the following 14 # disclaimer in the documentation and/or other materials provided 15 # with the distribution. 16 # * Neither the name of Fraunhofer nor the names of its 17 # contributors may be used to endorse or promote products derived 18 # from this software without specific prior written permission. 19 # 20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 # POSSIBILITY OF SUCH DAMAGE. 32 from datetime import datetime 33 from python_qt_binding import loadUi 34 from python_qt_binding.QtCore import Signal 35 try: 36 from python_qt_binding.QtGui import QDockWidget 37 except: 38 from python_qt_binding.QtWidgets import QDockWidget 39 import os 40 41 from .rosout_listener import RosoutListener 42 4345 ''' 46 The collect the the warning log messages from rosout and print it in a text 47 browser. 48 ''' 49 50 added_signal = Signal(int, int, int, int) 51 ''' 52 added_signal will be emitted on adding a new log entry. The parameter contains 53 the current count of messages (INFO, WARN, ERROR, FATAL) 54 ''' 55 56 cleared_signal = Signal() 5717059 ''' 60 Creates the window, connects the signals and init the class. 61 ''' 62 QDockWidget.__init__(self, parent) 63 self._log_info_count = 0 64 self._log_warn_count = 0 65 self._log_err_count = 0 66 self._log_fatal_count = 0 67 # load the UI file 68 log_dock_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'LogDockWidget.ui') 69 loadUi(log_dock_file, self) 70 self.setObjectName("LogWidget") 71 self.setFeatures(QDockWidget.DockWidgetFloatable | QDockWidget.DockWidgetMovable | QDockWidget.DockWidgetClosable) 72 # connect to the button signals 73 self.clearCloseButton.clicked.connect(self._on_log_clear_close_clicked) 74 self.closeButton.clicked.connect(self.hide) 75 # initialize the listener to the rosout topic 76 self._rosout_listener = RosoutListener() 77 self._rosout_listener.rosinfo_signal.connect(self._on_roslog_info) 78 self._rosout_listener.roswarn_signal.connect(self._on_roslog_warn) 79 self._rosout_listener.roserr_signal.connect(self._on_roslog_err) 80 self._rosout_listener.rosfatal_signal.connect(self._on_roslog_fatal) 81 self._rosout_listener.registerByROS()8284 ''' 85 Returns the count all current viewed log messages. 86 ''' 87 return self._log_info_count + self._log_warn_count + self._log_err_count + self._log_fatal_count8890 ''' 91 Removes all log messages and emit the `cleared_signal`. 92 ''' 93 self._log_info_count = 0 94 self._log_warn_count = 0 95 self._log_err_count = 0 96 self._log_fatal_count = 0 97 self.textBrowser.clear() 98 self.infoLabel.setText('') 99 self.cleared_signal.emit()100102 ''' 103 Unregister the listener thread from the `/rosout` topic. This method must be 104 called at the exit! 105 ''' 106 self._rosout_listener.stop()107109 # self._log_info_count += 1 110 if self.checkBox_info.isChecked(): 111 text = ('<pre style="padding:10px;"><dt><font color="#000000">' 112 '<b>[INFO]</b> %s (%s:%s:%s):' 113 '<br>%s</font></dt></pre>' % (self._formated_ts(msg.header.stamp), 114 msg.file, msg.function, msg.line, 115 msg.msg)) 116 self.textBrowser.append(text)117 # self._update_info_label() 118120 self._log_warn_count += 1 121 text = ('<pre style="padding:10px;"><dt><font color="#FE9A2E">' 122 '<b>[WARN]</b> %s (%s:%s:%s):' 123 '<br>%s</font></dt></pre>' % (self._formated_ts(msg.header.stamp), 124 msg.file, msg.function, msg.line, 125 msg.msg)) 126 self.textBrowser.append(text) 127 self._update_info_label()128130 self._log_err_count += 1 131 text = ('<pre style="padding:10px;"><dt><font color="#DF0101">' 132 '<b>[ERROR]</b> %s (%s:%s:%s):' 133 '<br>%s</font></dt></pre>' % (self._formated_ts(msg.header.stamp), 134 msg.file, msg.function, msg.line, 135 msg.msg)) 136 self.textBrowser.append(text) 137 self._update_info_label()138140 self._log_fatal_count += 1 141 text = ('<pre style="padding:10px;"><dt><font color="#610B0B">' 142 '<b>[FATAL]</b> %s (%s:%s:%s):' 143 '<br>%s</font></dt></pre>' % (self._formated_ts(msg.header.stamp), 144 msg.file, msg.function, msg.line, 145 msg.msg)) 146 self.textBrowser.append(text) 147 self._update_info_label()148150 self.clear()151 # self.hide() 152154 info_text = '' 155 if self._log_info_count > 0: 156 info_text = '%s INFO: %d ' % (info_text, self._log_info_count) 157 if self._log_warn_count > 0: 158 info_text = '%s WARN: %d ' % (info_text, self._log_warn_count) 159 if self._log_err_count > 0: 160 info_text = '%s ERROR: %d ' % (info_text, self._log_err_count) 161 if self._log_fatal_count > 0: 162 info_text = '%s FATAL: %d' % (info_text, self._log_fatal_count) 163 self.infoLabel.setText(info_text) 164 self.added_signal.emit(self._log_info_count, self._log_warn_count, 165 self._log_err_count, self._log_fatal_count)166
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Sat Jul 18 03:25:15 2020 | http://epydoc.sourceforge.net |