Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 import os
00034
00035 from python_qt_binding import loadUi
00036 from python_qt_binding.QtCore import qWarning
00037 from python_qt_binding.QtGui import QWidget
00038
00039
00040 class LoggerLevelWidget(QWidget):
00041 """
00042 Widget for use with LoggerLevelServiceCaller class to alter the ROS logger levels
00043 """
00044 def __init__(self, caller):
00045 """
00046 :param caller: service caller instance for sending service calls, ''LoggerLevelServiceCaller''
00047 """
00048 super(LoggerLevelWidget, self).__init__()
00049 ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'logger_level.ui')
00050 loadUi(ui_file, self)
00051 self.setObjectName('LoggerLevelWidget')
00052 self._caller = caller
00053
00054 self.node_list.currentRowChanged[int].connect(self.node_changed)
00055 self.logger_list.currentRowChanged[int].connect(self.logger_changed)
00056 self.level_list.currentRowChanged[int].connect(self.level_changed)
00057 self.refresh_button.clicked[bool].connect(self.refresh_nodes)
00058
00059 self.refresh_nodes()
00060 if self.node_list.count() > 0:
00061 self.node_list.setCurrentRow(0)
00062
00063 def refresh_nodes(self):
00064 """
00065 Refreshes the top level node list and repoulates the node_list widget.
00066 As a side effect the level and logger lists are cleared
00067 """
00068 self.level_list.clear()
00069 self.logger_list.clear()
00070 self.node_list.clear()
00071 for name in self._caller.get_node_names():
00072 self.node_list.addItem(name)
00073
00074 def node_changed(self, row):
00075 """
00076 Handles the rowchanged event for the node_list widget
00077 Populates logger_list with the loggers for the node selected
00078 :param row: the selected row in node_list, ''int''
00079 """
00080 if row == -1:
00081 return
00082 if row < 0 or row >= self.node_list.count():
00083 qWarning('Node row %s out of bounds. Current count: %s' % (row, self.node_list.count()))
00084 return
00085 self.logger_list.clear()
00086 self.level_list.clear()
00087 loggers = self._caller.get_loggers(self.node_list.item(row).text())
00088 if len(loggers) == 0:
00089 return
00090 for logger in sorted(loggers):
00091 self.logger_list.addItem(logger)
00092 if self.logger_list.count() != 0:
00093 self.logger_list.setCurrentRow(0)
00094
00095 def logger_changed(self, row):
00096 """
00097 Handles the rowchanged event for the logger_list widget
00098 Populates level_list with the levels for the logger selected
00099 :param row: the selected row in logger_list, ''int''
00100 """
00101 if row == -1:
00102 return
00103 if row < 0 or row >= self.logger_list.count():
00104 qWarning('Logger row %s out of bounds. Current count: %s' % (row, self.logger_list.count()))
00105 return
00106 if self.level_list.count() == 0:
00107 for level in self._caller.get_levels():
00108 self.level_list.addItem(level)
00109 for index in range(self.level_list.count()):
00110 if self.level_list.item(index).text().lower() == self._caller._current_levels[self.logger_list.currentItem().text()].lower():
00111 self.level_list.setCurrentRow(index)
00112
00113 def level_changed(self, row):
00114 """
00115 Handles the rowchanged event for the level_list widget
00116 Makes a service call to change the logger level for the indicated node/logger to the selected value
00117 :param row: the selected row in level_list, ''int''
00118 """
00119 if row == -1:
00120 return
00121 if row < 0 or row >= self.level_list.count():
00122 qWarning('Level row %s out of bounds. Current count: %s' % (row, self.level_list.count()))
00123 return
00124 self._caller.send_logger_change_message(self.node_list.currentItem().text(), self.logger_list.currentItem().text(), self.level_list.item(row).text())