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;
|
package com.cmvr.edge.client.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.cmvr.edge.client.model.hlc.EdgeTouchVO;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public interface EdgeHlcService {
|
public interface EdgeHlcService {
|
||||||
@ -13,4 +15,9 @@ public interface EdgeHlcService {
|
|||||||
* 图片标注
|
* 图片标注
|
||||||
*/
|
*/
|
||||||
public void markPoint(File image, int x, int y);
|
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 cmvr.api.HlcServiceGrpc;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.cmvr.edge.client.manage.GrpcServiceManager;
|
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.service.EdgeHlcService;
|
||||||
import com.cmvr.edge.client.utils.EdgeCommonUtil;
|
import com.cmvr.edge.client.utils.EdgeCommonUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -81,4 +82,16 @@ public class EdgeHlcServiceImpl implements EdgeHlcService {
|
|||||||
}
|
}
|
||||||
log.info("图片标注成功:{}", outPath);
|
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;
|
package com.cmvr.test.flow.context;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.cmvr.test.enums.RunModeEnum;
|
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> 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) {
|
public JSONObject getNodeOutput(String nodeId, List<Integer> iterations) {
|
||||||
// 1. 精确匹配:带循环层级
|
if (CollUtil.isEmpty(iterations)) {
|
||||||
String keyWithIterations = TaskKeyBuilder.buildKey(nodeId, iterations);
|
return nodeOutputs.get(TaskKeyBuilder.buildKey(nodeId, Collections.emptyList()));
|
||||||
JSONObject result = nodeOutputs.get(keyWithIterations);
|
|
||||||
if (ObjUtil.isNotEmpty(result)) {
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 回退匹配:循环外(全局)
|
// 从完整 iterations 开始逐级回退
|
||||||
String keyWithoutIterations = TaskKeyBuilder.buildKey(nodeId, Collections.emptyList());
|
for (int i = iterations.size(); i >= 0; i--) {
|
||||||
return nodeOutputs.get(keyWithoutIterations);
|
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,
|
FlowNodeWrapper node,
|
||||||
TaskNodeExecuteMessage rootMessage) {
|
TaskNodeExecuteMessage rootMessage) {
|
||||||
|
|
||||||
|
|
||||||
JSONObject input = new JSONObject();
|
JSONObject input = new JSONObject();
|
||||||
TaskContext ctx = taskInstHolder.getContext(rootMessage.getInstId());
|
TaskContext ctx = taskInstHolder.getContext(rootMessage.getInstId());
|
||||||
|
|
||||||
|
|||||||
@ -6,10 +6,10 @@ import com.alibaba.fastjson2.JSONObject;
|
|||||||
import com.cmvr.common.exception.GlobalException;
|
import com.cmvr.common.exception.GlobalException;
|
||||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||||
import com.cmvr.edge.client.model.biohead.EdgeFacialExpressionVO;
|
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.EdgeBioHeadService;
|
||||||
import com.cmvr.edge.client.service.EdgeCameraService;
|
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.EdgeMicrophoneService;
|
||||||
import com.cmvr.edge.client.service.EdgeSpeakerService;
|
import com.cmvr.edge.client.service.EdgeSpeakerService;
|
||||||
import com.cmvr.test.enums.ActionEnum;
|
import com.cmvr.test.enums.ActionEnum;
|
||||||
@ -26,7 +26,7 @@ public class FlowActionExecutorService {
|
|||||||
private final EdgeBioHeadService edgeBioHeadService;
|
private final EdgeBioHeadService edgeBioHeadService;
|
||||||
private final EdgeMicrophoneService edgeMicrophoneService;
|
private final EdgeMicrophoneService edgeMicrophoneService;
|
||||||
private final EdgeSpeakerService edgeSpeakerService;
|
private final EdgeSpeakerService edgeSpeakerService;
|
||||||
private final EdgeHumanoidRobotService edgeHumanoidRobotService;
|
private final EdgeHlcService edgeHlcService;
|
||||||
|
|
||||||
public String actionExecute(FlowActionRequestVO req) {
|
public String actionExecute(FlowActionRequestVO req) {
|
||||||
|
|
||||||
@ -81,8 +81,8 @@ public class FlowActionExecutorService {
|
|||||||
|
|
||||||
// ==== 触控 ====
|
// ==== 触控 ====
|
||||||
case TOUCH:
|
case TOUCH:
|
||||||
EdgeMoveJVO edgeMoveJVO = payload.to(EdgeMoveJVO.class);
|
EdgeTouchVO edgeTouchVO = payload.to(EdgeTouchVO.class);
|
||||||
return edgeHumanoidRobotService.moveJ(edgeMoveJVO);
|
return edgeHlcService.touch(edgeTouchVO);
|
||||||
|
|
||||||
// ==== 语料 ====
|
// ==== 语料 ====
|
||||||
case VI_PLAY_CORPUS:
|
case VI_PLAY_CORPUS:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user