From e03ed1cc335263f91aa8e8c13f6fc2b676ca1af1 Mon Sep 17 00:00:00 2001 From: Pang_mir Date: Fri, 9 May 2025 15:52:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/ShelfNetListenerComponent.cs | 6 +- .../Origin/application/InitNetWorkProcess.cs | 3 - .../Origin/device/agv/ForkAgvDevice.cs | 592 +++++++++--------- 3 files changed, 300 insertions(+), 301 deletions(-) diff --git a/Assets/GameLogic/Game/Core/Component/ShelfNetListenerComponent.cs b/Assets/GameLogic/Game/Core/Component/ShelfNetListenerComponent.cs index ed4c11c..92c3268 100644 --- a/Assets/GameLogic/Game/Core/Component/ShelfNetListenerComponent.cs +++ b/Assets/GameLogic/Game/Core/Component/ShelfNetListenerComponent.cs @@ -31,8 +31,10 @@ public class ShelfNetListenerComponent : MonoBehaviour,IWcsSocketDataHandle private void Start() { _shelfActor = GetComponent(); - _deviceCode = _shelfActor._shelfConfig.deviceCode; - _deviceType = _shelfActor._shelfConfig.deviceType; + _deviceCode = "DDJ01"; + // _deviceCode = _shelfActor._shelfConfig.deviceCode; + // _deviceType = _shelfActor._shelfConfig.deviceType; + _deviceType = "STACKER"; } public void DataHandle(object data, object other = null) diff --git a/Assets/GameLogic/Origin/application/InitNetWorkProcess.cs b/Assets/GameLogic/Origin/application/InitNetWorkProcess.cs index 2f46ea8..e10f083 100644 --- a/Assets/GameLogic/Origin/application/InitNetWorkProcess.cs +++ b/Assets/GameLogic/Origin/application/InitNetWorkProcess.cs @@ -16,7 +16,6 @@ public class InitNetWorkProcess : IProcessState [Autowired("WmsStorageWebsocket")] private WmsStorageWebsocket wmsStorageWebsocket; private bool executing = false; - [Autowired] AgvTaskListData _agvTaskListData; public string Name { get => "InitNetWorkProcess"; } public int Priority { get => 0; } public bool IsExecuteProcess { get => executing; set => executing = value; } @@ -38,8 +37,6 @@ public class InitNetWorkProcess : IProcessState ////监听后台数据变化 wmsStorageWebsocket.OnMessage(v.DataHandle); }); - //初始化agv任务列表 - _agvTaskListData.Init(); netWorkComponent?.ConnectAllWebSocket(); } diff --git a/Assets/GameLogic/Origin/device/agv/ForkAgvDevice.cs b/Assets/GameLogic/Origin/device/agv/ForkAgvDevice.cs index 0fc17d0..64d2eb1 100644 --- a/Assets/GameLogic/Origin/device/agv/ForkAgvDevice.cs +++ b/Assets/GameLogic/Origin/device/agv/ForkAgvDevice.cs @@ -154,301 +154,301 @@ public class ForkAgvDevice : AbstractDevice, ICar } - private void FixedUpdate() - { - //设备没初始化 - if (!initialize) - { - return; - } - - if (!hasTask) - { - return; - } - UpdateTask(); - //当任务状态是下发状态是,执行 - if (taskInfo.agvTaskStatus == AgvCarManage.CarTaskStatusEnum.SENT) - { - if (currentFeedBackStatus != AgvCarManage.CarTaskStatusEnum.TAKING) - { - currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.TAKING; - } - //多次申请 - FeedBackTaskStatus(currentFeedBackStatus); - } - //取货中 - if (taskInfo.agvTaskStatus == AgvCarManage.CarTaskStatusEnum.TAKING) - { - agent.isStopped = false; - //开始代理 - StartAgent(taskInfo.fromLocation); - // 起点旋转位置 - if (applyTakePosition.Count > 0) - { - Vector3 applyTakeVector = LastPosition(applyTakePosition,taskInfo.fromLocation); - //抵达后,申请取货流程 - Vector3 targetPosition = new Vector3(applyTakeVector.x, transform.position.y, applyTakeVector.z); - if (Vector3.Distance(transform.position, targetPosition) <= 0.1f) - { - agent.isStopped = true; - agent.updateRotation = false; - currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.APPLY_TAKE; - FeedBackTaskStatus(currentFeedBackStatus); - } - } - } - //申请取货 - if (taskInfo.agvTaskStatus == AgvCarManage.CarTaskStatusEnum.APPLY_TAKE) - { - //抵达终点 - Vector3 targetPosition = new Vector3(transform.position.x, agent.destination.y, transform.position.z); - if (Vector3.Distance(targetPosition, agent.destination) <= 0.1f) - { - //获取库位容器模型,绑定到货叉上 - GameObject game = deviceParseService.GameObjectByDevice(taskInfo.fromLocation); - if (game != null) - { - Container container = game.GetComponentInChildren(); - if (container != null) - { - container.transform.parent = forkCargo.transform; - container.Agent.enabled = false; - container.Agent.isStopped = true; - playable.Play(); - } - } - //反馈取货完成 - currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.TAKE_FINISHED; - FeedBackTaskStatus(currentFeedBackStatus); - } - Quaternion targetRotation = RotationByDevice(taskInfo.fromDevice); - if (transform.localRotation == targetRotation) - { - //校验起点是设备,需要提升货叉到高位 - if (!IsShelf(taskInfo.fromLocation)) - { - if(playable.time <= 1.3) - { - playable.Play(); - } - else - { - playable.Pause(); - } - } - if(playable.state == PlayState.Paused) - { - agent.isStopped = false; - } - } - else - { - transform.localRotation = Quaternion.RotateTowards(transform.localRotation, targetRotation, _speed * 2); - } - } - - - //取货完成 - if (taskInfo.agvTaskStatus == AgvCarManage.CarTaskStatusEnum.TAKE_FINISHED) - { - if (HasGood) - { - //是库位取货方式 - if (IsShelf(taskInfo.fromDevice)) - { - if (playable.time >= 0.4) - { - OnMinFPS(); - } - if (playable.state == PlayState.Paused) - { - agent.updateRotation = true; - currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.PUTTING; - FeedBackTaskStatus(currentFeedBackStatus); - } - } - else - { - //接驳点取货方式 - //需要回退到指定位置做货叉下降动作 - Vector3 target = LastPosition(applyTakePosition, taskInfo.fromDevice); - agent.isStopped = false; - //开始代理 - StartAgent(target); - Vector3 targetPosition = new Vector3(target.x, transform.position.y, target.z); - //到位后,开始下降货叉 - if (Vector3.Distance(transform.position, targetPosition) <= 0.1f) - { - if (playable.time >= 0.6) - { - playable.playableGraph.GetRootPlayable(0).SetSpeed(-1); - playable.Play(); - } - else - { - playable.Pause(); - agent.updateRotation = true; - currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.PUTTING; - FeedBackTaskStatus(currentFeedBackStatus); - } - } - else - { - //货叉升到满叉才执行后续动作 - if (playable.time < 1.99) - { - playable.Play(); - } - } - - } - - } - else - { - GameObject game = deviceParseService.GameObjectByDevice(taskInfo.fromLocation); - if (game != null) - { - Container container = game.GetComponentInChildren(); - - if (container != null) - { - container.isAwke = false; - container.transform.parent = forkCargo.transform; - playable.Play(); - } - } - } - return; - } - //放货中 - if (taskInfo.agvTaskStatus == AgvCarManage.CarTaskStatusEnum.PUTTING) - { - //未代理开始代理 - StartAgent(taskInfo.toLocation); - - // 起点旋转位置 - if (applyPutPosition.Count > 0) - { - Vector3 applyPutVector = LastPosition(applyPutPosition, taskInfo.toLocation); - //抵达后,申请取货流程 - Vector3 targetPosition = new Vector3(applyPutVector.x, transform.position.y, applyPutVector.z); - if (Vector3.Distance(transform.position, targetPosition) <= 0.1f) - { - agent.isStopped = true; - agent.updateRotation = false; - currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.APPLY_PUT; - FeedBackTaskStatus(currentFeedBackStatus); - } - - } - - } - //申请放货 - if (taskInfo.agvTaskStatus == AgvCarManage.CarTaskStatusEnum.APPLY_PUT && currentFeedBackStatus == AgvCarManage.CarTaskStatusEnum.APPLY_PUT) - { - //抵达终点 - if (Vector3.Distance(transform.position, agent.destination) <= 0.1f) - { - currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.PUT_FINISHED; - - } - Quaternion targetRotation = RotationByDevice(taskInfo.toDevice); - if (transform.localRotation == targetRotation) - { - //启用代理 - agent.isStopped = false; - //如果是设备将货叉提升完 - if(!IsShelf(taskInfo.toLocation)) - { - playable.Play(); - } - } - else - { - transform.localRotation = Quaternion.RotateTowards(transform.localRotation, targetRotation, _speed * 2); - } - } - - if (currentFeedBackStatus == AgvCarManage.CarTaskStatusEnum.PUT_FINISHED) - { - if (HasGood) - { - //校验是库位还是设备 - - if(IsShelf(taskInfo.toLocation)) - { - Debug.LogWarning("放货持续"); - if (playable.time > 0) - { - playable.playableGraph.GetRootPlayable(0).SetSpeed(-1); - playable.Play(); - } - else - { - //暂停播放 - //playable.Pause(); - ////解绑容器 - //Container container = forkCargo.transform.GetComponentInChildren(); - //container.transform.parent = null; - OnMaxFPS(); - } - } - else - { - if (playable.time > 1.5f) - { - playable.playableGraph.GetRootPlayable(0).SetSpeed(-1); - playable.Play(); - } - else - { - OnMaxFPS(); - } - } - - } - else - { - if(!IsShelf(taskInfo.toLocation)) - { - //当后退完成后最终下降完货叉,并重置agv状态 - Vector3 position = LastPosition(applyPutPosition, taskInfo.toLocation); - Vector3 targetPosition = new Vector3(position.x, transform.position.y, position.z); - - if (Vector3.Distance(transform.position, targetPosition) <= 0.1f) - { - if(playable.time > 0) - { - playable.Play(); - } - else - { - playable.Pause(); - FeedBackTaskStatus(currentFeedBackStatus); - Rest(); - } - } - } - else - { - Vector3 position = LastPosition(applyPutPosition, taskInfo.toLocation); - Vector3 targetPosition = new Vector3(position.x, transform.position.y, position.z); - if (Vector3.Distance(transform.position, targetPosition) <= 0.1f) - { - GameObject game = deviceParseService.GameObjectByDevice(taskInfo.toLocation); - Container container = containersManage.GetContainerByCode(taskInfo.containerCode); - container.transform.parent = game.transform; - container.transform.localPosition = new Vector3(0, -0.2472343f, 0.0006999969f); - container.Agent.enabled = true; - FeedBackTaskStatus(currentFeedBackStatus); - Rest(); - } - } - } - } - } + // private void FixedUpdate() + // { + // //设备没初始化 + // if (!initialize) + // { + // return; + // } + // + // if (!hasTask) + // { + // return; + // } + // UpdateTask(); + // //当任务状态是下发状态是,执行 + // if (taskInfo.agvTaskStatus == AgvCarManage.CarTaskStatusEnum.SENT) + // { + // if (currentFeedBackStatus != AgvCarManage.CarTaskStatusEnum.TAKING) + // { + // currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.TAKING; + // } + // //多次申请 + // FeedBackTaskStatus(currentFeedBackStatus); + // } + // //取货中 + // if (taskInfo.agvTaskStatus == AgvCarManage.CarTaskStatusEnum.TAKING) + // { + // agent.isStopped = false; + // //开始代理 + // StartAgent(taskInfo.fromLocation); + // // 起点旋转位置 + // if (applyTakePosition.Count > 0) + // { + // Vector3 applyTakeVector = LastPosition(applyTakePosition,taskInfo.fromLocation); + // //抵达后,申请取货流程 + // Vector3 targetPosition = new Vector3(applyTakeVector.x, transform.position.y, applyTakeVector.z); + // if (Vector3.Distance(transform.position, targetPosition) <= 0.1f) + // { + // agent.isStopped = true; + // agent.updateRotation = false; + // currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.APPLY_TAKE; + // FeedBackTaskStatus(currentFeedBackStatus); + // } + // } + // } + // //申请取货 + // if (taskInfo.agvTaskStatus == AgvCarManage.CarTaskStatusEnum.APPLY_TAKE) + // { + // //抵达终点 + // Vector3 targetPosition = new Vector3(transform.position.x, agent.destination.y, transform.position.z); + // if (Vector3.Distance(targetPosition, agent.destination) <= 0.1f) + // { + // //获取库位容器模型,绑定到货叉上 + // GameObject game = deviceParseService.GameObjectByDevice(taskInfo.fromLocation); + // if (game != null) + // { + // Container container = game.GetComponentInChildren(); + // if (container != null) + // { + // container.transform.parent = forkCargo.transform; + // container.Agent.enabled = false; + // container.Agent.isStopped = true; + // playable.Play(); + // } + // } + // //反馈取货完成 + // currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.TAKE_FINISHED; + // FeedBackTaskStatus(currentFeedBackStatus); + // } + // Quaternion targetRotation = RotationByDevice(taskInfo.fromDevice); + // if (transform.localRotation == targetRotation) + // { + // //校验起点是设备,需要提升货叉到高位 + // if (!IsShelf(taskInfo.fromLocation)) + // { + // if(playable.time <= 1.3) + // { + // playable.Play(); + // } + // else + // { + // playable.Pause(); + // } + // } + // if(playable.state == PlayState.Paused) + // { + // agent.isStopped = false; + // } + // } + // else + // { + // transform.localRotation = Quaternion.RotateTowards(transform.localRotation, targetRotation, _speed * 2); + // } + // } + // + // + // //取货完成 + // if (taskInfo.agvTaskStatus == AgvCarManage.CarTaskStatusEnum.TAKE_FINISHED) + // { + // if (HasGood) + // { + // //是库位取货方式 + // if (IsShelf(taskInfo.fromDevice)) + // { + // if (playable.time >= 0.4) + // { + // OnMinFPS(); + // } + // if (playable.state == PlayState.Paused) + // { + // agent.updateRotation = true; + // currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.PUTTING; + // FeedBackTaskStatus(currentFeedBackStatus); + // } + // } + // else + // { + // //接驳点取货方式 + // //需要回退到指定位置做货叉下降动作 + // Vector3 target = LastPosition(applyTakePosition, taskInfo.fromDevice); + // agent.isStopped = false; + // //开始代理 + // StartAgent(target); + // Vector3 targetPosition = new Vector3(target.x, transform.position.y, target.z); + // //到位后,开始下降货叉 + // if (Vector3.Distance(transform.position, targetPosition) <= 0.1f) + // { + // if (playable.time >= 0.6) + // { + // playable.playableGraph.GetRootPlayable(0).SetSpeed(-1); + // playable.Play(); + // } + // else + // { + // playable.Pause(); + // agent.updateRotation = true; + // currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.PUTTING; + // FeedBackTaskStatus(currentFeedBackStatus); + // } + // } + // else + // { + // //货叉升到满叉才执行后续动作 + // if (playable.time < 1.99) + // { + // playable.Play(); + // } + // } + // + // } + // + // } + // else + // { + // GameObject game = deviceParseService.GameObjectByDevice(taskInfo.fromLocation); + // if (game != null) + // { + // Container container = game.GetComponentInChildren(); + // + // if (container != null) + // { + // container.isAwke = false; + // container.transform.parent = forkCargo.transform; + // playable.Play(); + // } + // } + // } + // return; + // } + // //放货中 + // if (taskInfo.agvTaskStatus == AgvCarManage.CarTaskStatusEnum.PUTTING) + // { + // //未代理开始代理 + // StartAgent(taskInfo.toLocation); + // + // // 起点旋转位置 + // if (applyPutPosition.Count > 0) + // { + // Vector3 applyPutVector = LastPosition(applyPutPosition, taskInfo.toLocation); + // //抵达后,申请取货流程 + // Vector3 targetPosition = new Vector3(applyPutVector.x, transform.position.y, applyPutVector.z); + // if (Vector3.Distance(transform.position, targetPosition) <= 0.1f) + // { + // agent.isStopped = true; + // agent.updateRotation = false; + // currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.APPLY_PUT; + // FeedBackTaskStatus(currentFeedBackStatus); + // } + // + // } + // + // } + // //申请放货 + // if (taskInfo.agvTaskStatus == AgvCarManage.CarTaskStatusEnum.APPLY_PUT && currentFeedBackStatus == AgvCarManage.CarTaskStatusEnum.APPLY_PUT) + // { + // //抵达终点 + // if (Vector3.Distance(transform.position, agent.destination) <= 0.1f) + // { + // currentFeedBackStatus = AgvCarManage.CarTaskStatusEnum.PUT_FINISHED; + // + // } + // Quaternion targetRotation = RotationByDevice(taskInfo.toDevice); + // if (transform.localRotation == targetRotation) + // { + // //启用代理 + // agent.isStopped = false; + // //如果是设备将货叉提升完 + // if(!IsShelf(taskInfo.toLocation)) + // { + // playable.Play(); + // } + // } + // else + // { + // transform.localRotation = Quaternion.RotateTowards(transform.localRotation, targetRotation, _speed * 2); + // } + // } + // + // if (currentFeedBackStatus == AgvCarManage.CarTaskStatusEnum.PUT_FINISHED) + // { + // if (HasGood) + // { + // //校验是库位还是设备 + // + // if(IsShelf(taskInfo.toLocation)) + // { + // Debug.LogWarning("放货持续"); + // if (playable.time > 0) + // { + // playable.playableGraph.GetRootPlayable(0).SetSpeed(-1); + // playable.Play(); + // } + // else + // { + // //暂停播放 + // //playable.Pause(); + // ////解绑容器 + // //Container container = forkCargo.transform.GetComponentInChildren(); + // //container.transform.parent = null; + // OnMaxFPS(); + // } + // } + // else + // { + // if (playable.time > 1.5f) + // { + // playable.playableGraph.GetRootPlayable(0).SetSpeed(-1); + // playable.Play(); + // } + // else + // { + // OnMaxFPS(); + // } + // } + // + // } + // else + // { + // if(!IsShelf(taskInfo.toLocation)) + // { + // //当后退完成后最终下降完货叉,并重置agv状态 + // Vector3 position = LastPosition(applyPutPosition, taskInfo.toLocation); + // Vector3 targetPosition = new Vector3(position.x, transform.position.y, position.z); + // + // if (Vector3.Distance(transform.position, targetPosition) <= 0.1f) + // { + // if(playable.time > 0) + // { + // playable.Play(); + // } + // else + // { + // playable.Pause(); + // FeedBackTaskStatus(currentFeedBackStatus); + // Rest(); + // } + // } + // } + // else + // { + // Vector3 position = LastPosition(applyPutPosition, taskInfo.toLocation); + // Vector3 targetPosition = new Vector3(position.x, transform.position.y, position.z); + // if (Vector3.Distance(transform.position, targetPosition) <= 0.1f) + // { + // GameObject game = deviceParseService.GameObjectByDevice(taskInfo.toLocation); + // Container container = containersManage.GetContainerByCode(taskInfo.containerCode); + // container.transform.parent = game.transform; + // container.transform.localPosition = new Vector3(0, -0.2472343f, 0.0006999969f); + // container.Agent.enabled = true; + // FeedBackTaskStatus(currentFeedBackStatus); + // Rest(); + // } + // } + // } + // } + // } /// /// 重置设备状态 /// @@ -473,7 +473,7 @@ public class ForkAgvDevice : AbstractDevice, ICar { if(debugFeedBack) { - taskInfo.agvTaskStatus = status; + // taskInfo.agvTaskStatus = status; } FeedBackEntity feedBackDTO = new FeedBackEntity(); feedBackDTO.feedbackStatus = status.ToString();