1
huanghongfeng
2025-10-22 8d558cb173873004cd8a0d6c12f37865f03d7a4f
´úÂë¹ÜÀí/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SpeStackerCraneJob/GetDeviceAddress.cs
@@ -9,10 +9,11 @@
using WIDESEA_Common.Log;
using System.Xml.Linq;
using SixLabors.ImageSharp;
using WIDESEAWCS_QuartzJob.Service;
namespace WIDESEAWCS_Tasks.StackerCraneJob
{
    public class GetDeviceAddress
    {
@@ -25,9 +26,30 @@
        {
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
            GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
            return getStackerObject.RGVCurrentlocation;
            if (speStackerCrane == null) return 0;
            DeviceProDTO? deviceProDTO = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGVCurrentlocation" && x.DeviceProParamType == "RGVCurrentlocation");
            int MCGStatus = GetDeviceAddress.RGVGetLine(speStackerCrane, deviceProDTO.DeviceProAddress);
            return MCGStatus;
        }
        /// <summary>
        /// ä¼ å…¥è®¾å¤‡ï¼Œè¿”回设备信息
        /// </summary>
        /// <param name="ChildPosiDeviceCode">设备</param>
        /// <returns></returns>
        public static GetStackerObject GetChildDeviceCode(string ChildPosiDeviceCode)
        {
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
            if (speStackerCrane == null)
            {
                Console.WriteLine($"读取到设备为空,设备编号:{ChildPosiDeviceCode},002");
                return null;
            }
            GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
            return getStackerObject;
        }
        /// <summary>
        /// ä¼ å…¥è®¾å¤‡ï¼Œè¿”回当前设备信息
@@ -38,9 +60,14 @@
        {
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
            if (speStackerCrane == null)
            {
                Console.WriteLine($"读取到设备为空,设备编号:{ChildPosiDeviceCode},003");
                return 0;
            }
            GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
            if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
                        getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
                        getStackerObject.StaclerkJobJobStatusValue == RGV_Rgvtaskstutas.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
            {
                return getStackerObject.RGVCurrentlocation;
            }
@@ -60,9 +87,14 @@
        {
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
            if (speStackerCrane == null)
            {
                Console.WriteLine($"读取到设备为空,设备编号:{ChildPosiDeviceCode},004");
                return 0;
            }
            GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
            if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
                        getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction && getStackerObject.RgvCraneStatusValue == RgvEquipmentStatus.NoCargo)
                        getStackerObject.StaclerkJobJobStatusValue == RGV_Rgvtaskstutas.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction && getStackerObject.RgvCraneStatusValue == RgvEquipmentStatus.NoCargo)
            {
                return getStackerObject.RGVCurrentlocation;
            }
@@ -83,9 +115,14 @@
        {
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
            if (speStackerCrane == null)
            {
                Console.WriteLine($"读取到设备为空,设备编号:{ChildPosiDeviceCode},005");
                return false;
            }
            GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
            if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
                        getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
                        getStackerObject.StaclerkJobJobStatusValue == RGV_Rgvtaskstutas.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
            {
                return true;
            }
@@ -103,7 +140,7 @@
        /// <param name="SCAddress"></param>
        /// <param name="Interactivet"></param>
        /// <returns></returns>
        public static DeviceProDTO? GetDeviceProDTO(CommonStackerCrane Commonstacker, string SCAddress, string Interactivet)
        public static DeviceProDTO? GetDeviceProDTO(CommonConveyorLine Commonstacker, string SCAddress, string Interactivet)
        {
            return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet && x.DeviceProParamType == "ReadDeviceCommand");
        }
@@ -117,7 +154,7 @@
        /// <returns></returns>
        public static DeviceProDTO? GetRGVDeviceProDTO(SpeStackerCrane 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 == "RGV_Rgvtaskstutas");
        }
        /// <summary>
        /// è¯»å–设备信息
@@ -125,7 +162,7 @@
        /// <param name="conveyorLine"></param>
        /// <param name="DeviceProDataBlock"></param>
        /// <returns></returns>
        public static int GetLine(CommonStackerCrane Commonstacker, string DeviceProDataBlock)
        public static int GetLine(CommonConveyorLine Commonstacker, string DeviceProDataBlock)
        {
            return Commonstacker.Communicator.Read<short>(DeviceProDataBlock);
        }
@@ -154,9 +191,10 @@
        /// <param name="Platformnumber">站台编号</param>
        public static bool HCJIsstock(string Platformnumber)
        {
            return true;
            //获取需要区分是否去入库与去不合格载货台任务
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "HCJ2000");
            CommonStackerCrane Commonstacker = (CommonStackerCrane)device;
            CommonConveyorLine Commonstacker = (CommonConveyorLine)device;
            DeviceProDTO? deviceProDTO = GetDeviceProDTO(Commonstacker, Platformnumber.ToString(), "HCJ_GoodsStatus");
            int HCJGStatus = GetLine(Commonstacker, deviceProDTO.DeviceProAddress);
            if (HCJGStatus == 0)    //为无货
@@ -168,5 +206,76 @@
                return false;
            }
        }
        /// <summary>
        /// åˆ¤æ–­è®¾å¤‡æ˜¯å¦æœ‰è´§
        /// </summary>
        public static bool Mucheywhaddres(string DeviceCode)
        {
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceCode);
            SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
            DeviceProDTO? deviceProDTO = Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeviceCode && x.DeviceProParamName == "RgvEquipmentStatus" && x.DeviceProParamType == "RgvEquipmentStatus");
            int MCGStatus = GetDeviceAddress.RGVGetLine(Commonstacker, deviceProDTO.DeviceProAddress);
            if(MCGStatus== (int)RgvEquipmentStatus.NoCargo)
            {
                return true;
            }
            return false;
        }
        /// <summary>
        /// åˆ¤æ–­3个安全门状态
        /// </summary>
        public static bool AQMStatus(List<AGVStation> aGVStatList)
        {
            try
            {
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "HCJ2000");
                CommonConveyorLine Commonstacker = (CommonConveyorLine)device;
                foreach (var item in aGVStatList)
                {
                    DeviceProDTO? deviceProDTO = GetDeviceProDTO(Commonstacker, item.Station_code.ToString(), "HCJ_GoodsStatus");
                    int HCJGStatus = GetLine(Commonstacker, deviceProDTO.DeviceProAddress);
                    if (HCJGStatus != 0)    //为无货
                    {
                        return false;
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
                throw;
            }
        }
        public static List<string> StationareaList = new List<string>() { "RGV111", "RGV116", "RGV110", "RGV112", "RGV114", "RGV115" };
        public static bool OutbounMotherChildCartbool(string DeviceChildCode)
        {
            if (StationareaList.Contains(DeviceChildCode))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public static bool OutbounMotherChildCartbool2(string DeviceChildCode)
        {
            if (DeviceChildCode=="RGV104" || DeviceChildCode == "RGV107")
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}