From 3ecd03b3a0a30a57153468beaed3199bfe906772 Mon Sep 17 00:00:00 2001 From: huanghongfeng <huanghongfeng@hnkhzn.com> Date: 星期一, 11 十一月 2024 16:58:37 +0800 Subject: [PATCH] 1 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs | 102 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 62 insertions(+), 40 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" index a3a1fea..5dc3c5f 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" @@ -36,6 +36,7 @@ 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; @@ -67,8 +68,11 @@ { CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); - RequestInbound(conveyorLine); //妫�娴嬪叆鏂欏彛淇℃伅 - RequestInNextAddress(conveyorLine); + if( conveyorLine != null ) + { + RequestInbound(conveyorLine); //鍒ゆ柇宸烽亾鍘诲摢涓贩閬� + } + //RequestInNextAddress(conveyorLine); } @@ -91,20 +95,16 @@ /// <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._01_PLC_EVENT"); //鍒ゆ柇鏄惁鍙栫┖鎵� + CheckForEmptyPallet(conveyorLine, "PLC_WCS_C._01_PLC_EVENT"); //鍒ゆ柇鏄惁鍙栫┖鎵� + ProcessConveyorEvent(conveyorLine, "PLC_WCS_B._01_PLC_EVENT", "PLC_WCS_B._01_PLC_LPN", "R02-003-027-001-01");// 澶勭悊 B 绔欏彴浜嬩欢 //鍒ゆ柇杈撻�佺嚎鍒拌揪淇″彿 + ProcessConveyorEvent(conveyorLine, "PLC_WCS_C._03_PLC_EVENT", "PLC_WCS_C._03_PLC_LPN", "R01-003-041-001-01");// 澶勭悊 C 绔欏彴浜嬩欢 //鍒ゆ柇杈撻�佺嚎鍒拌揪淇″彿 } + /// <summary> /// 鍒ゆ柇鍑哄簱绔欏彴鏄惁闇�瑕佺┖鎵� @@ -127,46 +127,65 @@ /// <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 ((_taskService.ToPlatform(barcode)).Status) { - WriteLog.GetLog("PLC鏃ュ織").Write("鍐欏叆鍘诲悜锛�1", "鍘诲悜"); + // 鍐欏叆鍘诲悜1鍙峰爢鍨涙満 + bool result = conveyorLine.Communicator.Write(writeTag, 1); + if (result) + { + WriteLog.GetLog("PLC鏃ュ織").Write("鍐欏叆鍘诲悜锛�1", "鍘诲悜"); + } } - } - else - { - // 鍐欏叆鍘诲悜2鍙峰爢鍨涙満 - bool result = conveyorLine.Communicator.Write(writeTag, 2); - if (result) + /*else { - WriteLog.GetLog("PLC鏃ュ織").Write("鍐欏叆鍘诲悜锛�2", "鍘诲悜"); - } + // 鍐欏叆鍘诲悜2鍙峰爢鍨涙満 + *//*bool result = conveyorLine.Communicator.Write(writeTag, 2); + if (result) + { + WriteLog.GetLog("PLC鏃ュ織").Write("鍐欏叆鍘诲悜锛�2", "鍘诲悜"); + }*//* + + WriteLog.GetLog("PLC鏃ュ織").Write("鍏ュ簱澶辫触", "鍏ュ簱缁勭洏"); + }*/ } + } + catch (Exception ex) + { + + throw; } } //鐢ㄤ簬鍒ゆ柇鏄惁琛ョ┖鎵� private void CheckForEmptyPallet(CommonConveyorLine conveyorLine,string eventTag) { - int events = conveyorLine.Communicator.Read<int>(eventTag); // 璇诲彇浜嬩欢 + + Byte events = conveyorLine.Communicator.Read<Byte>(eventTag); // 璇诲彇浜嬩欢 if (events == 0) { WriteLog.GetLog("PLC鏃ュ織").Write($"璇诲彇鍒板嚭搴撳彛琛ョ┖鎵樹俊鍙凤細{events}", "闇�瑕佺┖鎵�"); // 鐢熸垚鍫嗗灈鏈哄彇绌烘墭浠诲姟 + if ((_taskService.RequestWMSTask2(conveyorLine.DeviceCode)).Status) + { + WriteLog.GetLog("PLC鏃ュ織").Write($"宸茬敓鎴愮┖鎵樺嚭搴撲换鍔★細{events}", "闇�瑕佺┖鎵�"); + } + else + { + WriteLog.GetLog("PLC鏃ュ織").Write($"鏈敓鎴愮┖鎵樺嚭搴撲换鍔★細{events}", "闇�瑕佺┖鎵�"); + } } } //鐢ㄤ簬鍒ゆ柇鍏ュ簱绔欏彴 - private void ProcessConveyorEvent(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string stationId, string taskCode) + private void ProcessConveyorEvent(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string taskCode) { - int eventStatus = conveyorLine.Communicator.Read<int>(eventTag); + byte eventStatus = conveyorLine.Communicator.Read<byte>(eventTag); if (eventStatus == 1) { string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); @@ -174,18 +193,21 @@ { // 鎷垮彇鎵樼洏鏉$爜鐢宠鍏ュ簱淇℃伅 WebResponseContent content = _taskService.RequestWMSTask(barcode, taskCode); // 鐢宠鍏ュ簱锛岀敓鎴愬爢鍨涙満浠诲姟 - if (content.Status) + if (content !=null) { - WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"鐢宠鍏ュ簱鎴愬姛锛岀珯鍙扮紪鍙蜂负锛歿stationId}", "绔欏彴淇℃伅"); - } - else - { - WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"鐢宠鍏ュ簱澶辫触锛岀珯鍙扮紪鍙蜂负锛歿stationId}", "绔欏彴淇℃伅"); + 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}", "绔欏彴淇℃伅"); } } } -- Gitblit v1.9.3