From 8e492faebda1640adfc30a780fc95b9ecd019c6d Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期一, 13 一月 2025 10:34:39 +0800
Subject: [PATCH] #
---
zy-acs-manager/src/main/java/com/zy/acs/manager/fake/AgvSimulatorTask.java | 43 +++++++++++++++++++++----------------------
1 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/fake/AgvSimulatorTask.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/fake/AgvSimulatorTask.java
index cd9b2aa..874926c 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/fake/AgvSimulatorTask.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/fake/AgvSimulatorTask.java
@@ -5,6 +5,8 @@
import com.zy.acs.common.domain.protocol.AGV_11_UP;
import com.zy.acs.common.enums.AgvCompleteType;
import com.zy.acs.common.utils.RedisSupport;
+import com.zy.acs.manager.core.scheduler.MapDataWsScheduler;
+import com.zy.acs.manager.core.service.MainService;
import com.zy.acs.manager.core.service.MapService;
import com.zy.acs.manager.manager.entity.Action;
import com.zy.acs.manager.manager.entity.Agv;
@@ -27,14 +29,13 @@
@Slf4j
public class AgvSimulatorTask implements Runnable {
- public static final int ACTION_DURING_TIME = 500;
-
private final Agv agv;
private final AgvDetailService agvDetailService;
private final ActionService actionService;
private final CodeService codeService;
private final MapService mapService;
private final JamService jamService;
+ private final MainService mainService;
private final List<Action> actionList;
private final RedisSupport redis;
@@ -49,6 +50,7 @@
, CodeService codeService
, MapService mapService
, JamService jamService
+ , MainService mainService
, List<Action> actionList
) {
this.agv = agv;
@@ -58,6 +60,7 @@
this.codeService = codeService;
this.mapService = mapService;
this.jamService = jamService;
+ this.mainService = mainService;
this.actionList = actionList;
this.groupId = actionList.get(0).getGroupId();
@@ -66,7 +69,6 @@
@Override
public void run() {
try {
- FakeProcessor.AGV_PROCESSING_MAP.put(agv.getId(), true);
String qrCode = null;
for (Action action : actionList) {
processAction(agv, action);
@@ -81,15 +83,11 @@
}
private void processAction(Agv agv, Action action) throws InterruptedException {
- AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
- if (agvDetail == null) {
- return;
- }
switch (Objects.requireNonNull(ActionTypeType.get(action.getActionTypeEl()))) {
case TurnCorner:
- simulateWalking(agv, agvDetail, action);
- simulateRotating(agv, agvDetail, action);
+ simulateWalking(agv, action);
+ simulateRotating(agv, action);
break;
case StraightBackUnturnable:
case StraightBackTurnable:
@@ -97,7 +95,7 @@
case StraightAheadTurnable:
case FinishPath:
case DockingCharge:
- simulateWalking(agv, agvDetail, action);
+ simulateWalking(agv, action);
break;
case ReadyTakeFromShelvesLoc:
case ReadyReleaseToShelvesLoc:
@@ -109,16 +107,17 @@
}
- private void simulateWalking(Agv agv, AgvDetail agvDetail, Action action) throws InterruptedException {
- Code code = codeService.selectByData(action.getCode());
- agvDetail.setPos(1);
- agvDetail.setCode(code.getId());
+ private void simulateWalking(Agv agv, Action action) throws InterruptedException {
+ Code code = codeService.getCacheByData(action.getCode());
+// agvDetail.setPos(1);
+// agvDetail.setCode(code.getId());
// 妯℃嫙鐢甸噺娑堣��
// agvDetail.setVol(agvDetail.getVol() - 0.1 * distanceToMove); // 鏍规嵁璺濈娑堣�楃數閲�
- Thread.sleep(ACTION_DURING_TIME);
+ Thread.sleep(MapDataWsScheduler.WEBSOCKET_BROADCAST_INTERVAL);
- agvDetailService.updateById(agvDetail);
+ agvDetailService.updatePosCodeByAgvId(agv.getId(), code.getId());
+// agvDetailService.updateById(agvDetail);
mapService.unlockPath(agv.getUuid(), code.getData());
jamService.checkIfFinish(agv.getId(), code.getData());
@@ -131,17 +130,16 @@
* 妯℃嫙AGV鏃嬭浆
*
* @param agv 褰撳墠AGV
- * @param agvDetail AGV璇︾粏淇℃伅
* @param action 褰撳墠鍔ㄤ綔
*/
- private void simulateRotating(Agv agv, AgvDetail agvDetail, Action action) throws InterruptedException {
+ private void simulateRotating(Agv agv, Action action) throws InterruptedException {
double actionAngle = Double.parseDouble(action.getParams());
- agvDetail.setAgvAngle(actionAngle);
+// agvDetail.setAgvAngle(actionAngle);
// 妯℃嫙鐢甸噺娑堣��?
// agvDetail.setVol(agvDetail.getVol() - 0.05 * (angleToRotate / 15.0)); // 鏍规嵁瑙掑害娑堣�楃數閲�
- Thread.sleep(ACTION_DURING_TIME);
- agvDetailService.updateById(agvDetail);
+ Thread.sleep(MapDataWsScheduler.WEBSOCKET_BROADCAST_INTERVAL);
+ agvDetailService.updateAngleByAgvId(agv.getId(), actionAngle);
action.setActionSts(ActionStsType.FINISH.val());
actionService.updateById(action);
}
@@ -155,6 +153,7 @@
agv_11_up.setQrCode(qrCode);
AgvProtocol agvProtocol = AgvProtocol.build(this.agv.getUuid()).setMessageBody(agv_11_up);
- redis.push(RedisConstant.AGV_COMPLETE_FLAG, agvProtocol);
+ mainService.upDataSubscribe(agvProtocol);
+// redis.push(RedisConstant.AGV_COMPLETE_FLAG, agvProtocol);
}
}
--
Gitblit v1.9.1