| | |
| | | using AutoMapper; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using Quartz; |
| | | using StackExchange.Profiling.Internal; |
| | |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DeviceBase; |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | |
| | | try |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if ( conveyorLine != null ) |
| | | { |
| | | if(conveyorLine.DeviceCode == "1002") |
| | | { |
| | | RequestInbound(conveyorLine); //䏿¥¼C,Båºä¸å¡ |
| | | } |
| | | |
| | | |
| | | RequestInbound(conveyorLine); //æ£æµå
¥æå£ä¿¡æ¯ |
| | | RequestInNextAddress(conveyorLine); |
| | | |
| | | } |
| | | //RequestInNextAddress(conveyorLine); |
| | | |
| | | |
| | | } |
| | |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¾é线请æ±å
¥åºå°åªä¸ªå··é |
| | | /// </summary> |
| | | /// <param name="conveyorLine">è¾é线å®ä¾å¯¹è±¡</param> |
| | | /// <param name="command">读åç请æ±ä¿¡æ¯</param> |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void RequestInbound(CommonConveyorLine conveyorLine) |
| | | { |
| | | HandleEvent(conveyorLine, "PLC_WCS_B.03_EVENT", "PLC_WCS_B.03_PLC_LPN", "PLC_WCS_B.03_WCS_TO"); |
| | | HandleEvent(conveyorLine, "PLC_WCS_C.02_EVENT", "PLC_WCS_C.02_PLC_LPN", "PLC_WCS_C.02_WCS_TO"); |
| | | |
| | | |
| | | CheckForEmptyPallet(conveyorLine,"PLC_WCS_B.01_EVENT"); |
| | | CheckForEmptyPallet(conveyorLine,"PLC_WCS_C.01_EVENT"); |
| | | |
| | | // å¤ç B ç«å°äºä»¶ |
| | | ProcessConveyorEvent(conveyorLine, "PLC_WCS_B.01_EVENT", "PLC_WCS_B.01_PLC_LPN", "B1", "R01-003-027-001-01"); |
| | | |
| | | // å¤ç C ç«å°äºä»¶ |
| | | ProcessConveyorEvent(conveyorLine, "PLC_WCS_C.03_EVENT", "PLC_WCS_C.03_PLC_LPN", "C7", "R01-003-041-001-01"); |
| | | //1楼è¾éçº¿å¤æ |
| | | HandleEvent(conveyorLine, "PLC_WCS_B._03_PLC_EVENT", "PLC_WCS_B._03_PLC_LPN", "WCS_PLC_B._03_WCS_TO"); //夿巷é |
| | | HandleEvent(conveyorLine, "PLC_WCS_C._02_PLC_EVENT", "PLC_WCS_C._02_PLC_LPN", "WCS_PLC_C._02_WCS_TO"); //夿巷é |
| | | CheckForEmptyPallet(conveyorLine, "PLC_WCS_B._02_PLC_EVENT", "PLC_WCS_B._02_PLC_LPN", "PLC_WCS_B._02_PLC_PUT", "R02-002-027-001-01"); //夿æ¯å¦å空æåºåº |
| | | CheckForEmptyPallet(conveyorLine, "PLC_WCS_C._01_PLC_EVENT", "PLC_WCS_C._01_PLC_LPN", "PLC_WCS_C._01_PLC_PUT", "R01-002-041-001-01"); //夿æ¯å¦å空æåºåº |
| | | ProcessConveyorEvent(conveyorLine, "PLC_WCS_B._01_PLC_EVENT", "PLC_WCS_B._01_PLC_LPN", "R02-003-027-001-01", "WCS_PLC_B._03_WCS_TO");// å¤ç B ç«å°äºä»¶ //夿è¾é线å°è¾¾ä¿¡å· |
| | | ProcessConveyorEvent(conveyorLine, "PLC_WCS_C._03_PLC_EVENT", "PLC_WCS_C._03_PLC_LPN", "R01-003-041-001-01", "WCS_PLC_C._02_WCS_TO");// å¤ç C |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 夿åºåºç«å°æ¯å¦éè¦ç©ºæ |
| | | /// </summary> |
| | | /// <param name="conveyorLine">è¾é线å®ä¾å¯¹è±¡</param> |
| | | /// <param name="command">读åç请æ±ä¿¡æ¯</param> |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void ConveyorLineInFinish(CommonConveyorLine conveyorLine) |
| | | public void RequestInbound2(CommonConveyorLine conveyorLine) |
| | | { |
| | | |
| | | //顶楼楼è¾éçº¿å¤æ |
| | | HandleEvent(conveyorLine, "PLC_WCS_D._05_PLC_EVENT", "PLC_WCS_D._05_PLC_LPN", "WCS_PLC_D._05_WCS_TO"); //夿å
¥åºå··é |
| | | |
| | | ProcessConveyorEvent(conveyorLine, "PLC_WCS_D._01_PLC_EVENT", "PLC_WCS_D._01_PLC_LPN", "R02-003-027-011-01", "WCS_PLC_D._05_WCS_TO");// å¤ç 1å··é ç«å°äºä»¶å
¥ç©º |
| | | ProcessConveyorEvent(conveyorLine, "PLC_WCS_D._03_PLC_EVENT", "PLC_WCS_D._03_PLC_LPN", "R01-003-041-011-01", "WCS_PLC_D._05_WCS_TO");// å¤ç 2å··é ç«å°äºä»¶ å
¥ç©º |
| | | |
| | | CheckForEmptyPallet2(conveyorLine, "PLC_WCS_D._02_PLC_EVENT", "PLC_WCS_D._02_PLC_LPN", "PLC_WCS_D._02_PLC_PUT", "R02-002-027-011-01"); //åææåºåº è¯»åæ¡ç éåºåºåºåº |
| | | CheckForEmptyPallet2(conveyorLine, "PLC_WCS_D._04_PLC_EVENT", "PLC_WCS_D._04_PLC_LPN", "PLC_WCS_D._04_PLC_PUT", "R01-002-041-011-01"); //åææåºåº è¯»åæ¡ç éåºåºåºåº |
| | | //ConveyorLineInFinish(conveyorLine); //ç¨äºåå
¥è¾é线æ¡ç ä¿¡æ¯ï¼ææ¶æªç¨ |
| | | } |
| | | |
| | | public void RequestInbound3(CommonConveyorLine conveyorLine) |
| | | { |
| | | ProcessConveyorEvent(conveyorLine, "PLC_WCS_A._02_PLC_EVENT", "PLC_WCS_A._02_PLC_LPN", "R02-003-043-011-01", "WCS_PLC_A._02_WCS_TO");// å¤ç A21 ç«å°äºä»¶å
¥åº |
| | | |
| | | ProcessConveyorEvent(conveyorLine, "PLC_WCS_A._03_PLC_EVENT", "PLC_WCS_A._03_PLC_LPN", "R01-003-042-011-01", "WCS_PLC_A._03_WCS_TO");// å¤ç A22 ç«å°äºä»¶ å
¥æ |
| | | |
| | | ConveyorLineInFinish(conveyorLine,"R01-002-044-001-01"); //ç¨äºåå
¥è¾é线æ¡ç ä¿¡æ¯ï¼ç¨äºåºåº |
| | | } |
| | | |
| | | public void ConveyorLineInFinish(CommonConveyorLine conveyorLine,string SCAddress) |
| | | { |
| | | DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine,SCAddress, "R_StackerCraneLowered"); //读åè¾é线 âå åæºæ¾ä¸â ä¿¡å· |
| | | if ( deviceProDTO2 != null ) |
| | | { |
| | | byte strsd = GetLine(conveyorLine, deviceProDTO2.DeviceChildCode); |
| | | if (strsd == 1) |
| | | { |
| | | Dt_Task task = _taskService.IngStackerCraneTask2(conveyorLine.DeviceCode); |
| | | if(task != null && task.TaskType==(int)TaskOutboundTypeEnum.Outbound) |
| | | { |
| | | byte PalletType = 2; |
| | | if (task.TargetAddress == "R02-002-027-001-01" || task.TargetAddress == "R01-002-041-001-01") |
| | | { |
| | | PalletType = 1; |
| | | } |
| | | DeviceProDTO? deviceProDTO3 = GetDeviceProDTO(conveyorLine, SCAddress, "W_PalletBarcode"); //åå
¥æ¡ç |
| | | DeviceProDTO? deviceProDTO4 = GetDeviceProDTO(conveyorLine, SCAddress, "W_PalletLayers"); //屿° |
| | | DeviceProDTO? deviceProDTO5 = GetDeviceProDTO(conveyorLine, SCAddress, "W_PalletType"); //ç±»å |
| | | DeviceProDTO? deviceProDTO6 = GetDeviceProDTO(conveyorLine, SCAddress, "W_Destination"); //ç±»å |
| | | if (deviceProDTO3 != null && deviceProDTO4 != null && deviceProDTO5 != null && deviceProDTO6 != null) |
| | | { |
| | | if (SetLinestring(conveyorLine, deviceProDTO3.DeviceProDataBlock, task.PalletCode) && SetLine(conveyorLine, deviceProDTO4.DeviceProDataBlock, (byte)task.PalletCodequantity) && SetLine(conveyorLine, deviceProDTO5.DeviceProDataBlock, PalletType) && SetLine(conveyorLine, deviceProDTO6.DeviceProDataBlock, (byte)task.PLCTo)) |
| | | { |
| | | |
| | | LogSignalStatus($"åå
¥æ¾è´§å®æä¿¡æ¯ï¼æçæ¡ç ï¼å±æ°ï¼ç±»åä¿¡æ¯æå", deviceProDTO2.DeviceChildCode); |
| | | |
| | | } |
| | | else |
| | | { |
| | | LogSignalStatus($"åå
¥æ¾è´§å®æä¿¡æ¯ï¼æçæ¡ç ï¼å±æ°ï¼ç±»åä¿¡æ¯å¤±è´¥", deviceProDTO2.DeviceChildCode); |
| | | |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogSignalStatus($"æªæ¾å°è¾é线å议信æ¯", task.TargetAddress); |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | //è·åè¾é线å®ä¾ |
| | | public DeviceProDTO? GetDeviceProDTO(CommonConveyorLine conveyorLine, string SCAddress, string Interactivet) |
| | | { |
| | | return conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ç¨äºå
¥åºå¤æå··é |
| | |
| | | /// <param name="writeTag"></param> |
| | | private void HandleEvent(CommonConveyorLine conveyorLine,string eventTag, string barcodeTag, string writeTag) |
| | | { |
| | | int events = conveyorLine.Communicator.Read<int>(eventTag); // 读åäºä»¶ |
| | | if (events == 1) |
| | | try |
| | | { |
| | | string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); // è¯»åæ¡ç |
| | | if ((_taskService.ToPlatform(barcode)).Status) |
| | | byte events = conveyorLine.Communicator.Read<byte>(eventTag); // 读åäºä»¶ |
| | | if (events == 1) |
| | | { |
| | | // åå
¥å»å1å·å åæº |
| | | bool result = conveyorLine.Communicator.Write(writeTag, 1); |
| | | if (result) |
| | | string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); // è¯»åæ¡ç |
| | | if(barcode != "1" || barcode != "0") |
| | | { |
| | | WriteLog.GetLog("PLCæ¥å¿").Write("åå
¥å»åï¼1", "å»å"); |
| | | if ((_taskService.ToPlatform(barcode)).Status) |
| | | { |
| | | // åå
¥å»å2å·å åæº |
| | | bool result = conveyorLine.Communicator.Write(writeTag, (byte)1); //åææå»å |
| | | if (result) |
| | | { |
| | | WriteLog.GetLog("PLCæ¥å¿").Write("åå
¥å»åï¼3", "å»å"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // åå
¥å»å2å·å åæº |
| | | bool result = conveyorLine.Communicator.Write(writeTag, 2); |
| | | if (result) |
| | | |
| | | |
| | | if (barcode == "1") |
| | | { |
| | | WriteLog.GetLog("PLCæ¥å¿").Write("åå
¥å»åï¼2", "å»å"); |
| | | // åå
¥å»å2å·å åæº |
| | | bool result = conveyorLine.Communicator.Write(writeTag, (byte)1); //空æå»å |
| | | if (result) |
| | | { |
| | | WriteLog.GetLog("PLCæ¥å¿").Write("空æå
¥åºï¼åå
¥å»åï¼1", "å»å"); |
| | | } |
| | | } |
| | | /*else |
| | | { |
| | | // åå
¥å»å1å·å åæº |
| | | bool result = conveyorLine.Communicator.Write(writeTag, (byte)1); |
| | | if (result) |
| | | { |
| | | WriteLog.GetLog("PLCæ¥å¿").Write("åå
¥å»åï¼2", "å»å"); |
| | | } |
| | | |
| | | WriteLog.GetLog("PLCæ¥å¿").Write("å
¥åºå¤±è´¥", "å
¥åºç»ç"); |
| | | }*/ |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | //ç¨äºå¤ææ¯å¦è¡¥ç©ºæ |
| | | private void CheckForEmptyPallet(CommonConveyorLine conveyorLine,string eventTag) |
| | | private void CheckForEmptyPallet(CommonConveyorLine conveyorLine,string eventTag, string barcodeTag,string plcput,string Loc) |
| | | { |
| | | int events = conveyorLine.Communicator.Read<int>(eventTag); // 读åäºä»¶ |
| | | if (events == 0) |
| | | |
| | | try |
| | | { |
| | | WriteLog.GetLog("PLCæ¥å¿").Write($"读åå°åºåºå£è¡¥ç©ºæä¿¡å·ï¼{events}", "éè¦ç©ºæ"); |
| | | // çæå åæºå空æä»»å¡ |
| | | Byte events = conveyorLine.Communicator.Read<Byte>(eventTag); // 读åäºä»¶ |
| | | if (events == 1) //1为空ï¼0为æ |
| | | { |
| | | string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); // è¯»åæ¡ç |
| | | if(barcode == "") |
| | | { |
| | | WriteLog.GetLog("PLCæ¥å¿åºåºæ¥å¿").Write($"读åå°åºåºå£è¡¥ç©ºæä¿¡å·ï¼{events}", "éè¦ç©ºæ"); |
| | | // çæå åæºå空æä»»å¡ |
| | | byte plcputts = conveyorLine.Communicator.Read<byte>(plcput); |
| | | if (plcputts != 1) |
| | | { |
| | | if ((_taskService.RequestWMSTask2("", Loc)).Status) |
| | | { |
| | | WriteLog.GetLog("PLCæ¥å¿åºåºæ¥å¿").Write($"å·²çæç©ºæåºåºä»»å¡ï¼{events}", "éè¦ç©ºæ"); |
| | | } |
| | | else |
| | | { |
| | | WriteLog.GetLog("PLCæ¥å¿åºåºæ¥å¿").Write($"æªçæç©ºæåºåºä»»å¡ï¼{events}", "éè¦ç©ºæ"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | //ç¨äºå¤æå
¥åºç«å° |
| | | private void ProcessConveyorEvent(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string stationId, string taskCode) |
| | | //ç¨äºå¤ææ¯å¦åºç©ºæ |
| | | private void CheckForEmptyPallet2(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string plcput, string Loc) |
| | | { |
| | | int eventStatus = conveyorLine.Communicator.Read<int>(eventTag); |
| | | if (eventStatus == 1) |
| | | Byte events = conveyorLine.Communicator.Read<Byte>(eventTag); // 读åäºä»¶ |
| | | if (events == 1) //1为空ï¼0为æ |
| | | { |
| | | string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); |
| | | if (barcode != null) |
| | | string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); // è¯»åæ¡ç |
| | | if (barcode != "1" || barcode != "0") |
| | | { |
| | | // æ¿åæçæ¡ç ç³è¯·å
¥åºä¿¡æ¯ |
| | | WebResponseContent content = _taskService.RequestWMSTask(barcode, taskCode); // ç³è¯·å
¥åºï¼çæå åæºä»»å¡ |
| | | if (content.Status) |
| | | WriteLog.GetLog("PLCæ¥å¿åºåºæ¥å¿").Write($"读åå°åææåºåºä¿¡æ¯ï¼æ¡ç ä¿¡æ¯ï¼{barcode}", "åææåºåº"); |
| | | |
| | | byte outCount = conveyorLine.Communicator.Read<byte>(plcput); |
| | | if ((_taskService.RequestWMSTask3(barcode, outCount,Loc)).Status) |
| | | { |
| | | WriteLog.GetLog("PLCå
¥åºç«å°æ¥å¿").Write($"ç³è¯·å
¥åºæåï¼ç«å°ç¼å·ä¸ºï¼{stationId}", "ç«å°ä¿¡æ¯"); |
| | | //åå
¥è¾é线æ¸
é¤ä¿¡æ¯ |
| | | WriteLog.GetLog("PLCæ¥å¿åºåºæ¥å¿").Write($"å·²çæåææåºåºä»»å¡ï¼æ¡ç ä¿¡æ¯ï¼{barcode}", "åææåºåº"); |
| | | } |
| | | else |
| | | { |
| | | WriteLog.GetLog("PLCå
¥åºç«å°æ¥å¿").Write($"ç³è¯·å
¥åºå¤±è´¥ï¼ç«å°ç¼å·ä¸ºï¼{stationId}", "ç«å°ä¿¡æ¯"); |
| | | WriteLog.GetLog("PLCæ¥å¿åºåºæ¥å¿").Write($"æªçæåææåºåºä»»å¡ï¼æ¡ç ä¿¡æ¯ï¼{barcode}", "åææåºåº"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | //ç¨äºå¤æå
¥åºç«å° |
| | | private void ProcessConveyorEvent(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string taskCode,string writeTag) |
| | | { |
| | | byte eventStatus = conveyorLine.Communicator.Read<byte>(eventTag); |
| | | if (eventStatus == 1) |
| | | { |
| | | WriteLog.GetLog("PLCå
¥åºç«å°æ¥å¿").Write($"读åå°è¾é线ç³è¯·å
¥åºä¿¡æ¯EVENT为ï¼{eventStatus}ï¼ç«å°ç¼å·ä¸ºï¼{taskCode}", "ç«å°ä¿¡æ¯"); |
| | | string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); |
| | | if(barcode == "1") |
| | | { |
| | | string currentTime = DateTime.Now.ToString("HHmmss"); |
| | | barcode = "KTP" + currentTime; |
| | | |
| | | } |
| | | if (barcode != null) |
| | | { |
| | | bool result = conveyorLine.Communicator.Write(writeTag, (byte)0); |
| | | if(taskCode== "R01-003-042-011-01") |
| | | { |
| | | if ((_taskService.ToPlatform(barcode)).Status) |
| | | { |
| | | WriteLog.GetLog("PLCå
¥åºç«å°æ¥å¿").Write($"ç»çæåï¼ç«å°ç¼å·ä¸ºï¼{taskCode}", "ç«å°ä¿¡æ¯"); |
| | | } |
| | | } |
| | | // æ¿åæçæ¡ç ç³è¯·å
¥åºä¿¡æ¯ |
| | | WebResponseContent content = _taskService.RequestWMSTask(barcode, taskCode); // ç³è¯·å
¥åºï¼çæå åæºä»»å¡ |
| | | if (content !=null) |
| | | { |
| | | if (content.Status) |
| | | { |
| | | WriteLog.GetLog("PLCå
¥åºç«å°æ¥å¿").Write($"ç³è¯·å
¥åºæåï¼ç«å°ç¼å·ä¸ºï¼{taskCode}", "ç«å°ä¿¡æ¯"); |
| | | } |
| | | else |
| | | { |
| | | WriteLog.GetLog("PLCå
¥åºç«å°æ¥å¿").Write($"ç³è¯·å
¥åºå¤±è´¥ï¼ç«å°ç¼å·ä¸ºï¼{taskCode}", "ç«å°ä¿¡æ¯"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WriteLog.GetLog("PLCå
¥åºç«å°æ¥å¿").Write($"读åå°è¾é线信æ¯ä¸ºç©ºï¼ç«å°ç¼å·ä¸ºï¼{stationId}", "ç«å°ä¿¡æ¯"); |
| | | WriteLog.GetLog("PLCå
¥åºç«å°æ¥å¿").Write($"读åå°è¾é线信æ¯ä¸ºç©ºï¼ç«å°ç¼å·ä¸ºï¼{taskCode}", "ç«å°ä¿¡æ¯"); |
| | | } |
| | | } |
| | | } |
| | | public bool SetLine(CommonConveyorLine conveyorLine, string DeviceProDataBlock, byte Pali) |
| | | { |
| | | return conveyorLine.Communicator.Write(DeviceProDataBlock, Pali); |
| | | } |
| | | public bool SetLinestring(CommonConveyorLine conveyorLine, string DeviceProDataBlock, string Pali) |
| | | { |
| | | return conveyorLine.Communicator.Write(DeviceProDataBlock, Pali); |
| | | } |
| | | |
| | | public byte GetLine(CommonConveyorLine conveyorLine, string DeviceProDataBlock) |
| | | { |
| | | return conveyorLine.Communicator.Read<byte>(DeviceProDataBlock); |
| | | } |
| | | private void LogSignalStatus(string message, string sourceAddress) |
| | | { |
| | | WriteLog.GetLog("å åæºä¸plc交äºä¿¡å·").Write($"ç«å°ç¼å·ï¼{sourceAddress},ä¿¡æ¯ï¼{message}", $"{sourceAddress}"); |
| | | } |
| | | } |
| | | } |