diff --git a/safety_user_plugin/scripts/qt_wrapper.py b/safety_user_plugin/scripts/qt_wrapper.py index e797903..b91b801 100644 --- a/safety_user_plugin/scripts/qt_wrapper.py +++ b/safety_user_plugin/scripts/qt_wrapper.py @@ -8,6 +8,8 @@ import math from enums.clutch_state import ClutchState as CS from enums.stop_state import StopState as SS +from python_qt_binding.QtGui import QPixmap + class QtWrapper: @@ -16,6 +18,11 @@ class QtWrapper: self.logger_counter = 0 self.displayed_robots_id_list = [] + self.clear_robot_info() + # self.ok_pixmap = QPixmap('../ui/Ok.jpg') + self.ok_pixmap = QPixmap('/home/olek/safetysystemL1.5/src/SafetySystem/safety_user_plugin/ui/Ok.jpg') + self.cancel_pixmap = QPixmap('/home/olek/safetysystemL1.5/src/SafetySystem/safety_user_plugin/ui/Cancel.jpg') + def disconnect_signals(self): self.widget.clutchButton.clicked.disconnect() self.widget.stopButton.clicked.disconnect() @@ -51,6 +58,26 @@ class QtWrapper: else: return None + 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.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.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.setText('Zatrzymaj robota') + + 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.setText('Odblokuj robota') + def handle_not_selected_error(self): self.log_error('Najpierw wybierz PIONIERA z listy robotow') @@ -139,45 +166,37 @@ class QtWrapper: # self.log_info(str(robot_info.clutch == CS.ENGAGED)) if robot_info.clutch == CS.ENGAGED: - self.widget.clutchLabel.setText('1') + self.display_clutch_on() else: - self.widget.clutchLabel.setText('0') + self.display_clutch_off() if robot_info.state == SS.RUNNING: - self.widget.stateLabel.setText('1') + self.display_state_on() else: - self.widget.stateLabel.setText('0') + self.display_state_off() def master_stopped(self): - # raise NotImplementedError self.log_info('Przycisk masterSTOP zostal nacisniety. Zatrzymuje roboty') def master_started(self): - # raise NotImplementedError self.log_info('Przycisk masterSTOP odcisniety. Mozesz uruchomic robota') def user_stopped(self): - # raise NotImplementedError self.log_info('Robot zatrzymany') - self.widget.stateLabel.setText('0') + self.display_state_off() def user_started(self): - # raise NotImplementedError self.log_info('Robot wystartowal') - self.widget.stateLabel.setText('1') + self.display_state_on() def disengage_clutch(self): - # raise NotImplementedError self.log_info('Rozprzegam sprzeglo') - self.widget.clutchLabel.setText('0') - # pass + self.display_clutch_off() def engage_clutch(self): - # raise NotImplementedError self.log_info('Sprzegam sprzeglo') - # self.signal.('disengage_clutch') - self.widget.clutchLabel.setText('1') - + self.display_clutch_on() + def master_is_stopped_notify(self): self.log_error('Nie mozna wystartowac robota. MasterSTOP wcisniety!') @@ -224,4 +243,10 @@ class QtWrapper: self.widget.stateLabel.setText('-') self.widget.clutchLabel.setText('-') - self.widget.choiceButton.setText('Wybierz') \ No newline at end of file + self.widget.choiceButton.setText('Wybierz') + + self.widget.stopButton.setText('-') + self.widget.stopButton.setStyleSheet("") + + self.widget.clutchButton.setText('-') + self.widget.clutchButton.setStyleSheet("") \ No newline at end of file diff --git a/safety_user_plugin/ui/Cancel.jpg b/safety_user_plugin/ui/Cancel.jpg new file mode 100644 index 0000000..ff6a442 Binary files /dev/null and b/safety_user_plugin/ui/Cancel.jpg differ diff --git a/safety_user_plugin/ui/Ok.jpg b/safety_user_plugin/ui/Ok.jpg new file mode 100644 index 0000000..f052a71 Binary files /dev/null and b/safety_user_plugin/ui/Ok.jpg differ diff --git a/safety_user_plugin/ui/user_view.ui b/safety_user_plugin/ui/user_view.ui index e744a25..a95711a 100644 --- a/safety_user_plugin/ui/user_view.ui +++ b/safety_user_plugin/ui/user_view.ui @@ -75,7 +75,7 @@ - + QLayout::SetDefaultConstraint @@ -124,7 +124,7 @@ - +