diff --git a/edc-web/app/__pycache__/config.cpython-311.pyc b/edc-web/app/__pycache__/config.cpython-311.pyc index caade31..d635b3c 100644 Binary files a/edc-web/app/__pycache__/config.cpython-311.pyc and b/edc-web/app/__pycache__/config.cpython-311.pyc differ diff --git a/edc-web/app/models.py b/edc-web/app/models.py index 62c5eb9..cd008a4 100644 --- a/edc-web/app/models.py +++ b/edc-web/app/models.py @@ -108,6 +108,17 @@ def get_serialnet_records(dnt_id: int, limit: int = 50) -> list[dict]: conn.close() +def clear_serialnet_records(dnt_id: int): + """清除指定设备的所有透传记录""" + conn = get_conn() + try: + with conn.cursor() as cur: + cur.execute("DELETE FROM tb_serialnet WHERE dnt_id=%s", (dnt_id,)) + conn.commit() + finally: + conn.close() + + # ─── tb_state_tst ────────────────────────────────────────────────── def get_latest_test_state(dnt_id: int) -> dict | None: diff --git a/edc-web/app/routes/test_op.py b/edc-web/app/routes/test_op.py index 911cfbf..91a29f2 100644 --- a/edc-web/app/routes/test_op.py +++ b/edc-web/app/routes/test_op.py @@ -8,6 +8,7 @@ from app.models import ( get_serialnet_stats, get_latest_test_state, get_automation_averages, + clear_serialnet_records, ) bp = Blueprint("test_op", __name__) @@ -54,7 +55,8 @@ def api_automation_start(): dnt_id = data.get("dnt_id") count = int(data.get("count", 1)) - # 插入第一条 0xB0 指令 + # 清除旧记录,然后插入第一条 0xB0 + clear_serialnet_records(dnt_id) record_id = insert_serialnet(dnt_id, COMMANDS["B0"]) return jsonify({ "ok": True, diff --git a/edc-web/app/static/js/test_op.js b/edc-web/app/static/js/test_op.js index 6da7a7c..6590701 100644 --- a/edc-web/app/static/js/test_op.js +++ b/edc-web/app/static/js/test_op.js @@ -48,9 +48,14 @@ async function startAuto() { autoFailed = 0; autoRemaining = count; - // 清空平均值显示 + // 清空显示 resetAverages(); - updateUI(); + document.getElementById("latest-result").innerHTML = '

等待测试...

'; + document.getElementById("progress-bar").style.width = "0%"; + document.getElementById("progress-text").textContent = "0/" + count + " (0 失败)"; + document.getElementById("stat-done").textContent = "0"; + document.getElementById("stat-failed").textContent = "0"; + document.getElementById("stat-remaining").textContent = count; const btn = document.getElementById("btn-auto"); btn.textContent = "结束";