diff --git a/Server/emergency.py b/Server/emergency.py index 5c8f47c..85dbef9 100644 --- a/Server/emergency.py +++ b/Server/emergency.py @@ -1,34 +1,82 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'emergency.ui' +# +# Created by: PyQt5 UI code generator 5.11.3 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets import os import glob from PyQt5 import QtWidgets from PyQt5.QtGui import QStandardItemModel, QStandardItem -from PyQt5.QtCore import Qt, pyqtSlot -from PyQt5.QtWidgets import QFileDialog, QMessageBox -from PyQt5 import QtCore, QtGui, QtWidgets -from server import * +from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal, QObject + +from PyQt5.QtWidgets import QDialog + +# Importing gui form from server_qt import * +from server import * class Ui_Dialog(object): + + def __init__(self): + self.Dialog = None def setupUi(self, Dialog): + self.Dialog = Dialog Dialog.setObjectName("Dialog") - Dialog.resize(632, 214) - self.pushButton_2 = QtWidgets.QPushButton(Dialog) - self.pushButton_2.setGeometry(QtCore.QRect(470, 110, 121, 61)) - self.pushButton_2.setSizeIncrement(QtCore.QSize(16, 16)) - self.pushButton_2.setObjectName("pushButton_2") - self.pushButton_3 = QtWidgets.QPushButton(Dialog) - self.pushButton_3.setGeometry(QtCore.QRect(40, 100, 121, 61)) - self.pushButton_3.setSizeIncrement(QtCore.QSize(16, 16)) - self.pushButton_3.setObjectName("pushButton_3") - self.pushButton_2.clicked.connect(self.btn_2) - self.pushButton_3.clicked.connect(self.btn_3) + Dialog.resize(746, 620) + Dialog.setStyleSheet("QDialog{\n" +"background-color: #fffdd0;\n" +"}") + self.two_button = QtWidgets.QPushButton(Dialog) + self.two_button.setGeometry(QtCore.QRect(420, 120, 231, 171)) + self.two_button.setSizeIncrement(QtCore.QSize(16, 16)) + self.two_button.setStyleSheet("QPushButton{\n" +"color: white;\n" +"font-weight: 600;\n" +"font-size: 25pt;\n" +"background-color: red;\n" +"}") + self.two_button.setObjectName("two_button") self.label = QtWidgets.QLabel(Dialog) - self.label.setGeometry(QtCore.QRect(40, 40, 561, 51)) + self.label.setGeometry(QtCore.QRect(90, 30, 561, 51)) font = QtGui.QFont() font.setPointSize(16) self.label.setFont(font) self.label.setObjectName("label") + self.one_button = QtWidgets.QPushButton(Dialog) + self.one_button.setGeometry(QtCore.QRect(90, 120, 231, 171)) + self.one_button.setSizeIncrement(QtCore.QSize(16, 16)) + self.one_button.setStyleSheet("QPushButton{\n" +"color: white;\n" +"font-weight: 600;\n" +"font-size: 25pt;\n" +"background-color: RGB(118, 255, 122);\n" +"}") + self.one_button.setObjectName("one_button") + self.land_emergency_button = QtWidgets.QPushButton(Dialog) + self.land_emergency_button.setGeometry(QtCore.QRect(90, 340, 561, 81)) + self.land_emergency_button.setStyleSheet("QPushButton{\n" +"font-weight: 600;\n" +"font-size: 25pt;\n" +"background-color: white;\n" +"}") + self.land_emergency_button.setObjectName("land_emergency_button") + self.disarm_emergency_button = QtWidgets.QPushButton(Dialog) + self.disarm_emergency_button.setGeometry(QtCore.QRect(90, 460, 561, 81)) + self.disarm_emergency_button.setStyleSheet("QPushButton{\n" +"font-weight: 600;\n" +"font-size: 25pt;\n" +"background-color: white;\n" +"}") + self.disarm_emergency_button.setObjectName("disarm_emergency_button") + self.one_button.clicked.connect(self.one_button_click) + self.two_button.clicked.connect(self.two_button_click) + self.land_emergency_button.clicked.connect(self.land_emergency_click) + self.disarm_emergency_button.clicked.connect(self.disarm_emergency_click) self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog) @@ -36,23 +84,22 @@ class Ui_Dialog(object): def retranslateUi(self, Dialog): _translate = QtCore.QCoreApplication.translate Dialog.setWindowTitle(_translate("Dialog", "Dialog")) - self.pushButton_2.setText(_translate("Dialog", "PushButton")) - self.pushButton_3.setText(_translate("Dialog", "PushButton")) + self.two_button.setText(_translate("Dialog", "2")) self.label.setText(_translate("Dialog", "\n" "Select a group in which the drone does not work correctly")) - def btn_2(self): - for row_num in range(model.rowCount()): - item = model.item(row_num, 0) - if item.isCheckable() and item.checkState() == Qt.Checked: - copter = Client.get_by_id(item.text()) - copter.send_message("green") - def btn_3(self): - for row_num in range(model.rowCount()): - item = model.item(row_num, 0) - if item.isCheckable() and item.checkState() == Qt.Checked: - copter = Client.get_by_id(item.text()) - copter.send_message("red") - + self.one_button.setText(_translate("Dialog", "1")) + self.land_emergency_button.setText(_translate("Dialog", "Land")) + self.disarm_emergency_button.setText(_translate("Dialog", "Disarm")) + def one_button_click(self): + self.Dialog.done(1) + def two_button_click(self): + self.Dialog.done(2) + def land_emergency_click(self): + self.Dialog.done(3) + def disarm_emergency_click(self): + self.Dialog.done(4) + + if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) diff --git a/Server/emergency.ui b/Server/emergency.ui index a26c978..df5c698 100644 --- a/Server/emergency.ui +++ b/Server/emergency.ui @@ -6,20 +6,25 @@ 0 0 - 632 - 214 + 746 + 620 Dialog - + + QDialog{ +background-color: #fffdd0; +} + + - 470 - 110 - 121 - 61 + 420 + 120 + 231 + 171 @@ -28,34 +33,23 @@ 16 - - PushButton - - - - - - 40 - 100 - 121 - 61 - - - - - 16 - 16 - + + QPushButton{ +color: white; +font-weight: 600; +font-size: 25pt; +background-color: red; +} - PushButton + 2 - 40 - 40 + 90 + 30 561 51 @@ -70,6 +64,73 @@ Select a group in which the drone does not work correctly + + + + 90 + 120 + 231 + 171 + + + + + 16 + 16 + + + + QPushButton{ +color: white; +font-weight: 600; +font-size: 25pt; +background-color: RGB(118, 255, 122); +} + + + 1 + + + + + + 90 + 340 + 561 + 81 + + + + QPushButton{ +font-weight: 600; +font-size: 25pt; +background-color: white; +} + + + Land + + + + + + 90 + 460 + 561 + 81 + + + + QPushButton{ +font-weight: 600; +font-size: 25pt; +background-color: white; +} + + + Disarm + + diff --git a/Server/server_qt.py b/Server/server_qt.py index b0c9888..9b1b873 100644 --- a/Server/server_qt.py +++ b/Server/server_qt.py @@ -3,7 +3,7 @@ import glob from PyQt5 import QtWidgets from PyQt5.QtGui import QStandardItemModel, QStandardItem -from PyQt5.QtCore import Qt, pyqtSlot +from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal, QObject from PyQt5.QtWidgets import QFileDialog, QMessageBox @@ -13,7 +13,6 @@ from server_gui import Ui_MainWindow from server import * from emergency import * - # noinspection PyArgumentList,PyCallByClass class MainWindow(QtWidgets.QMainWindow): def __init__(self): @@ -43,6 +42,8 @@ class MainWindow(QtWidgets.QMainWindow): # Initing table and table model self.ui.tableView.setModel(model) self.ui.tableView.horizontalHeader().setStretchLastSection(True) + # self.ui = Communicate() + # self.ui.button.connect(self.button1) @pyqtSlot() def check_selected(self): @@ -196,17 +197,40 @@ class MainWindow(QtWidgets.QMainWindow): copter.send_message("service_restart", {"name": "clever"}) @pyqtSlot() def emergency(self): - for row_num in range(model.rowCount()): - item = model.item(row_num, 0) - if item.isCheckable() and item.checkState() == Qt.Checked: - copter = Client.get_by_id(item.text()) - copter.send_message("emergency") - Dialog = QtWidgets.QDialog() - ui = Ui_Dialog() - ui.setupUi(Dialog) - Dialog.show() - Dialog.exec_() + client_row_min = 0 + client_row_max = model.rowCount() + result = 0 + while (client_row_min != client_row_max) and (result != 3) and (result != 4): + # light_green_red(min, max) + client_row_mid = (client_row_max-client_row_min) / 2 + for row_mun in range(client_row_min, client_row_mid): + copter = Client.get_by_id(item.text()) + copter.send_message("led_fill", {"red": 255}) + for row_num in range(client_row_mid, client_row_max): + copter = Client.get_by_id(item.text()) + copter.send_message("led_fill", {"green": 255}) + Dialog = QtWidgets.QDialog() + ui = Ui_Dialog() + ui.setupUi(Dialog) + Dialog.show() + result = Dialog.exec() + if (result == 1): + client_row_max = client_row_mid + elif (result == 2): + client_row_min = client_row_mid + if result == 3: + for row_num in range(client_row_min, client_row_max): + item = model.item(row_num, 0) + copter = Client.get_by_id(item.text()) + copter.send_message("land") + + elif result == 4: + for row_num in range(client_row_min, client_row_max): + item = model.item(row_num, 0) + copter = Client.get_by_id(item.text()) + copter.send_message("disarm") + @pyqtSlot() def flip(self): reply = QMessageBox.question( @@ -225,9 +249,6 @@ class MainWindow(QtWidgets.QMainWindow): else: print("Cancelled") pass - - - model = QStandardItemModel() model.setHorizontalHeaderLabels( ('copter ID', 'animation ID', 'battery V', 'battery %', 'selfcheck', 'time UTC')