代码变更

This commit is contained in:
Pang_mir 2025-05-09 15:52:45 +08:00
parent 2eb6590e59
commit e03ed1cc33
3 changed files with 300 additions and 301 deletions

View File

@ -31,8 +31,10 @@ public class ShelfNetListenerComponent : MonoBehaviour,IWcsSocketDataHandle
private void Start()
{
_shelfActor = GetComponent<ShelfActor>();
_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)

View File

@ -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();
}

View File

@ -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<Container>();
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<Container>();
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>();
//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<Container>();
// 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<Container>();
//
// 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>();
// //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();
// }
// }
// }
// }
// }
/// <summary>
/// 重置设备状态
/// </summary>
@ -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();