| | |
| | | using WIDESEAWCS_Common.AGVEnum; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common.AGVEnum; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | |
| | | } |
| | | |
| | | // 读åä»»å¡ç¶æ |
| | | int taskFbInteractive = plcClient.Communicator.Read<int>(taskFbInteractiveR); |
| | | int taskFbInteractiveW = plcClient.Communicator.Read<int>(taskFbInteractive2); |
| | | int resetTaskFbInteractiveRValue = plcClient.Communicator.Read<int>(resetTaskFbInteractiveR); |
| | | int taskFbInteractive = plcClient.Communicator.Read<ushort>(taskFbInteractiveR); |
| | | int taskFbInteractiveW = plcClient.Communicator.Read<ushort>(taskFbInteractive2); |
| | | int resetTaskFbInteractiveRValue = plcClient.Communicator.Read<ushort>(resetTaskFbInteractiveR); |
| | | |
| | | // 妿resetTaskFbInteractiveR为1ï¼åéç½®taskFbInteractiveW为0ï¼å¹¶çå¾
å
¶å为0 |
| | | if (resetTaskFbInteractiveRValue == 1) |
| | | { |
| | | plcClient.Communicator.Write(taskFbInteractive2, 0); |
| | | plcClient.Communicator.Write<ushort>(taskFbInteractive2, 0); |
| | | // é¿å
使ç¨Thread.Sleepæ¥çå¾
ç¶æååï¼ä½¿ç¨æ´é«æççå¾
æºå¶ |
| | | for (int i = 0; i < 5; i++) |
| | | { |
| | | Task.Delay(300).Wait(); // 使ç¨Task.Delayæ¿ä»£Thread.Sleepï¼é¿å
é»å¡çº¿ç¨æ± ä¸ççº¿ç¨ |
| | | int agvNumber = plcClient.Communicator.Read<int>(taskFbInteractive2); |
| | | int agvNumber = plcClient.Communicator.Read<ushort>(taskFbInteractive2); |
| | | if (agvNumber != 0) |
| | | { |
| | | plcClient.Communicator.Write(taskFbInteractive2, 0); |
| | | plcClient.Communicator.Write<ushort>(taskFbInteractive2, 0); |
| | | } |
| | | else |
| | | { |
| | |
| | | // åªæå½taskFbInteractive为1ä¸taskFbInteractiveW为0æ¶æå¤çä»»å¡ç¶æ |
| | | if (taskFbInteractive == 1 && taskFbInteractiveW == 0) |
| | | { |
| | | string taskId = plcClient.Communicator.Read<int>(taskIDFb).ToString(); // ä»»å¡ID |
| | | int taskState = plcClient.Communicator.Read<int>(taskStatusFb); // ä»»å¡ç¶æ |
| | | string taskId = plcClient.Communicator.Read<string>(taskIDFb).ToString(); // ä»»å¡ID |
| | | int taskState = plcClient.Communicator.Read<ushort>(taskStatusFb); // ä»»å¡ç¶æ |
| | | |
| | | // 妿任å¡ç¶ææ æï¼åç´æ¥è¿å |
| | | if (taskState == 0) |
| | |
| | | } |
| | | |
| | | // æ ¹æ®ä»»å¡IDæ¥è¯¢æ°æ®åºä¸çä»»å¡ |
| | | var agvTask = taskRepository.QueryFirst(r => r.TaskNum.ToString() == taskId); |
| | | int tasknum = int.Parse(taskId.Split('-')[1]); |
| | | var agvTask = taskRepository.QueryFirst(r => r.TaskNum.ToString() == tasknum.ToString()); |
| | | if (agvTask == null) |
| | | { |
| | | plcClient.Communicator.Write(taskFbInteractive2, 1); |
| | | plcClient.Communicator.Write<ushort>(taskFbInteractive2, 1); |
| | | return; // 妿任å¡ä¸åå¨ï¼ç´æ¥è¿åï¼ä¸éè¦å次åå
¥ |
| | | } |
| | | |
| | |
| | | } |
| | | else if (taskState == 4) // ä»»å¡ç»ç¹å®æ |
| | | { |
| | | if (agvTask.TaskState != (int)TaskInStatusEnum.SC_InExecuting) |
| | | if (agvTask.TaskState != (int)TaskInStatusEnum.SC_InFinish) |
| | | { |
| | | // 妿任å¡ç¶æä¸æ¯ç»ç¹æ§è¡ä¸ï¼æåºå¼å¸¸ |
| | | throw new Exception($"ä»»å¡ç¶ææ´æ¹ä¸º4ç»ç¹å·²å®æå¤±è´¥,ä»»å¡ID:{taskId},å½åç¶æ:{agvTask.TaskState}"); |
| | |
| | | { |
| | | // 空ç线è¿çç®± |
| | | // TODO: 任塿ªå宿´æ¡ç |
| | | var materials = new List<BakingClass>(); |
| | | var details = agvTask.ExceptionMessage; |
| | | string[] splitDetails = details.Split(','); |
| | | |
| | | var materials = splitDetails |
| | | .Select(part => new BakingClass |
| | | { |
| | | MaterialType = "", |
| | | BarCode = part |
| | | }) |
| | | .ToList(); |
| | | |
| | | MESback WMSbackresult = MESAPIInvoke.BakingFeedingBinding(agvTask.TargetAddress, materials); |
| | | if (WMSbackresult.Code > 0) { new Exception(WMSbackresult.Message); return; } |
| | |
| | | // }) |
| | | // .ToList(); |
| | | |
| | | var details = _detailsRepository.QueryData(x => x.TaskEndAddress == agvTask.TargetAddress && x.TaskName == agvTask.Roadway).OrderBy(x => x.CreateDate).ToList(); |
| | | var details = _detailsRepository.QueryData(x => x.TaskEndAddress == agvTask.TargetAddress).ToList(); |
| | | |
| | | if (details.Count >= 2) |
| | | { |
| | |
| | | |
| | | // å é¤å·²å®æçä»»å¡ |
| | | taskRepository.DeleteData(agvTask); |
| | | plcClient.Communicator.Write(taskFbInteractive2, 1); |
| | | plcClient.Communicator.Write<ushort>(taskFbInteractive2, 1); |
| | | EnsureTaskFeedback(taskFbInteractive2, plcClient); |
| | | } |
| | | else if (taskState == 5) |
| | | { |
| | | plcClient.Communicator.Write(taskFbInteractive2, 1); |
| | | plcClient.Communicator.Write<ushort>(taskFbInteractive2, 1); |
| | | } |
| | | } |
| | | |
| | | // 妿taskFbInteractive为0ä¸taskFbInteractiveW为1ï¼åéç½®taskFbInteractiveW为0 |
| | | if (taskFbInteractive == 0 && taskFbInteractiveW == 1) |
| | | { |
| | | plcClient.Communicator.Write(taskFbInteractive2, 0); |
| | | plcClient.Communicator.Write<ushort>(taskFbInteractive2, 0); |
| | | EnsureTaskFeedback(taskFbInteractive2, plcClient); |
| | | } |
| | | } |
| | |
| | | // æ´æ°ä»»å¡ç¶æå¹¶åå
¥AGVåé¦å°å |
| | | private static void UpdateTaskStatus(AGV plcClient, Dt_Task agvTask, TaskInStatusEnum targetStatus, ITaskRepository taskRepository, string taskFbInteractive2) |
| | | { |
| | | if (agvTask.TaskState != (int)targetStatus) |
| | | { |
| | | plcClient.Communicator.Write(taskFbInteractive2, 1); // ç¶æä¸å¹é
ï¼åå
¥åé¦ |
| | | } |
| | | //if (agvTask.TaskState != (int)targetStatus) |
| | | //{ |
| | | // plcClient.Communicator.Write<ushort>(taskFbInteractive2, 1); // ç¶æä¸å¹é
ï¼åå
¥åé¦ |
| | | //} |
| | | |
| | | // æ´æ°ä»»å¡ç¶æä¸ºä¸ä¸ä¸ªæªå®æç¶æ |
| | | agvTask.TaskState = agvTask.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); |
| | | taskRepository.UpdateData(agvTask); |
| | | plcClient.Communicator.Write(taskFbInteractive2, 1); |
| | | plcClient.Communicator.Write<ushort>(taskFbInteractive2, 1); |
| | | EnsureTaskFeedback(taskFbInteractive2, plcClient); |
| | | } |
| | | |
| | |
| | | int agvNumber = plcClient.Communicator.Read<int>(taskFbInteractive2); |
| | | if (agvNumber != 1) |
| | | { |
| | | plcClient.Communicator.Write(taskFbInteractive2, 1); |
| | | plcClient.Communicator.Write<ushort>(taskFbInteractive2, 1); |
| | | } |
| | | else |
| | | { |