| | |
| | | //æ¥è¯¢æåæº/ç»ç«æºä¿¡å· |
| | | //Task.Run(delegate |
| | | //{ |
| | | try |
| | | try |
| | | { |
| | | if (commonStackerCrane != null) |
| | | { |
| | | if (commonStackerCrane != null) |
| | | |
| | | Dt_Task? task1001 = _taskService.QueryStackerCraneTaskByAGVRequest("SC01"); |
| | | if (task1001 != null) |
| | | { |
| | | |
| | | Dt_Task? task1001 = _taskService.QueryStackerCraneTaskByAGVRequest("SC01"); |
| | | if (task1001 != null) |
| | | //读åæåæºä¿¡å·ï¼ç¡®å®æ¯å¦å¯ä»¥è¿å
¥ |
| | | int IsAllow = 0; |
| | | if (task1001.SourceAddress == "SC01-002-000-001")//WMS 1001ç«ç¹ |
| | | { |
| | | //读åæåæºä¿¡å·ï¼ç¡®å®æ¯å¦å¯ä»¥è¿å
¥ |
| | | int IsAllow = 0; |
| | | if (task1001.SourceAddress == "SC01-002-000-001")//WMS 1001ç«ç¹ |
| | | IsAllow = commonStackerCrane.Communicator.Read<short>("DB2.0.0"); |
| | | } |
| | | else if (task1001.SourceAddress == "SC01-002-000-002")//WMS 1002ç«ç¹ |
| | | { |
| | | IsAllow = commonStackerCrane.Communicator.Read<short>("DB2.8.0"); |
| | | } |
| | | if (IsAllow == 1)//å¦æä¸º1ï¼åå
计AGVè¿å
¥ï¼åä¼ WMS |
| | | { |
| | | MESSendCMD sendcmd = new MESSendCMD { cmd = 2001, task_id = task1001.TaskNum, status = 6 }; |
| | | MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); |
| | | if (res != null && res.code != 0) |
| | | { |
| | | IsAllow = commonStackerCrane.Communicator.Read<short>("DB2.0.0"); |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"å
计AGVè¿å
¥æåæºï¼åä¼ WMS失败ï¼ä»»å¡å·{task1001.TaskNum}"); |
| | | } |
| | | else if (task1001.SourceAddress == "SC01-002-000-002")//WMS 1002ç«ç¹ |
| | | else |
| | | { |
| | | IsAllow = commonStackerCrane.Communicator.Read<short>("DB2.8.0"); |
| | | } |
| | | if (IsAllow == 1)//å¦æä¸º1ï¼åå
计AGVè¿å
¥ï¼åä¼ WMS |
| | | { |
| | | MESSendCMD sendcmd = new MESSendCMD { cmd = 2001, task_id = task1001.TaskNum, status = 6 }; |
| | | MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); |
| | | if (res != null && res.code != 0) |
| | | { |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æåæºæå宿ï¼åä¼ WMS失败ï¼ä»»å¡å·{task1001.TaskNum}"); |
| | | } |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"å
计AGVè¿å
¥æåæºï¼åä¼ WMSæåï¼ä»»å¡å·{task1001.TaskNum}"); |
| | | } |
| | | } |
| | | Dt_Task? task3001 = _taskService.QueryStackerCraneTaskByAGVPutFinish("SC01"); |
| | | if (task3001 != null) |
| | | else |
| | | { |
| | | int IsFinish = 0; |
| | | int IsWriteOne = 0; |
| | | int IsWriteTwo = 0; |
| | | if (task3001.SourceAddress == "SC01-002-000-001")//WMS 1001ç«ç¹ |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æªè¯»åå°æåæºå
计è¿å
¥ä¿¡å·ï¼æä¸å
计AGVè¿å
¥æåæºï¼ä»»å¡å·{task1001.TaskNum}"); |
| | | } |
| | | } |
| | | Dt_Task? task3001 = _taskService.QueryStackerCraneTaskByAGVPutFinish("SC01"); |
| | | if (task3001 != null) |
| | | { |
| | | int IsFinish = 0; |
| | | int IsWriteOne = 0; |
| | | int IsWriteTwo = 0; |
| | | if (task3001.SourceAddress == "SC01-002-000-001")//WMS 1001ç«ç¹ |
| | | { |
| | | //æåæºæ¯å¦å¤äºå°±ç»ªç¶æ |
| | | |
| | | int IsReady = commonStackerCrane.Communicator.Read<short>("DB2.0.0"); |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æåæºç¶æï¼{IsReady}ä»»å¡å·ï¼{task3001.TaskNum}"); |
| | | //åå
¥æåä¿¡æ¯ |
| | | IsWriteOne = commonStackerCrane.Communicator.Read<short>("DB1.0.0"); |
| | | if (IsWriteOne == 0 && IsReady == 1) |
| | | { |
| | | //æåæºæ¯å¦å¤äºå°±ç»ªç¶æ |
| | | int IsReady= commonStackerCrane.Communicator.Read<short>("DB2.0.0"); |
| | | //åå
¥æåä¿¡æ¯ |
| | | IsWriteOne = commonStackerCrane.Communicator.Read<short>("DB1.0.0"); |
| | | if(IsWriteOne == 0&& IsReady == 1) |
| | | { |
| | | commonStackerCrane.Communicator.Write<short>("DB1.0.0", 1); |
| | | } |
| | | //读åæåæºä¿¡å·ï¼ç¡®å®æ¯å¦æå宿 |
| | | |
| | | IsFinish= commonStackerCrane.Communicator.Read<short>("DB2.2.0"); |
| | | commonStackerCrane.Communicator.Write<short>("DB1.0.0", 1); |
| | | } |
| | | else if (task3001.SourceAddress == "SC01-002-000-002")//WMS 1002ç«ç¹ |
| | | else |
| | | { |
| | | //æåæºæ¯å¦å¤äºå°±ç»ªç¶æ |
| | | int IsReady = commonStackerCrane.Communicator.Read<short>("DB2.0.0"); |
| | | //åå
¥æåä¿¡æ¯ |
| | | IsWriteTwo = commonStackerCrane.Communicator.Read<short>("DB1.6.0"); |
| | | if (IsWriteTwo == 0 && IsReady == 1) |
| | | { |
| | | commonStackerCrane.Communicator.Write<short>("DB1.6.0", 1); |
| | | } |
| | | //读åæåæºä¿¡å·ï¼ç¡®å®æ¯å¦æå宿 |
| | | IsFinish = commonStackerCrane.Communicator.Read<short>("DB2.10.0"); |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æªåå
¥æåä¿¡å·ï¼å¯è½æ¯å·²åå
¥æè
æåæºæªå¤çå°±ç»ªç¶æ,ä»»å¡å·ï¼{task3001.TaskNum}"); |
| | | } |
| | | if (IsFinish == 1)//å¦æä¸º1ï¼å表示æå宿ï¼åä¼ WMS |
| | | { |
| | | MESSendCMD sendcmd = new MESSendCMD { cmd = 2002, task_id = task3001.TaskNum, status = 6 }; |
| | | MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); |
| | | string inparam = JsonConvert.SerializeObject(sendcmd); |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æåæºæå宿ï¼åä¼ WMS,å
¥åï¼{inparam}"); |
| | | //读åæåæºä¿¡å·ï¼ç¡®å®æ¯å¦æå宿 |
| | | |
| | | if (res != null && res.code != 0) |
| | | { |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æåæºæå宿ï¼åä¼ WMS失败ï¼ä»»å¡å·{task3001.TaskNum}"); |
| | | } |
| | | IsFinish = commonStackerCrane.Communicator.Read<short>("DB2.2.0"); |
| | | } |
| | | else if (task3001.SourceAddress == "SC01-002-000-002")//WMS 1002ç«ç¹ |
| | | { |
| | | //æåæºæ¯å¦å¤äºå°±ç»ªç¶æ |
| | | |
| | | int IsReady = commonStackerCrane.Communicator.Read<short>("DB2.0.0"); |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æåæºç¶æï¼{IsReady}ä»»å¡å·ï¼{task3001.TaskNum}"); |
| | | //åå
¥æåä¿¡æ¯ |
| | | IsWriteTwo = commonStackerCrane.Communicator.Read<short>("DB1.6.0"); |
| | | if (IsWriteTwo == 0 && IsReady == 1) |
| | | { |
| | | commonStackerCrane.Communicator.Write<short>("DB1.6.0", 1); |
| | | } |
| | | else |
| | | { |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æªåå
¥æåä¿¡å·ï¼å¯è½æ¯ä¿¡å·å·²åå
¥æè
æåæºæªå¤çå°±ç»ªç¶æï¼ä»»å¡å·ï¼{task3001.TaskNum}"); |
| | | } |
| | | //读åæåæºä¿¡å·ï¼ç¡®å®æ¯å¦æå宿 |
| | | IsFinish = commonStackerCrane.Communicator.Read<short>("DB2.10.0"); |
| | | } |
| | | if (IsFinish == 1)//å¦æä¸º1ï¼å表示æå宿ï¼åä¼ WMS |
| | | { |
| | | MESSendCMD sendcmd = new MESSendCMD { cmd = 2002, task_id = task3001.TaskNum, status = 6 }; |
| | | MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); |
| | | string inparam = JsonConvert.SerializeObject(sendcmd); |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æåæºæå宿ï¼åä¼ WMS,å
¥åï¼{inparam}"); |
| | | |
| | | if (res != null && res.code != 0) |
| | | { |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æåæºæå宿ï¼åä¼ WMS失败ï¼ä»»å¡å·{task3001.TaskNum}"); |
| | | } |
| | | } |
| | | |
| | | //å°å åæºåºåºå®æä»»å¡ |
| | | Dt_Task? taskSmall = _taskService.QueryStackerCraneFinishTask(); |
| | | if(taskSmall != null) |
| | | else |
| | | { |
| | | //æ ¹æ®ä»»å¡æºå°åç¡®å®åå
¥PLCä½ç½® Depth |
| | | Dt_LocationInfo location = _locationInfoRepository.QueryFirst(x=>x.LocationCode==taskSmall.SourceAddress); |
| | | if(location != null) |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æåæºæåä¸...ï¼ä»»å¡å·ï¼{task3001.TaskNum}"); |
| | | } |
| | | } |
| | | |
| | | //å°å åæºåºåºå®æä»»å¡ |
| | | Dt_Task? taskSmall = _taskService.QueryStackerCraneFinishTask(); |
| | | if (taskSmall != null) |
| | | { |
| | | //æ ¹æ®ä»»å¡æºå°åç¡®å®åå
¥PLCä½ç½® Depth |
| | | Dt_LocationInfo location = _locationInfoRepository.QueryFirst(x => x.LocationCode == taskSmall.SourceAddress); |
| | | if (location != null) |
| | | { |
| | | string[] Levels = taskSmall.Remark.Split("-"); |
| | | if (Levels.Length == 2) |
| | | { |
| | | string[] Levels = taskSmall.Remark.Split("-"); |
| | | if (Levels.Length == 2) |
| | | if (!string.IsNullOrEmpty(Levels[0]) && !string.IsNullOrEmpty(Levels[1])) |
| | | { |
| | | if (!string.IsNullOrEmpty(Levels[0]) && !string.IsNullOrEmpty(Levels[1])) |
| | | int level = Convert.ToInt16(Levels[0]) - Convert.ToInt16(Levels[1]); |
| | | |
| | | //å©ä½å±æ°åå
¥ |
| | | bool issuccess = commonStackerCrane.Communicator.Write<short>("DB28." + location.Depth + ".0", Convert.ToInt16(level)); |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"å©ä½å±æ°ä¿¡å·åå
¥{level}-ä»»å¡å·{taskSmall.TaskNum}"); |
| | | |
| | | |
| | | //妿å½åæå屿°çäºæ»å±æ°ï¼å表示æè½¦ææç屿°åå® |
| | | if (level == 0) |
| | | { |
| | | int level = Convert.ToInt16(Levels[0]) - Convert.ToInt16(Levels[1]); |
| | | |
| | | //å©ä½å±æ°åå
¥ |
| | | bool issuccess = commonStackerCrane.Communicator.Write<short>("DB28." + location.Depth + ".0", Convert.ToInt16(level)); |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"å©ä½å±æ°ä¿¡å·åå
¥{level}-ä»»å¡å·{taskSmall.TaskNum}"); |
| | | |
| | | |
| | | //妿å½åæå屿°çäºæ»å±æ°ï¼å表示æè½¦ææç屿°åå® |
| | | if (level == 0) |
| | | //æºå°åï¼æåä½ï¼å¯¹åºçç®æ å°åï¼ç»ç«æºï¼location.Remark |
| | | if (!string.IsNullOrEmpty(location.Remark)) |
| | | { |
| | | //æºå°åï¼æåä½ï¼å¯¹åºçç®æ å°åï¼ç»ç«æºï¼location.Remark |
| | | if (!string.IsNullOrEmpty(location.Remark)) |
| | | { |
| | | //æ ¹æ®ç®æ å°åæ¥è¯¢ç»ç«æºç«ç¹ä¿¡æ¯ï¼è·ååå
¥æ´è½¦å®æçDBå Depth |
| | | Dt_LocationInfo location2 = _locationInfoRepository.QueryFirst(x => x.LocationCode == location.Remark); |
| | | //æ ¹æ®ç®æ å°åæ¥è¯¢ç»ç«æºç«ç¹ä¿¡æ¯ï¼è·ååå
¥æ´è½¦å®æçDBå Depth |
| | | Dt_LocationInfo location2 = _locationInfoRepository.QueryFirst(x => x.LocationCode == location.Remark); |
| | | //æ´è½¦å®æåå
¥å±æ° |
| | | int sn = 0; |
| | | if(taskSmall.SourceAddress== "SC01-001-006-001"|| taskSmall.SourceAddress == "SC01-001-012-001"|| taskSmall.SourceAddress == "SC01-001-018-001" || taskSmall.SourceAddress == "SC01-001-022-001"|| taskSmall.SourceAddress == "SC01-001-026-001") |
| | | if (taskSmall.SourceAddress == "SC01-001-006-001" || taskSmall.SourceAddress == "SC01-001-012-001" || taskSmall.SourceAddress == "SC01-001-018-001" || taskSmall.SourceAddress == "SC01-001-022-001" || taskSmall.SourceAddress == "SC01-001-026-001") |
| | | { |
| | | sn = 1; |
| | | } |
| | | else if(taskSmall.SourceAddress == "SC01-001-007-001" || taskSmall.SourceAddress == "SC01-001-013-001" || taskSmall.SourceAddress == "SC01-001-019-001" || taskSmall.SourceAddress == "SC01-001-023-001" || taskSmall.SourceAddress == "SC01-001-027-001") |
| | | else if (taskSmall.SourceAddress == "SC01-001-007-001" || taskSmall.SourceAddress == "SC01-001-013-001" || taskSmall.SourceAddress == "SC01-001-019-001" || taskSmall.SourceAddress == "SC01-001-023-001" || taskSmall.SourceAddress == "SC01-001-027-001") |
| | | { |
| | | sn = 2; |
| | | } |
| | |
| | | { |
| | | sn = 3; |
| | | } |
| | | bool issuccess2 = commonStackerCrane.Communicator.Write<short>("DB28." + location2.Depth+".0", Convert.ToInt16(sn)); |
| | | if (issuccess2&&issuccess) |
| | | { |
| | | _taskService.UpdateTaskStatus(taskSmall.TaskId, (int)TaskOutStatusEnum.OutFinish); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(taskSmall.TaskId, $"åºåºä»»å¡å®æ"); |
| | | } |
| | | else |
| | | { |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æ´è½¦å®æä¿¡å·åå
¥å¤±è´¥ï¼ä»»å¡å·{taskSmall.TaskNum}"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | if (issuccess) |
| | | bool issuccess2 = commonStackerCrane.Communicator.Write<short>("DB28." + location2.Depth + ".0", Convert.ToInt16(sn)); |
| | | if (issuccess2 && issuccess) |
| | | { |
| | | _taskService.UpdateTaskStatus(taskSmall.TaskId, (int)TaskOutStatusEnum.OutFinish); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(taskSmall.TaskId, $"åºåºä»»å¡å®æ"); |
| | | } |
| | | else |
| | | { |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"å©ä½å±æ°ä¿¡å·åå
¥å¤±è´¥ï¼ä»»å¡å·{taskSmall.TaskNum}"); |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"æ´è½¦å®æä¿¡å·åå
¥å¤±è´¥ï¼ä»»å¡å·{taskSmall.TaskNum}"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | if (issuccess) |
| | | { |
| | | _taskService.UpdateTaskStatus(taskSmall.TaskId, (int)TaskOutStatusEnum.OutFinish); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(taskSmall.TaskId, $"åºåºä»»å¡å®æ"); |
| | | } |
| | | else |
| | | { |
| | | WriteDebug(nameof(CommonStackerCraneJob), $"å©ä½å±æ°ä¿¡å·åå
¥å¤±è´¥ï¼ä»»å¡å·{taskSmall.TaskNum}"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteError(nameof(CommonStackerCraneJob), "æ¥è¯¢æåå
¥PLCç¶æå¤±è´¥ï¼", ex); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteError(nameof(CommonStackerCraneJob), "æ¥è¯¢æåå
¥PLCç¶æå¤±è´¥ï¼", ex); |
| | | } |
| | | WriteDebug("大å åæºè¿è¡æ¥å¿", "ç»ææ¶é´" + DateTime.Now); |
| | | //}); |
| | | return Task.CompletedTask; |