feat(touch): 完善触控编排、媒体分析与灵巧手操作
This commit is contained in:
parent
8c1cde3f2a
commit
9d2806a17a
@ -102,6 +102,8 @@ export function flowAction(data) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/flow/action',
|
url: '/flow/action',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
// 留出后端返回边端超时结果的时间。
|
||||||
|
timeout: ['TOUCH', 'DEX_HAND_GET_STATE'].includes(data?.action) ? 65000 : undefined,
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import Player, { Events } from 'xgplayer'; // 引入西瓜视频模块
|
import Player, { Events } from 'xgplayer'; // 引入西瓜视频模块
|
||||||
import 'xgplayer/dist/index.min.css'; // 引入西瓜视频样式
|
import 'xgplayer/dist/index.min.css'; // 引入西瓜视频样式
|
||||||
|
import { workflowVideoUrl } from "@/utils/workflowVideo";
|
||||||
|
|
||||||
const { videoUrl } = defineProps({
|
const { videoUrl } = defineProps({
|
||||||
videoUrl: {
|
videoUrl: {
|
||||||
@ -30,7 +31,7 @@ const init = () => {
|
|||||||
// width: 600,
|
// width: 600,
|
||||||
// height: 400, // 视频宽高尺寸
|
// height: 400, // 视频宽高尺寸
|
||||||
isLive: false,
|
isLive: false,
|
||||||
url: videoUrl, // 视频源
|
url: workflowVideoUrl(videoUrl), // 视频源
|
||||||
// poster: "http://ashuai.work/static/img/avantar.png", // 视频封面
|
// poster: "http://ashuai.work/static/img/avantar.png", // 视频封面
|
||||||
...conf,
|
...conf,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<video
|
<video
|
||||||
:src="src"
|
:src="workflowVideoUrl(src)"
|
||||||
controls
|
controls
|
||||||
:style="style"
|
:style="style"
|
||||||
class="video"
|
class="video"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { workflowVideoUrl } from '@/utils/workflowVideo'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
src: {
|
src: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { getDeviceKindForAction, getRequiredDeviceIdForAction, isNeckDeviceId, NECK_DEVICE_ID } from '@/utils/robotDevice'
|
import { getDeviceKindForAction, getRequiredDeviceIdForAction, isNeckDeviceId, NECK_DEVICE_ID } from '@/utils/robotDevice'
|
||||||
|
import { mergeTouchOutputs, touchCoordinatesInput, touchPathSearchOutputs, touchPathStepOutputs, touchRetryInput, touchRetryOutput } from '@/utils/touchFlow'
|
||||||
|
|
||||||
export const FLOW_SCHEMA_VERSION = 2
|
export const FLOW_SCHEMA_VERSION = 2
|
||||||
export const DEFAULT_ROLE_KEY = 'default_executor'
|
export const DEFAULT_ROLE_KEY = 'default_executor'
|
||||||
@ -24,6 +25,7 @@ const DEVICE_KIND_META = Object.freeze({
|
|||||||
2: { key: 'arm', name: '机械臂' },
|
2: { key: 'arm', name: '机械臂' },
|
||||||
4: { key: 'bio_head', name: '仿生头' },
|
4: { key: 'bio_head', name: '仿生头' },
|
||||||
5: { key: 'camera', name: '摄像头' },
|
5: { key: 'camera', name: '摄像头' },
|
||||||
|
7: { key: 'dex_hand', name: '灵巧手' },
|
||||||
9: { key: 'microphone', name: '麦克风' },
|
9: { key: 'microphone', name: '麦克风' },
|
||||||
12: { key: 'robot', name: '机器人本体' },
|
12: { key: 'robot', name: '机器人本体' },
|
||||||
13: { key: 'speaker', name: '扬声器' },
|
13: { key: 'speaker', name: '扬声器' },
|
||||||
@ -143,6 +145,23 @@ export const normalizeFlowResourceSchema = (sourceGraph) => {
|
|||||||
node.type = LEGACY_NODE_TYPE_ALIASES[node.type] || node.type
|
node.type = LEGACY_NODE_TYPE_ALIASES[node.type] || node.type
|
||||||
// 早期图片分析图数据可能只保存节点类型,加载时补齐运行端识别所需的协议字段。
|
// 早期图片分析图数据可能只保存节点类型,加载时补齐运行端识别所需的协议字段。
|
||||||
const properties = node.properties || (node.properties = {})
|
const properties = node.properties || (node.properties = {})
|
||||||
|
if (properties.action === 'TI_PATH_SEARCH') {
|
||||||
|
properties.outputParams = mergeTouchOutputs(properties.outputParams, touchPathSearchOutputs())
|
||||||
|
}
|
||||||
|
if (properties.action === 'GET_CURRENT_OBJECT' && (properties.loopValueType === 'touchPathStep' ||
|
||||||
|
properties.outputParams?.some(field => field.name === 'object' &&
|
||||||
|
field.children?.some(child => child.name === 'functionName' && child.type === 'string')))) {
|
||||||
|
properties.outputParams = mergeTouchOutputs(properties.outputParams, touchPathStepOutputs())
|
||||||
|
}
|
||||||
|
if (properties.action === 'TOUCH') {
|
||||||
|
const params = properties.nodeParams || (properties.nodeParams = [])
|
||||||
|
const coordinates = params.find(param => param.name === 'touchCoordinates')
|
||||||
|
if (!coordinates) params.push(touchCoordinatesInput())
|
||||||
|
if (!params.some(param => param.name === 'retryCount')) params.push(touchRetryInput())
|
||||||
|
const legacy = params.find(param => param.name === 'touchParams')
|
||||||
|
if (legacy) legacy.required = false
|
||||||
|
properties.outputParams = mergeTouchOutputs(properties.outputParams, [touchRetryOutput()])
|
||||||
|
}
|
||||||
if (['AGV_MOVE_TO_POINT', 'AGV_MOVE_TO_STATION'].includes(properties.action)) {
|
if (['AGV_MOVE_TO_POINT', 'AGV_MOVE_TO_STATION'].includes(properties.action)) {
|
||||||
properties.nodeParams = Array.isArray(properties.nodeParams) ? properties.nodeParams : []
|
properties.nodeParams = Array.isArray(properties.nodeParams) ? properties.nodeParams : []
|
||||||
if (!properties.nodeParams.some((param) => param?.name === 'blockedTimeoutMs')) {
|
if (!properties.nodeParams.some((param) => param?.name === 'blockedTimeoutMs')) {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ export const DEVICE_KIND = Object.freeze({
|
|||||||
ARM: 2,
|
ARM: 2,
|
||||||
BIO_HEAD: 4,
|
BIO_HEAD: 4,
|
||||||
CAMERA: 5,
|
CAMERA: 5,
|
||||||
|
DEX_HAND: 7,
|
||||||
MICROPHONE: 9,
|
MICROPHONE: 9,
|
||||||
ROBOT: 12,
|
ROBOT: 12,
|
||||||
SPEAKER: 13,
|
SPEAKER: 13,
|
||||||
@ -14,6 +15,61 @@ export const DEVICE_KIND = Object.freeze({
|
|||||||
|
|
||||||
export const NECK_DEVICE_ID = 'neck_arm'
|
export const NECK_DEVICE_ID = 'neck_arm'
|
||||||
export const isNeckDeviceId = (deviceId) => deviceId === NECK_DEVICE_ID || deviceId === 'xiaozhao_head'
|
export const isNeckDeviceId = (deviceId) => deviceId === NECK_DEVICE_ID || deviceId === 'xiaozhao_head'
|
||||||
|
export const dexHandAxisLabels = Object.freeze(['小拇指', '无名指', '中指', '食指', '大拇指弯曲', '大拇指旋转'])
|
||||||
|
|
||||||
|
const DEX_HAND_POSITION_LIMIT = 2000
|
||||||
|
const DEX_HAND_ANGLE_COMMAND_LIMIT = 1000
|
||||||
|
const DEX_HAND_AXIS_COUNT = 6
|
||||||
|
|
||||||
|
function dexHandAxes(state, captureKind) {
|
||||||
|
const model = String(state?.model || '').trim()
|
||||||
|
if (!/^(ROH-(LiteS001|AP001)|OYMotionAP001)$/i.test(model)) {
|
||||||
|
throw new Error(model ? `当前机型 ${model} 不支持${captureKind}回填` : `设备未上报支持${captureKind}回填的机型`)
|
||||||
|
}
|
||||||
|
if (state.initialized !== true) throw new Error('灵巧手尚未初始化')
|
||||||
|
if (!Array.isArray(state.hands) || state.hands.length !== DEX_HAND_AXIS_COUNT) {
|
||||||
|
throw new Error('灵巧手未返回完整的六轴位置')
|
||||||
|
}
|
||||||
|
|
||||||
|
const axes = Array(DEX_HAND_AXIS_COUNT).fill(null)
|
||||||
|
for (const axis of state.hands) {
|
||||||
|
const { id, position, error, errorMessages } = axis || {}
|
||||||
|
if (!Number.isInteger(id) || id < 0 || id >= DEX_HAND_AXIS_COUNT || axes[id] !== null
|
||||||
|
|| !Number.isInteger(position) || position < 0 || position > DEX_HAND_POSITION_LIMIT) {
|
||||||
|
throw new Error('灵巧手反馈中的自由度编号或位置无效')
|
||||||
|
}
|
||||||
|
if (error || errorMessages?.length) throw new Error(`灵巧手存在故障,无法保存当前${captureKind}`)
|
||||||
|
axes[id] = axis
|
||||||
|
}
|
||||||
|
return axes
|
||||||
|
}
|
||||||
|
|
||||||
|
function dexHandTarget(id, units, limit) {
|
||||||
|
const ratio = units / limit
|
||||||
|
// The edge truncates a float32 product. Nudge ratios that would land one register unit below.
|
||||||
|
const value = Math.fround(Math.fround(ratio) * limit) < units ? ratio + 0.0000001 : ratio
|
||||||
|
return { id, value }
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dexHandPositionTargets(state) {
|
||||||
|
return dexHandAxes(state, '位置').map(({ id, position }) => dexHandTarget(id, position, DEX_HAND_POSITION_LIMIT))
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dexHandAngleSnapshot(state) {
|
||||||
|
const axes = dexHandAxes(state, '角度')
|
||||||
|
if (axes.some(axis => !Number.isInteger(axis.angle))) {
|
||||||
|
throw new Error('灵巧手未返回完整的六轴实测角度')
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
angles: axes.map(({ id, angle }) => ({ id, degrees: angle / 100 })),
|
||||||
|
// The ROH angle command drives logical travel, while angle feedback is in centidegrees.
|
||||||
|
values: axes.map(({ id, position }) => dexHandTarget(
|
||||||
|
id,
|
||||||
|
Math.round(position * DEX_HAND_ANGLE_COMMAND_LIMIT / DEX_HAND_POSITION_LIMIT),
|
||||||
|
DEX_HAND_ANGLE_COMMAND_LIMIT,
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流程动作到所需设备类型的全局映射。
|
* 流程动作到所需设备类型的全局映射。
|
||||||
@ -35,6 +91,13 @@ export const DEVICE_KIND_BY_ACTION = Object.freeze({
|
|||||||
ARM_NECK_STOP: DEVICE_KIND.ARM,
|
ARM_NECK_STOP: DEVICE_KIND.ARM,
|
||||||
ARM_NECK_ENABLE: DEVICE_KIND.ARM,
|
ARM_NECK_ENABLE: DEVICE_KIND.ARM,
|
||||||
ARM_NECK_DISABLE: DEVICE_KIND.ARM,
|
ARM_NECK_DISABLE: DEVICE_KIND.ARM,
|
||||||
|
DEX_HAND_GET_STATE: DEVICE_KIND.DEX_HAND,
|
||||||
|
DEX_HAND_SET_ANGLE: DEVICE_KIND.DEX_HAND,
|
||||||
|
DEX_HAND_SET_POSITION: DEVICE_KIND.DEX_HAND,
|
||||||
|
DEX_HAND_SET_FORCE: DEVICE_KIND.DEX_HAND,
|
||||||
|
DEX_HAND_SET_SPEED: DEVICE_KIND.DEX_HAND,
|
||||||
|
DEX_HAND_PLAY_PRESET: DEVICE_KIND.DEX_HAND,
|
||||||
|
DEX_HAND_GET_TACTILE: DEVICE_KIND.DEX_HAND,
|
||||||
TOUCH: DEVICE_KIND.ARM,
|
TOUCH: DEVICE_KIND.ARM,
|
||||||
BIO_HEAD_SPEAK_START: DEVICE_KIND.BIO_HEAD,
|
BIO_HEAD_SPEAK_START: DEVICE_KIND.BIO_HEAD,
|
||||||
BIO_HEAD_SPEAK_STOP: DEVICE_KIND.BIO_HEAD,
|
BIO_HEAD_SPEAK_STOP: DEVICE_KIND.BIO_HEAD,
|
||||||
|
|||||||
56
src/utils/touchFlow.js
Normal file
56
src/utils/touchFlow.js
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
export const touchProjectInputs = () => [
|
||||||
|
{ name: 'vehicleConfigId', type: 'number', desc: '车机版本,由触控项目传入', required: true, disabled: true },
|
||||||
|
{ name: 'funcIds', type: 'array<number>', desc: '功能列表,按项目编排顺序传入,可重复', required: true, disabled: true },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const touchPathStepFields = () => [
|
||||||
|
{ name: 'sourceUiName', type: 'string', desc: '本步所在界面' },
|
||||||
|
{ name: 'sourceUiCandidates', type: 'array<string>', desc: '本步可能所在的界面,以拍照识别结果为准' },
|
||||||
|
{ name: 'functionName', type: 'string', desc: '本步点击的功能' },
|
||||||
|
{ name: 'targetUiName', type: 'string', desc: '本步预期到达的界面' },
|
||||||
|
{ name: 'targetUiCandidates', type: 'array<string>', desc: '本步可能到达的界面' },
|
||||||
|
{ name: 'iconUrl', type: 'string', desc: '按钮参考图' },
|
||||||
|
{ name: 'operationType', type: 'string', desc: '动作类型' },
|
||||||
|
{ name: 'repeatCount', type: 'number', desc: '重复次数' },
|
||||||
|
{ name: 'waitMs', type: 'number', desc: '动作等待毫秒' },
|
||||||
|
{ name: 'isLastStep', type: 'boolean', desc: '本路径的最后一步,点击成功后可结束循环' },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const touchPathSearchOutputs = () => [
|
||||||
|
{ name: 'nextLocation', type: 'string', desc: '下一步点击的功能', disabled: true },
|
||||||
|
{ name: 'isEnd', type: 'boolean', desc: '本次搜索是否只剩最后一步', disabled: true },
|
||||||
|
{ name: 'iconUrl', type: 'string', desc: '按钮参考图', disabled: true },
|
||||||
|
{ name: 'pathLength', type: 'number', desc: '路径步数', disabled: true },
|
||||||
|
{ name: 'path', type: 'array<object>', desc: '完整点击路径,供内层循环引用', disabled: true, children: touchPathStepFields() },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const touchPathStepOutputs = () => [
|
||||||
|
{ name: 'index', type: 'number', desc: '索引', disabled: true },
|
||||||
|
{ name: 'object', type: 'object', desc: '当前点击步骤', disabled: true, children: touchPathStepFields() },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const touchCoordinatesInput = () => ({
|
||||||
|
name: 'touchCoordinates', displayName: '触控坐标', type: 'input', input: '',
|
||||||
|
desc: '引用获取功能坐标的 point', disabled: true, required: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
export const touchRetryInput = () => ({
|
||||||
|
name: 'retryCount', displayName: '失败重试次数', type: 'input', componentType: 'number',
|
||||||
|
input: 0, min: 0, stepStrictly: true, disabled: true, required: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
export const touchRetryOutput = () => ({
|
||||||
|
name: 'retryAttempts', type: 'number', desc: '本次触控实际重试的次数', disabled: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
export function mergeTouchOutputs(saved, fields) {
|
||||||
|
const definitions = new Map((saved || []).map(field => [field.name, field]))
|
||||||
|
for (const field of fields) {
|
||||||
|
const old = definitions.get(field.name)
|
||||||
|
definitions.set(field.name, {
|
||||||
|
...old, ...field,
|
||||||
|
...(field.children ? { children: mergeTouchOutputs(old?.children, field.children) } : {}),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return [...definitions.values()]
|
||||||
|
}
|
||||||
6
src/utils/workflowVideo.js
Normal file
6
src/utils/workflowVideo.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export function workflowVideoUrl(value) {
|
||||||
|
if (typeof value !== 'string') return ''
|
||||||
|
const match = /^https?:\/\/minio(?::\d+)?\/[^/]+\/(VIDEO\/\d{8}\/[\w.-]+\.mp4)(?:\?.*)?$/i.exec(value)
|
||||||
|
if (!match) return value
|
||||||
|
return `${import.meta.env.VITE_APP_BASE_API}/system/file/workflow-video?object=${encodeURIComponent(match[1])}`
|
||||||
|
}
|
||||||
@ -29,18 +29,18 @@
|
|||||||
<!-- deviceSlots 是该角色所需的设备用途,例如底盘、相机、机械臂;选项依赖当前机器人。 -->
|
<!-- deviceSlots 是该角色所需的设备用途,例如底盘、相机、机械臂;选项依赖当前机器人。 -->
|
||||||
<el-form-item v-for="slot in role.deviceSlots" :key="slot.slotKey" :label="slot.displayName" :required="slot.required">
|
<el-form-item v-for="slot in role.deviceSlots" :key="slot.slotKey" :label="slot.displayName" :required="slot.required">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="memberOf(role).devices[slot.slotKey]"
|
:model-value="memberOf(role).devices[slot.slotKey]"
|
||||||
filterable
|
filterable
|
||||||
:loading="autoAssigning || loadingRoleKey === role.roleKey"
|
:loading="autoAssigning || loadingRoleKey === role.roleKey"
|
||||||
:disabled="!memberOf(role).robotId"
|
:disabled="!memberOf(role).robotId || autoAssigning || loadingRoleKey === role.roleKey"
|
||||||
:placeholder="memberOf(role).robotId ? '请选择设备' : '请先选择机器人'"
|
:placeholder="memberOf(role).robotId ? '请选择设备' : '请先选择机器人'"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
@change="emitValue"
|
@change="(deviceId) => changeDevice(role, slot, deviceId)"
|
||||||
>
|
>
|
||||||
<el-option v-for="item in optionsOf(role, slot)" :key="item.value" :label="item.label" :value="item.value" />
|
<el-option v-for="item in optionsOf(role, slot, true)" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
</el-select>
|
</el-select>
|
||||||
<!-- 已选择机器人但没有可选设备时给出局部提示,最终阻断仍由 validate 统一完成。 -->
|
<!-- 已选择机器人但没有可选设备时给出局部提示,最终阻断仍由 validate 统一完成。 -->
|
||||||
<div v-if="memberOf(role).robotId && !optionsOf(role, slot).length" class="runtime-role__error">
|
<div v-if="memberOf(role).robotId && !optionsOf(role, slot, true).length" class="runtime-role__error">
|
||||||
该机器人没有匹配的在线设备
|
该机器人没有匹配的在线设备
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -55,7 +55,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive, ref, watch } from 'vue'
|
import { computed, reactive, ref, watch } from 'vue'
|
||||||
import { getRobotList, getRobotDevicesByRobotId } from '@/api/resource/robot'
|
import { getRobotList, getRobotDevicesByRobotId } from '@/api/resource/robot'
|
||||||
import { deviceMatchesSlot, toDeviceOptions } from '@/utils/robotDevice'
|
import { DEVICE_KIND, deviceMatchesSlot, toDeviceOptions } from '@/utils/robotDevice'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* roles 来自流程起点的 resourceRoles,描述本次任务需要哪些机器人角色和设备用途。
|
* roles 来自流程起点的 resourceRoles,描述本次任务需要哪些机器人角色和设备用途。
|
||||||
@ -244,14 +244,44 @@ const autoAssignRoles = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
const isCameraSlot = (slot) => Number(slot.deviceKind) === DEVICE_KIND.CAMERA
|
||||||
* 生成某个设备用途的下拉选项。
|
|
||||||
*
|
const cameraConflicts = (role, slot, deviceId) => props.roles
|
||||||
* 同一角色内已经被其他用途占用、且不允许复用的设备会被过滤掉;
|
.filter(otherRole => itemScopeOf(otherRole) === itemScopeOf(role)
|
||||||
* 当前 slot 已选中的值会保留在选项中,避免选项刷新时把正在编辑的值瞬间隐藏。
|
&& memberOf(otherRole).robotId === memberOf(role).robotId)
|
||||||
*/
|
.flatMap(otherRole => (otherRole.deviceSlots || [])
|
||||||
const optionsOf = (role, slot) => {
|
.filter(otherSlot => (otherRole.roleKey !== role.roleKey || otherSlot.slotKey !== slot.slotKey)
|
||||||
|
&& memberOf(otherRole).devices[otherSlot.slotKey] === deviceId
|
||||||
|
&& (!slot.allowReuse || !otherSlot.allowReuse))
|
||||||
|
.map(otherSlot => ({ role: otherRole, slot: otherSlot })))
|
||||||
|
|
||||||
|
const cameraChoice = (role, slot, deviceId, allowSwap) => {
|
||||||
|
const currentId = memberOf(role).devices[slot.slotKey]
|
||||||
|
const conflicts = cameraConflicts(role, slot, deviceId)
|
||||||
|
if (!conflicts.length || currentId === deviceId) return {}
|
||||||
|
if (!allowSwap || !currentId || conflicts.length !== 1 || !isCameraSlot(conflicts[0].slot)) return null
|
||||||
|
|
||||||
|
const { role: otherRole, slot: otherSlot } = conflicts[0]
|
||||||
|
const currentDevice = (devicesByRole[otherRole.roleKey] || []).find(device => device.deviceId === currentId)
|
||||||
|
if (!deviceMatchesSlot(currentDevice, otherSlot)) return null
|
||||||
|
|
||||||
|
// The current slot releases its device during the swap. Other bindings still apply.
|
||||||
|
const reverseConflict = cameraConflicts(otherRole, otherSlot, currentId)
|
||||||
|
.some(conflict => conflict.role.roleKey !== role.roleKey || conflict.slot.slotKey !== slot.slotKey)
|
||||||
|
return reverseConflict ? null : { swap: conflicts[0] }
|
||||||
|
}
|
||||||
|
|
||||||
|
const optionsOf = (role, slot, allowSwap = false) => {
|
||||||
const member = memberOf(role)
|
const member = memberOf(role)
|
||||||
|
const devices = (devicesByRole[role.roleKey] || []).filter(device => deviceMatchesSlot(device, slot))
|
||||||
|
if (isCameraSlot(slot)) {
|
||||||
|
return toDeviceOptions(devices).flatMap((option) => {
|
||||||
|
const choice = cameraChoice(role, slot, option.value, allowSwap)
|
||||||
|
if (!choice) return []
|
||||||
|
const label = choice.swap ? `${option.label}(与${choice.swap.slot.displayName}交换)` : option.label
|
||||||
|
return [{ ...option, label }]
|
||||||
|
})
|
||||||
|
}
|
||||||
const unavailableDeviceIds = new Set((role.deviceSlots || [])
|
const unavailableDeviceIds = new Set((role.deviceSlots || [])
|
||||||
.filter((otherSlot) => (
|
.filter((otherSlot) => (
|
||||||
otherSlot.slotKey !== slot.slotKey
|
otherSlot.slotKey !== slot.slotKey
|
||||||
@ -259,12 +289,25 @@ const optionsOf = (role, slot) => {
|
|||||||
))
|
))
|
||||||
.map((otherSlot) => member.devices[otherSlot.slotKey])
|
.map((otherSlot) => member.devices[otherSlot.slotKey])
|
||||||
.filter(Boolean))
|
.filter(Boolean))
|
||||||
return toDeviceOptions((devicesByRole[role.roleKey] || []).filter((device) => (
|
return toDeviceOptions(devices.filter((device) => (
|
||||||
deviceMatchesSlot(device, slot)
|
!unavailableDeviceIds.has(device.deviceId) || member.devices[slot.slotKey] === device.deviceId
|
||||||
&& (!unavailableDeviceIds.has(device.deviceId) || member.devices[slot.slotKey] === device.deviceId)
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const changeDevice = (role, slot, deviceId) => {
|
||||||
|
const member = memberOf(role)
|
||||||
|
if (isCameraSlot(slot)) {
|
||||||
|
const choice = cameraChoice(role, slot, deviceId, true)
|
||||||
|
if (!choice) return
|
||||||
|
if (choice.swap) {
|
||||||
|
const { role: otherRole, slot: otherSlot } = choice.swap
|
||||||
|
memberOf(otherRole).devices[otherSlot.slotKey] = member.devices[slot.slotKey]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
member.devices[slot.slotKey] = deviceId
|
||||||
|
emitValue()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按角色当前选择的机器人加载设备列表,并根据 preserve 决定是否尽量保留旧设备选择。
|
* 按角色当前选择的机器人加载设备列表,并根据 preserve 决定是否尽量保留旧设备选择。
|
||||||
*
|
*
|
||||||
|
|||||||
@ -100,7 +100,7 @@
|
|||||||
<!-- 同一日志可同时携带多种媒体;mediaOf 负责从新旧字段提取并按“类型+URL”去重。 -->
|
<!-- 同一日志可同时携带多种媒体;mediaOf 负责从新旧字段提取并按“类型+URL”去重。 -->
|
||||||
<div v-if="mediaOf(log).length" class="task-log__media">
|
<div v-if="mediaOf(log).length" class="task-log__media">
|
||||||
<template v-for="media in mediaOf(log)" :key="`${media.type}:${media.url}`">
|
<template v-for="media in mediaOf(log)" :key="`${media.type}:${media.url}`">
|
||||||
<el-image
|
<WorkflowImage
|
||||||
v-if="media.type === 'image'"
|
v-if="media.type === 'image'"
|
||||||
class="task-log__image"
|
class="task-log__image"
|
||||||
:src="media.url"
|
:src="media.url"
|
||||||
@ -109,7 +109,7 @@
|
|||||||
fit="cover"
|
fit="cover"
|
||||||
/>
|
/>
|
||||||
<!-- 视频和音频只预加载元数据,避免日志列表初次渲染时下载完整媒体文件。 -->
|
<!-- 视频和音频只预加载元数据,避免日志列表初次渲染时下载完整媒体文件。 -->
|
||||||
<video v-else-if="media.type === 'video'" class="task-log__video" :src="media.url" controls preload="metadata" />
|
<video v-else-if="media.type === 'video'" class="task-log__video" :src="workflowVideoUrl(media.url)" controls preload="metadata" />
|
||||||
<audio v-else class="task-log__audio" :src="media.url" controls preload="metadata" />
|
<audio v-else class="task-log__audio" :src="media.url" controls preload="metadata" />
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@ -144,6 +144,8 @@ import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'
|
|||||||
import { ArrowRight, Bottom } from '@element-plus/icons-vue'
|
import { ArrowRight, Bottom } from '@element-plus/icons-vue'
|
||||||
import { formatDate } from '@/utils/index'
|
import { formatDate } from '@/utils/index'
|
||||||
import AudioCorrectionDialog from './AudioCorrectionDialog.vue'
|
import AudioCorrectionDialog from './AudioCorrectionDialog.vue'
|
||||||
|
import WorkflowImage from './WorkflowImage.vue'
|
||||||
|
import { workflowVideoUrl } from '@/utils/workflowVideo'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list: 任务或流程节点产生的日志数组。组件只负责展示,不修改日志对象。
|
* list: 任务或流程节点产生的日志数组。组件只负责展示,不修改日志对象。
|
||||||
|
|||||||
64
src/views/flow/components/WorkflowImage.vue
Normal file
64
src/views/flow/components/WorkflowImage.vue
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<template>
|
||||||
|
<el-image
|
||||||
|
:src="resolved[src]"
|
||||||
|
:preview-src-list="previewSrcList.map(url => resolved[url]).filter(Boolean)"
|
||||||
|
>
|
||||||
|
<template v-if="failed" #placeholder>
|
||||||
|
<span>图片读取失败</span>
|
||||||
|
</template>
|
||||||
|
</el-image>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, shallowRef, watch } from 'vue'
|
||||||
|
import { getToken } from '@/utils/auth'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
src: { type: String, required: true },
|
||||||
|
previewSrcList: { type: Array, default: () => [] }
|
||||||
|
})
|
||||||
|
|
||||||
|
const resolved = shallowRef({})
|
||||||
|
const failed = ref(false)
|
||||||
|
|
||||||
|
function privateImageKey(url) {
|
||||||
|
const match = /^https?:\/\/minio(?::\d+)?\/[^/]+\/(IMAGE\/\d{8}\/[\w.-]+\.(?:jpe?g|png|webp))(?:\?.*)?$/i.exec(url)
|
||||||
|
return match?.[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => JSON.stringify([props.src, ...props.previewSrcList]), (imageList, _, onCleanup) => {
|
||||||
|
const cancel = new AbortController()
|
||||||
|
const blobUrls = []
|
||||||
|
onCleanup(() => {
|
||||||
|
cancel.abort()
|
||||||
|
blobUrls.forEach(url => URL.revokeObjectURL(url))
|
||||||
|
})
|
||||||
|
resolved.value = {}
|
||||||
|
failed.value = false
|
||||||
|
|
||||||
|
for (const url of new Set(JSON.parse(imageList).filter(Boolean))) {
|
||||||
|
const key = privateImageKey(url)
|
||||||
|
if (!key) {
|
||||||
|
resolved.value = { ...resolved.value, [url]: url }
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const endpoint = `${import.meta.env.VITE_APP_BASE_API}/system/file/workflow-image?object=${encodeURIComponent(key)}`
|
||||||
|
fetch(endpoint, {
|
||||||
|
headers: { Authorization: `Bearer ${getToken()}` },
|
||||||
|
signal: cancel.signal
|
||||||
|
}).then(response => {
|
||||||
|
if (!response.ok || !response.headers.get('Content-Type')?.startsWith('image/')) {
|
||||||
|
throw new Error('Image request failed')
|
||||||
|
}
|
||||||
|
return response.blob()
|
||||||
|
}).then(blob => {
|
||||||
|
if (cancel.signal.aborted) return
|
||||||
|
const objectUrl = URL.createObjectURL(blob)
|
||||||
|
blobUrls.push(objectUrl)
|
||||||
|
resolved.value = { ...resolved.value, [url]: objectUrl }
|
||||||
|
}).catch(() => {
|
||||||
|
if (!cancel.signal.aborted && props.src === url) failed.value = true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, { immediate: true })
|
||||||
|
</script>
|
||||||
@ -27,18 +27,36 @@
|
|||||||
<el-row>
|
<el-row>
|
||||||
<el-form-item :label="index === 0 ? '参数名' : ''" :prop="`nodeParams.${index}.name`"
|
<el-form-item :label="index === 0 ? '参数名' : ''" :prop="`nodeParams.${index}.name`"
|
||||||
:rules="[{ required: true, message: '请输入参数名', trigger: 'blur' }]">
|
:rules="[{ required: true, message: '请输入参数名', trigger: 'blur' }]">
|
||||||
<el-input :disabled="property?.disabled || false" class="param-name"
|
<el-input v-if="property.displayName || isVehicleVersionField(property)"
|
||||||
|
:model-value="isVehicleVersionField(property) ? '车机版本' : property.displayName" disabled class="param-name" />
|
||||||
|
<el-input v-else :disabled="property?.disabled || false" class="param-name"
|
||||||
v-model="property.name" placeholder="请输入" clearable />
|
v-model="property.name" placeholder="请输入" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="index === 0 ? '参数值' : ''" :prop="`nodeParams.${index}.type`">
|
<el-form-item :label="index === 0 ? '参数值' : ''" :prop="`nodeParams.${index}.type`">
|
||||||
<el-select v-model="property.type" class="param-type" :disabled="property?.forceSelect || false" @change="handleTypeChange(property)">
|
<el-select v-model="property.type" class="param-type" :disabled="property?.forceSelect || false" @change="changeParamType(property)">
|
||||||
<el-option label="引用" value="quote" />
|
<el-option label="引用" value="quote" />
|
||||||
<el-option label="输入" value="input" />
|
<el-option :label="isVehicleVersionField(property) ? '选择' : '输入'" value="input" />
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-form-item v-if="property.type === 'input'"
|
<el-form-item v-if="property.type === 'input'"
|
||||||
:rules="testRule(property)"
|
:rules="testRule(property)"
|
||||||
:prop="`nodeParams.${index}.input`">
|
:prop="`nodeParams.${index}.input`">
|
||||||
<el-input-number class="param-value" v-if="property.componentType === 'number'"
|
<VehicleVersionSelect v-if="isVehicleVersionField(property)" v-model="property.input" class="param-value" />
|
||||||
|
<div v-else-if="isDexHandReadback(props.data.properties.action) && property.name === 'values'"
|
||||||
|
class="dex-hand-values">
|
||||||
|
<el-input type="textarea" :rows="4" v-model="property.input"
|
||||||
|
:placeholder="props.data.properties.action === DEX_HAND_ANGLE_ACTION
|
||||||
|
? '读取当前角度可自动填入全部自由度' : '读取当前位置可自动填入全部自由度'"
|
||||||
|
@input="delete property.measuredAngles" />
|
||||||
|
<div v-if="property.measuredAngles?.length" class="measured-angles">
|
||||||
|
<span>实测角度(°)</span>
|
||||||
|
<div class="measured-angle-list">
|
||||||
|
<span v-for="axis in property.measuredAngles" :key="axis.id">
|
||||||
|
{{ dexHandAxisLabels[axis.id] }} {{ axis.degrees.toFixed(2) }}°
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-input-number class="param-value" v-else-if="property.componentType === 'number'"
|
||||||
v-model="property.input" :min="property.min ?? 0" :max="property.max || Infinity"
|
v-model="property.input" :min="property.min ?? 0" :max="property.max || Infinity"
|
||||||
:controls="property?.controls || true" :step-strictly="property.stepStrictly ?? true" :step="property.step || 1" placeholder="请输入" clearable />
|
:controls="property?.controls || true" :step-strictly="property.stepStrictly ?? true" :step="property.step || 1" placeholder="请输入" clearable />
|
||||||
<el-select v-model="property.input" class="param-value"
|
<el-select v-model="property.input" class="param-value"
|
||||||
@ -114,7 +132,8 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="dialogVisible = false">取消</el-button>
|
<el-button @click="dialogVisible = false">取消</el-button>
|
||||||
<el-button type="primary" :loading="robotFormLoading" @click="submitRobotForm">确认</el-button>
|
<el-button type="primary" :loading="robotFormLoading" :disabled="deviceLoading"
|
||||||
|
@click="submitRobotForm">{{ isDexHandReadback(robotFormAction) ? '读取并回填' : '确认' }}</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
@ -124,16 +143,18 @@ import { computed, ref, reactive, watch } from 'vue'
|
|||||||
import { Plus, Minus } from '@element-plus/icons-vue'
|
import { Plus, Minus } from '@element-plus/icons-vue'
|
||||||
import FormItemRecursive from '../FormItemRecursive.vue'
|
import FormItemRecursive from '../FormItemRecursive.vue'
|
||||||
import RobotExecutionTarget from './RobotExecutionTarget.vue'
|
import RobotExecutionTarget from './RobotExecutionTarget.vue'
|
||||||
|
import VehicleVersionSelect from './VehicleVersionSelect.vue'
|
||||||
import { useQuote } from './useQuote.js'
|
import { useQuote } from './useQuote.js'
|
||||||
import { getArmStatus, getArmJointState, getAgvStatus, getAgvStations } from '@/api/flow/flow'
|
import { flowAction, getArmStatus, getArmJointState, getAgvStatus, getAgvStations } from '@/api/flow/flow'
|
||||||
import { getRobotList, getRobotDevicesByRobotId } from '@/api/resource/robot'
|
import { getRobotList, getRobotDevicesByRobotId } from '@/api/resource/robot'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { deviceMatchesSlot, getDeviceKindForAction, getRequiredDeviceIdForAction, toDeviceOptions } from '@/utils/robotDevice'
|
import { dexHandAngleSnapshot, dexHandAxisLabels, dexHandPositionTargets, deviceMatchesSlot, getDeviceKindForAction, getRequiredDeviceIdForAction, toDeviceOptions } from '@/utils/robotDevice'
|
||||||
import { actionRequiresDevice } from '@/utils/flowResources'
|
import { actionRequiresDevice } from '@/utils/flowResources'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: Object
|
data: Object
|
||||||
})
|
})
|
||||||
|
const isVehicleVersionField = (param) => props.data.properties?.action === 'TI_PATH_SEARCH' && param.name === 'vehicleConfigId'
|
||||||
|
|
||||||
const emit = defineEmits(['save-success', 'save-error'])
|
const emit = defineEmits(['save-success', 'save-error'])
|
||||||
|
|
||||||
@ -151,6 +172,10 @@ const activeNames = ref(['1', '2'])
|
|||||||
|
|
||||||
// 使用共享的 quote 逻辑
|
// 使用共享的 quote 逻辑
|
||||||
const { quoteOptions, cascaderRefs, handleTypeChange, cascaderChange, visibleChange } = useQuote(props.data.id)
|
const { quoteOptions, cascaderRefs, handleTypeChange, cascaderChange, visibleChange } = useQuote(props.data.id)
|
||||||
|
const changeParamType = (property) => {
|
||||||
|
delete property.measuredAngles
|
||||||
|
handleTypeChange(property)
|
||||||
|
}
|
||||||
|
|
||||||
// 添加表单项
|
// 添加表单项
|
||||||
/**
|
/**
|
||||||
@ -310,6 +335,9 @@ const loadRobotDevices = async (robotId) => {
|
|||||||
* @param {*} property 参数属性
|
* @param {*} property 参数属性
|
||||||
*/
|
*/
|
||||||
const testRule = (property) => {
|
const testRule = (property) => {
|
||||||
|
if (isVehicleVersionField(property)) {
|
||||||
|
return [{ required: true, message: '请选择车机版本', trigger: 'change' }]
|
||||||
|
}
|
||||||
if (property?.name === 'stationId' && props.data.properties.action === 'AGV_MOVE_TO_STATION') {
|
if (property?.name === 'stationId' && props.data.properties.action === 'AGV_MOVE_TO_STATION') {
|
||||||
return [
|
return [
|
||||||
{ required: true, message: '请从站点列表中选择站点', trigger: 'change' },
|
{ required: true, message: '请从站点列表中选择站点', trigger: 'change' },
|
||||||
@ -354,21 +382,27 @@ const testRule = (property) => {
|
|||||||
const robotFormAction = ref()
|
const robotFormAction = ref()
|
||||||
const robotFormLoading = ref(false)
|
const robotFormLoading = ref(false)
|
||||||
const NECK_MOVE_ACTION = 'ARM_NECK_MOVE_J'
|
const NECK_MOVE_ACTION = 'ARM_NECK_MOVE_J'
|
||||||
|
const DEX_HAND_POSITION_ACTION = 'DEX_HAND_SET_POSITION'
|
||||||
|
const DEX_HAND_ANGLE_ACTION = 'DEX_HAND_SET_ANGLE'
|
||||||
|
const isDexHandReadback = (action) => [DEX_HAND_POSITION_ACTION, DEX_HAND_ANGLE_ACTION].includes(action)
|
||||||
const XIAOZHAO_NECK_JOINTS = ['neck-joint1', 'neck-joint2', 'neck-joint3']
|
const XIAOZHAO_NECK_JOINTS = ['neck-joint1', 'neck-joint2', 'neck-joint3']
|
||||||
const POSITION_ACTIONS = ['AGV_MOVE_TO_POINT', 'ARM_MOVE_TO_POINT', 'ARM_MOVE_TO_J', NECK_MOVE_ACTION]
|
const POSITION_ACTIONS = ['AGV_MOVE_TO_POINT', 'ARM_MOVE_TO_POINT', 'ARM_MOVE_TO_J', NECK_MOVE_ACTION]
|
||||||
const isRobotNode = computed(() => props.data.properties?.nodeType === 'EDGE')
|
const isRobotNode = computed(() => props.data.properties?.nodeType === 'EDGE')
|
||||||
const hasDeviceDebugAction = computed(() => (
|
const hasDeviceDebugAction = computed(() => (
|
||||||
POSITION_ACTIONS.includes(props.data.properties.action)
|
isDexHandReadback(props.data.properties.action) || POSITION_ACTIONS.includes(props.data.properties.action)
|
||||||
|| props.data.properties.action === 'AGV_MOVE_TO_STATION'
|
|| props.data.properties.action === 'AGV_MOVE_TO_STATION'
|
||||||
))
|
))
|
||||||
const robotActionButtonText = computed(() => {
|
const robotActionButtonText = computed(() => {
|
||||||
if (props.data.properties.action === 'AGV_MOVE_TO_STATION') return '选择机器人并加载站点'
|
if (props.data.properties.action === 'AGV_MOVE_TO_STATION') return '选择机器人并加载站点'
|
||||||
if (props.data.properties.action === NECK_MOVE_ACTION) return '获取当前位置'
|
if (props.data.properties.action === DEX_HAND_ANGLE_ACTION) return '获取当前角度'
|
||||||
|
if ([DEX_HAND_POSITION_ACTION, NECK_MOVE_ACTION].includes(props.data.properties.action)) return '获取当前位置'
|
||||||
if (POSITION_ACTIONS.includes(props.data.properties.action)) return '选择机器人并获取位置'
|
if (POSITION_ACTIONS.includes(props.data.properties.action)) return '选择机器人并获取位置'
|
||||||
return '选择机器人设备'
|
return '选择机器人设备'
|
||||||
})
|
})
|
||||||
const robotDialogTitle = computed(() => {
|
const robotDialogTitle = computed(() => {
|
||||||
if (robotFormAction.value === 'AGV_MOVE_TO_STATION') return '选择AGV并加载站点'
|
if (robotFormAction.value === 'AGV_MOVE_TO_STATION') return '选择AGV并加载站点'
|
||||||
|
if (robotFormAction.value === DEX_HAND_ANGLE_ACTION) return '读取灵巧手当前角度'
|
||||||
|
if (robotFormAction.value === DEX_HAND_POSITION_ACTION) return '读取灵巧手当前位置'
|
||||||
if (robotFormAction.value === NECK_MOVE_ACTION) return '读取颈部当前位置'
|
if (robotFormAction.value === NECK_MOVE_ACTION) return '读取颈部当前位置'
|
||||||
if (POSITION_ACTIONS.includes(robotFormAction.value)) return '选择机器人并读取当前位置'
|
if (POSITION_ACTIONS.includes(robotFormAction.value)) return '选择机器人并读取当前位置'
|
||||||
return '选择机器人设备'
|
return '选择机器人设备'
|
||||||
@ -378,7 +412,47 @@ const robotDialogTitle = computed(() => {
|
|||||||
* 处理 submitRobotForm 对应的数据或交互;作用范围仅限当前组件或模块。
|
* 处理 submitRobotForm 对应的数据或交互;作用范围仅限当前组件或模块。
|
||||||
*/
|
*/
|
||||||
const submitRobotForm = () => {
|
const submitRobotForm = () => {
|
||||||
if (robotFormAction.value === 'AGV_MOVE_TO_POINT') {
|
const action = robotFormAction.value
|
||||||
|
if (isDexHandReadback(action)) {
|
||||||
|
const captureAngle = action === DEX_HAND_ANGLE_ACTION
|
||||||
|
const captureKind = captureAngle ? '角度' : '位置'
|
||||||
|
robotFormRef.value.validate(async (valid) => {
|
||||||
|
if (!valid) return
|
||||||
|
const { robotId, deviceId } = robotForm
|
||||||
|
const nodeId = props.data.id
|
||||||
|
robotFormLoading.value = true
|
||||||
|
try {
|
||||||
|
const { data } = await flowAction({
|
||||||
|
action: 'DEX_HAND_GET_STATE',
|
||||||
|
payload: { robotId, deviceId },
|
||||||
|
})
|
||||||
|
if (!dialogVisible.value || props.data.id !== nodeId || props.data.properties.action !== action
|
||||||
|
|| robotForm.robotId !== robotId || robotForm.deviceId !== deviceId) return
|
||||||
|
|
||||||
|
const state = typeof data === 'string' ? JSON.parse(data) : data
|
||||||
|
const snapshot = captureAngle ? dexHandAngleSnapshot(state) : { values: dexHandPositionTargets(state) }
|
||||||
|
let batchParam = formData.nodeParams.find(param => param.name === 'values')
|
||||||
|
if (!batchParam) {
|
||||||
|
formData.nodeParams.push({ name: 'values', displayName: '多自由度参数', disabled: true, required: false })
|
||||||
|
batchParam = formData.nodeParams.at(-1)
|
||||||
|
}
|
||||||
|
for (const param of formData.nodeParams) {
|
||||||
|
if (!['id', 'value', 'values'].includes(param.name)) continue
|
||||||
|
param.type = 'input'
|
||||||
|
param.quote = []
|
||||||
|
delete param.quoteType
|
||||||
|
param.input = param === batchParam ? JSON.stringify(snapshot.values) : null
|
||||||
|
}
|
||||||
|
if (captureAngle) batchParam.measuredAngles = snapshot.angles
|
||||||
|
dialogVisible.value = false
|
||||||
|
ElMessage.success(`已回填 ${snapshot.values.length} 个自由度的${captureKind}目标,请保存节点`)
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error(error?.message || `读取灵巧手当前${captureKind}失败`)
|
||||||
|
} finally {
|
||||||
|
robotFormLoading.value = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if (robotFormAction.value === 'AGV_MOVE_TO_POINT') {
|
||||||
robotFormRef.value.validate(async (valid) => {
|
robotFormRef.value.validate(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
try {
|
try {
|
||||||
@ -565,6 +639,23 @@ defineExpose({ validateAndSave })
|
|||||||
width: 160px;
|
width: 160px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dex-hand-values {
|
||||||
|
width: 280px;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.measured-angles {
|
||||||
|
margin-top: 8px;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.measured-angle-list {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 4px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -86,18 +86,32 @@
|
|||||||
<div class="field-hint">开启后分析在后台并行执行,流程结束前统一等待分析结果。</div>
|
<div class="field-hint">开启后分析在后台并行执行,流程结束前统一等待分析结果。</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 视频模型依赖自然语言标准判断是否通过;音频节点使用 expectedLabel,不需要 instruction。 -->
|
<template v-if="isVideo">
|
||||||
<el-form-item v-if="isVideo" label="通过标准" prop="instruction" required>
|
<el-form-item label="评判标准" required>
|
||||||
<el-input
|
<el-segmented v-model="formData.instructionMode" :options="instructionModes" />
|
||||||
v-model="formData.instruction"
|
</el-form-item>
|
||||||
type="textarea"
|
<el-form-item v-if="formData.instructionMode === 'quote'" prop="instructionQuote">
|
||||||
:rows="4"
|
<el-cascader
|
||||||
maxlength="2000"
|
v-model="formData.instructionQuote"
|
||||||
show-word-limit
|
:options="quoteOptions"
|
||||||
placeholder="例如:车辆启动后,仪表必须在3秒内点亮"
|
placeholder="选择上游节点的文本字段"
|
||||||
/>
|
style="width: 100%"
|
||||||
|
clearable
|
||||||
|
@visible-change="loadQuoteOptions"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-else prop="instruction">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.instruction"
|
||||||
|
type="textarea"
|
||||||
|
:rows="4"
|
||||||
|
maxlength="2000"
|
||||||
|
show-word-limit
|
||||||
|
placeholder="例如:车辆启动后,仪表必须在3秒内点亮"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
<div class="field-hint">未观察到完整证据或置信度不足时,结果按未通过处理。</div>
|
<div class="field-hint">未观察到完整证据或置信度不足时,结果按未通过处理。</div>
|
||||||
</el-form-item>
|
</template>
|
||||||
|
|
||||||
<!-- 切换分析模式时同步恢复该模式预设,避免旧模式的微调参数意外带入新模式。 -->
|
<!-- 切换分析模式时同步恢复该模式预设,避免旧模式的微调参数意外带入新模式。 -->
|
||||||
<el-form-item v-if="isVideo" label="分析模式">
|
<el-form-item v-if="isVideo" label="分析模式">
|
||||||
@ -203,7 +217,9 @@ const formData = reactive({
|
|||||||
mediaQuote: [],
|
mediaQuote: [],
|
||||||
mediaQuoteType: 'output',
|
mediaQuoteType: 'output',
|
||||||
mediaUrl: '',
|
mediaUrl: '',
|
||||||
|
instructionMode: 'input',
|
||||||
instruction: '',
|
instruction: '',
|
||||||
|
instructionQuote: [],
|
||||||
analysisMode: 'AUTO',
|
analysisMode: 'AUTO',
|
||||||
detailedOutput: false,
|
detailedOutput: false,
|
||||||
asynchronous: false,
|
asynchronous: false,
|
||||||
@ -228,6 +244,10 @@ const mediaModes = [
|
|||||||
{ label: '引用节点输出', value: 'quote' },
|
{ label: '引用节点输出', value: 'quote' },
|
||||||
{ label: '直接输入地址', value: 'input' },
|
{ label: '直接输入地址', value: 'input' },
|
||||||
]
|
]
|
||||||
|
const instructionModes = [
|
||||||
|
{ label: '手动输入', value: 'input' },
|
||||||
|
{ label: '引用节点参数', value: 'quote' },
|
||||||
|
]
|
||||||
const analysisModes = [
|
const analysisModes = [
|
||||||
{ label: '快速', value: 'FAST' },
|
{ label: '快速', value: 'FAST' },
|
||||||
{ label: '均衡', value: 'AUTO' },
|
{ label: '均衡', value: 'AUTO' },
|
||||||
@ -313,11 +333,18 @@ const rules = {
|
|||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
}],
|
}],
|
||||||
instruction: [{
|
instruction: [{
|
||||||
validator: (_, value) => !isVideo.value || String(value || '').trim()
|
validator: (_, value) => String(value || '').trim()
|
||||||
? Promise.resolve()
|
? Promise.resolve()
|
||||||
: Promise.reject(new Error('请输入明确的通过标准')),
|
: Promise.reject(new Error('请输入评判标准')),
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
}],
|
}],
|
||||||
|
instructionQuote: [{
|
||||||
|
validator: (_, value) => Array.isArray(value) && value.length >= 3
|
||||||
|
&& ['input', 'output'].includes(value[1])
|
||||||
|
? Promise.resolve()
|
||||||
|
: Promise.reject(new Error('请选择评判标准引用的字段')),
|
||||||
|
trigger: 'change',
|
||||||
|
}],
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用 Object.assign 保留 analysisTuning 的响应式引用,只覆盖当前模式定义的预设字段。
|
// 使用 Object.assign 保留 analysisTuning 的响应式引用,只覆盖当前模式定义的预设字段。
|
||||||
@ -415,7 +442,9 @@ const initData = () => {
|
|||||||
formData.mediaQuote = Array.isArray(media?.quote) ? [...media.quote] : []
|
formData.mediaQuote = Array.isArray(media?.quote) ? [...media.quote] : []
|
||||||
formData.mediaQuoteType = media?.quoteType || 'output'
|
formData.mediaQuoteType = media?.quoteType || 'output'
|
||||||
formData.mediaUrl = media?.input || ''
|
formData.mediaUrl = media?.input || ''
|
||||||
formData.instruction = instruction?.input || ''
|
formData.instructionMode = instruction?.type === 'quote' ? 'quote' : 'input'
|
||||||
|
formData.instruction = typeof instruction?.input === 'string' ? instruction.input : ''
|
||||||
|
formData.instructionQuote = Array.isArray(instruction?.quote) ? [...instruction.quote] : []
|
||||||
formData.analysisMode = analysisPresets[analysisMode?.input] ? analysisMode.input : 'AUTO'
|
formData.analysisMode = analysisPresets[analysisMode?.input] ? analysisMode.input : 'AUTO'
|
||||||
// 兼容旧流程或外部写入的字符串值,表单内部统一使用布尔值驱动开关。
|
// 兼容旧流程或外部写入的字符串值,表单内部统一使用布尔值驱动开关。
|
||||||
formData.detailedOutput = detailedOutput?.input === true || detailedOutput?.input === 'true'
|
formData.detailedOutput = detailedOutput?.input === true || detailedOutput?.input === 'true'
|
||||||
@ -496,8 +525,11 @@ const validateAndSave = async () => {
|
|||||||
if (isVideo.value) {
|
if (isVideo.value) {
|
||||||
nodeParams.push({
|
nodeParams.push({
|
||||||
name: 'instruction',
|
name: 'instruction',
|
||||||
type: 'input',
|
displayName: '评判标准',
|
||||||
input: formData.instruction.trim(),
|
type: formData.instructionMode,
|
||||||
|
...(formData.instructionMode === 'quote'
|
||||||
|
? { quote: [...formData.instructionQuote], quoteType: formData.instructionQuote[1] }
|
||||||
|
: { input: formData.instruction.trim() }),
|
||||||
required: true,
|
required: true,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@ -37,6 +37,7 @@
|
|||||||
<el-collapse-item name="inputs">
|
<el-collapse-item name="inputs">
|
||||||
<template #title>
|
<template #title>
|
||||||
输入参数
|
输入参数
|
||||||
|
<el-button link type="primary" @click.stop="addTouchProjectInputs">添加触控项目参数</el-button>
|
||||||
<el-button circle size="small" class="addFormItem" @click="(event) => addFormItem(event, 'inputParams')">
|
<el-button circle size="small" class="addFormItem" @click="(event) => addFormItem(event, 'inputParams')">
|
||||||
<el-icon :size="14"><Plus /></el-icon>
|
<el-icon :size="14"><Plus /></el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
@ -69,6 +70,7 @@ import { Delete, Minus, Plus } from '@element-plus/icons-vue'
|
|||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import FormItemRecursive from '../FormItemRecursive.vue'
|
import FormItemRecursive from '../FormItemRecursive.vue'
|
||||||
import { DEVICE_KIND, NECK_DEVICE_ID } from '@/utils/robotDevice'
|
import { DEVICE_KIND, NECK_DEVICE_ID } from '@/utils/robotDevice'
|
||||||
|
import { touchProjectInputs } from '@/utils/touchFlow'
|
||||||
import {
|
import {
|
||||||
createDefaultRobotRole,
|
createDefaultRobotRole,
|
||||||
createDeviceSlot,
|
createDeviceSlot,
|
||||||
@ -85,6 +87,7 @@ const deviceKinds = [
|
|||||||
{ label: '机械臂', value: 2 },
|
{ label: '机械臂', value: 2 },
|
||||||
{ label: '仿生头', value: 4 },
|
{ label: '仿生头', value: 4 },
|
||||||
{ label: '摄像头', value: 5 },
|
{ label: '摄像头', value: 5 },
|
||||||
|
{ label: '灵巧手', value: DEVICE_KIND.DEX_HAND },
|
||||||
{ label: '麦克风', value: 9 },
|
{ label: '麦克风', value: 9 },
|
||||||
{ label: '机器人本体', value: 12 },
|
{ label: '机器人本体', value: 12 },
|
||||||
{ label: '扬声器', value: 13 },
|
{ label: '扬声器', value: 13 },
|
||||||
@ -141,6 +144,14 @@ const addFormItem = (event, type) => {
|
|||||||
formData[type].push({ name: '', type: 'string', required: false, children: [], input: '' })
|
formData[type].push({ name: '', type: 'string', required: false, children: [], input: '' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const addTouchProjectInputs = () => {
|
||||||
|
for (const field of touchProjectInputs()) {
|
||||||
|
const existing = formData.inputParams.find(param => param.name === field.name)
|
||||||
|
if (existing) Object.assign(existing, field)
|
||||||
|
else formData.inputParams.push(field)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const deleteTopLevelItem = (fullPath, propPath) => {
|
const deleteTopLevelItem = (fullPath, propPath) => {
|
||||||
let currentLevel = formData[propPath]
|
let currentLevel = formData[propPath]
|
||||||
for (let index = 0; index < fullPath.length - 1; index += 1) {
|
for (let index = 0; index < fullPath.length - 1; index += 1) {
|
||||||
|
|||||||
51
src/views/flow/components/params/VehicleVersionSelect.vue
Normal file
51
src/views/flow/components/params/VehicleVersionSelect.vue
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<template>
|
||||||
|
<el-cascader
|
||||||
|
:model-value="modelValue == null ? '' : String(modelValue)"
|
||||||
|
:options="options"
|
||||||
|
:props="{ emitPath: false }"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
:disabled="loading || !options.length"
|
||||||
|
aria-label="车机版本"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
@update:model-value="value => emit('update:modelValue', value ?? '')"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed, onMounted, ref } from 'vue'
|
||||||
|
import { getTreeDataApi } from '@/api/is/func/index'
|
||||||
|
|
||||||
|
defineProps({ modelValue: [String, Number] })
|
||||||
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
const options = ref([])
|
||||||
|
const loading = ref(true)
|
||||||
|
const failed = ref(false)
|
||||||
|
const placeholder = computed(() => {
|
||||||
|
if (loading.value) return '正在加载车机版本'
|
||||||
|
if (failed.value) return '车机版本加载失败'
|
||||||
|
return options.value.length ? '请选择车企 / 车型 / 版本' : '暂无可用车机版本'
|
||||||
|
})
|
||||||
|
|
||||||
|
const levels = ['oem', 'model', 'version']
|
||||||
|
|
||||||
|
function versionOptions(nodes, depth = 0) {
|
||||||
|
return (nodes || []).flatMap(node => {
|
||||||
|
if (node.type !== levels[depth] || node.id == null) return []
|
||||||
|
const option = { value: String(node.id), label: node.label }
|
||||||
|
if (node.type === 'version') return [option]
|
||||||
|
const children = versionOptions(node.children, depth + 1)
|
||||||
|
return children.length ? [{ ...option, children }] : []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
options.value = versionOptions(await getTreeDataApi())
|
||||||
|
} catch {
|
||||||
|
failed.value = true
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@ -15,6 +15,8 @@ import audioSvg from './icon/audio.svg'
|
|||||||
import touchSvg from './icon/touch.svg'
|
import touchSvg from './icon/touch.svg'
|
||||||
import expressionSvg from './icon/expression.svg'
|
import expressionSvg from './icon/expression.svg'
|
||||||
import { DEFAULT_CHAT_SYSTEM_PROMPT } from './chatPrompt.js'
|
import { DEFAULT_CHAT_SYSTEM_PROMPT } from './chatPrompt.js'
|
||||||
|
import { dexHandAxisLabels } from '@/utils/robotDevice'
|
||||||
|
import { touchCoordinatesInput, touchPathSearchOutputs, touchPathStepOutputs, touchRetryInput, touchRetryOutput } from '@/utils/touchFlow'
|
||||||
|
|
||||||
const pointOutputChildren = () => [
|
const pointOutputChildren = () => [
|
||||||
{ name: 'x', type: 'number', desc: 'X坐标' },
|
{ name: 'x', type: 'number', desc: 'X坐标' },
|
||||||
@ -124,6 +126,80 @@ const neckNodes = [
|
|||||||
nodeParams: [], outputParams: [], ...node,
|
nodeParams: [], outputParams: [], ...node,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
const dexHandValues = () => [
|
||||||
|
{
|
||||||
|
...headParam('id', null), displayName: '自由度', componentType: 'select', required: false,
|
||||||
|
selectOptions: dexHandAxisLabels.map((label, value) => ({ value, label })),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...headNumber('value'), displayName: '目标比例(0–1)', input: null, min: 0, max: 1, required: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...headParam('values', '', '可选,填写 JSON 数组,如 [{"id":3,"value":0.5}]'),
|
||||||
|
displayName: '多自由度参数', required: false,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
const dexHandNodes = [
|
||||||
|
{
|
||||||
|
name: '查询灵巧手状态', action: 'DEX_HAND_GET_STATE', desc: '读取设备型号、初始化状态和各自由度反馈',
|
||||||
|
outputParams: [
|
||||||
|
...[
|
||||||
|
['initialized', 'boolean', '是否已初始化'], ['model', 'string', '设备型号'],
|
||||||
|
['hasTactileFeedback', 'boolean', '设备是否上报触觉反馈能力'],
|
||||||
|
].map(headOutput),
|
||||||
|
{
|
||||||
|
...headOutput(['hands', 'array<object>', '各自由度的实际反馈']),
|
||||||
|
children: [
|
||||||
|
['id', 'number', '自由度编号'], ['angle', 'number', '实际角度'],
|
||||||
|
['position', 'number', '执行器位置'], ['speed', 'number', '实际速度'],
|
||||||
|
['force', 'number', '实际受力'], ['current', 'number', '电流'],
|
||||||
|
['temperature', 'number', '温度'], ['error', 'number', '故障码'],
|
||||||
|
['errorMessages', 'array<string>', '故障描述'],
|
||||||
|
].map(headOutput),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
...[
|
||||||
|
['设置灵巧手角度', 'DEX_HAND_SET_ANGLE', '可读取当前角度并保存,运行时批量设置自由度'],
|
||||||
|
['设置灵巧手位置', 'DEX_HAND_SET_POSITION', '可读取当前位置并保存,运行时批量设置自由度'],
|
||||||
|
['设置灵巧手力度', 'DEX_HAND_SET_FORCE', '按比例设置目标力度,需设备支持'],
|
||||||
|
['设置灵巧手速度', 'DEX_HAND_SET_SPEED', '按比例设置目标速度,需设备支持'],
|
||||||
|
].map(([name, action, desc]) => ({
|
||||||
|
name, action, desc, nodeParams: dexHandValues(),
|
||||||
|
outputParams: [{
|
||||||
|
...headOutput(['values', 'array<object>', '已下发的目标值']),
|
||||||
|
children: [['id', 'number', '自由度编号'], ['value', 'number', '目标比例']].map(headOutput),
|
||||||
|
}],
|
||||||
|
})),
|
||||||
|
{
|
||||||
|
name: '执行灵巧手预设动作', action: 'DEX_HAND_PLAY_PRESET', desc: '按设备支持的动作编号执行预设动作',
|
||||||
|
nodeParams: [{
|
||||||
|
...headNumber('presetActId'), displayName: '预设动作编号', input: null, min: 0, step: 1, stepStrictly: true, required: true,
|
||||||
|
}],
|
||||||
|
outputParams: [headOutput(['presetActId', 'number', '已下发的动作编号'])],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '读取灵巧手触觉', action: 'DEX_HAND_GET_TACTILE', desc: '读取当前各触觉传感器的采样矩阵',
|
||||||
|
outputParams: [{
|
||||||
|
...headOutput(['sensors', 'array<object>', '触觉传感器列表']),
|
||||||
|
children: [
|
||||||
|
...[
|
||||||
|
['name', 'string', '传感器名称'], ['fingerType', 'number', '手指类型编码'],
|
||||||
|
['partType', 'number', '部位编码'], ['rows', 'number', '采样行数'], ['cols', 'number', '采样列数'],
|
||||||
|
].map(headOutput),
|
||||||
|
{
|
||||||
|
...headOutput(['data', 'array<object>', '逐行采样数据']),
|
||||||
|
children: [headOutput(['values', 'array<number>', '当前行的采样值'])],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
].map(({ outputParams, ...node }) => ({
|
||||||
|
icon: touchSvg, type: 'serviceNode', nodeType: 'EDGE', outputType: 'json', nodeParams: [], ...node,
|
||||||
|
outputParams: [headOutput(['success', 'boolean', '边端操作已确认']), ...outputParams],
|
||||||
|
}))
|
||||||
|
|
||||||
const expressOptions = () => {
|
const expressOptions = () => {
|
||||||
return [{
|
return [{
|
||||||
value: 1,
|
value: 1,
|
||||||
@ -240,7 +316,7 @@ export const collapseList = [
|
|||||||
type: "loop",
|
type: "loop",
|
||||||
action: 'START_LOOP',
|
action: 'START_LOOP',
|
||||||
desc: "实现对列表对象循环执行一系列任务",
|
desc: "实现对列表对象循环执行一系列任务",
|
||||||
nodeParams: [{ name: "loopNum", type: "input", input: null, quote: "" }],
|
nodeParams: [{ name: "loopNum", displayName: "列表或次数", type: "input", input: null, quote: "" }],
|
||||||
outputParams: [],
|
outputParams: [],
|
||||||
outputType: 'json'
|
outputType: 'json'
|
||||||
},
|
},
|
||||||
@ -589,6 +665,7 @@ function handler(params) {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ collapseTitle: '颈部', nodeList: neckNodes },
|
{ collapseTitle: '颈部', nodeList: neckNodes },
|
||||||
|
{ collapseTitle: '灵巧手', nodeList: dexHandNodes },
|
||||||
{
|
{
|
||||||
collapseTitle: "音频",
|
collapseTitle: "音频",
|
||||||
nodeList: [
|
nodeList: [
|
||||||
@ -667,7 +744,7 @@ function handler(params) {
|
|||||||
nodeParams: [
|
nodeParams: [
|
||||||
{ name: "profileCode", type: "input", input: "aima.power_video.v1", required: true, disabled: true },
|
{ name: "profileCode", type: "input", input: "aima.power_video.v1", required: true, disabled: true },
|
||||||
{ name: "videoUrl", type: "quote", input: "", quote: "", required: true, disabled: true },
|
{ name: "videoUrl", type: "quote", input: "", quote: "", required: true, disabled: true },
|
||||||
{ name: "instruction", type: "input", input: "", required: true, disabled: true },
|
{ name: "instruction", displayName: "评判标准", type: "input", input: "", required: true, disabled: true },
|
||||||
{ name: "analysisMode", type: "input", input: "AUTO", required: false, disabled: true },
|
{ name: "analysisMode", type: "input", input: "AUTO", required: false, disabled: true },
|
||||||
// 默认返回精简结论;用户开启详细输出时,执行端才补充事件证据。
|
// 默认返回精简结论;用户开启详细输出时,执行端才补充事件证据。
|
||||||
{ name: "detailedOutput", type: "input", input: false, required: false, disabled: true, componentType: "switch" },
|
{ name: "detailedOutput", type: "input", input: false, required: false, disabled: true, componentType: "switch" },
|
||||||
@ -783,6 +860,32 @@ function handler(params) {
|
|||||||
{
|
{
|
||||||
collapseTitle: "触控交互",
|
collapseTitle: "触控交互",
|
||||||
nodeList: [
|
nodeList: [
|
||||||
|
{
|
||||||
|
icon: touchSvg,
|
||||||
|
name: "获取功能坐标",
|
||||||
|
type: "serviceNode",
|
||||||
|
desc: "从车机截图定位指定功能,输出照片像素坐标",
|
||||||
|
action: "UI_LOCATE_BUTTON",
|
||||||
|
nodeType: "LLM",
|
||||||
|
outputType: "json",
|
||||||
|
nodeParams: [
|
||||||
|
{ name: "imageUrl", displayName: "截图", type: "quote", input: "", quote: [], required: true, disabled: true },
|
||||||
|
{ name: "target", displayName: "功能名称", type: "input", input: "", desc: "例如打开自动空调", required: true, disabled: true },
|
||||||
|
{ name: "pageName", displayName: "页面名称(选填)", type: "input", input: "", desc: "可引用获取当前页面名称", required: false, disabled: true },
|
||||||
|
],
|
||||||
|
outputParams: [
|
||||||
|
{ name: "point", type: "array<number>", children: [], desc: "照片像素坐标 [x, y]", disabled: true },
|
||||||
|
{ name: "status", type: "string", desc: "定位状态", disabled: true },
|
||||||
|
{ name: "pageName", type: "string", desc: "当前页面名称", disabled: true },
|
||||||
|
{ name: "imageSize", type: "object", children: [
|
||||||
|
{ name: "width", type: "number", desc: "图片宽度" },
|
||||||
|
{ name: "height", type: "number", desc: "图片高度" },
|
||||||
|
], desc: "图片尺寸", disabled: true },
|
||||||
|
{ name: "coordinateSystem", type: "string", desc: "坐标系", disabled: true },
|
||||||
|
{ name: "needsReview", type: "boolean", desc: "点位是否需要复核", disabled: true },
|
||||||
|
{ name: "reason", type: "string", desc: "无法定位的原因", disabled: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
icon: touchSvg,
|
icon: touchSvg,
|
||||||
name: "触控",
|
name: "触控",
|
||||||
@ -791,9 +894,12 @@ function handler(params) {
|
|||||||
action: 'TOUCH',
|
action: 'TOUCH',
|
||||||
nodeType: "EDGE",
|
nodeType: "EDGE",
|
||||||
nodeParams: [
|
nodeParams: [
|
||||||
{ name: "touchParams", type: "input", input: "", disabled: true }
|
{ name: "touchParams", type: "input", input: "", disabled: true, required: false },
|
||||||
|
touchCoordinatesInput(),
|
||||||
|
touchRetryInput(),
|
||||||
],
|
],
|
||||||
outputType: 'json',
|
outputType: 'json',
|
||||||
|
outputParams: [touchRetryOutput()],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: expressionSvg,
|
icon: expressionSvg,
|
||||||
@ -832,20 +938,40 @@ function handler(params) {
|
|||||||
icon: touchSvg,
|
icon: touchSvg,
|
||||||
name: "路径搜索",
|
name: "路径搜索",
|
||||||
type: "serviceNode",
|
type: "serviceNode",
|
||||||
desc: "路径搜索",
|
desc: "从识别到的车机界面搜索到目标功能的点击顺序",
|
||||||
action: 'TI_PATH_SEARCH',
|
action: 'TI_PATH_SEARCH',
|
||||||
nodeType: "EDGE",
|
nodeType: "EDGE",
|
||||||
nodeParams: [
|
nodeParams: [
|
||||||
{ name: "currentLocation", type: "input", input: "", disabled: true },
|
{ name: "currentLocation", displayName: "当前界面", type: "quote", input: "", quote: [], desc: "引用获取当前页面名称", disabled: true, required: true },
|
||||||
{ name: "funcId", type: "input", input: "", disabled: true },
|
{ name: "funcId", displayName: "目标功能", type: "input", input: "", desc: "可引用当前项目功能,也可直接输入", disabled: true, required: true },
|
||||||
{ name: "vehicleConfigId", type: "input", input: "", disabled: true },
|
{ name: "vehicleConfigId", displayName: "车机版本", type: "input", input: "", disabled: true, required: true },
|
||||||
],
|
],
|
||||||
outputType: 'json',
|
outputType: 'json',
|
||||||
|
outputParams: touchPathSearchOutputs(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: touchSvg,
|
||||||
|
name: '获取当前项目功能',
|
||||||
|
type: 'currentLoop',
|
||||||
|
action: 'GET_CURRENT_OBJECT',
|
||||||
|
desc: '从项目功能列表取出当前一项,按编排顺序返回功能 ID',
|
||||||
|
nodeParams: [],
|
||||||
|
outputType: 'json',
|
||||||
outputParams: [
|
outputParams: [
|
||||||
{ name: 'nextLocation', type: 'string', desc: '下一路径位置', disabled: true},
|
{ name: 'index', type: 'number', desc: '索引', disabled: true },
|
||||||
{ name: 'isEnd', type: 'string', desc: '是否结束', disabled: true},
|
{ name: 'object', type: 'number', desc: '当前项目功能 ID', disabled: true },
|
||||||
{ name: 'iconUrl', type: 'string', desc: '图标路径', disabled: true}
|
],
|
||||||
]
|
},
|
||||||
|
{
|
||||||
|
icon: touchSvg,
|
||||||
|
name: '获取当前路径步骤',
|
||||||
|
loopValueType: 'touchPathStep',
|
||||||
|
type: 'currentLoop',
|
||||||
|
action: 'GET_CURRENT_OBJECT',
|
||||||
|
desc: '依次读取循环节点所引用的完整路径',
|
||||||
|
nodeParams: [],
|
||||||
|
outputType: 'json',
|
||||||
|
outputParams: touchPathStepOutputs(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: touchSvg,
|
icon: touchSvg,
|
||||||
|
|||||||
@ -272,6 +272,14 @@
|
|||||||
:label="index === 0 ? '参数名' : ''"
|
:label="index === 0 ? '参数名' : ''"
|
||||||
>
|
>
|
||||||
<el-input
|
<el-input
|
||||||
|
v-if="(nodeAction === 'TI_PATH_SEARCH' && field.param.name === 'vehicleConfigId')
|
||||||
|
|| (field.param.disabled && field.param.displayName)"
|
||||||
|
:model-value="nodeAction === 'TI_PATH_SEARCH' && field.param.name === 'vehicleConfigId'
|
||||||
|
? '车机版本' : field.param.displayName"
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
<el-input
|
||||||
|
v-else
|
||||||
:disabled="field.param?.disabled || false"
|
:disabled="field.param?.disabled || false"
|
||||||
v-model="field.param.name"
|
v-model="field.param.name"
|
||||||
:placeholder="field.param.placeholder || '请输入'"
|
:placeholder="field.param.placeholder || '请输入'"
|
||||||
@ -282,8 +290,12 @@
|
|||||||
class="single-node-param-value"
|
class="single-node-param-value"
|
||||||
:label="index === 0 ? '参数值' : ''"
|
:label="index === 0 ? '参数值' : ''"
|
||||||
>
|
>
|
||||||
|
<VehicleVersionSelect
|
||||||
|
v-if="nodeAction === 'TI_PATH_SEARCH' && field.param.name === 'vehicleConfigId'"
|
||||||
|
v-model="field.param.input"
|
||||||
|
/>
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-if="field.param.componentType === 'number'"
|
v-else-if="field.param.componentType === 'number'"
|
||||||
v-model="field.param.input"
|
v-model="field.param.input"
|
||||||
:min="field.param.min ?? 0"
|
:min="field.param.min ?? 0"
|
||||||
:max="field.param.max || Infinity"
|
:max="field.param.max || Infinity"
|
||||||
@ -381,6 +393,7 @@ import TestRun from "./components/TestRun.vue";
|
|||||||
import ParamsDrawer from "./components/ParamsDrawer.vue";
|
import ParamsDrawer from "./components/ParamsDrawer.vue";
|
||||||
import Aside from "./components/Aside.vue";
|
import Aside from "./components/Aside.vue";
|
||||||
import ActionQueueSingleRun from "./components/ActionQueueSingleRun.vue";
|
import ActionQueueSingleRun from "./components/ActionQueueSingleRun.vue";
|
||||||
|
import VehicleVersionSelect from "./components/params/VehicleVersionSelect.vue";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
import { useFlowStore } from "@/store/modules/flow";
|
import { useFlowStore } from "@/store/modules/flow";
|
||||||
import { emitter } from "@/utils/eventBus";
|
import { emitter } from "@/utils/eventBus";
|
||||||
@ -2239,7 +2252,7 @@ const singleNodeExecution = async (e) => {
|
|||||||
singleNodeExecuting.value = false;
|
singleNodeExecuting.value = false;
|
||||||
singleQueueStepExecutingIndex.value = -1;
|
singleQueueStepExecutingIndex.value = -1;
|
||||||
stationLoading.value = false;
|
stationLoading.value = false;
|
||||||
if (effectiveNodeType === "EDGE") {
|
if (effectiveNodeType === "EDGE" && normalizedAction !== "TI_PATH_SEARCH") {
|
||||||
await loadSingleNodeRobots();
|
await loadSingleNodeRobots();
|
||||||
const cachedRobotId = singleNodeRobotCache.get(activeSingleNodeId.value) || lastSingleNodeRobotId;
|
const cachedRobotId = singleNodeRobotCache.get(activeSingleNodeId.value) || lastSingleNodeRobotId;
|
||||||
if (normalizedAction === "SYSTEM_EXECUTE_ACTION_QUEUE") {
|
if (normalizedAction === "SYSTEM_EXECUTE_ACTION_QUEUE") {
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
sort
|
sort
|
||||||
theme="light"
|
theme="light"
|
||||||
/>
|
/>
|
||||||
<el-image
|
<WorkflowImage
|
||||||
v-if="props.properties.outputType === 'img'"
|
v-if="props.properties.outputType === 'img'"
|
||||||
v-for="item in outputJsonData.imageUrl"
|
v-for="item in outputJsonData.imageUrl"
|
||||||
style="width: 60px; height: 60px"
|
style="width: 60px; height: 60px"
|
||||||
@ -81,6 +81,7 @@
|
|||||||
import { computed, ref, onMounted } from "vue";
|
import { computed, ref, onMounted } from "vue";
|
||||||
import NodeTitle from "../../components/NodeTitle.vue";
|
import NodeTitle from "../../components/NodeTitle.vue";
|
||||||
import NodeState from "../../components/NodeState.vue";
|
import NodeState from "../../components/NodeState.vue";
|
||||||
|
import WorkflowImage from "../../components/WorkflowImage.vue";
|
||||||
import "vue3-json-viewer/dist/index.css";
|
import "vue3-json-viewer/dist/index.css";
|
||||||
import { useFlowEvents } from "../../composables/useFlowEvents";
|
import { useFlowEvents } from "../../composables/useFlowEvents";
|
||||||
import IPlayer from "@/components/IPlayer/index.vue";
|
import IPlayer from "@/components/IPlayer/index.vue";
|
||||||
|
|||||||
@ -3,14 +3,18 @@ import { readFileSync } from 'node:fs'
|
|||||||
import test from 'node:test'
|
import test from 'node:test'
|
||||||
import vm from 'node:vm'
|
import vm from 'node:vm'
|
||||||
import { getStandaloneFlowError } from './standalone.js'
|
import { getStandaloneFlowError } from './standalone.js'
|
||||||
|
import * as touchFlow from '../../utils/touchFlow.js'
|
||||||
|
import { dexHandAxisLabels } from '../../utils/robotDevice.js'
|
||||||
|
|
||||||
/** 直接执行节点配置,使用稳定占位值替换构建时图标与项目常量,验证真实节点协议。 */
|
/** 直接执行节点配置,使用稳定占位值替换构建时图标与项目常量,验证真实节点协议。 */
|
||||||
const readPalette = () => {
|
const readPalette = () => {
|
||||||
const source = readFileSync(new URL('./config.js', import.meta.url), 'utf8')
|
const source = readFileSync(new URL('./config.js', import.meta.url), 'utf8')
|
||||||
.replace(/^import\s+(\w+)\s+from\s+.*$/gm, 'const $1 = "$1"')
|
.replace(/^import\s+(\w+)\s+from\s+.*$/gm, 'const $1 = "$1"')
|
||||||
.replace(/^import\s+\{ DEFAULT_CHAT_SYSTEM_PROMPT \}\s+from\s+.*$/gm, 'const DEFAULT_CHAT_SYSTEM_PROMPT = "prompt"')
|
.replace(/^import\s+\{ DEFAULT_CHAT_SYSTEM_PROMPT \}\s+from\s+.*$/gm, 'const DEFAULT_CHAT_SYSTEM_PROMPT = "prompt"')
|
||||||
|
.replace(/^import .* from '@\/utils\/touchFlow'\r?$/gm, '')
|
||||||
|
.replace(/^import .* from '@\/utils\/robotDevice'\r?$/gm, '')
|
||||||
.replaceAll('export const ', 'const ')
|
.replaceAll('export const ', 'const ')
|
||||||
return vm.runInNewContext(`${source}\ncollapseList`, { __PROJECT_NAME__: 'cmvr' })
|
return vm.runInNewContext(`${source}\ncollapseList`, { __PROJECT_NAME__: 'cmvr', ...touchFlow, dexHandAxisLabels })
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 配置必须物理删除专属语音和语料节点,避免仅隐藏后仍保留入口。 */
|
/** 配置必须物理删除专属语音和语料节点,避免仅隐藏后仍保留入口。 */
|
||||||
|
|||||||
@ -43,12 +43,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="iconUrl" label="图片" >
|
<el-table-column prop="iconUrl" label="图片" >
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-image
|
<WorkflowImage v-if="row.iconUrl" style="height: 32px" :src="row.iconUrl" :preview-src-list="[row.iconUrl]" preview-teleported />
|
||||||
v-if="row.iconUrl"
|
|
||||||
style="height: 32px"
|
|
||||||
:src="row.iconUrl"
|
|
||||||
@click="showViewer(row.iconUrl)">
|
|
||||||
</el-image>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="remark" label="描述" show-overflow-tooltip />
|
<el-table-column prop="remark" label="描述" show-overflow-tooltip />
|
||||||
@ -72,13 +67,6 @@
|
|||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 手动控制的预览组件,append-to-body 使其挂载到 body 末尾 -->
|
|
||||||
<ElImageViewer
|
|
||||||
v-if="isViewerOpen"
|
|
||||||
:url-list="[currentImage]"
|
|
||||||
@close="closeViewer"
|
|
||||||
append-to-body
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 功能编辑对话框 -->
|
<!-- 功能编辑对话框 -->
|
||||||
<FunctionDialog
|
<FunctionDialog
|
||||||
@ -92,8 +80,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import WorkflowImage from '@/views/flow/components/WorkflowImage.vue'
|
||||||
import { ref, reactive, watch } from 'vue'
|
import { ref, reactive, watch } from 'vue'
|
||||||
import { ElMessage, ElMessageBox, ElImageViewer } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { Plus } from '@element-plus/icons-vue'
|
import { Plus } from '@element-plus/icons-vue'
|
||||||
import FunctionDialog from './FunctionDialog.vue'
|
import FunctionDialog from './FunctionDialog.vue'
|
||||||
import { addFunction, getFunction, updateFunction, deleteFunction } from '@/api/is/func/index'
|
import { addFunction, getFunction, updateFunction, deleteFunction } from '@/api/is/func/index'
|
||||||
@ -241,18 +230,6 @@ const getDataList = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const isViewerOpen = ref(false);
|
|
||||||
const currentImage = ref('');
|
|
||||||
|
|
||||||
const showViewer = (url) => {
|
|
||||||
currentImage.value = url;
|
|
||||||
isViewerOpen.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const closeViewer = () => {
|
|
||||||
isViewerOpen.value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleUpdateFunction = (row) => {
|
const handleUpdateFunction = (row) => {
|
||||||
functionDialogTitle.value = '编辑功能'
|
functionDialogTitle.value = '编辑功能'
|
||||||
isAdd.value = false
|
isAdd.value = false
|
||||||
|
|||||||
@ -16,12 +16,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="iconUrl" label="图片" >
|
<el-table-column prop="iconUrl" label="图片" >
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-image
|
<WorkflowImage v-if="row.iconUrl" style="height: 32px" :src="row.iconUrl" :preview-src-list="[row.iconUrl]" preview-teleported />
|
||||||
v-if="row.iconUrl"
|
|
||||||
style="height: 32px"
|
|
||||||
:src="row.iconUrl"
|
|
||||||
@click="showViewer(row.iconUrl)">
|
|
||||||
</el-image>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
@ -82,12 +77,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="iconUrl" label="图片" >
|
<el-table-column prop="iconUrl" label="图片" >
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-image
|
<WorkflowImage v-if="row.iconUrl" style="height: 32px" :src="row.iconUrl" :preview-src-list="[row.iconUrl]" preview-teleported />
|
||||||
v-if="row.iconUrl"
|
|
||||||
style="height: 32px"
|
|
||||||
:src="row.iconUrl"
|
|
||||||
@click="showViewer(row.iconUrl)">
|
|
||||||
</el-image>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -99,18 +89,11 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 手动控制的预览组件,append-to-body 使其挂载到 body 末尾 -->
|
|
||||||
<ElImageViewer
|
|
||||||
v-if="isViewerOpen"
|
|
||||||
:url-list="[currentImage]"
|
|
||||||
@close="closeViewer"
|
|
||||||
append-to-body
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import WorkflowImage from '@/views/flow/components/WorkflowImage.vue'
|
||||||
import { onMounted } from "vue";
|
import { onMounted } from "vue";
|
||||||
import { ElImageViewer } from 'element-plus'
|
|
||||||
import { getFunction } from '@/api/is/func/index'
|
import { getFunction } from '@/api/is/func/index'
|
||||||
import { useDict } from '@/utils/dict'
|
import { useDict } from '@/utils/dict'
|
||||||
|
|
||||||
@ -219,18 +202,6 @@ const formatFuncName = (funcKey) => {
|
|||||||
return dict?.label || ''
|
return dict?.label || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const isViewerOpen = ref(false);
|
|
||||||
const currentImage = ref('');
|
|
||||||
|
|
||||||
const showViewer = (url) => {
|
|
||||||
currentImage.value = url;
|
|
||||||
isViewerOpen.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const closeViewer = () => {
|
|
||||||
isViewerOpen.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getList();
|
getList();
|
||||||
if (props.funcIds) {
|
if (props.funcIds) {
|
||||||
|
|||||||
@ -43,12 +43,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="uiUrl" label="图片" >
|
<el-table-column prop="uiUrl" label="图片" >
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-image
|
<WorkflowImage v-if="row.uiUrl" style="height: 32px" :src="row.uiUrl" :preview-src-list="[row.uiUrl]" preview-teleported />
|
||||||
v-if="row.uiUrl"
|
|
||||||
style="height: 32px"
|
|
||||||
:src="row.uiUrl"
|
|
||||||
@click="showViewer(row.uiUrl)">
|
|
||||||
</el-image>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="funcIds" label="功能id数组" show-overflow-tooltip />
|
<el-table-column prop="funcIds" label="功能id数组" show-overflow-tooltip />
|
||||||
@ -73,13 +68,6 @@
|
|||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 手动控制的预览组件,append-to-body 使其挂载到 body 末尾 -->
|
|
||||||
<ElImageViewer
|
|
||||||
v-if="isViewerOpen"
|
|
||||||
:url-list="[currentImage]"
|
|
||||||
@close="closeViewer"
|
|
||||||
append-to-body
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 界面编辑对话框 -->
|
<!-- 界面编辑对话框 -->
|
||||||
<FunctionDialog
|
<FunctionDialog
|
||||||
@ -93,8 +81,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import WorkflowImage from '@/views/flow/components/WorkflowImage.vue'
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive } from 'vue'
|
||||||
import { ElMessage, ElMessageBox, ElImageViewer } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { Plus } from '@element-plus/icons-vue'
|
import { Plus } from '@element-plus/icons-vue'
|
||||||
import FunctionDialog from './Dialog.vue'
|
import FunctionDialog from './Dialog.vue'
|
||||||
import { addUi, getUiList, deleteUiList, updateUI } from '@/api/is/im/index'
|
import { addUi, getUiList, deleteUiList, updateUI } from '@/api/is/im/index'
|
||||||
@ -231,18 +220,6 @@ const formatUiName = (uiKey) => {
|
|||||||
return dict?.label || ''
|
return dict?.label || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const isViewerOpen = ref(false);
|
|
||||||
const currentImage = ref('');
|
|
||||||
|
|
||||||
const showViewer = (url) => {
|
|
||||||
currentImage.value = url;
|
|
||||||
isViewerOpen.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const closeViewer = () => {
|
|
||||||
isViewerOpen.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(() => props.selectNode,
|
watch(() => props.selectNode,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (newVal && newVal.type === 'version') {
|
if (newVal && newVal.type === 'version') {
|
||||||
|
|||||||
117
src/views/is/project/TouchFunctionSequence.vue
Normal file
117
src/views/is/project/TouchFunctionSequence.vue
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<template>
|
||||||
|
<div class="function-sequence">
|
||||||
|
<section class="sequence-panel" aria-label="可用功能">
|
||||||
|
<h4>可用功能</h4>
|
||||||
|
<el-input v-model="filter" placeholder="搜索功能" clearable />
|
||||||
|
<div class="sequence-list">
|
||||||
|
<div v-for="option in filteredOptions" :key="option.value" class="sequence-row"
|
||||||
|
:draggable="!disabled" @dragstart="startDrag($event, { id: option.value })" @dragend="clearDrag">
|
||||||
|
<span>{{ option.label }}</span>
|
||||||
|
<el-button link type="primary" :disabled="disabled" :aria-label="'添加 ' + option.label"
|
||||||
|
@click="insert(option.value, sequence.length)">添加</el-button>
|
||||||
|
</div>
|
||||||
|
<p v-if="!filteredOptions.length" class="sequence-empty">{{ disabled ? '请先选择车机版本' : '没有匹配的功能' }}</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section class="sequence-panel" aria-label="执行顺序">
|
||||||
|
<h4>执行顺序 <small>{{ sequence.length }} 项</small></h4>
|
||||||
|
<div class="sequence-list sequence-drops" @dragover="allowDrop" @drop="drop($event, sequence.length)">
|
||||||
|
<div v-for="(id, index) in sequence" :key="index" class="sequence-row"
|
||||||
|
:class="{ 'sequence-row--drop': dropIndex === index }" :draggable="!disabled"
|
||||||
|
@dragstart="startDrag($event, { index })" @dragend="clearDrag"
|
||||||
|
@dragover.stop="allowDrop($event, index)" @drop.stop="drop($event, index)">
|
||||||
|
<span>{{ index + 1 }}. {{ labelById.get(String(id)) || ('功能 ' + id) }}</span>
|
||||||
|
<div class="sequence-actions">
|
||||||
|
<el-button link :disabled="disabled || index === 0" aria-label="上移" @click="move(index, index - 1)">上移</el-button>
|
||||||
|
<el-button link :disabled="disabled || index === sequence.length - 1" aria-label="下移" @click="move(index, index + 1)">下移</el-button>
|
||||||
|
<el-button link type="danger" :disabled="disabled" aria-label="移除" @click="remove(index)">移除</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p v-if="!sequence.length || drag" class="sequence-empty sequence-drop-target"
|
||||||
|
:class="{ 'sequence-row--drop': dropIndex === sequence.length }">从左侧拖入功能,可重复添加</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: Array,
|
||||||
|
options: { type: Array, default: () => [] },
|
||||||
|
disabled: Boolean,
|
||||||
|
})
|
||||||
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
const filter = ref('')
|
||||||
|
const drag = ref(null)
|
||||||
|
const dropIndex = ref(null)
|
||||||
|
const sequence = computed(() => props.modelValue || [])
|
||||||
|
const labelById = computed(() => new Map(props.options.map(option => [String(option.value), option.label])))
|
||||||
|
const filteredOptions = computed(() => {
|
||||||
|
const query = filter.value.trim().toLowerCase()
|
||||||
|
return props.options.filter(option => option.label.toLowerCase().includes(query))
|
||||||
|
})
|
||||||
|
|
||||||
|
function insert(id, index) {
|
||||||
|
const ordered = [...sequence.value]
|
||||||
|
ordered.splice(index, 0, id)
|
||||||
|
emit('update:modelValue', ordered)
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove(index) {
|
||||||
|
emit('update:modelValue', sequence.value.filter((_, position) => position !== index))
|
||||||
|
}
|
||||||
|
|
||||||
|
function move(from, to) {
|
||||||
|
if (from === to || to < 0 || to >= sequence.value.length) return
|
||||||
|
const ordered = [...sequence.value]
|
||||||
|
const [item] = ordered.splice(from, 1)
|
||||||
|
ordered.splice(to, 0, item)
|
||||||
|
emit('update:modelValue', ordered)
|
||||||
|
}
|
||||||
|
|
||||||
|
function startDrag(event, source) {
|
||||||
|
if (props.disabled || !event.dataTransfer) return
|
||||||
|
drag.value = source
|
||||||
|
event.dataTransfer.effectAllowed = source.index == null ? 'copy' : 'move'
|
||||||
|
event.dataTransfer.setData('text/plain', source.id == null ? 'move' : String(source.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearDrag() {
|
||||||
|
drag.value = null
|
||||||
|
dropIndex.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
function allowDrop(event, index = sequence.value.length) {
|
||||||
|
if (!drag.value || props.disabled) return
|
||||||
|
event.preventDefault()
|
||||||
|
event.dataTransfer.dropEffect = drag.value.index == null ? 'copy' : 'move'
|
||||||
|
dropIndex.value = index
|
||||||
|
}
|
||||||
|
|
||||||
|
function drop(event, index) {
|
||||||
|
event.preventDefault()
|
||||||
|
if (!drag.value || props.disabled) return
|
||||||
|
const { id, index: from } = drag.value
|
||||||
|
if (from == null) insert(id, index)
|
||||||
|
else move(from, index > from ? index - 1 : index)
|
||||||
|
clearDrag()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.function-sequence { width: 100%; display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px; }
|
||||||
|
.sequence-panel { min-width: 0; border: 1px solid var(--el-border-color-light); border-radius: 6px; padding: 8px; }
|
||||||
|
.sequence-panel h4 { margin: 0 4px 6px; line-height: 24px; }
|
||||||
|
.sequence-panel small { margin-left: 6px; color: var(--el-text-color-secondary); font-weight: normal; }
|
||||||
|
.sequence-list { height: 208px; overflow: auto; }
|
||||||
|
.sequence-drops { border: 1px dashed var(--el-border-color); border-radius: 4px; }
|
||||||
|
.sequence-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; line-height: 20px; min-height: 32px; padding: 2px 4px; border-bottom: 1px solid var(--el-border-color-lighter); }
|
||||||
|
.sequence-row[draggable=true] { cursor: grab; }
|
||||||
|
.sequence-row--drop { box-shadow: inset 0 2px var(--el-color-primary); background: var(--el-color-primary-light-9); }
|
||||||
|
.sequence-actions { white-space: nowrap; }
|
||||||
|
.sequence-actions .el-button + .el-button { margin-left: 5px; }
|
||||||
|
.sequence-empty { padding: 10px 4px; margin: 0; line-height: 20px; text-align: center; color: var(--el-text-color-secondary); }
|
||||||
|
@media (max-width: 620px) { .function-sequence { grid-template-columns: 1fr; } }
|
||||||
|
</style>
|
||||||
@ -14,12 +14,14 @@
|
|||||||
:label="`${item.itemName} · V${item.versionNo}`" />
|
:label="`${item.itemName} · V${item.versionNo}`" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-empty v-if="!loadingItems && !items.length" description="暂无启用且已发布的检测项" />
|
<el-empty v-if="!loadingItems && !items.length" description="暂无可执行检测项,请在开始节点添加触控项目参数后发布" />
|
||||||
<template v-if="preparedItem">
|
<template v-if="preparedItem">
|
||||||
<div v-if="roles.length" class="run-section-title">本次执行安排</div>
|
<div v-if="roles.length" class="run-section-title">本次执行安排</div>
|
||||||
<RuntimeAssignmentsEditor v-if="roles.length" ref="runtimeEditorRef" v-model="runtimeAssignments" :roles="roles" />
|
<RuntimeAssignmentsEditor v-if="roles.length" ref="runtimeEditorRef" v-model="runtimeAssignments" :roles="roles" />
|
||||||
<div class="run-section-title run-section-title--params">运行参数</div>
|
<p class="run-project-inputs">车机版本和功能顺序取自触控项目的配置。</p>
|
||||||
|
<div v-if="formData.tableData[0]?.config.length" class="run-section-title run-section-title--params">其他运行参数</div>
|
||||||
<el-table
|
<el-table
|
||||||
|
v-if="formData.tableData[0]?.config.length"
|
||||||
:data="formData.tableData"
|
:data="formData.tableData"
|
||||||
:border="parentBorder"
|
:border="parentBorder"
|
||||||
:preserve-expanded-content="preserveExpanded"
|
:preserve-expanded-content="preserveExpanded"
|
||||||
@ -82,6 +84,7 @@ import { flowVersionDetail } from '@/api/flow/flow'
|
|||||||
import RuntimeAssignmentsEditor from '@/views/flow/components/RuntimeAssignmentsEditor.vue'
|
import RuntimeAssignmentsEditor from '@/views/flow/components/RuntimeAssignmentsEditor.vue'
|
||||||
import { firstAssignedRobotId } from '@/utils/flowExecution'
|
import { firstAssignedRobotId } from '@/utils/flowExecution'
|
||||||
import { getResourceRoles, normalizeFlowResourceSchema, validateFlowResources } from '@/utils/flowResources'
|
import { getResourceRoles, normalizeFlowResourceSchema, validateFlowResources } from '@/utils/flowResources'
|
||||||
|
import { touchProjectInputs } from '@/utils/touchFlow'
|
||||||
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -108,6 +111,7 @@ const loadingSelection = ref(false)
|
|||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
let selectionRequest = 0
|
let selectionRequest = 0
|
||||||
let listRequest = 0
|
let listRequest = 0
|
||||||
|
const projectInputNames = new Set([...touchProjectInputs().map(field => field.name), 'projectId'])
|
||||||
|
|
||||||
const clearSelection = () => {
|
const clearSelection = () => {
|
||||||
preparedItem.value = null
|
preparedItem.value = null
|
||||||
@ -130,7 +134,9 @@ const loadSelection = async (itemId) => {
|
|||||||
const graph = normalizeFlowResourceSchema(JSON.parse(version.flowData))
|
const graph = normalizeFlowResourceSchema(JSON.parse(version.flowData))
|
||||||
const validation = validateFlowResources(graph)
|
const validation = validateFlowResources(graph)
|
||||||
if (validation.errors.length) throw new Error(validation.errors[0].message)
|
if (validation.errors.length) throw new Error(validation.errors[0].message)
|
||||||
const config = version.config ? addValueProperty(JSON.parse(version.config)) : []
|
const config = version.config
|
||||||
|
? addValueProperty(JSON.parse(version.config).filter(field => !projectInputNames.has(field.name)))
|
||||||
|
: []
|
||||||
roles.value = getResourceRoles(validation.graph)
|
roles.value = getResourceRoles(validation.graph)
|
||||||
formData.value.tableData = [{ ...item, config }]
|
formData.value.tableData = [{ ...item, config }]
|
||||||
preparedItem.value = item
|
preparedItem.value = item
|
||||||
@ -200,4 +206,5 @@ watch(
|
|||||||
<style scoped>
|
<style scoped>
|
||||||
.run-section-title { margin: 4px 0 10px; font-size: 15px; font-weight: 650; }
|
.run-section-title { margin: 4px 0 10px; font-size: 15px; font-weight: 650; }
|
||||||
.run-section-title--params { margin-top: 22px; }
|
.run-section-title--params { margin-top: 22px; }
|
||||||
|
.run-project-inputs { color: var(--el-text-color-secondary); line-height: 1.5; }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -166,32 +166,16 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="车机版本" prop="vehicleConfigId">
|
<el-form-item label="车机版本" prop="vehicleConfigId">
|
||||||
<el-tree-select
|
<VehicleVersionSelect
|
||||||
v-model="form.vehicleConfigId"
|
v-model="form.vehicleConfigId"
|
||||||
node-key="id"
|
|
||||||
:data="treeData"
|
|
||||||
:render-after-expand="false"
|
|
||||||
clearable
|
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
@change="vehicleConfigChange"
|
@update:model-value="vehicleConfigChange"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="24">
|
||||||
<el-form-item label="功能选择" prop="testFuncIds">
|
<el-form-item label="功能编排" prop="testFuncIds">
|
||||||
<el-select
|
<TouchFunctionSequence v-model="form.testFuncIds" :options="funcIdOptions" :disabled="!form.vehicleConfigId" />
|
||||||
v-model="form.testFuncIds"
|
|
||||||
:multiple="true"
|
|
||||||
:disabled="!form.vehicleConfigId"
|
|
||||||
style="width: 240px"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in funcIdOptions"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
@ -266,7 +250,6 @@
|
|||||||
import TableSearch from "@/components/TableSearch/index.vue";
|
import TableSearch from "@/components/TableSearch/index.vue";
|
||||||
import { useContainerHeight } from "@/hooks/tableHeight";
|
import { useContainerHeight } from "@/hooks/tableHeight";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
import { getTreeDataApi } from '@/api/is/func/index'
|
|
||||||
import { getFunction } from "@/api/is/func/index.js";
|
import { getFunction } from "@/api/is/func/index.js";
|
||||||
import {
|
import {
|
||||||
addProject,
|
addProject,
|
||||||
@ -277,6 +260,8 @@ import {
|
|||||||
queryExecuteInstId,
|
queryExecuteInstId,
|
||||||
} from "@/api/is/project/index.js";
|
} from "@/api/is/project/index.js";
|
||||||
import Run from "@/views/is/project/evaluate/Run.vue";
|
import Run from "@/views/is/project/evaluate/Run.vue";
|
||||||
|
import TouchFunctionSequence from "./TouchFunctionSequence.vue";
|
||||||
|
import VehicleVersionSelect from "@/views/flow/components/params/VehicleVersionSelect.vue";
|
||||||
import { appendParamsToPath } from "@/utils/fn.js";
|
import { appendParamsToPath } from "@/utils/fn.js";
|
||||||
|
|
||||||
const topContainerRef = ref();
|
const topContainerRef = ref();
|
||||||
@ -314,20 +299,6 @@ const data = reactive({
|
|||||||
|
|
||||||
const { queryParams, form, rules } = toRefs(data);
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
const treeData = ref([])
|
|
||||||
|
|
||||||
const getTreeData = async () => {
|
|
||||||
try {
|
|
||||||
const res = await getTreeDataApi();
|
|
||||||
if (res) {
|
|
||||||
treeData.value = res;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error("获取树数据异常:", err);
|
|
||||||
ElMessage.error("加载车机版本树失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询触控项目列表,并在存在执行中项目时定时刷新以展示最新状态。 */
|
/** 查询触控项目列表,并在存在执行中项目时定时刷新以展示最新状态。 */
|
||||||
function getList() {
|
function getList() {
|
||||||
getProjectList(queryParams.value)
|
getProjectList(queryParams.value)
|
||||||
@ -463,7 +434,7 @@ const handleUpdate = (row) => {
|
|||||||
} catch {
|
} catch {
|
||||||
arr = []
|
arr = []
|
||||||
} finally {
|
} finally {
|
||||||
form.value.testFuncIds = arr
|
form.value.testFuncIds = Array.isArray(arr) ? arr : []
|
||||||
getFuncList(form.value.vehicleConfigId)
|
getFuncList(form.value.vehicleConfigId)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -485,14 +456,23 @@ const handleDelete = (row) => {
|
|||||||
|
|
||||||
const { proxy } = getCurrentInstance()
|
const { proxy } = getCurrentInstance()
|
||||||
const { ti_function_config } = proxy.useDict("ti_function_config")
|
const { ti_function_config } = proxy.useDict("ti_function_config")
|
||||||
const funcIdOptions = ref([])
|
const availableFunctions = ref([])
|
||||||
|
const funcIdOptions = computed(() => {
|
||||||
|
const labels = new Map((ti_function_config.value || []).map(item => [String(item.value), item.label]))
|
||||||
|
return availableFunctions.value.map(item => ({
|
||||||
|
label: labels.get(String(item.funcKey)) || item.funcKey || `功能 ${item.id}`,
|
||||||
|
value: item.id,
|
||||||
|
}))
|
||||||
|
})
|
||||||
const vehicleConfigChange = (value) => {
|
const vehicleConfigChange = (value) => {
|
||||||
form.value.testFuncIds = null
|
form.value.testFuncIds = []
|
||||||
funcIdOptions.value = []
|
|
||||||
getFuncList(value)
|
getFuncList(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let functionListRequest = 0
|
||||||
const getFuncList = async (value) => {
|
const getFuncList = async (value) => {
|
||||||
|
const request = ++functionListRequest
|
||||||
|
availableFunctions.value = []
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
try {
|
try {
|
||||||
const res = await getFunction({
|
const res = await getFunction({
|
||||||
@ -500,20 +480,12 @@ const getFuncList = async (value) => {
|
|||||||
pageSize: 10000,
|
pageSize: 10000,
|
||||||
vehicleConfigId: value
|
vehicleConfigId: value
|
||||||
});
|
});
|
||||||
|
if (request !== functionListRequest) return;
|
||||||
if (res.code !== 200) {
|
if (res.code !== 200) {
|
||||||
ElMessage.error(res.msg || "加载功能列表失败");
|
ElMessage.error(res.msg || "加载功能列表失败");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const dictItems = ti_function_config.value || [];
|
availableFunctions.value = res.rows || [];
|
||||||
funcIdOptions.value = (res.rows || []).map(item => {
|
|
||||||
const dictItem = dictItems.find(func => {
|
|
||||||
return String(func.value) === String(item.funcKey)
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
label: dictItem?.label || item.funcKey || `功能 ${item.id}`,
|
|
||||||
value: item.id
|
|
||||||
};
|
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("加载功能列表异常:", err);
|
console.error("加载功能列表异常:", err);
|
||||||
ElMessage.error("网络异常,加载功能列表失败");
|
ElMessage.error("网络异常,加载功能列表失败");
|
||||||
@ -584,7 +556,6 @@ const closeRun = () => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getList();
|
getList();
|
||||||
getTreeData();
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
55
tests/dexHandPosition.test.mjs
Normal file
55
tests/dexHandPosition.test.mjs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import test from 'node:test'
|
||||||
|
import { dexHandAngleSnapshot, dexHandPositionTargets } from '../src/utils/robotDevice.js'
|
||||||
|
|
||||||
|
function feedback(positions, model = 'ROH-LiteS001') {
|
||||||
|
return {
|
||||||
|
model,
|
||||||
|
initialized: true,
|
||||||
|
hands: positions.map((position, id) => ({ id, position })).reverse(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test('按自由度顺序回填全部位置并精确保留边端整数值', () => {
|
||||||
|
for (let position = 0; position <= 2000; position += 1) {
|
||||||
|
const raw = [position, 0, 2000, 251, 1009, 1614]
|
||||||
|
const targets = dexHandPositionTargets(feedback(raw))
|
||||||
|
assert.deepEqual(targets.map(target => target.id), [0, 1, 2, 3, 4, 5])
|
||||||
|
assert.deepEqual(targets.map(({ value }) => Math.trunc(Math.fround(Math.fround(value) * 2000))), raw)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test('拒绝未初始化、有故障、缺失或无效的位置反馈', () => {
|
||||||
|
const state = feedback([0, 100, 500, 1000, 1500, 2000], 'ROH-AP001')
|
||||||
|
assert.equal(dexHandPositionTargets(state).length, 6)
|
||||||
|
assert.throws(() => dexHandPositionTargets({ ...state, initialized: false }), /尚未初始化/)
|
||||||
|
assert.throws(() => dexHandPositionTargets({ ...state, hands: state.hands.slice(1) }), /完整的六轴/)
|
||||||
|
assert.throws(() => dexHandPositionTargets(feedback([0, 100, null, 1000, 1500, 2000])), /位置无效/)
|
||||||
|
assert.throws(() => dexHandPositionTargets(feedback([0, 100, 2001, 1000, 1500, 2000])), /位置无效/)
|
||||||
|
state.hands[0].errorMessages = ['servo disconnected']
|
||||||
|
assert.throws(() => dexHandPositionTargets(state), /存在故障/)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('拒绝无位置反馈能力的机型和重复自由度', () => {
|
||||||
|
assert.throws(() => dexHandPositionTargets(feedback([0, 0, 0, 0, 0, 0], 'RH56D')), /不支持位置回填/)
|
||||||
|
const state = feedback([0, 100, 500, 1000, 1500, 2000])
|
||||||
|
state.hands[0].id = state.hands[1].id
|
||||||
|
assert.throws(() => dexHandPositionTargets(state), /自由度编号或位置无效/)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('实测角度按百分之一度显示,回放按边端行程比例生成', () => {
|
||||||
|
const position = [0, 250, 501, 1000, 1501, 2000]
|
||||||
|
const angles = [17470, 17209, 17168, 13701, 3354, 99]
|
||||||
|
const state = feedback(position)
|
||||||
|
for (const axis of state.hands) axis.angle = angles[axis.id]
|
||||||
|
|
||||||
|
const snapshot = dexHandAngleSnapshot(state)
|
||||||
|
assert.deepEqual(snapshot.angles, angles.map((angle, id) => ({ id, degrees: angle / 100 })))
|
||||||
|
assert.deepEqual(
|
||||||
|
snapshot.values.map(({ value }) => Math.trunc(Math.fround(Math.fround(value) * 1000))),
|
||||||
|
position.map(raw => Math.round(raw / 2)),
|
||||||
|
)
|
||||||
|
assert.throws(() => dexHandAngleSnapshot({ ...state, model: 'RH56D' }), /不支持角度回填/)
|
||||||
|
state.hands[0].angle = null
|
||||||
|
assert.throws(() => dexHandAngleSnapshot(state), /完整的六轴实测角度/)
|
||||||
|
})
|
||||||
@ -1,6 +1,7 @@
|
|||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import { readFileSync } from 'node:fs'
|
import { readFileSync } from 'node:fs'
|
||||||
import { resolve } from 'node:path'
|
import { resolve } from 'node:path'
|
||||||
|
import { pathToFileURL } from 'node:url'
|
||||||
import test from 'node:test'
|
import test from 'node:test'
|
||||||
|
|
||||||
/** 使用实际源码并解析 Vite 的本地别名,让 Node 能验证资源协议而无需启动浏览器。 */
|
/** 使用实际源码并解析 Vite 的本地别名,让 Node 能验证资源协议而无需启动浏览器。 */
|
||||||
@ -10,12 +11,52 @@ async function loadResourceModules() {
|
|||||||
const robotUrl = `data:text/javascript;base64,${Buffer.from(robotSource).toString('base64')}`
|
const robotUrl = `data:text/javascript;base64,${Buffer.from(robotSource).toString('base64')}`
|
||||||
const resourceSource = readFileSync(resolve(sourceRoot, 'utils/flowResources.js'), 'utf8')
|
const resourceSource = readFileSync(resolve(sourceRoot, 'utils/flowResources.js'), 'utf8')
|
||||||
.replace("'@/utils/robotDevice'", JSON.stringify(robotUrl))
|
.replace("'@/utils/robotDevice'", JSON.stringify(robotUrl))
|
||||||
|
.replace("'@/utils/touchFlow'", JSON.stringify(pathToFileURL(resolve(sourceRoot, 'utils/touchFlow.js')).href))
|
||||||
return {
|
return {
|
||||||
robot: await import(robotUrl),
|
robot: await import(robotUrl),
|
||||||
resource: await import(`data:text/javascript;base64,${Buffer.from(resourceSource).toString('base64')}`)
|
resource: await import(`data:text/javascript;base64,${Buffer.from(resourceSource).toString('base64')}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test('灵巧手动作分配独立的 7 号设备用途', async () => {
|
||||||
|
const { robot, resource } = await loadResourceModules()
|
||||||
|
const graph = { nodes: [
|
||||||
|
{ id: 'start', type: 'start', properties: {} },
|
||||||
|
{ id: 'hand', type: 'serviceNode', properties: { nodeType: 'EDGE', action: 'DEX_HAND_SET_ANGLE' } },
|
||||||
|
], edges: [] }
|
||||||
|
const normalized = resource.normalizeFlowResourceSchema(graph)
|
||||||
|
const target = normalized.nodes[1].properties.executionTarget
|
||||||
|
const slot = normalized.nodes[0].properties.resourceRoles[0].deviceSlots.find(item => item.slotKey === target.deviceSlotKey)
|
||||||
|
assert.equal(slot.deviceKind, 7)
|
||||||
|
assert.equal(slot.displayName, '灵巧手')
|
||||||
|
assert.equal(robot.deviceMatchesSlot({ deviceKind: 2, deviceId: 'arm' }, slot), false)
|
||||||
|
assert.equal(robot.deviceMatchesSlot({ deviceKind: 7, deviceId: 'hand' }, slot), true)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('旧触控流程补齐路径数组、最后一步和坐标引用字段', async () => {
|
||||||
|
const { resource } = await loadResourceModules()
|
||||||
|
const graph = { nodes: [
|
||||||
|
{ id: 'start', type: 'start', properties: {} },
|
||||||
|
{ id: 'search', type: 'serviceNode', properties: {
|
||||||
|
action: 'TI_PATH_SEARCH', outputParams: [{ name: 'isEnd', type: 'string' }],
|
||||||
|
} },
|
||||||
|
{ id: 'step', type: 'currentLoop', properties: {
|
||||||
|
action: 'GET_CURRENT_OBJECT', outputParams: [
|
||||||
|
{ name: 'object', type: 'object', children: [{ name: 'functionName', type: 'string' }] },
|
||||||
|
],
|
||||||
|
} },
|
||||||
|
{ id: 'touch', type: 'serviceNode', properties: { action: 'TOUCH', nodeParams: [] } },
|
||||||
|
], edges: [] }
|
||||||
|
const [, search, step, touch] = resource.normalizeFlowResourceSchema(graph).nodes
|
||||||
|
assert.equal(search.properties.outputParams.find(field => field.name === 'path').type, 'array<object>')
|
||||||
|
assert.equal(search.properties.outputParams.find(field => field.name === 'isEnd').type, 'boolean')
|
||||||
|
assert.equal(step.properties.outputParams[0].children.find(field => field.name === 'isLastStep').type, 'boolean')
|
||||||
|
assert.equal(touch.properties.nodeParams[0].name, 'touchCoordinates')
|
||||||
|
assert.equal(touch.properties.nodeParams.find(field => field.name === 'retryCount').input, 0)
|
||||||
|
assert.equal(touch.properties.outputParams.find(field => field.name === 'retryAttempts').type, 'number')
|
||||||
|
assert.equal(graph.nodes[1].properties.outputParams.length, 1)
|
||||||
|
})
|
||||||
|
|
||||||
test('视觉定位迁移保留相机和机械臂的独立资源绑定且不改写原图', async () => {
|
test('视觉定位迁移保留相机和机械臂的独立资源绑定且不改写原图', async () => {
|
||||||
const { resource } = await loadResourceModules()
|
const { resource } = await loadResourceModules()
|
||||||
const graph = { nodes: [
|
const graph = { nodes: [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user