| | |
| | | using Autofac.Core; |
| | | using HslCommunication; |
| | | using Microsoft.AspNetCore.Components.Routing; |
| | | using Microsoft.AspNetCore.Hosting; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | |
| | | using System.Collections.Generic; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Diagnostics.Eventing.Reader; |
| | | using System.DirectoryServices.Protocols; |
| | | using System.IO.Ports; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Reflection.Metadata; |
| | | using System.Security.Cryptography.Xml; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Transactions; |
| | |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Enums; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_ISystemServices; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_QuartzJob.StackerCrane.Enum; |
| | | using WIDESEAWCS_TaskInfoService; |
| | | using WIDESEAWCS_Tasks.StackerCraneJob; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | |
| | | { |
| | | try |
| | | { |
| | | |
| | | CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (commonStackerCrane != null) |
| | | { |
| | | WriteLog.Write_Log("å åæºå½åç¶æ", $"{commonStackerCrane.DeviceCode}åºå åæºç¶æä¿¡æ¯", |
| | | $"å åæºè®¾å¤å°å:ãDB105.2.0ã,读åçæ°æ®ï¼ã{commonStackerCrane.StackerCraneAutoStatusDes}ã\n" + |
| | | $"å åæºå·¥ä½æ¨¡å¼å°å:ãDB105.3.0ã,读åçæ°æ®ï¼ã{commonStackerCrane.StackerCraneStatusDes}ã\n" + |
| | | $"å åæºä½ä¸ç¶æå°å:ãDB105.22.0ã,读åçæ°æ®ï¼ã{commonStackerCrane.StackerCraneWorkStatusDes}ã\n" + |
| | | $"å åæºå½å任塿§è¡ä¸å°å:ãDB105.18.0ã,读åçæ°æ®ï¼ã{commonStackerCrane.CurrentTaskNum}ã\n"); |
| | | |
| | | UpdateHandShake(commonStackerCrane.CurrentTaskNum, commonStackerCrane.StackerCraneWorkStatusDes); |
| | | //ä»»å¡å®æStackerCraneWorkStatus |
| | | if (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.WorkCompleted) |
| | | { |
| | |
| | | Dt_Task? currtask = _taskService.CurrtaskInfo(commonStackerCrane.CurrentTaskNum); |
| | | if(currtask != null) |
| | | { |
| | | string PalletCode = ""; |
| | | //夿任å¡ç±»å |
| | | if(currtask.TaskType== (int)TaskTypeEnum.Inventorybound) |
| | | if (currtask.TaskType== (int)TaskTypeEnum.Inventorybound) |
| | | { |
| | | //è¯»åæ¡ç ï¼è¿è¡é
对 |
| | | |
| | | |
| | | DeviceProDTO? deviceProDTO = commonStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == "SCBarcode"); |
| | | byte[] bytes = commonStackerCrane.Communicator.Read(deviceProDTO.DeviceProAddress, 64); |
| | | string result = Encoding.ASCII.GetString(bytes).Replace(" ", ""); |
| | | |
| | | bool pandianBort = false; |
| | | if(currtask.PalletCode== result) pandianBort= true; |
| | | |
| | | //读åçæçæ¡ç |
| | | PalletCode = Encoding.ASCII.GetString(bytes).Replace(" ", ""); |
| | | } |
| | | |
| | | WebResponseContent webResponse = _taskService.StackCraneTaskCompleted(commonStackerCrane.CurrentTaskNum); |
| | | WebResponseContent webResponse = _taskService.StackCraneTaskCompleted(commonStackerCrane.CurrentTaskNum, PalletCode); |
| | | if (webResponse.Status) |
| | | { |
| | | WriteLog.Write_Log("å åæºä»»å¡ä¸æ¥å®æä¿¡æ¯", "å åæºä»»å¡ä¸æ¥å®æä¿¡æ¯", $"ã{commonStackerCrane.DeviceCode}ãåºå åæºä¸æ¥ä»»å¡å·:ã{commonStackerCrane.CurrentTaskNum}ãå®æä¿¡å·ï¼"); |
| | | |
| | | bool ddjfk = commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); |
| | | } |
| | |
| | | |
| | | if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal) |
| | | { |
| | | |
| | | if (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) |
| | | { |
| | | |
| | | |
| | | Dt_Task? task = GetTask(commonStackerCrane); |
| | | if (task != null) |
| | | { |
| | |
| | | commonStackerCrane.Communicator.Write("DB105.52", 1); |
| | | |
| | | WebResponseContent webResponseContent=_taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | //å»¶è¿1s |
| | | Thread.Sleep(1000); |
| | | } |
| | | } |
| | | } |
| | |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(nameof(CommonStackerCraneJob) + ":" + ex.ToString()); |
| | | WriteLog.Write_Log("å åæºæ¥éä¿¡æ¯", "å åæºæ¥éä¿¡æ¯", $"å åæºæ¥éä¿¡æ¯ï¼ã{ex.ToString()}ã"); |
| | | |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | |
| | | if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5 && e.TaskNum !=0) |
| | | { |
| | | //Console.Out.WriteLine("TaskCompleted" + e.TaskNum); |
| | | _taskService.StackCraneTaskCompleted(e.TaskNum); |
| | | //_taskService.StackCraneTaskCompleted(e.TaskNum,); |
| | | commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); |
| | | } |
| | | } |
| | |
| | | } |
| | | else if (taskItem.TaskType == (int)TaskTypeEnum.Inbound || taskItem.TaskType == (int)TaskTypeEnum.Inventorybound) |
| | | { |
| | | InTaskStationIsOccupied(taskItem.SourceAddress, taskItem.Roadway); |
| | | return taskItem; |
| | | } |
| | | } |
| | |
| | | |
| | | int StationNum = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress); |
| | | int HandShake = conveyorLine.Communicator.Read<ushort>(HandShakeprodto.DeviceProAddress); |
| | | |
| | | WriteLog.Write_Log("åºåºåºå£ç¶æä¿¡æ¯", "åºåºåºå£ç¶æä¿¡æ¯", $"åºå£æ¯ã{NextAddress}ãï¼ç³è¯·ç¶æå°åï¼ã{HandShakeprodto.DeviceProAddress}ã,读åçæ°æ®ï¼ã{HandShake}ã\n" + |
| | | $"åºå£æ¯å¦æè´§ç¶æå°åï¼ã{deviceProDTO.DeviceProAddress}ãï¼è¯»åçæ°æ®ã{StationNum}ã"); |
| | | if (StationNum == 0 && HandShake == 0 && Roadway == "C") |
| | | { |
| | | return true; |
| | |
| | | |
| | | int StationNum = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress); |
| | | int HandShake = conveyorLine.Communicator.Read<ushort>(HandShakeprodto.DeviceProAddress); |
| | | WriteLog.Write_Log("åºåºåºå£ç¶æä¿¡æ¯", "åºåºåºå£ç¶æä¿¡æ¯", $"åºå£æ¯ã{NextAddress}ãï¼ç³è¯·ç¶æå°åï¼ã{HandShakeprodto.DeviceProAddress}ã,读åçæ°æ®ï¼ã{HandShake}ã\n" + |
| | | $"åºå£æ¯å¦æè´§ç¶æå°åï¼ã{deviceProDTO.DeviceProAddress}ãï¼è¯»åçæ°æ®ã{StationNum}ã"); |
| | | |
| | | if ((StationNum == 1 && HandShake == 0 && Roadway == "B") || (StationNum == 0 && HandShake == 0 && Roadway != "B")) |
| | | { |
| | | return true; |
| | |
| | | |
| | | return false; |
| | | } |
| | | /// <summary> |
| | | /// å
¥åºä»»å¡åºå£æè´§æ è´§ç¶æ |
| | | /// </summary> |
| | | private void InTaskStationIsOccupied(string SourceAddress, string Roadway) |
| | | { |
| | | try |
| | | { |
| | | if (Roadway == "C") |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1004"); |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "StationNum"); |
| | | DeviceProDTO? HandShakeprodto = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "HandShake"); |
| | | |
| | | int StationNum = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress); |
| | | int HandShake = conveyorLine.Communicator.Read<ushort>(HandShakeprodto.DeviceProAddress); |
| | | WriteLog.Write_Log("å
¥åºåºå£ç¶æä¿¡æ¯", "å
¥åºåºå£ç¶æä¿¡æ¯", $"åºå£æ¯ã{SourceAddress}ãï¼ç³è¯·ç¶æå°åï¼ã{HandShakeprodto.DeviceProAddress}ã,读åçæ°æ®ï¼ã{HandShake}ã\n" + |
| | | $"åºå£æ¯å¦æè´§ç¶æå°åï¼ã{deviceProDTO.DeviceProAddress}ãï¼è¯»åçæ°æ®ã{StationNum}ã"); |
| | | } |
| | | else |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1003"); |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "StationNum"); |
| | | DeviceProDTO? HandShakeprodto = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "HandShake"); |
| | | |
| | | int StationNum = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress); |
| | | int HandShake = conveyorLine.Communicator.Read<ushort>(HandShakeprodto.DeviceProAddress); |
| | | WriteLog.Write_Log("å
¥åºåºå£ç¶æä¿¡æ¯", "å
¥åºåºå£ç¶æä¿¡æ¯", $"åºå£æ¯ã{SourceAddress}ãï¼ç³è¯·ç¶æå°åï¼ã{HandShakeprodto.DeviceProAddress}ã,读åçæ°æ®ï¼ã{HandShake}ã\n" + |
| | | $"åºå£æ¯å¦æè´§ç¶æå°åï¼ã{deviceProDTO.DeviceProAddress}ãï¼è¯»åçæ°æ®ã{StationNum}ã"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine("读åç«å°ä¿¡æ¯é误ï¼" + ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡å®ä½è½¬æ¢æå½ä»¤Model |
| | |
| | | { |
| | | StackerCraneTaskCommand stackerCraneTaskCommand = new StackerCraneTaskCommand(); |
| | | |
| | | |
| | | stackerCraneTaskCommand.Barcode = task.PalletCode; |
| | | stackerCraneTaskCommand.TaskNum = task.TaskNum; |
| | | stackerCraneTaskCommand.WorkType = 1; |
| | | stackerCraneTaskCommand.TrayType = 0; |
| | | if (task.Roadway == "B" || task.Roadway == "C") |
| | | { |
| | | //夿 task.PalletCode æ¯ä¸æ¯ä¸ä¸ªææç GUID |
| | | stackerCraneTaskCommand.Barcode = stackerCraneTaskCommand.Barcode = Guid.TryParse(task.PalletCode, out var guid) ? guid.ToString("N")[0..6] : task.PalletCode; |
| | | } |
| | | else if (task.Roadway == "G" ) |
| | | { |
| | | if (Guid.TryParse(task.PalletCode, out var palletGuid)) |
| | | { |
| | | stackerCraneTaskCommand.Barcode = palletGuid.ToString("N")[0..6]; |
| | | |
| | | // æ åGUIDå°±æ¯36ä½ï¼æä»¥ç´æ¥å¤æé¿åº¦å³å¯ |
| | | stackerCraneTaskCommand.TrayType = (short)(task.PalletCode.Length == 36 ? 1 : 2); |
| | | } |
| | | else |
| | | { |
| | | stackerCraneTaskCommand.Barcode = task.PalletCode; |
| | | stackerCraneTaskCommand.TrayType = 2; |
| | | } |
| | | } |
| | | |
| | | if (task.TaskType == (int)TaskTypeEnum.Inbound)//夿æ¯å¦æ¯å
¥åºä»»å¡ |
| | | { |
| | | //è·åç«å°ç¼å· |
| | | Dt_PlatformStation dt_Platform=_DtPlatformStationService.getStatiomInfo(task.SourceAddress); |
| | | |
| | | Dt_PlatformStation dt_Platform = _DtPlatformStationService.getStatiomInfo(task.SourceAddress); |
| | | string[] targetCodest = dt_Platform.Station_storey.Split("-"); |
| | | if (targetCodest.Length == 3) |
| | | { |
| | |
| | | string EndRow = EndCodest[0].Substring(1); |
| | | string SCEndRow = LaneModification(task.Roadway, int.Parse(EndRow)); |
| | | |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(SCEndRow ); |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(SCEndRow); |
| | | stackerCraneTaskCommand.EndColumn = Convert.ToInt16(EndCodest[1]); |
| | | stackerCraneTaskCommand.EndLayer = Convert.ToInt16(EndCodest[2]); |
| | | } |
| | |
| | | if (EndCodest.Length == 3) |
| | | { |
| | | string EndRow = EndCodest[0].Substring(1); |
| | | string SCEnRow=LaneModification(task.Roadway,int.Parse(EndRow)); |
| | | string SCEnRow = LaneModification(task.Roadway, int.Parse(EndRow)); |
| | | |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(SCEnRow); |
| | | stackerCraneTaskCommand.EndColumn = (short)(Convert.ToInt16(EndCodest[1]) + 1); |
| | |
| | | } |
| | | else |
| | | { |
| | | |
| | | |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"ç§»åºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | return stackerCraneTaskCommand; |
| | | } |
| | | |
| | | public string LaneModification(string Roadway,int SCRow) |
| | | { |
| | | if (Roadway == "F") |
| | | if (Roadway == "G") |
| | | { |
| | | return SCRow == 1 ? "3" : "4"; |
| | | }else if(Roadway == "C") |
| | |
| | | return SCRow.ToString(); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// çæµGåºãCåºåºåºæ¾è´§æ¶å±è½å
æ
|
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="stackerCraneWorkStatusDes"></param> |
| | | public void UpdateHandShake(int taskNum, string stackerCraneWorkStatusDes) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task? dtTask = _taskRepository.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (dtTask == null) return; |
| | | |
| | | string[] targetAddresses = { "G03", "G04", "C02", "C01" }; |
| | | if (dtTask.TaskType != 100 || !targetAddresses.Contains(dtTask.TargetAddress)) |
| | | return; |
| | | |
| | | short writeValue = stackerCraneWorkStatusDes switch |
| | | { |
| | | "æ¾è´§ä¸" => 1, |
| | | "ä»»å¡å®æ" => 0, |
| | | _ => -1 |
| | | }; |
| | | |
| | | if (writeValue == -1) return; |
| | | |
| | | string deviceCode = dtTask.CurrentAddress.StartsWith("C") ? "1004" : "1003"; |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == deviceCode); |
| | | if (device == null) return; |
| | | |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | DeviceProDTO? handShake = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == dtTask.TargetAddress && x.DeviceProParamName == "HandShake"); |
| | | if (handShake == null) return; |
| | | |
| | | conveyorLine.Communicator.Write<short>(handShake.DeviceProAddress, writeValue); |
| | | } |
| | | catch |
| | | { |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | } |