initial commit
This commit is contained in:
42
main.py
Normal file
42
main.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import toml
|
||||
import queue
|
||||
import threading
|
||||
from loguru import logger
|
||||
import subtask as sb
|
||||
|
||||
# 读取配置
|
||||
cfg_main = toml.load('cfg_main.toml')
|
||||
|
||||
# 配置日志输出
|
||||
logger.add(cfg_main['debug'].get('logger_filename'), format=cfg_main['debug'].get('logger_format'), level="INFO")
|
||||
|
||||
task_queue = queue.Queue()
|
||||
|
||||
task_queue.put(sb.task(sb.get_block, cfg_main['task'].get('GetBlock_enable')))
|
||||
task_queue.put(sb.task(sb.put_block, cfg_main['task'].get('PutBlock_enable')))
|
||||
task_queue.put(sb.task(sb.get_bball, cfg_main['task'].get('GetBBall_enable')))
|
||||
task_queue.put(sb.task(sb.up_tower, cfg_main['task'].get('UpTower_enable')))
|
||||
task_queue.put(sb.task(sb.get_rball, cfg_main['task'].get('GetRBall_enable')))
|
||||
task_queue.put(sb.task(sb.put_bball, cfg_main['task'].get('PutBBall_enable')))
|
||||
task_queue.put(sb.task(sb.put_hanoi, cfg_main['task'].get('PutHanoi_enable')))
|
||||
task_queue.put(sb.task(sb.move_area, cfg_main['task'].get('MoveArea_enable')))
|
||||
task_queue.put(sb.task(sb.kick_ass, cfg_main['task'].get('KickAss_enable')))
|
||||
|
||||
task_queuem_t = sb.task_queuem(task_queue)
|
||||
|
||||
def worker_thread():
|
||||
while task_queuem_t.exec() is True:
|
||||
pass
|
||||
|
||||
worker = threading.Thread(target=worker_thread, daemon=True)
|
||||
worker.start()
|
||||
|
||||
# 主线程仅在子线程搜索 (SEARCHING) 和 空闲 (IDLE) 状态下进行操作
|
||||
while task_queuem_t.busy is True:
|
||||
if task_queuem_t.status is sb.task_queuem_status.EXECUTING:
|
||||
pass
|
||||
else:
|
||||
# 模拟执行回归任务
|
||||
logger.info("***** sim huigui task *****")
|
||||
|
||||
logger.info("Main thread exit")
|
||||
Reference in New Issue
Block a user