From 211b4767c13e30fdbdadbc99cb34b3af83fb1fc7 Mon Sep 17 00:00:00 2001
From: bmy <2583236812@qq.com>
Date: Tue, 16 Jul 2024 17:36:48 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=96=B0=E9=81=A0?=
=?UTF-8?q?=E7=A8=8B=E9=A0=81=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app.py | 22 +++++++
main_upper.py | 1 +
templates/index.html | 21 ++++---
templates/index1.html | 139 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 173 insertions(+), 10 deletions(-)
create mode 100644 templates/index1.html
diff --git a/app.py b/app.py
index 438216b..abd6182 100644
--- a/app.py
+++ b/app.py
@@ -23,6 +23,8 @@ processes = []
time_record = None
+task_run_flag = False
+
# 日志队列
queue = Queue()
# 跳过任务 干预任务调度
@@ -54,6 +56,10 @@ fileOptions_list = ['cfg_args.toml','cfg_main.toml', 'cfg_subtask.toml']
def index():
return render_template('index.html')
+@app.route('/run')
+def run():
+ return render_template('index1.html')
+
@app.route('/csdn')
def csdn():
return render_template('csdn.html')
@@ -64,6 +70,7 @@ def operate_handle(data):
global task_process
global processes
global time_record
+ global task_run_flag
if data['type'] == 'save_config':
f = open(os.path.join(fileOptions_path,data['file_name']), 'w')
ret = toml.dump(data['content'], f)
@@ -99,6 +106,7 @@ def operate_handle(data):
elif data['type'] == 'operate_task':
# 任务函数
if data['content'] == 'run':
+ task_run_flag = True
if task_process != None:
task_process.terminate()
time_record = time.perf_counter()
@@ -106,6 +114,7 @@ def operate_handle(data):
task_process.start()
logger.info("开启 task")
elif data['content'] == 'stop':
+ task_run_flag = False
task_process.terminate()
logger.info(f"任务结束 用时{time.perf_counter() - time_record}s")
logger.info("关闭 task")
@@ -125,6 +134,12 @@ def operate_handle(data):
elif data['type'] == 'skip_task':
logger.info(data)
skip_task_queue.put(1)
+ elif data['type'] == 'save_target_person':
+ config_path = os.path.join(fileOptions_path, 'cfg_args.toml')
+ config_args = toml.load(config_path)
+ config_args['lane_mode']['mode_index'] = int(data['content'])
+ with open(config_path, 'w') as config_file:
+ toml.dump(config_args, config_file)
@socketio.on('connect')
def test_connect():
@@ -134,6 +149,7 @@ def test_connect():
for item in fileOptions_list:
config_data[item] = toml.load(os.path.join(fileOptions_path,item))
socketio.emit('config_data', {'type': 'config_data', 'content': config_data})
+ socketio.emit('task_status', {'type': 'task_status', 'content': int(task_run_flag)})
def thread_function():
global queue
while True:
@@ -146,6 +162,12 @@ def thread_function():
if __name__ == '__main__':
+ config_path = os.path.join(fileOptions_path, 'cfg_args.toml')
+ config_args = toml.load(config_path)
+ config_args['lane_mode']['mode_index'] = 1
+ with open(config_path, 'w') as config_file:
+ toml.dump(config_args, config_file)
+
log_file = "server_processes.log"
log = open(log_file, "w")
time.sleep(2)
diff --git a/main_upper.py b/main_upper.py
index 5cfd16b..7b6a295 100644
--- a/main_upper.py
+++ b/main_upper.py
@@ -40,6 +40,7 @@ def main_func(_queue, _skip_queue):
# 配置日志输出
logger.add(cfg_main['debug']['logger_filename'], format=cfg_main['debug']['logger_format'], retention = 5, level="INFO")
+ logger.info(cfg_args)
act.axis.camera(0)
act.axis.x2(140)
diff --git a/templates/index.html b/templates/index.html
index a9359e2..d3e1094 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -109,7 +109,7 @@
{{ sectionName }}