diff --git a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/model/hlc/EdgeTouchVO.java b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/model/hlc/EdgeTouchVO.java new file mode 100644 index 0000000..29a61bd --- /dev/null +++ b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/model/hlc/EdgeTouchVO.java @@ -0,0 +1,13 @@ +package com.cmvr.edge.client.model.hlc; + +import com.cmvr.edge.client.model.EdgeCommonVO; +import lombok.Data; + +import java.util.List; + +@Data +public class EdgeTouchVO extends EdgeCommonVO { + private int x; + private int y; + private double maxForce; +} diff --git a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/EdgeHlcService.java b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/EdgeHlcService.java index 2194037..dac8ac5 100644 --- a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/EdgeHlcService.java +++ b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/EdgeHlcService.java @@ -1,6 +1,8 @@ package com.cmvr.edge.client.service; +import com.cmvr.edge.client.model.hlc.EdgeTouchVO; + import java.io.File; public interface EdgeHlcService { @@ -13,4 +15,9 @@ public interface EdgeHlcService { * 图片标注 */ public void markPoint(File image, int x, int y); + + /** + * 触控 + */ + public String touch(EdgeTouchVO edgeTouchVO); } diff --git a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/impl/EdgeHlcServiceImpl.java b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/impl/EdgeHlcServiceImpl.java index 2704735..4b28786 100644 --- a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/impl/EdgeHlcServiceImpl.java +++ b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/impl/EdgeHlcServiceImpl.java @@ -4,6 +4,7 @@ import cmvr.api.HlcCommand; import cmvr.api.HlcServiceGrpc; import com.alibaba.fastjson2.JSON; import com.cmvr.edge.client.manage.GrpcServiceManager; +import com.cmvr.edge.client.model.hlc.EdgeTouchVO; import com.cmvr.edge.client.service.EdgeHlcService; import com.cmvr.edge.client.utils.EdgeCommonUtil; import lombok.RequiredArgsConstructor; @@ -81,4 +82,16 @@ public class EdgeHlcServiceImpl implements EdgeHlcService { } log.info("图片标注成功:{}", outPath); } + + @Override + public String touch(EdgeTouchVO edgeTouchVO) { + HlcServiceGrpc.HlcServiceBlockingStub stub = grpcServiceManager.getGrpcClient(edgeTouchVO.getTerminalId(), HlcServiceGrpc.HlcServiceBlockingStub.class); + HlcCommand.Touch.Request request = HlcCommand.Touch.Request.newBuilder() + .setHeader(EdgeCommonUtil.buildRequest(edgeTouchVO.getDeviceId())) + .setU(edgeTouchVO.getX()) + .setV(edgeTouchVO.getY()) + .setMaxForce(edgeTouchVO.getMaxForce()) + .build(); + return JSON.toJSONString(stub.touch(request).getHeader()); + } } diff --git a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/context/TaskContext.java b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/context/TaskContext.java index 8572c35..5a0531c 100644 --- a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/context/TaskContext.java +++ b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/context/TaskContext.java @@ -1,5 +1,6 @@ package com.cmvr.test.flow.context; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjUtil; import com.alibaba.fastjson2.JSONObject; import com.cmvr.test.enums.RunModeEnum; @@ -76,6 +77,11 @@ public class TaskContext { */ private final Map nodeOutputs = new ConcurrentHashMap<>(); + /** + * 存储节点输入参数(暂时覆盖存入) + */ + private final Map nodeInputs = new ConcurrentHashMap<>(); + /** * 运行任务时的初始参数 */ @@ -116,15 +122,29 @@ public class TaskContext { * 获取节点输出 */ public JSONObject getNodeOutput(String nodeId, List iterations) { - // 1. 精确匹配:带循环层级 - String keyWithIterations = TaskKeyBuilder.buildKey(nodeId, iterations); - JSONObject result = nodeOutputs.get(keyWithIterations); - if (ObjUtil.isNotEmpty(result)) { - return result; + if (CollUtil.isEmpty(iterations)) { + return nodeOutputs.get(TaskKeyBuilder.buildKey(nodeId, Collections.emptyList())); } - // 2. 回退匹配:循环外(全局) - String keyWithoutIterations = TaskKeyBuilder.buildKey(nodeId, Collections.emptyList()); - return nodeOutputs.get(keyWithoutIterations); + // 从完整 iterations 开始逐级回退 + for (int i = iterations.size(); i >= 0; i--) { + List subIterations = iterations.subList(0, i); + String key = TaskKeyBuilder.buildKey(nodeId, subIterations); + + JSONObject result = nodeOutputs.get(key); + if (ObjUtil.isNotEmpty(result)) { + return result; + } + } + + return null; + } + + /** + * 保存节点输入 + */ + public void setNodeInput(String nodeId, JSONObject outputParams) { + nodeOutputs.put(nodeId, outputParams != null ? outputParams : new JSONObject()); + updateTimestamp(); } } diff --git a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/engine/support/FlowNodeParamPreparer.java b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/engine/support/FlowNodeParamPreparer.java index 507dc7f..78a49b7 100644 --- a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/engine/support/FlowNodeParamPreparer.java +++ b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/engine/support/FlowNodeParamPreparer.java @@ -30,7 +30,6 @@ public class FlowNodeParamPreparer { FlowNodeWrapper node, TaskNodeExecuteMessage rootMessage) { - JSONObject input = new JSONObject(); TaskContext ctx = taskInstHolder.getContext(rootMessage.getInstId()); diff --git a/cmvr-iot-test/src/main/java/com/cmvr/test/service/FlowActionExecutorService.java b/cmvr-iot-test/src/main/java/com/cmvr/test/service/FlowActionExecutorService.java index 997ebd0..3155b1d 100644 --- a/cmvr-iot-test/src/main/java/com/cmvr/test/service/FlowActionExecutorService.java +++ b/cmvr-iot-test/src/main/java/com/cmvr/test/service/FlowActionExecutorService.java @@ -6,10 +6,10 @@ import com.alibaba.fastjson2.JSONObject; import com.cmvr.common.exception.GlobalException; import com.cmvr.edge.client.model.EdgeCommonVO; import com.cmvr.edge.client.model.biohead.EdgeFacialExpressionVO; -import com.cmvr.edge.client.model.humanoid.EdgeMoveJVO; +import com.cmvr.edge.client.model.hlc.EdgeTouchVO; import com.cmvr.edge.client.service.EdgeBioHeadService; import com.cmvr.edge.client.service.EdgeCameraService; -import com.cmvr.edge.client.service.EdgeHumanoidRobotService; +import com.cmvr.edge.client.service.EdgeHlcService; import com.cmvr.edge.client.service.EdgeMicrophoneService; import com.cmvr.edge.client.service.EdgeSpeakerService; import com.cmvr.test.enums.ActionEnum; @@ -26,7 +26,7 @@ public class FlowActionExecutorService { private final EdgeBioHeadService edgeBioHeadService; private final EdgeMicrophoneService edgeMicrophoneService; private final EdgeSpeakerService edgeSpeakerService; - private final EdgeHumanoidRobotService edgeHumanoidRobotService; + private final EdgeHlcService edgeHlcService; public String actionExecute(FlowActionRequestVO req) { @@ -81,8 +81,8 @@ public class FlowActionExecutorService { // ==== 触控 ==== case TOUCH: - EdgeMoveJVO edgeMoveJVO = payload.to(EdgeMoveJVO.class); - return edgeHumanoidRobotService.moveJ(edgeMoveJVO); + EdgeTouchVO edgeTouchVO = payload.to(EdgeTouchVO.class); + return edgeHlcService.touch(edgeTouchVO); // ==== 语料 ==== case VI_PLAY_CORPUS: