Files
windows-fenjian/tools/_test_inbound_manual_mode.py
T
Ubuntu 4966345424 feat(1.0.75): 同步秤端 v1.0.75 源码(UI 抖动修复 + 严格入库/分拣样本)
来自 入库分拣工作站_源代码_v1.0.75:点商品名抖动的中间帧修复、ui/osk/tablet 调整、严格入库校验、分拣场景样本(review_queue station=picking);版本/安装包/说明同步 1.0.75。注意:本版 confirm_before_submit 恒 True、submit_on_remove 恒 False,1.0.71 的 inbound_auto_submit 账号开关被移除;models/cls 与 data/ 未入库。EXE 由用户侧打包分发,本次只推源码。
2026-12-03 16:26:17 +08:00

92 lines
3.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""两种工位都自动识别,必须人工确认。"""
import sys
import io
import os
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from core.flow import FlowEngine
CFG = {
'flow': {'min_scale_kg': 0.05, 'stable_ms': 400, 'stable_delta_kg': 0.03},
'scale': {'simulate': True},
'camera': {'simulate': True},
'vision': {'min_confidence': 65},
'server': {'mock': True},
'account': {'role': 'inspection'},
}
logs = []
eng = FlowEngine(CFG, lambda ev, p=None: logs.append((ev, p)))
eng.refresh_pending = lambda initial=False: None
fail = []
def check(name, cond, extra=''):
print(('PASS ' if cond else 'FAIL ') + name
+ ('' if cond else ' %r' % (extra,)))
if not cond:
fail.append(name)
# 旧配置要求自动提交,也必须等人点确认。
eng.cfg['flow'].update(confirm_before_submit=False, submit_on_remove=True)
for station in ('inspection', 'picking'):
eng.station = station
check(station + ':识别后进确认页', eng.confirm_before_submit() is True)
check(station + ':拿走货不提交', eng.submit_on_remove() is False)
check(station + ':免称重仍自动识别', eng.auto_noweigh_on() is True)
check(station + ':拒绝自动确认入口', not eng.confirm_focus(auto_remove=True)[0])
# 2b) 免称重认出后必须进确认页(不是直接记账)
seen = []
eng._to_focus = lambda *a, **k: seen.append((a, k))
eng._auto_round = True
_one = {'id': 'x1', 'item_name': '土豆', 'unit': '袋',
'required_qty': 3, 'remaining_qty': 3}
eng._to_count_confirm('土豆', _one, [_one])
check('免称重认出后进确认页(不直接提交)', len(seen) == 1, )
# 5) 登录按服务端下发值接线:api.login 写 False ⇒ 引擎变手动
CFG_LOGIN = dict(CFG)
CFG_LOGIN['account'] = {'role': 'inspection', 'username': 'u', 'password': 'p'}
eng2 = FlowEngine(CFG_LOGIN, lambda ev, p=None: None)
eng2.refresh_pending = lambda initial=False: None
eng2._sync_prompts = lambda force=False: None
def fake_login():
eng2.api.inbound_auto_submit = True # 服务端 profile 下发:默认关
return {}
eng2.api.login = fake_login
eng2.login('u', 'p', 'inspection')
check('登录后按服务端开关生效:入库变手动确认', eng2.submit_on_remove() is False)
# 6) 登录返回的 profile 里没这个字段 ⇒ False(安全侧:手动)
from core.api.client import ApiClient # noqa: E402
def client_with(profile):
c = ApiClient({'server': {'base_url': 'https://x/api', 'mock': False},
'account': {'username': 'u', 'password': 'p'},
'flow': {}})
c._request = lambda *a, **k: {'access_token': 't', 'profile': profile}
c.login()
return c
check('服务端未下发该字段 ⇒ 手动(False)',
client_with({'id': 1}).inbound_auto_submit is False)
check('服务端下发 true ⇒ 自动提交(True)',
client_with({'id': 1, 'inbound_auto_submit': True})
.inbound_auto_submit is True)
print('')
print('FAILED: %d' % len(fail) if fail else 'ALL PASS')
sys.exit(1 if fail else 0)