huanghongfeng
5 天以前 23cdbe08ee002d12c6d2a9034cc265fea0270a88
´úÂë¹ÜÀí/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SpeStackerCraneJob/SpeStackerCraneJob.cs
@@ -67,17 +67,18 @@
                    GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
                    //读取设备完成信息
                    if (getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Completed && getStackerObject.CurrentRgvtaskid!=0)
                    if (getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Completed && getStackerObject.CurrentRgvtaskid != 0)
                    {
                        _taskService.UpdateTaskStatus(getStackerObject.CurrentRgvtaskid);
                    }
                    if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
                        getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
                    {
                        //下发RGV任务之前,先读取一下安全门状态
@@ -126,7 +127,7 @@
            {
                (int)TaskInStatusEnum.RGV_InNew => task,
                (int)TaskInStatusEnum.RGV_InPickupFinish => HandlePickupFinish(task),
                (int)TaskInStatusEnum.RGV_InReleaseFinish => task,  //需要判断子车是内侧区还是外侧取货(待完成)
                (int)TaskInStatusEnum.RGV_InReleaseFinish => HandInneRouterSides(task),
                (int)TaskInStatusEnum.RGV_InZicheFinish => HandleZicheFinish(task),
                (int)TaskInStatusEnum.RGV_InZicheReleaseFinish => HandleZicheReleaseFinish(task),
                (int)TaskInStatusEnum.RGV_InZichemoveFinish => HandleZicheMoveFinish(task),
@@ -150,6 +151,60 @@
        }
        #region å…¥åº“方法
        private Dt_Task? HandInneRouterSides(Dt_Task task)
        {
            // éªŒè¯è¾“å…¥
            if (task == null) throw new ArgumentNullException(nameof(task));
            if (string.IsNullOrEmpty(task.CurrentAddress)) return null;
            // èŽ·å–å½“å‰ç«™å°ä¿¡æ¯
            AGVStation currentStation = _agvStationService.GetAllStationByDeviceCode(int.Parse(task.CurrentAddress));
            if (currentStation == null) return null;
            // åªå¤„理特定类型的站台
            if (currentStation.Station_material != (int)AgvStationEnum.HCJAisleplatform)
                return task;
            // èŽ·å–å­è½¦ä½ç½®
            int zicheAddress = GetZichelocation(task, task.CurrentAddress);
            if (zicheAddress == 0) return null;
            AGVStation zicheStation = _agvStationService.GetAllStationByDeviceCode(zicheAddress);
            if (zicheStation == null) return null;
            // æ ¹æ®å­è½¦ä½ç½®å¤„理不同情况
            switch (zicheStation.Station_material)
            {
                case (int)AgvStationEnum.Aisleplatform_Outside:
                    // å­è½¦åœ¨å¤–ä¾§ - ç›´æŽ¥è¿”回任务
                    return task;
                case (int)AgvStationEnum.Aisleplatform_Medial:
                    // å­è½¦åœ¨å†…ä¾§ - æ£€æŸ¥æ¯è½¦ä½ç½®
                    return HandleMedialCase(task, currentStation, zicheStation);
                default:
                    // æœªçŸ¥çš„子车位置状态
                    return null;
            }
        }
        private Dt_Task? HandleMedialCase(Dt_Task task, AGVStation currentStation, AGVStation zicheStation)
        {
            int motherCarAddress = GetMothercarlocation(task.TaskNum, currentStation.MotherCarDeviceCode);
            if (motherCarAddress == 0) return null;
            // å¦‚果母车不在预期位置,下发移动任务
            if (motherCarAddress != int.Parse(currentStation.MotherCarDeviceCode))
            {
                RGVMovetask(zicheStation.Motherinlaw, currentStation.ChildPosiDeviceCode, task.TaskId);
                return null; // æ¯è½¦éœ€è¦ç§»åŠ¨ï¼Œæš‚ä¸è¿”å›žä»»åŠ¡
            }
            // æ¯è½¦å·²åœ¨æ­£ç¡®ä½ç½®
            return task;
        }
        private Dt_Task? HandlePickupFinish(Dt_Task task)
        {
            try
@@ -203,7 +258,7 @@
            }
            else if (aGVStation.Station_Area == 3)  //当前地址为HCJ站台,且AGV任务为取货
            {
                return task;    //去取货,需要判断子车当前位子,(后续优化)
                return task;    //去取货位,需要判断子车当前位子,(后续优化)
            }
            return null;
@@ -226,13 +281,13 @@
        private bool MotherCarMoves(Dt_Task _Task, AGVStation aGVStation)
        {
            int mcadder = GetMothercarlocation(_Task.TaskNum, aGVStation.Motherinlaw);      //获取到母车外侧位置
            if(mcadder != 0)
            if (mcadder != 0)
            {
                if (mcadder == int.Parse(_Task.CurrentAddress))
                {
                    return true;
                }
                 RGVMovetask(_Task.CurrentAddress, aGVStation.ChildPosiDeviceCode,_Task.TaskId);
                RGVMovetask(_Task.CurrentAddress, aGVStation.ChildPosiDeviceCode, _Task.TaskId);
            }
            return false;
        }
@@ -243,7 +298,7 @@
        /// <param name="RGVAdders">目标地址</param>
        /// <param name="ChildPosiDeviceCode">设备编号</param>
        /// <returns></returns>
        private bool RGVMovetask(string RGVAdders,string ChildPosiDeviceCode,int taskid)
        private bool RGVMovetask(string RGVAdders, string ChildPosiDeviceCode, int taskid)
        {
            RgvCraneTaskCommand standardCommands = ConvertMotherCarTaskCommand(RGVAdders);
            bool sendFlag = SendCommand2(standardCommands, ChildPosiDeviceCode);
@@ -288,14 +343,14 @@
            }
            return false;
        }
        private bool HCJMotherCarMovesinside(Dt_Task _Task, AGVStation aGVStation)
        private bool HCJMotherCarMovesinside(Dt_Task _Task, AGVStation aGVStation)
        {
            //获取外侧母车位置
            int mcadder = GetMothercarlocation(_Task.TaskNum, aGVStation.MotherCarDeviceCode);
            //获取内侧母车位置
            int ncadder = GetMothercarlocation(_Task.TaskNum, aGVStation.MotherCardeputy);
            int ncadder = GetMothercarlocation(_Task.TaskNum, aGVStation.MotherCardeputy);
            if (mcadder != int.Parse(aGVStation.MotherCarDeviceCode) && ncadder != int.Parse(aGVStation.MotherCardeputy))
            if (mcadder != int.Parse(aGVStation.MotherCarDeviceCode) && ncadder != int.Parse(aGVStation.MotherCardeputy))
            {
                return true;
            }
@@ -319,7 +374,7 @@
            return false;
        }
        //判断是否
        public bool GetMotherCarCurrentAdder(Dt_Task task)
@@ -358,7 +413,7 @@
            try
            {
                //利用入库站台地址获取母车plc
                AGVStation aGVStation =_agvStationService.GetMothercarCode(MotherCarDeviceCode);
                AGVStation aGVStation = _agvStationService.GetMothercarCode(MotherCarDeviceCode);
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == aGVStation.ChildPosiDeviceCode);
                CommonStackerCrane Commonstacker = (CommonStackerCrane)device;
                DeviceProDTO? deviceProDTO = GetDeviceProDTO(Commonstacker, aGVStation.ChildPosiDeviceCode, "RGVCurrentlocation");
@@ -461,7 +516,7 @@
        /// <returns></returns>
        public DeviceProDTO? GetDeviceProDTO(CommonStackerCrane Commonstacker, string SCAddress, string Interactivet)
        {
            return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet && x.DeviceProParamType== "ReadDeviceCommand");
            return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet && x.DeviceProParamType == "ReadDeviceCommand");
        }
        /// <summary>
        /// æ ¹åœ°å€è¯»å–输送线信息
@@ -483,7 +538,7 @@
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceCode);
                CommonStackerCrane Commonstacker = (CommonStackerCrane)device;
                DeviceProDTO? deviceProDTO =  GetDeviceProDTO(Commonstacker, DeviceCode, "RGV_Rgvtaskstutas");
                DeviceProDTO? deviceProDTO = GetDeviceProDTO(Commonstacker, DeviceCode, "RGV_Rgvtaskstutas");
                int MCGStatus = GetLine(Commonstacker, deviceProDTO.DeviceProAddress);
                if (Commonstacker.IsConnected)
                {