完善扫描成果与比对资料管理,精简业务菜单和任务工作台,更新批量导入模板。 适配机械臂新协议、坐标系管理及目标位姿组件,增加扫描参数字典和角色自动分配。 修复试运行终止状态与过期扫描任务资源释放,补充回归测试、迁移脚本及接口文档。
22 lines
3.6 KiB
Python
22 lines
3.6 KiB
Python
"""Memory-only verification of actual role selector and shared allocation/commit helpers."""
|
||
from pathlib import Path
|
||
ROOT=Path(__file__).resolve().parents[1]
|
||
PAGE=r'''<!doctype html><html lang="zh"><meta charset="utf-8"><title>自动角色分配离线验证</title><body><div id="app"></div><script type="module">
|
||
import {createApp,h,ref} from '/node_modules/.vite/deps/vue.js';
|
||
import ElementPlus from '/node_modules/.vite/deps/element-plus.js';
|
||
import '/node_modules/element-plus/dist/index.css';
|
||
import zhCn from '/node_modules/element-plus/es/locale/lang/zh-cn.mjs';
|
||
import Target from '/src/cmvr/common/views/flow/components/params/RobotExecutionTarget.vue';
|
||
import {ensureNodeExecutionResources,finishNodeResourceEdit} from '/src/cmvr/common/utils/flowResources.js';
|
||
const slot=(slotKey,deviceKind,managedBy='USER')=>({slotKey,deviceKind,displayName:slotKey,managedBy});
|
||
const role=(roleKey,displayName,deviceSlots)=>({roleKey,displayName,deviceSlots});
|
||
const node=(id,action,name,roleKey,deviceSlotKey)=>({id,type:'serviceNode',properties:{action,name,nodeType:'EDGE',executionTarget:roleKey?{roleKey,deviceSlotKey,dispatchPolicy:'ONE'}:undefined}});
|
||
const g=ref({nodes:[{id:'start',type:'start',properties:{resourceRoles:[role('arm','机械臂工位',[slot('机械臂',2),slot('误加的扫描仪',14,'FLOW_NODE')]),role('scan','扫描仪工位',[slot('扫描仪',14)]),role('scan2','第二扫描工位',[slot('扫描仪2',14)])]}},node('arm','ARM_ENABLE','机械臂节点','arm','机械臂'),node('old','SCANNER_STATUS','待改绑扫描节点','arm','误加的扫描仪'),node('existing','SCANNER_HEALTH','已有扫描节点','scan','扫描仪')],edges:[]});
|
||
const current=ref('old'),target=ref({...g.value.nodes[2].properties.executionTarget}),message=ref(''),counter=ref(0);
|
||
window.lf={getGraphData:()=>g.value};
|
||
const app=createApp({setup(){return()=>h('main',{style:'max-width:850px;margin:24px auto;padding:24px;font:14px sans-serif'},[h('h2','自动角色分配 · 离线验证(不连接设备)'),h('p','修改角色后保存,自动清理旧设备要求;后续新增节点沿用已保存选择。'),h(Target,{key:current.value,data:g.value.nodes.find(n=>n.id===current.value),modelValue:target.value,'onUpdate:modelValue':v=>target.value=v}),h('button',{onClick:()=>{g.value.nodes.find(n=>n.id===current.value).properties.executionTarget={...target.value};g.value=finishNodeResourceEdit(g.value,current.value).graph;target.value={...g.value.nodes.find(n=>n.id===current.value).properties.executionTarget};message.value='已保存,自动清理完成'}},'保存角色设置'),h('button',{onClick:()=>{const n=node('new'+(++counter.value),'SCANNER_STATUS','新增扫描仪节点');g.value.nodes.push(n);g.value=ensureNodeExecutionResources(g.value,n.id).graph;current.value=n.id;target.value={...g.value.nodes.find(x=>x.id===n.id).properties.executionTarget};message.value='已自动分配新增扫描仪节点'}},'新增扫描仪节点'),h('p',{role:'status'},message.value),h('h3','开始节点中的设备要求'),h('ul',g.value.nodes[0].properties.resourceRoles.map(r=>h('li',r.displayName+':'+r.deviceSlots.map(s=>s.displayName).join('、')))),h('h3','各节点的绑定'),h('pre',{'data-testid':'bindings'},g.value.nodes.slice(1).map(n=>n.properties.name+' → '+g.value.nodes[0].properties.resourceRoles.find(r=>r.roleKey===n.properties.executionTarget?.roleKey)?.displayName+' / '+n.properties.executionTarget?.deviceSlotKey).join('\n'))])}});
|
||
app.use(ElementPlus,{locale:zhCn});app.mount('#app');
|
||
</script></body></html>'''
|
||
if __name__=='__main__':
|
||
p=ROOT/'am-web/auto-role-verification.html';p.write_text(PAGE,encoding='utf-8');print(p)
|