1
huanghongfeng
2024-11-11 3ecd03b3a0a30a57153468beaed3199bfe906772
´úÂë¹ÜÀí/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}", "站台信息");
                }
            }
        }