diff --git a/safety_user_plugin/scripts/qt_wrapper.py b/safety_user_plugin/scripts/qt_wrapper.py
index b91b801..4b0c71f 100644
--- a/safety_user_plugin/scripts/qt_wrapper.py
+++ b/safety_user_plugin/scripts/qt_wrapper.py
@@ -4,18 +4,19 @@ import rospy
import rospkg
import math
+import datetime
from enums.clutch_state import ClutchState as CS
from enums.stop_state import StopState as SS
from python_qt_binding.QtGui import QPixmap
+from python_qt_binding.QtWidgets import QMessageBox
class QtWrapper:
def __init__(self,widget):
self.widget = widget
- self.logger_counter = 0
self.displayed_robots_id_list = []
self.clear_robot_info()
@@ -30,7 +31,7 @@ class QtWrapper:
def connect_robot_signals(self):
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)
def connect_signals(self):
@@ -50,6 +51,16 @@ class QtWrapper:
method_with_argument = 'self.{0}({1})'.format(method_name,argument[0])
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):
current_text = self.widget.robotsList.currentText()
@@ -60,23 +71,25 @@ class QtWrapper:
def display_clutch_on(self):
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')
def display_clutch_off(self):
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')
def display_state_on(self):
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.robot_state = SS.RUNNING
def display_state_off(self):
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.robot_state = SS.STOPPED
def handle_not_selected_error(self):
self.log_error('Najpierw wybierz PIONIERA z listy robotow')
@@ -206,20 +219,20 @@ class QtWrapper:
self.widget.angularRestrictionLabel.setText("{:.2f}".format(restrictions.angular_velocity))
def log_info(self,info_text):
- self.logger_counter += 1
- self.widget.logsBrowser.insertHtml('' + str(self.logger_counter) + '. ' + info_text + '
')
+ time = datetime.datetime.now().strftime('[%H:%M:%S]')
+ self.widget.logsBrowser.insertHtml('' + str(time) + '. ' + info_text + '
')
self.scroll_to_bottom()
# self.widget.logsBrowser.insertHtml(str(self.logger_counter) + '\t[INFO]\t' + info_text)
def log_warning(self,warning_text):
- self.logger_counter += 1
- self.widget.logsBrowser.insertHtml('' + str(self.logger_counter) + '. ' + warning_text + '
')
+ time = datetime.datetime.now().strftime('[%H:%M:%S]')
+ self.widget.logsBrowser.insertHtml('' + str(time) + '. ' + warning_text + '
')
self.scroll_to_bottom()
# self.widget.logsBrowser.append(str(self.logger_counter) + '\t[WARN]\t' + warning_text)
def log_error(self,error_text):
- self.logger_counter += 1
- self.widget.logsBrowser.insertHtml('' + str(self.logger_counter) + '. ' + error_text + '
')
+ time = datetime.datetime.now().strftime('[%H:%M:%S]')
+ self.widget.logsBrowser.insertHtml('' + str(time) + '. ' + error_text + '
')
self.scroll_to_bottom()
# self.widget.logsBrowser.append(str(self.logger_counter) + '\t[ERROR]\t' + error_text)