"""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()