From b7ade7485f82f82812544aa2f09bc2964b5e4558 Mon Sep 17 00:00:00 2001 From: Olek Bojda Date: Tue, 25 Sep 2018 15:36:28 +0200 Subject: [PATCH] Added initial code and first idea for GUI setup in .ui file --- .../scripts/enums/__init__.py | 0 .../scripts/enums/clutch_state.py | 6 + .../scripts/enums/stop_state.py | 6 + safety_master_plugin/scripts/master_plugin.py | 24 ++- safety_master_plugin/scripts/master_widget.py | 18 ++ safety_master_plugin/ui/master_view.ui | 201 +++++++++++++++--- 6 files changed, 219 insertions(+), 36 deletions(-) create mode 100644 safety_master_plugin/scripts/enums/__init__.py create mode 100644 safety_master_plugin/scripts/enums/clutch_state.py create mode 100644 safety_master_plugin/scripts/enums/stop_state.py create mode 100644 safety_master_plugin/scripts/master_widget.py diff --git a/safety_master_plugin/scripts/enums/__init__.py b/safety_master_plugin/scripts/enums/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/safety_master_plugin/scripts/enums/clutch_state.py b/safety_master_plugin/scripts/enums/clutch_state.py new file mode 100644 index 0000000..9479b62 --- /dev/null +++ b/safety_master_plugin/scripts/enums/clutch_state.py @@ -0,0 +1,6 @@ + + +class ClutchState: + ENGAGED = 4 + DISENGAGED = 5 + UNKNOWN = 6 \ No newline at end of file diff --git a/safety_master_plugin/scripts/enums/stop_state.py b/safety_master_plugin/scripts/enums/stop_state.py new file mode 100644 index 0000000..17d5939 --- /dev/null +++ b/safety_master_plugin/scripts/enums/stop_state.py @@ -0,0 +1,6 @@ + + +class StopState: + STOPPED = 1 + RUNNING = 2 + UNKNOWN = 3 \ No newline at end of file diff --git a/safety_master_plugin/scripts/master_plugin.py b/safety_master_plugin/scripts/master_plugin.py index 1386ad7..6b23abc 100755 --- a/safety_master_plugin/scripts/master_plugin.py +++ b/safety_master_plugin/scripts/master_plugin.py @@ -1,4 +1,22 @@ -class MasterPlugin: - def __init__(self): - pass \ No newline at end of file + +from qt_gui.plugin import Plugin + +from master_widget import MasterWidget + +class MasterPlugin(Plugin): + + def __init__(self,context): + super(MasterPlugin, self).__init__(context) + self.setObjectName('Master Plugin - L1.5 safety system') + + self._widget = MasterWidget(context) + # self._qt_wrapper = QtWrapper(self._widget) + # self._ros_wrapper = ROSWrapper() + + # self.set_callback_functions() + + + + def set_callback_functions(self): + raise NotImplementedError diff --git a/safety_master_plugin/scripts/master_widget.py b/safety_master_plugin/scripts/master_widget.py new file mode 100644 index 0000000..ffa07f5 --- /dev/null +++ b/safety_master_plugin/scripts/master_widget.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python +import os +import rospkg + +from python_qt_binding.QtWidgets import QWidget +from python_qt_binding import loadUi + +class MasterWidget(QWidget): + + def __init__(self,context): + super(MasterWidget, self).__init__() + ui_file = os.path.join(rospkg.RosPack().get_path('safety_master_plugin'), 'ui', 'master_view.ui') + loadUi(ui_file, self) + self.setObjectName('Master Plugin - L1.5 safety system') + + if context.serial_number() > 1: + self.setWindowTitle(self.windowTitle() + (' (%d)' % context.serial_number())) + context.add_widget(self) \ No newline at end of file diff --git a/safety_master_plugin/ui/master_view.ui b/safety_master_plugin/ui/master_view.ui index 85bbe95..832eef5 100644 --- a/safety_master_plugin/ui/master_view.ui +++ b/safety_master_plugin/ui/master_view.ui @@ -13,39 +13,174 @@ Form - - - - 50 - 30 - 601 - 201 - - - - - - - 50 - 451 - 621 - 91 - - - - - - - 510 - 270 - 141 - 141 - - - - STOP - - + + + + + + + + Qt::Vertical + + + + 20 + 25 + + + + + + + + + + + + Ograniczenia robotów + + + Qt::AlignCenter + + + + + + + + + + + Obrazek1 + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + + + + 0.45 + + + Qt::AlignCenter + + + + + + + + + + + Obrazek2 + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + + + + 0.67 + + + Qt::AlignCenter + + + + + + + + + + + Obrazek3 + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + + + + 0.45 + + + Qt::AlignCenter + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 80 + + + + STOP + + + + + + + + + Qt::Vertical + + + + 20 + 25 + + + + + + + +