mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-05-26 07:07:58 +00:00
Added dronepoint command to server and template for client file
This commit is contained in:
35
drone/dronepoint_flight.py
Normal file
35
drone/dronepoint_flight.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import threading
|
||||
|
||||
# Add parent dir to PATH to import messaging_lib and config_lib
|
||||
current_dir = (os.path.dirname(os.path.realpath(__file__)))
|
||||
lib_dir = os.path.realpath(os.path.join(current_dir, '../lib'))
|
||||
sys.path.insert(0, lib_dir)
|
||||
|
||||
import messaging
|
||||
import modules.client_core as client_core
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG, # INFO
|
||||
stream=sys.stdout,
|
||||
format="%(asctime)s [%(name)-7.7s] [%(threadName)-12.12s] [%(levelname)-5.5s] %(message)s",
|
||||
handlers=[
|
||||
logging.StreamHandler(sys.stdout),
|
||||
])
|
||||
|
||||
|
||||
@messaging.message_callback("dronepoint")
|
||||
def dronepoint_callback(connection, dronepoint_id=None):
|
||||
# this function only called after receiving "dronepoint" message from the server
|
||||
logging.info("Dronepoint_id: {}".format(dronepoint_id)) # dronepoint_id - int
|
||||
# your code goes here
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# logging.basicConfig(level=logging.DEBUG)
|
||||
client = client_core.Client()
|
||||
client.start()
|
||||
print("Client started")
|
||||
# your code can go here
|
||||
@@ -3,6 +3,7 @@ import re
|
||||
import sys
|
||||
import glob
|
||||
import time
|
||||
import random
|
||||
import logging
|
||||
import asyncio
|
||||
import platform
|
||||
@@ -37,6 +38,7 @@ from modules.visual_land_dialog import VisualLandDialog
|
||||
from modules.config_editor_models import ConfigDialog
|
||||
|
||||
startup_cwd = os.getcwd()
|
||||
random.seed()
|
||||
|
||||
def multi_glob(*patterns):
|
||||
return itertools.chain.from_iterable(glob.iglob(pattern) for pattern in patterns)
|
||||
@@ -183,6 +185,13 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
self.ui.action_update_client_repo.triggered.connect(b_partial(self.send_to_selected, "update_repo"))
|
||||
|
||||
menubar = self.menuBar()
|
||||
custom_menu = menubar.addMenu('Custom')
|
||||
|
||||
send_dronepoint_command = QtWidgets.QAction('Dronepoint', self)
|
||||
send_dronepoint_command.triggered.connect(self.dronepoint_command)
|
||||
custom_menu.addAction(send_dronepoint_command)
|
||||
|
||||
def init_table(self):
|
||||
# Remove standard table widget
|
||||
self.ui.horizontalLayout.removeWidget(self.ui.tableView)
|
||||
@@ -630,6 +639,12 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
ConfigDialog().call_config_dialog(config, save_callback, restart, name="server config")
|
||||
|
||||
@pyqtSlot()
|
||||
def dronepoint_command(self):
|
||||
dronepoint_id = random.randint(1, 2)
|
||||
logging.info(f"Dronepoint_id: {dronepoint_id}")
|
||||
self.send_to_selected("dronepoint", command_kwargs={"dronepoint_id": dronepoint_id})
|
||||
|
||||
def register_callbacks(self):
|
||||
@messaging.message_callback("telemetry")
|
||||
def get_telem_data(client, value, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user