Skip to content

Commit

Permalink
Server: Repaired bugs with takeoff ready check, confirmation_required…
Browse files Browse the repository at this point in the history
… decorators, resume time sending
  • Loading branch information
goldarte committed Jul 5, 2019
1 parent 4455678 commit 7c34cfc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Server/copter_table_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def all_checks(copter_item):

def takeoff_checks(copter_item):
for i in range(3):
if not check_selfcheck(copter_item[2+i]):
if not CopterDataModel.checks[2+i](copter_item[2+i]):
return False
return True

Expand Down
33 changes: 18 additions & 15 deletions Server/server_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def wrapper(*args, **kwargs):
)
if reply == QMessageBox.Yes:
print("Dialog accepted")
return f(*args, **kwargs)
#print(args)
return f(args[0])
else:
print("Dialog declined")

Expand Down Expand Up @@ -77,7 +78,7 @@ def init_ui(self):
# Connecting
self.ui.check_button.clicked.connect(self.selfcheck_selected)
self.ui.start_button.clicked.connect(self.send_starttime)
self.ui.pause_button.clicked.connect(self.pause_resume_all)
self.ui.pause_button.clicked.connect(self.pause_resume_selected)
self.ui.stop_button.clicked.connect(self.stop_all)
self.ui.emergency_button.clicked.connect(self.emergency)

Expand Down Expand Up @@ -130,24 +131,24 @@ def _set_copter_data(self, value, col, copter_id):

self.signals.update_data_signal.emit(row, col, data)

@pyqtSlot()
@confirmation_required("This operation will takeoff selected copters with delay and start animation. Proceed?")
def send_starttime(self):
@pyqtSlot()
def send_starttime(self, **kwargs):
dt = self.ui.start_delay_spin.value()
for copter in self.model.user_selected():
if all_checks(copter):
server.send_starttime(copter.client, dt)

@pyqtSlot()
@confirmation_required("This operation will takeoff copters immediately. Proceed?")
def takeoff_selected(self):
@pyqtSlot()
def takeoff_selected(self, **kwargs):
for copter in self.model.user_selected():
if all_checks(copter):
copter.client.send_message("takeoff")

@pyqtSlot()
@confirmation_required("This operation will flip(!!!) copters immediately. Proceed?")
def flip(self):
@pyqtSlot()
def flip(self, **kwargs):
for copter in self.model.user_selected():
if all_checks(copter):
copter.client.send_message("flip")
Expand All @@ -162,17 +163,19 @@ def stop_all(self):
Client.broadcast_message("stop")

@pyqtSlot()
def pause_resume_all(self):
def pause_resume_selected(self):
if self.ui.pause_button.text() == 'Pause':
Client.broadcast_message('pause')
for copter in self.model.user_selected():
copter.client.send_message("pause")
self.ui.pause_button.setText('Resume')
else:
self._resume_all()
self._resume_selected()

@confirmation_required("This operation will resume ALL copter tasks with given delay. Proceed?")
def _resume_all(self):
dt = self.ui.start_delay_spin.value()
Client.broadcast_message('resume', {"time": 0 if dt == 0 else server.time_now()})
#@confirmation_required("This operation will resume ALL copter tasks with given delay. Proceed?")
def _resume_selected(self, **kwargs):
time_gap = 0.1
for copter in self.model.user_selected():
copter.client.send_message('resume', {"time": server.time_now() + time_gap})
self.ui.pause_button.setText('Pause')

@pyqtSlot()
Expand Down

0 comments on commit 7c34cfc

Please sign in to comment.