Added confirmation MessageBox when starting robot. Also commands logger shows time instead of message counter
This commit is contained in:
parent
630edc000e
commit
a3061fa7d3
@ -4,18 +4,19 @@ import rospy
|
|||||||
import rospkg
|
import rospkg
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
import datetime
|
||||||
|
|
||||||
from enums.clutch_state import ClutchState as CS
|
from enums.clutch_state import ClutchState as CS
|
||||||
from enums.stop_state import StopState as SS
|
from enums.stop_state import StopState as SS
|
||||||
|
|
||||||
from python_qt_binding.QtGui import QPixmap
|
from python_qt_binding.QtGui import QPixmap
|
||||||
|
from python_qt_binding.QtWidgets import QMessageBox
|
||||||
|
|
||||||
|
|
||||||
class QtWrapper:
|
class QtWrapper:
|
||||||
|
|
||||||
def __init__(self,widget):
|
def __init__(self,widget):
|
||||||
self.widget = widget
|
self.widget = widget
|
||||||
self.logger_counter = 0
|
|
||||||
self.displayed_robots_id_list = []
|
self.displayed_robots_id_list = []
|
||||||
|
|
||||||
self.clear_robot_info()
|
self.clear_robot_info()
|
||||||
@ -30,7 +31,7 @@ class QtWrapper:
|
|||||||
|
|
||||||
def connect_robot_signals(self):
|
def connect_robot_signals(self):
|
||||||
self.widget.clutchButton.clicked.connect(self.handle_clutchButton_clicked_callback)
|
self.widget.clutchButton.clicked.connect(self.handle_clutchButton_clicked_callback)
|
||||||
self.widget.stopButton.clicked.connect(self.handle_stopButton_clicked_callback)
|
self.widget.stopButton.clicked.connect(self.handle_stopButton_clicked)
|
||||||
self.widget.choiceButton.clicked.connect(self.handle_closeButton_clicked)
|
self.widget.choiceButton.clicked.connect(self.handle_closeButton_clicked)
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
@ -50,6 +51,16 @@ class QtWrapper:
|
|||||||
method_with_argument = 'self.{0}({1})'.format(method_name,argument[0])
|
method_with_argument = 'self.{0}({1})'.format(method_name,argument[0])
|
||||||
exec(method_with_argument)
|
exec(method_with_argument)
|
||||||
|
|
||||||
|
def handle_stopButton_clicked(self):
|
||||||
|
if self.robot_state == SS.RUNNING:
|
||||||
|
self.handle_stopButton_clicked_callback()
|
||||||
|
else:
|
||||||
|
reply = QMessageBox.warning(self.widget,"UWAGA","Na pewno chcesz odblokowac robota?",QMessageBox.Yes,QMessageBox.No)
|
||||||
|
|
||||||
|
if reply == QMessageBox.Yes:
|
||||||
|
self.handle_stopButton_clicked_callback()
|
||||||
|
|
||||||
|
|
||||||
def get_selected_robot_id(self):
|
def get_selected_robot_id(self):
|
||||||
current_text = self.widget.robotsList.currentText()
|
current_text = self.widget.robotsList.currentText()
|
||||||
|
|
||||||
@ -60,23 +71,25 @@ class QtWrapper:
|
|||||||
|
|
||||||
def display_clutch_on(self):
|
def display_clutch_on(self):
|
||||||
self.widget.clutchLabel.setPixmap(self.ok_pixmap.scaled(40,40))
|
self.widget.clutchLabel.setPixmap(self.ok_pixmap.scaled(40,40))
|
||||||
self.widget.clutchButton.setStyleSheet("QPushButton { color: black; background-color: green; font: bold 24px}")
|
self.widget.clutchButton.setStyleSheet("QPushButton { color: black; background-color: green; font: bold 20px}")
|
||||||
self.widget.clutchButton.setText('Rozlacz sprzeglo')
|
self.widget.clutchButton.setText('Rozlacz sprzeglo')
|
||||||
|
|
||||||
def display_clutch_off(self):
|
def display_clutch_off(self):
|
||||||
self.widget.clutchLabel.setPixmap(self.cancel_pixmap.scaled(40,40))
|
self.widget.clutchLabel.setPixmap(self.cancel_pixmap.scaled(40,40))
|
||||||
self.widget.clutchButton.setStyleSheet("QPushButton { color: black; background-color: red; font: bold 24px}")
|
self.widget.clutchButton.setStyleSheet("QPushButton { color: black; background-color: red; font: bold 20px}")
|
||||||
self.widget.clutchButton.setText('Polacz sprzeglo')
|
self.widget.clutchButton.setText('Polacz sprzeglo')
|
||||||
|
|
||||||
def display_state_on(self):
|
def display_state_on(self):
|
||||||
self.widget.stateLabel.setPixmap(self.ok_pixmap.scaled(40,40))
|
self.widget.stateLabel.setPixmap(self.ok_pixmap.scaled(40,40))
|
||||||
self.widget.stopButton.setStyleSheet("QPushButton { color: black; background-color: green; font: bold 24px}")
|
self.widget.stopButton.setStyleSheet("QPushButton { color: black; background-color: green; font: bold 20px}")
|
||||||
self.widget.stopButton.setText('Zatrzymaj robota')
|
self.widget.stopButton.setText('Zatrzymaj robota')
|
||||||
|
self.robot_state = SS.RUNNING
|
||||||
|
|
||||||
def display_state_off(self):
|
def display_state_off(self):
|
||||||
self.widget.stateLabel.setPixmap(self.cancel_pixmap.scaled(40,40))
|
self.widget.stateLabel.setPixmap(self.cancel_pixmap.scaled(40,40))
|
||||||
self.widget.stopButton.setStyleSheet("QPushButton { color: black; background-color: red; font: bold 24px}")
|
self.widget.stopButton.setStyleSheet("QPushButton { color: black; background-color: red; font: bold 20px}")
|
||||||
self.widget.stopButton.setText('Odblokuj robota')
|
self.widget.stopButton.setText('Odblokuj robota')
|
||||||
|
self.robot_state = SS.STOPPED
|
||||||
|
|
||||||
def handle_not_selected_error(self):
|
def handle_not_selected_error(self):
|
||||||
self.log_error('Najpierw wybierz PIONIERA z listy robotow')
|
self.log_error('Najpierw wybierz PIONIERA z listy robotow')
|
||||||
@ -206,20 +219,20 @@ class QtWrapper:
|
|||||||
self.widget.angularRestrictionLabel.setText("{:.2f}".format(restrictions.angular_velocity))
|
self.widget.angularRestrictionLabel.setText("{:.2f}".format(restrictions.angular_velocity))
|
||||||
|
|
||||||
def log_info(self,info_text):
|
def log_info(self,info_text):
|
||||||
self.logger_counter += 1
|
time = datetime.datetime.now().strftime('[%H:%M:%S]')
|
||||||
self.widget.logsBrowser.insertHtml('<font color="black">' + str(self.logger_counter) + '. ' + info_text + '</font><br>')
|
self.widget.logsBrowser.insertHtml('<font color="black">' + str(time) + '. ' + info_text + '</font><br>')
|
||||||
self.scroll_to_bottom()
|
self.scroll_to_bottom()
|
||||||
# self.widget.logsBrowser.insertHtml(str(self.logger_counter) + '\t[INFO]\t' + info_text)
|
# self.widget.logsBrowser.insertHtml(str(self.logger_counter) + '\t[INFO]\t' + info_text)
|
||||||
|
|
||||||
def log_warning(self,warning_text):
|
def log_warning(self,warning_text):
|
||||||
self.logger_counter += 1
|
time = datetime.datetime.now().strftime('[%H:%M:%S]')
|
||||||
self.widget.logsBrowser.insertHtml('<font color="orange">' + str(self.logger_counter) + '. ' + warning_text + '</font><br> ')
|
self.widget.logsBrowser.insertHtml('<font color="orange">' + str(time) + '. ' + warning_text + '</font><br> ')
|
||||||
self.scroll_to_bottom()
|
self.scroll_to_bottom()
|
||||||
# self.widget.logsBrowser.append(str(self.logger_counter) + '\t[WARN]\t' + warning_text)
|
# self.widget.logsBrowser.append(str(self.logger_counter) + '\t[WARN]\t' + warning_text)
|
||||||
|
|
||||||
def log_error(self,error_text):
|
def log_error(self,error_text):
|
||||||
self.logger_counter += 1
|
time = datetime.datetime.now().strftime('[%H:%M:%S]')
|
||||||
self.widget.logsBrowser.insertHtml('<font color="red">' + str(self.logger_counter) + '. ' + error_text + '</font><br>')
|
self.widget.logsBrowser.insertHtml('<font color="red">' + str(time) + '. ' + error_text + '</font><br>')
|
||||||
self.scroll_to_bottom()
|
self.scroll_to_bottom()
|
||||||
# self.widget.logsBrowser.append(str(self.logger_counter) + '\t[ERROR]\t' + error_text)
|
# self.widget.logsBrowser.append(str(self.logger_counter) + '\t[ERROR]\t' + error_text)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user