Skip to content

Commit 9790d2b

Browse files
committed
Server: Repair bug in emegrency land function
1 parent fd4f40a commit 9790d2b

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

Server/server_qt.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import glob
3+
import math
34

45
from PyQt5 import QtWidgets
56
from PyQt5.QtGui import QStandardItemModel, QStandardItem
@@ -202,25 +203,35 @@ def emergency(self):
202203
result = -1
203204
while (result!=0) and (result != 3) and (result != 4):
204205
# 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)
206208
for row_num in range(client_row_min, client_row_mid):
207209
item = model.item(row_num, 0)
208210
copter = Client.get_by_id(item.text())
209-
copter.send_message("led_fill", {"red": 255})
211+
copter.send_message("led_fill", {"green": 255})
210212
for row_num in range(client_row_mid, client_row_max + 1):
211213
item = model.item(row_num, 0)
212214
copter = Client.get_by_id(item.text())
213-
copter.send_message("led_fill", {"green": 255})
215+
copter.send_message("led_fill", {"red": 255})
214216
Dialog = QtWidgets.QDialog()
215217
ui = Ui_Dialog()
216218
ui.setupUi(Dialog)
217219
Dialog.show()
218220
result = Dialog.exec()
219221
print("Dialog result: {}".format(result))
220222
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+
223230
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")
224235
client_row_min = client_row_mid
225236

226237
if result == 0:

0 commit comments

Comments
 (0)