fix: 触控接口及循环外输出参数引用
This commit is contained in:
parent
cdaae95289
commit
195937bdf2
@ -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;
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<String, JSONObject> nodeOutputs = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 存储节点输入参数(暂时覆盖存入)
|
||||
*/
|
||||
private final Map<String, JSONObject> nodeInputs = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 运行任务时的初始参数
|
||||
*/
|
||||
@ -116,15 +122,29 @@ public class TaskContext {
|
||||
* 获取节点输出
|
||||
*/
|
||||
public JSONObject getNodeOutput(String nodeId, List<Integer> 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<Integer> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,6 @@ public class FlowNodeParamPreparer {
|
||||
FlowNodeWrapper node,
|
||||
TaskNodeExecuteMessage rootMessage) {
|
||||
|
||||
|
||||
JSONObject input = new JSONObject();
|
||||
TaskContext ctx = taskInstHolder.getContext(rootMessage.getInstId());
|
||||
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user