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 @@ - 强制跳转 + 关闭 @@ -128,12 +128,16 @@ --> + 保存配置 + + {{ showConfigForm ? '关闭' : '打开' }} 配置 +

{{ sectionName }}

- +
- 保存配置 - - {{ showConfigForm ? '关闭' : '打开' }} 配置 - +

Log Display

@@ -197,16 +198,16 @@ timer: null, target_person_options: [{ value: 1, - label: '模式 1' + label: '6_9' }, { value: 2, - label: '模式 2' + label: '7_10_2' }, { value: 3, - label: '模式 3' + label: '7_14_2' }, { value: 4, - label: '模式 4' + label: '7_15_4' }], }, methods: { diff --git a/templates/index1.html b/templates/index1.html new file mode 100644 index 0000000..b0c59bb --- /dev/null +++ b/templates/index1.html @@ -0,0 +1,139 @@ + + + + + + btl143 + + + + + + + + +
+ + +

btl143 upper

+ + + + + + {{ taskActive ? `开启 task ${counter}` : `关闭 task ${counter}` }} + + + +
+
+
+
+ +
+
+
+ + + + \ No newline at end of file