am-freescan/scripts/verify_scan_only_isolated.py
lixiaolong 64db825a9f feat: 完善设备工作流集成、组合执行与主题适配
集成旋转底座、机械臂示教与坐标系,完善扫描参数、电量和框架点复用。增加组合执行、步骤进度与日志,优化首屏和流程画布性能,修复表头主题适配,并保留验证脚本和回归测试。
2026-11-02 17:38:34 +08:00

58 lines
2.5 KiB
Python

"""Run existing scan-only acceptance on an isolated loopback AGV fixture.
Useful when the persistent demo simulator belongs to a different developer host.
Uses the original protobuf service and business acceptance suite; no real motion.
All temporary identities are marked, while permanent demo resources stay intact.
"""
import datetime as dt
import uuid
import argparse
from pathlib import Path
import robot_simulator as simulator
import verify_scan_only as acceptance
from verify_scanner_workflow import LocalResources
def main():
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--resources',action='store_true',help='Run resource scheduling/concurrency acceptance instead')
parser.add_argument('--report',type=Path,help='Keep a UTF-8 report after successful scoped cleanup')
options=parser.parse_args()
prefix='E2E-AGV-'+dt.datetime.now().strftime('%m%d%H%M%S')+'-'+uuid.uuid4().hex[:4]
resources=LocalResources(prefix,0)
simulator.ROBOT_ID=acceptance.ROBOT_ID=resources.robot
simulator.DEVICE_ID=acceptance.DEVICE_ID=resources.device
world=simulator.SimulatedAgv()
server,port=simulator.create_grpc_server(0,world)
resources.port=port
server.start()
try:
resources.provision()
with resources.store.cursor() as c:
c.execute('UPDATE iot_device SET device_kind=1,device_type=%s WHERE robot_id=%s AND device_id=%s AND create_by=%s',
('LOCALHOST_AGV_FIXTURE',resources.robot,resources.device,prefix))
resources.store.connection.commit()
if options.resources:
from verify_resource_scheduling import ResourceSchedulingVerifier
verifier=ResourceSchedulingVerifier()
verifier.fixture_world=world
else:verifier=acceptance.ScanOnlyVerifier()
verifier.report['fixtureResourcePrefix']=prefix
print('Isolated resource prefix: '+prefix,flush=True)
# Failure cleanup must not start or stop the permanent simulator process.
verifier.simulator=lambda action: None
if options.resources:verifier.run()
else:verifier.run(stop_failure=False)
if options.report:
from verify_cmvr_native import safe
import json
options.report.parent.mkdir(parents=True,exist_ok=True)
options.report.write_text(json.dumps(safe(dict(verifier.report,fixtureResourcePrefix=prefix)),ensure_ascii=False,indent=2),encoding='utf-8')
finally:
resources.close()
server.stop(1).wait()
if __name__=='__main__':main()