1
HuBingJie
7 天以前 5da3a276b7847187a7c155ee069d3cd4c9e58074
´úÂë¹ÜÀí/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs
@@ -25,6 +25,7 @@
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using Quartz.Util;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -40,6 +41,7 @@
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm.Http;
using WIDESEA_Common.Log;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
@@ -54,13 +56,12 @@
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEA_Common.Log;
namespace WIDESEAWCS_TaskInfoService
{
    public class RgvoperainformService : ServiceBase<Dt_Task_hty, ITask_HtyRepository>, IRgvoperainformService
    {
        private readonly IAgvStationService _gvStationService;
        private readonly IAgvStationService _agvStationService;
        private readonly IServiceProvider _serviceProvider;
        private static bool _isMonitoring = false;
        private readonly IRepository<DeviceAlarmLog> _deviceAlarmLog;
@@ -79,7 +80,7 @@
        private CancellationTokenSource _safetyDoorCancellationTokenSource;
        public RgvoperainformService(ITask_HtyRepository BaseDal, IAgvStationService agvStationService, IServiceProvider serviceProvider, IRepository<DeviceAlarmLog> deviceAlarmLog) : base(BaseDal)
        {
            _gvStationService = agvStationService;
            _agvStationService = agvStationService;
            _serviceProvider = serviceProvider;
            _deviceAlarmLog = deviceAlarmLog;
        }
@@ -663,7 +664,7 @@
            int zhi = 1002011;
            try
            {
            switch (operationType)
            {
                case "cs":          //初始化
@@ -727,7 +728,9 @@
                        //RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationxj3.DeviceProAddress, 0);
                        return webResponse.OK();
                case "dz":          //地址
                    DeviceProParamName = "RGV_RGVTasklocationt";
                        if (!YiDongPD(Commonstacker, parameter)) { return webResponse.Error("目标地址被占用或条件不满足,禁止移动"); }
                        DeviceProParamName = "RGV_RGVTasklocationt";
                    DeviceProParamType = "DeviceCommand";
                    zhi = parameter;
                        //获取实例
@@ -780,6 +783,657 @@
                return webResponse.Error("设备操作失败");
            }
        }
    /// <summary>
    /// 1、判断子车区域
    /// 2、判断子车当前位置
    /// 3、判断子车要去的位置
    /// 4、根据子车要去的为获取母车位置
    ///
    /// </summary>
    /// <param name="device">要移动的设备</param>
    /// <param name="parameter">要去的目标地址</param>
    /// <returns></returns>
        private bool YiDongPD(SpeStackerCrane Commonstacker, int parameter)
        {
            //入库设备
            List<string> InDevices = new List<string> {  "RGV104", "RGV107" };
            //出库设备
            List<string>  OutDevices = new List<string> {"RGV116", "RGV111"};
            Dictionary<int, string> HCJ = new Dictionary<int, string>
        {
            { 1061, "HCJ106" },
            { 1021, "HCJ102" },
            { 1131, "HCJ113" },
            { 1171, "HCJ117" },
        };
            AGVStation RGVTaskdevice = _agvStationService.Corridorequipment(Commonstacker.DeviceCode);   //根据设备获取到内容
            //根据子车获取到母车设备
            // æ ¹æ®å­è½¦èŽ·å–åˆ°æ¯è½¦è®¾å¤‡
            AGVStation Mu1 = _agvStationService.GetMothervehicle(RGVTaskdevice.MotherCarDeviceCode);
            AGVStation Mu2 = _agvStationService.GetMothervehicle(RGVTaskdevice.MotherCardeputy);
            // èŽ·å–å­è½¦ä½ç½®
            int zhicheWZ = GetzicheWZ(Commonstacker, Commonstacker.DeviceCode);
            // ç»Ÿä¸€ç›®æ ‡å ç”¨æ£€æŸ¥ï¼ˆæ‰«æå…¶å®ƒ RGV æ˜¯å¦åœ¨åŒä¸€ç›®æ ‡åœ°å€ï¼‰
            bool IsAddressOccupied(int addr)
            {
                var allCodes = InDevices.Concat(OutDevices).Where(code => code != Commonstacker.DeviceCode).ToList();
                foreach (var code in allCodes)
                {
                    var dev = Storage.Devices.FirstOrDefault(x => x.DeviceCode == code) as SpeStackerCrane;
                    if (dev == null) continue;
                    try
                    {
                        DeviceProDTO? locDto = RgvOperationService.GetRGVDeviceProDTO(dev, code, "RGVCurrentlocation", "RGVCurrentlocation");
                        if (locDto == null) continue;
                        int loc = RgvOperationService.GetLine(dev, locDto.DeviceProAddress);
                        if (loc == addr) return true; // ç›®æ ‡è¢«å ç”¨
                    }
                    catch
                    {
                        // è¯»å–异常不当作占用,避免误拒
                    }
                }
                return false;
            }
            // ç›®æ ‡è¢«å…¶ä»– RGV å ç”¨åˆ™ç¦æ­¢
            if (IsAddressOccupied(parameter)) return false;
            if (RGVTaskdevice.Station_Area == 6) // å¤–ä¾§
            {
                if (zhicheWZ == RGVTaskdevice.WaitmomentOne) // ç­‰å¾…点1
                {
                    // åˆ¤æ–­å¤–侧小车是否在 HCJ ä¸Š
                    var zichestation = _agvStationService.OutGetZicheDeepHCJ(RGVTaskdevice.HCJStorageaddress);
                    int waiziche = GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
                    //判断传进来设备是否是入库
                    if (InDevices.Contains(Commonstacker.DeviceCode))
                    {
                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1021) && waiziche != zichestation.HCJStorageaddress))
                        {
                            return false;
                        }
                    }
                    else
                    {
                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1171) && waiziche != zichestation.HCJStorageaddress))
                        {
                            return false;
                        }
                    }
                    if (parameter == Mu1.ZicheMotherinlaw) //母1
                    {
                        int taraddress = parameter;
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode))//判断是否有货
                        {
                            if (mu1 == Mu1.ZicheMotherinlaw && mu1 != Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else if (parameter == Mu2.ZicheMotherinlaw) // æ¯2
                    {
                        int taraddress = parameter;
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//判断是否有货
                        {
                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.ZicheMotherinlaw && mu2 != Mu2.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else if (parameter == RGVTaskdevice.HCJStorageaddress)
                    {
                        string hcj = HCJ[RGVTaskdevice.HCJStorageaddress];
                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu2.ChildPosiDeviceCode) && Mucheywhaddres(hcj))//判断是否有货
                        {
                            if (mu2 != Mu2.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && !IsAddressOccupied(Mu2.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }else if(parameter == 1021 || parameter == 1171)
                    {
                        if (RGVTaskdevice.ChildPosiDeviceCode == "RGV116" && Mucheywhaddres("HCJ102"))
                        {
                            return true;
                        }
                        string hcj = HCJ[parameter];
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(hcj))//判断是否有货
                        {
                            if (mu1 != Mu1.ZicheMotherinlaw && mu1 == Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else
                    {
                        int taraddress = parameter;
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//判断是否有货
                        {
                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
                else if (zhicheWZ == RGVTaskdevice.WaitmomentTwo) // ç­‰å¾…点2
                {
                    // åˆ¤æ–­å¤–侧小车是否在 HCJ ä¸Š
                    var zichestation = _agvStationService.OutGetZicheDeepHCJ(RGVTaskdevice.HCJStorageaddress);
                    int waiziche = GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
                    //判断传进来设备是否是入库
                    if (InDevices.Contains(Commonstacker.DeviceCode))
                    {
                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1021) && waiziche != zichestation.HCJStorageaddress))
                        {
                            return false;
                        }
                    }
                    else
                    {
                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1171) && waiziche != zichestation.HCJStorageaddress))
                        {
                            return false;
                        }
                    }
                    if (parameter == Mu1.ZicheMotherinlaw)
                    {
                        int taraddress = parameter;
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode))//判断是否有货
                        {
                            if (mu1 == Mu1.ZicheMotherinlaw && mu1 != Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else if (parameter == Mu2.ZicheMotherinlaw)
                    {
                        int taraddress = parameter;
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//判断是否有货
                        {
                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else if (parameter == RGVTaskdevice.HCJStorageaddress)
                    {
                        string hcj = HCJ[RGVTaskdevice.HCJStorageaddress];
                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu2.ChildPosiDeviceCode) && Mucheywhaddres(hcj))//判断是否有货
                        {
                            if (mu2 != Mu2.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && !IsAddressOccupied(Mu2.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else if (parameter == 1021 || parameter == 1171)
                    {
                        string hcj = HCJ[parameter];
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode) && Mucheywhaddres(hcj))//判断是否有货
                        {
                            if (mu1 != Mu1.ZicheMotherinlaw && mu1 == Mu1.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else
                    {
                        int taraddress = parameter;
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//判断是否有货
                        {
                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
            else if (RGVTaskdevice.Station_Area == 5) // å†…ä¾§
            {
                if (zhicheWZ == RGVTaskdevice.WaitmomentOne) // ç­‰å¾…点1
                {
                    // åˆ¤æ–­å¤–侧小车是否在 HCJ ä¸Š
                    var zichestation = _agvStationService.OutGetZicheDeepHCJ(RGVTaskdevice.HCJStorageaddress);
                    int waiziche = GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
                    //判断传进来设备是否是入库
                    if (InDevices.Contains(Commonstacker.DeviceCode))
                    {
                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1021) && waiziche != zichestation.HCJStorageaddress))
                        {
                            return false;
                        }
                    }
                    else
                    {
                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1171) && waiziche != zichestation.HCJStorageaddress))
                        {
                            return false;
                        }
                    }
                    if (parameter == Mu1.ZicheMotherinlaw) //母1
                    {
                        int taraddress = parameter;
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode))//判断是否有货
                        {
                            if (mu1 == Mu1.ZicheMotherinlaw && mu1 != Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else if (parameter == Mu2.ZicheMotherinlaw) // æ¯2
                    {
                        int taraddress = parameter;
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//判断是否有货
                        {
                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }else if (parameter == RGVTaskdevice.HCJStorageaddress)
                    {
                        string hcj = HCJ[RGVTaskdevice.HCJStorageaddress];
                        if (Mucheywhaddres(hcj))
                        {
                            return true;
                        }
                    }
                    else
                    {
                        int taraddress = parameter;
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//判断是否有货
                        {
                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
                else if (zhicheWZ == RGVTaskdevice.WaitmomentTwo) // ç­‰å¾…点2
                {
                    // åˆ¤æ–­å¤–侧小车是否在 HCJ ä¸Š
                    var zichestation = _agvStationService.OutGetZicheDeepHCJ(RGVTaskdevice.HCJStorageaddress);
                    int waiziche = GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
                    //判断传进来设备是否是入库
                    if (InDevices.Contains(Commonstacker.DeviceCode))
                    {
                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1021) && waiziche != zichestation.HCJStorageaddress))
                        {
                            return false;
                        }
                    }
                    else
                    {
                        if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1171) && waiziche != zichestation.HCJStorageaddress))
                        {
                            return false;
                        }
                    }
                    if (parameter == Mu1.ZicheMotherinlaw)
                    {
                        int taraddress = parameter;
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode))//判断是否有货
                        {
                            if (mu1 == Mu1.ZicheMotherinlaw && mu1 != Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else if (parameter == Mu2.ZicheMotherinlaw)
                    {
                        int taraddress = parameter;
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//判断是否有货
                        {
                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else if (parameter == RGVTaskdevice.HCJStorageaddress)
                    {
                        string hcj = HCJ[RGVTaskdevice.HCJStorageaddress];
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode)&&Mucheywhaddres(hcj))//判断是否有货
                        {
                            if (mu1 != Mu1.ZicheMotherinlaw && mu1 == Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else
                    {
                        int taraddress = parameter;
                        int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
                        int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
                        if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//判断是否有货
                        {
                            if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
            // é»˜è®¤ï¼šæœªè¢«æ‹¦æˆªä¸”目标未占用 -> æ”¾è¡Œ
            return true;
        }
        /// <summary>
        /// ä¼ å…¥è®¾å¤‡ï¼Œè¿”回当前设备信息
        /// </summary>
        /// <param name="ChildPosiDeviceCode">设备</param>
        /// <returns></returns>
        public static int GetEquipmentInformation(string ChildPosiDeviceCode)
        {
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
            if (speStackerCrane == null)
            {
                Console.WriteLine($"读取到设备为空,设备编号:{ChildPosiDeviceCode},003");
                return 0;
            }
            DeviceProDTO? deviceProDTOGZMS = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RgvCraneAutoStatus" && x.DeviceProParamType == "RgvCraneAutoStatus");
            int GZMS = RGVGetLine(speStackerCrane, deviceProDTOGZMS.DeviceProAddress);
            DeviceProDTO? deviceProDTORWZT = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGV_Rgvtaskstutas" && x.DeviceProParamType == "RGV_Rgvtaskstutas");
            int RWZT = RGVGetLine(speStackerCrane, deviceProDTORWZT.DeviceProAddress);
            DeviceProDTO? deviceProDTOBJGC = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGVStepprocess" && x.DeviceProParamType == "RGVStepprocess");
            int BJGC = RGVGetLine(speStackerCrane, deviceProDTOBJGC.DeviceProAddress);
            DeviceProDTO? deviceProDTOWZ = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGVCurrentlocation" && x.DeviceProParamType == "RGVCurrentlocation");
            int WZ = RGVGetLine(speStackerCrane, deviceProDTOWZ.DeviceProAddress);
            if (GZMS == 1 && RWZT == 0 && BJGC == 0)
            {
                return WZ;
            }
            else
            {
                return 0;
            }
        }
        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 = RGVGetLine(Commonstacker, deviceProDTO.DeviceProAddress);
            if (MCGStatus == (int)RgvEquipmentStatus.NoCargo)
            {
                return true;
            }
            return false;
        }
        /// <summary>
        /// RGV设备状态
        /// </summary>
        public enum RgvEquipmentStatus
        {
            /// <summary>
            /// æ— è´§
            /// </summary>
            [Description("无货")]
            NoCargo,
            /// <summary>
            /// æœ‰è´§
            /// </summary>
            [Description("有货")]
            HasCargo,
            /// <summary>
            /// æœªçŸ¥
            /// </summary>
            [Description("未知")]
            Unkonw = 6
        }
        /// <summary>
        /// ä¼ å…¥è®¾å¤‡ï¼ŒèŽ·å–å½“å‰ä½ç½®ä½ç½®
        /// </summary>
        /// <param name="ChildPosiDeviceCode">设备</param>
        /// <returns></returns>
        public static int GetEquipmentlocation(string ChildPosiDeviceCode)
        {
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
            if (speStackerCrane == null) return 0;
            DeviceProDTO? deviceProDTO = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGVCurrentlocation" && x.DeviceProParamType == "RGVCurrentlocation");
            int MCGStatus = RGVGetLine(speStackerCrane, deviceProDTO.DeviceProAddress);
            return MCGStatus;
        }
        public static int RGVGetLine(SpeStackerCrane Commonstacker, string DeviceProDataBlock)
        {
            return Commonstacker.Communicator.Read<short>(DeviceProDataBlock);
        }
        /// <summary>
        /// èŽ·å–åˆ°å­è½¦ä½ç½®
        /// </summary>
        /// <param name="commonstacker"></param>
        /// <param name="deviceCode"></param>
        /// <returns></returns>
        private int GetzicheWZ(SpeStackerCrane commonstacker, string deviceCode)
        {
            DeviceProDTO? RGVCurrentlocation = RgvOperationService.GetRGVDeviceProDTO(commonstacker, commonstacker.DeviceCode, "RGVCurrentlocation", "RGVCurrentlocation");
            return RgvOperationService.GetLine(commonstacker, RGVCurrentlocation.DeviceProAddress);
        }
@@ -935,40 +1589,48 @@
        private string HandleExternalRGVAlarm(int alarmCode)
        {
            var alarmMessages = new Dictionary<int, string>
            {
        {0, "无报警"},
        {1, "RGV小车急停被按下"},
        {2, "正转雷达报警"},
        {3, "反转雷达报警"},
        {4, "前进限位报警"},
        {5, "后退限位报警"},
        {6, ""},
        {7, "PLC摸块故障"},
        {8, "PLC扩展模块故障"},
        {9, "称重模块故障"},
        {10, "扫码定位故障"},
        {11, "RGV长时间空转故障"},
        {12, "目的地不等于实际位置故障"},
        {13, "与总控通讯故障"},
        {14, "前雷达屏蔽警告"},
        {15, "后雷达屏蔽警告"},
        {16, "行走变频器故障"},
        {17, "伸缩叉变频器故障"},
        {18, "液压单元过载保护故障"},
        {19, "液压上升超时报警"},
        {20, "液压下降超时报警"},
        {21, "伸缩叉伸出超时报警"},
        {22, "伸缩叉缩回超时报警"},
        {23, "外形检测报警"},
        {24, "称重超重报警"},
        {25, "货叉伸出极限限位报警"},
        {26, "货叉缩回极限限位报警"},
        {27, "取货时自身有货物报警"},
        {28, "放货时自身无货物报警"},
        {29, "货叉未回到初始位报警"},
        {30, "触发仅移动命令时货叉不在初始位报警"},
                {31, "货叉到达初始位但中位传感器未检测到报警"}
            };
{
    {0, "无报警"},
    {1, "RGV小车急停被按下"},
    {2, "正转雷达报警"},
    {3, "反转雷达报警"},
    {4, "前进限位报警"},
    {5, "后退限位报警"},
    {6, ""},
    {7, "PLC模块故障"},
    {8, "PLC扩展模块故障"},
    {9, "称重模块故障"},
    {10, "扫码定位故障"},
    {11, "RGV长时间空转故障"},
    {12, "目的地不等于实际位置故障"},
    {13, "与总控通讯故障"},
    {14, "前雷达屏蔽警告"},
    {15, "后雷达屏蔽警告"},
    {16, "行走变频器故障"},
    {17, "伸缩叉变频器故障"},
    {18, "液压单元过载保护故障"},
    {19, "液压上升超时报警"},
    {20, "液压下降超时报警"},
    {21, "伸缩叉伸出超时报警"},
    {22, "伸缩叉缩回超时报警"},
    {23, "外形检测报警"},
    {24, "称重超重报警"},
    {25, "货叉伸出极限限位报警"},
    {26, "货叉缩回极限限位报警"},
    {27, "取货时自身有货物报警"},
    {28, "放货时自身无货物报警"},
    {29, "货叉未回到初始位报警"},
    {30, "触发仅移动命令时货叉不在初始位报警"},
    {31, "货叉到达初始位但中位传感器未检测到报警"},
    {32, "行走轴没到位禁止货叉伸出"},
    {33, "取货异常报警"},
    {34, "放货异常报警"},
    {35, "外型检测-前超出报警"},
    {36, "外型检测-后超出报警"},
    {37, "外型检测-左超出报警"},
    {38, "外型检测-右超出报警"},
    {39, "外型检测-上超出报警"}
};
            return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "未知报警代码";
        }