|
1 | 1 | import os
|
2 | 2 | import glob
|
| 3 | +import math |
3 | 4 |
|
4 | 5 | from PyQt5 import QtWidgets
|
5 | 6 | from PyQt5.QtGui import QStandardItemModel, QStandardItem
|
@@ -202,25 +203,35 @@ def emergency(self):
|
202 | 203 | result = -1
|
203 | 204 | while (result!=0) and (result != 3) and (result != 4):
|
204 | 205 | # light_green_red(min, max)
|
205 |
| - client_row_mid = int((client_row_max+client_row_min) / 2) |
| 206 | + client_row_mid = int(math.ceil((client_row_max+client_row_min) / 2.0)) |
| 207 | + print(client_row_min, client_row_mid, client_row_max) |
206 | 208 | for row_num in range(client_row_min, client_row_mid):
|
207 | 209 | item = model.item(row_num, 0)
|
208 | 210 | copter = Client.get_by_id(item.text())
|
209 |
| - copter.send_message("led_fill", {"red": 255}) |
| 211 | + copter.send_message("led_fill", {"green": 255}) |
210 | 212 | for row_num in range(client_row_mid, client_row_max + 1):
|
211 | 213 | item = model.item(row_num, 0)
|
212 | 214 | copter = Client.get_by_id(item.text())
|
213 |
| - copter.send_message("led_fill", {"green": 255}) |
| 215 | + copter.send_message("led_fill", {"red": 255}) |
214 | 216 | Dialog = QtWidgets.QDialog()
|
215 | 217 | ui = Ui_Dialog()
|
216 | 218 | ui.setupUi(Dialog)
|
217 | 219 | Dialog.show()
|
218 | 220 | result = Dialog.exec()
|
219 | 221 | print("Dialog result: {}".format(result))
|
220 | 222 | if (client_row_max != client_row_min):
|
221 |
| - if (result == 1): |
222 |
| - client_row_max = client_row_mid |
| 223 | + if (result == 1): |
| 224 | + for row_num in range(client_row_mid, client_row_max + 1): |
| 225 | + item = model.item(row_num, 0) |
| 226 | + copter = Client.get_by_id(item.text()) |
| 227 | + copter.send_message("led_fill") |
| 228 | + client_row_max = client_row_mid - 1 |
| 229 | + |
223 | 230 | elif (result == 2):
|
| 231 | + for row_num in range(client_row_min, client_row_mid): |
| 232 | + item = model.item(row_num, 0) |
| 233 | + copter = Client.get_by_id(item.text()) |
| 234 | + copter.send_message("led_fill") |
224 | 235 | client_row_min = client_row_mid
|
225 | 236 |
|
226 | 237 | if result == 0:
|
|
0 commit comments