am-freescan/scripts/prepare_arm_workflow_ui.py
lixiaolong ba0f749d40 feat: 完善检测任务、夹具轨迹与设备工作流
完善扫描成果与比对资料管理,精简业务菜单和任务工作台,更新批量导入模板。

适配机械臂新协议、坐标系管理及目标位姿组件,增加扫描参数字典和角色自动分配。

修复试运行终止状态与过期扫描任务资源释放,补充回归测试、迁移脚本及接口文档。
2026-11-06 10:50:49 +08:00

27 lines
3.6 KiB
Python
Raw Permalink 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.

"""Temporary actual workflow parameter panels, memory graph and read-only fake edge data only."""
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,reactive} 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 Panel from '/src/cmvr/common/views/flow/components/params/ArmTeachingParams.vue';
import {createArmTeachingGroup,validateArmTeachingConfiguration} from '/src/cmvr/common/utils/armTeaching.mjs';
const group=createArmTeachingGroup(),saved=ref('尚未保存'),calls=ref([]);
const roles=[{roleKey:'arm',displayName:'执行机械臂',required:true,deviceSlots:[{slotKey:'arm',displayName:'机械臂',deviceKind:2}]}];
const make=action=>{const n=group.nodeList.find(n=>n.action===action);return {id:action,type:'serviceNode',properties:{...n,executionTarget:{roleKey:'arm',deviceSlotKey:'arm'},nodeParams:structuredClone(n.nodeParams)}}};
const current=ref('ARM_MOVE_COORDINATE_STEP'),data=reactive(make(current.value));
window.lf={getGraphData:()=>({nodes:[{id:'start',type:'start',properties:{name:'开始',resourceRoles:roles}},data],edges:[{sourceNodeId:'start',targetNodeId:data.id}]}),setProperties:(id,p)=>{validateArmTeachingConfiguration(p.action,p.nodeParams);saved.value=JSON.stringify({action:p.action,executionTarget:p.executionTarget,params:Object.fromEntries(p.nodeParams.map(v=>[v.name,{type:v.type,value:v.input}]))},null,2);calls.value.push('保存内存配置:'+p.action)}};
const app=createApp({setup(){return()=>h('main',{style:'max-width:760px;margin:20px auto;padding:20px;font:14px sans-serif'},[h('h2','工作流配置离线验证 · 不连接现场设备'),h('p','验证真实组件:机械臂选择、坐标系下拉、自动版本、方向和单位、保存。'),h('div',group.nodeList.filter(n=>['ARM_MOVE_COORDINATE_STEP','ARM_APPLY_USER_COORDINATE_SYSTEM'].includes(n.action)).map(n=>h('button',{onClick:()=>{current.value=n.action;Object.assign(data,make(n.action));saved.value='尚未保存'}},n.name))),h(Panel,{key:current.value,data,onSaveSuccess:()=>calls.value.push('配置成功')}),h('h3','已保存配置'),h('pre',{'data-testid':'saved'},saved.value),h('h3','只读调用记录'),h('pre',calls.value.join('\n'))])}});
app.provide('armWorkflowRobotReader',async()=>({rows:[{robotId:'offline-robot',robotName:'离线机器人'}]}));
app.provide('armWorkflowDeviceReader',async()=>({data:[{deviceId:'offline-arm',deviceName:'离线机械臂',deviceKind:2}]}));
app.provide('armWorkflowCoordinateApi',async(op,p)=>{if(op==='getUserCoordinateSystem'){calls.value.push(op+'(只读)');return {data:{coordinate:{name:p.name,revision:p.expectedRevision}}}};if(op!=='listUserCoordinateSystems')throw Error('禁止控制操作');calls.value.push(op+'(只读)');return {data:{coordinates:[{name:'离线夹具坐标系',revision:'9007199254740993'},{name:'__builtin_base__',revision:'1'}]}}});
app.provide('armWorkflowPoseReader',async p=>{calls.value.push('getPose(只读)');return {data:{x:0.1,y:-0.2,z:0.3,rx:0.1,ry:0.2,rz:0.3,referenceFrame:p.baseLink,endFrame:'tcp'}}});
app.provide('armWorkflowValidate',async()=>({data:true}));
app.use(ElementPlus,{locale:zhCn});app.mount('#app');
</script></body></html>'''
if __name__=='__main__':
path=ROOT/'am-web/arm-workflow-verification.html'
path.write_text(PAGE,encoding='utf-8');print(path)