1
HuBingJie
2025-12-05 28110912ca4803e5793f181517d7bf2d7a5ea2ad
´úÂë¹ÜÀí/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs
@@ -1,4 +1,4 @@
#region << ç‰ˆ æœ¬ æ³¨ é‡Š >>
#region << ç‰ˆ æœ¬ æ³¨ é‡Š >>
/*----------------------------------------------------------------
 * å‘½åç©ºé—´ï¼šWIDESEAWCS_TaskInfoService
 * åˆ›å»ºè€…:胡童庆
@@ -41,6 +41,7 @@
using System.Threading.Tasks;
using WIDESEA_Comm.Http;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_DTO.Enum;
@@ -53,6 +54,7 @@
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEA_Common.Log;
namespace WIDESEAWCS_TaskInfoService
{
@@ -61,40 +63,42 @@
        private readonly IAgvStationService _gvStationService;
        private readonly IServiceProvider _serviceProvider;
        private static bool _isMonitoring = false;
        private readonly IRepository<DeviceAlarmLog> _deviceAlarmLog;
        //private static CancellationTokenSource _cancellationTokenSource;
        // åœ¨ç±»çº§åˆ«æ·»åŠ ç‹¬ç«‹çš„ç›‘æŽ§çŠ¶æ€
        private bool _isOutboundMonitoring = false;
        private bool _isInboundMonitoring = false;
        private bool _isSafetyDoorMonitoring = false;
        private bool _isPlatformMonitoring = false;
        // åœ¨ç±»çš„字段区
        private CancellationTokenSource? _platformCancellationTokenSource;
        private CancellationTokenSource _outboundCancellationTokenSource;
        private CancellationTokenSource _inboundCancellationTokenSource;
        private CancellationTokenSource _safetyDoorCancellationTokenSource;
        public RgvoperainformService(ITask_HtyRepository BaseDal, IAgvStationService agvStationService, IServiceProvider serviceProvider) : base(BaseDal)
        public RgvoperainformService(ITask_HtyRepository BaseDal, IAgvStationService agvStationService, IServiceProvider serviceProvider, IRepository<DeviceAlarmLog> deviceAlarmLog) : base(BaseDal)
        {
            _gvStationService = agvStationService;
            _serviceProvider = serviceProvider;
            _deviceAlarmLog = deviceAlarmLog;
        }
        //=================================================读取设备信息==========================================================
        /// <summary>
        /// èŽ·å–è®¾å¤‡çŠ¶æ€ï¼ˆæ”¯æŒå‡ºåº“ã€å…¥åº“å’Œå®‰å…¨é—¨ç‹¬ç«‹ç›‘æŽ§ï¼‰
        /// èŽ·å–è®¾å¤‡çŠ¶æ€ï¼ˆæ”¯æŒå‡ºåº“ã€å…¥åº“ã€å®‰å…¨é—¨å’Œç«™å°ç‹¬ç«‹ç›‘æŽ§ï¼‰
        /// </summary>
        /// <param name="off">0:停止 1:启动 2:仅查询</param>
        /// <param name="monitorType">监控类型:outbound-出库 inbound-入库 safetydoor-安全门 all-全部</param>
        /// <param name="monitorType">监控类型:outbound-出库 inbound-入库 safetydoor-安全门 platform-站台 all-全部</param>
        /// <returns></returns>
        public WebResponseContent GetDeviceStatusDto(int off, string monitorType = "outbound")
        {
            bool isOutbound = monitorType == "outbound" || monitorType == "all";//出库
            bool isInbound = monitorType == "inbound" || monitorType == "all";//入库
            bool isSafetyDoor = monitorType == "safetydoor" || monitorType == "all";//安全门
            bool isPlatform = monitorType == "platform" || monitorType == "all";//站台
            if (off == 1)
            {
@@ -120,6 +124,13 @@
                    _ = Task.Run(async () => await StartDeviceMonitoring(_safetyDoorCancellationTokenSource.Token, "safetydoor"));
                }
                if (isPlatform && !_isPlatformMonitoring)
                {
                    _isPlatformMonitoring = true;
                    _platformCancellationTokenSource = new CancellationTokenSource();
                    _ = Task.Run(async () => await StartDeviceMonitoring(_platformCancellationTokenSource.Token, "platform"));
                }
                var immediateData = GetImmediateDeviceData(monitorType);
                string message = GetMonitorStatusMessage(monitorType);
                return WebResponseContent.Instance.OK($"设备状态监控已启动 - {message}", immediateData);
@@ -143,6 +154,12 @@
                {
                    _isSafetyDoorMonitoring = false;
                    _safetyDoorCancellationTokenSource?.Cancel();
                }
                if (isPlatform && _isPlatformMonitoring)
                {
                    _isPlatformMonitoring = false;
                    _platformCancellationTokenSource?.Cancel();
                }
                var finalData = GetImmediateDeviceData(monitorType);
@@ -212,6 +229,9 @@
                case "safetydoor":
                    _isSafetyDoorMonitoring = false;
                    break;
                case "platform":
                    _isPlatformMonitoring = false;
                    break;
            }
        }
@@ -236,7 +256,14 @@
                ["MaterialIn"] = new List<string> { "RGV101" },
                // å®‰å…¨é—¨è®¾å¤‡
                ["SafetyDoor"] = new List<string> { "HCJ2000" }, // å®‰å…¨é—¨
                ["SafetyDoor"] = new List<string> { "HCJ2000" },
                // ç«™å°è®¾å¤‡ - æ ¹æ®æ‚¨æä¾›çš„协议添加所有站台
                //        ["Platform"] = new List<string> {
                //    "1001", "1002", "2016", "2017", "2018", "2019", "1021", "1061", "1131", "1171"
                //}
                ["Platform"] = new List<string> { "HCJ2000" },
            };
            // è®¾å¤‡ç±»åž‹å¯¹åº”的参数配置
@@ -339,6 +366,13 @@
            ("ResetStatus", "ReadDeviceCommand", "安全门复位状态"),
            ("AlarmSummary", "DeviceCommand", "报警信息"),
            ("OpenDoor", "DeviceCommand", "开门信息")
        },
                // ç«™å°è®¾å¤‡å‚数配置 - æ ¹æ®æ‚¨æä¾›çš„协议添加
                ["Platform"] = new List<(string, string, string)>
        {
            ("HCJ_GoodsStatus", "ReadDeviceCommand", "光电信号"),
            ("DoorRequest", "DeviceCommand", "任务id")
        }
            };
@@ -352,13 +386,13 @@
                {
                    "outbound" => group.Key == "MotherCar" || group.Key == "TransferCar" || group.Key == "MaterialOut",
                    "inbound" => group.Key == "MaterialIn" || group.Key == "InboundMotherCar" || group.Key == "InboundTransferCar",
                    "safetydoor" => group.Key == "SafetyDoor", // å®‰å…¨é—¨ç›‘控类型
                    "safetydoor" => group.Key == "SafetyDoor",
                    "platform" => group.Key == "Platform", // ç«™å°ç›‘控类型
                    "all" => true,
                    _ => group.Key == "MotherCar" || group.Key == "TransferCar" || group.Key == "MaterialOut"
                };
            }).ToDictionary(x => x.Key, x => x.Value);
            int i = 0;
            // éåŽ†ç­›é€‰åŽçš„è®¾å¤‡ç»„
            foreach (var deviceGroup in filteredDeviceGroups)
            {
@@ -413,57 +447,83 @@
                    }
                    else if (device is CommonConveyorLine conveyorLine)
                    {
                        // å¤„理安全门设备(CommonConveyorLine ç±»åž‹ï¼‰
                        // åˆ›å»ºä¸‰ä¸ªå®‰å…¨é—¨è®¾å¤‡çš„æ•°æ®
                        List<string> safetyDoorList = new List<string> { "AQM001", "AQM002", "AQM003" };
                        // ä¸ºæ¯ä¸ªå®‰å…¨é—¨åˆ›å»ºæ•°æ®
                        foreach (string safetyDoorCode in safetyDoorList)
                        // å¤„理安全门设备和站台设备(CommonConveyorLine ç±»åž‹ï¼‰
                        if (deviceType == "SafetyDoor")
                        {
                            var deviceData = new Dictionary<string, int>();
                            // å®‰å…¨é—¨è®¾å¤‡å¤„理逻辑(保持不变)
                            List<string> safetyDoorList = new List<string> { "AQM001", "AQM002", "AQM003" };
                            // éåŽ†è¯¥è®¾å¤‡çš„æ‰€æœ‰å‚æ•°
                            foreach (var param in deviceParams)
                            foreach (string safetyDoorCode in safetyDoorList)
                            {
                                try
                                {
                                    // ä½¿ç”¨å®‰å…¨é—¨åç§°æŸ¥è¯¢å¯¹åº”的参数
                                    DeviceProDTO? devicePro = GetSafetyDoorDeviceProDTO(
                                        conveyorLine, safetyDoorCode, param.DeviceProParamName, param.DeviceProParamType);
                                var deviceData = new Dictionary<string, int>();
                                    if (devicePro != null)
                                    {
                                        // å¯¹äºŽ CommonConveyorLine ç±»åž‹ï¼Œä½¿ç”¨é€šç”¨çš„æ•°æ®è¯»å–方法
                                        int res = ReadCommonConveyorLineData(conveyorLine, devicePro.DeviceProAddress);
                                        deviceData[param.DeviceProRemark] = res;
                                    }
                                    else
                                    {
                                        deviceData[param.DeviceProRemark] = -1; // ä½¿ç”¨ -1 è¡¨ç¤ºæŸ¥è¯¢å¤±è´¥
                                    }
                                }
                                catch (Exception)
                                foreach (var param in deviceParams)
                                {
                                    deviceData[param.DeviceProRemark] = -1; // ä½¿ç”¨ -1 è¡¨ç¤ºæŸ¥è¯¢å¼‚常
                                    try
                                    {
                                        DeviceProDTO? devicePro = GetSafetyDoorDeviceProDTO(
                                            conveyorLine, safetyDoorCode, param.DeviceProParamName, param.DeviceProParamType);
                                        if (devicePro != null)
                                        {
                                            int res = ReadCommonConveyorLineData(conveyorLine, devicePro.DeviceProAddress);
                                            deviceData[param.DeviceProRemark] = res;
                                        }
                                        else
                                        {
                                            deviceData[param.DeviceProRemark] = -1;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        deviceData[param.DeviceProRemark] = -1;
                                    }
                                }
                                finalResult[safetyDoorCode] = deviceData;
                            }
                        }
                            // å°†å½“前安全门设备的数据添加到最终结果中,使用安全门名称作为key
                            finalResult[safetyDoorCode] = deviceData;
                        if (deviceType == "Platform")
                        {
                            // å®‰å…¨é—¨è®¾å¤‡å¤„理逻辑(保持不变)
                            List<string> PlatformList = new List<string> { "1001", "1002", "2016", "2017", "2018", "2019", "1021", "1061", "1131", "1171" };
                            foreach (string Platform in PlatformList)
                            {
                                var deviceData = new Dictionary<string, int>();
                                foreach (var param in deviceParams)
                                {
                                    try
                                    {
                                        DeviceProDTO? devicePro = GetSafetyDoorDeviceProDTO(
                                            conveyorLine, Platform, param.DeviceProParamName, param.DeviceProParamType);
                                        if (devicePro != null)
                                        {
                                            int res = ReadCommonConveyorLineData(conveyorLine, devicePro.DeviceProAddress);
                                            deviceData[param.DeviceProRemark] = res;
                                        }
                                        else
                                        {
                                            deviceData[param.DeviceProRemark] = -1;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        deviceData[param.DeviceProRemark] = -1;
                                    }
                                }
                                finalResult[Platform] = deviceData;
                            }
                        }
                    }
                    else
                    {
                        // å³ä½¿è®¾å¤‡ä¸å­˜åœ¨æˆ–不是支持的类型,也创建一个空字典
                        finalResult[deviceChildCode] = new Dictionary<string, int>();
                        /*if (device != null)
                        {
                            Console.WriteLine($"警告:设备 {deviceChildCode} ç±»åž‹ {device.GetType().Name} ä¸æ”¯æŒï¼Œæ— æ³•读取数据");
                        }
                        else
                        {
                            Console.WriteLine($"警告:设备 {deviceChildCode} ä¸å­˜åœ¨");
                        }*/
                    }
                }
            }
@@ -483,7 +543,8 @@
                "outbound" => $"出库监控: {(_isOutboundMonitoring ? "运行中" : "已停止")}",
                "inbound" => $"入库监控: {(_isInboundMonitoring ? "运行中" : "已停止")}",
                "safetydoor" => $"安全门监控: {(_isSafetyDoorMonitoring ? "运行中" : "已停止")}",
                "all" => $"出库监控: {(_isOutboundMonitoring ? "运行中" : "已停止")}, å…¥åº“监控: {(_isInboundMonitoring ? "运行中" : "已停止")}, å®‰å…¨é—¨ç›‘控: {(_isSafetyDoorMonitoring ? "运行中" : "已停止")}",
                "platform" => $"站台监控: {(_isPlatformMonitoring ? "运行中" : "已停止")}", // ç«™å°ç›‘控状态
                "all" => $"出库监控: {(_isOutboundMonitoring ? "运行中" : "已停止")}, å…¥åº“监控: {(_isInboundMonitoring ? "运行中" : "已停止")}, å®‰å…¨é—¨ç›‘控: {(_isSafetyDoorMonitoring ? "运行中" : "已停止")}, ç«™å°ç›‘控: {(_isPlatformMonitoring ? "运行中" : "已停止")}",
                _ => $"出库监控: {(_isOutboundMonitoring ? "运行中" : "已停止")}"
            };
        }
@@ -500,11 +561,11 @@
                "outbound" => "出库",
                "inbound" => "入库",
                "safetydoor" => "安全门",
                "platform" => "站台", // ç«™å°æ˜¾ç¤ºåç§°
                "all" => "全部",
                _ => "出库"
            };
        }
        /// <summary>
        /// è¯»å–设备信息
@@ -517,7 +578,6 @@
            return Commonstacker.Communicator.Read<short>(DeviceProDataBlock);
        }
        /// <summary>
        /// æŸ¥è¯¢å®‰å…¨é—¨è®¾å¤‡
        /// </summary>
@@ -528,6 +588,19 @@
        public static DeviceProDTO? GetSafetyDoorDeviceProDTO(CommonConveyorLine Commonstacker, string SCAddress, string DeviceProParamName, string DeviceProParamType)
        {
            return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == DeviceProParamName && x.DeviceProParamType == DeviceProParamType);
        }
        /// <summary>
        /// æŸ¥è¯¢ç«™å°è®¾å¤‡
        /// </summary>
        /// <param name="Commonstacker"></param>
        /// <param name="PlatformCode">站台编号</param>
        /// <param name="DeviceProParamName">参数名称</param>
        /// <param name="DeviceProParamType">参数类型</param>
        /// <returns></returns>
        public static DeviceProDTO? GetPlatformDeviceProDTO(CommonConveyorLine Commonstacker, string PlatformCode, string DeviceProParamName, string DeviceProParamType)
        {
            return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == PlatformCode && x.DeviceProParamName == DeviceProParamName && x.DeviceProParamType == DeviceProParamType);
        }
        //=================================================读取设备信息==========================================================
@@ -624,12 +697,35 @@
                    DeviceProParamName = "RGV_Risingsignalplace";
                    DeviceProParamType = "DeviceCommand";
                    zhi = parameter;
                    break;
                case "xj":          //下降
                    DeviceProDTO? RGV_Resetoperationss1 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, DeviceProParamName, DeviceProParamType);        //上升
                    RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationss1.DeviceProAddress, (short)zhi);
                    //DeviceProDTO? RGV_Resetoperationss2 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, "RGV_Risingsignalplace", "ReadDeviceCommand");        //上升到位信号
                    //    int resss = 0;
                    //    while (resss == 0)
                    //    {
                    //        Thread.Sleep(2000);
                    //        resss = RgvOperationService.GetLine(Commonstacker, RGV_Resetoperationss2.DeviceProAddress);
                    //    }
                    //    DeviceProDTO? RGV_Resetoperationss3 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, DeviceProParamName, DeviceProParamType);        //上升
                    //    RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationss3.DeviceProAddress, 0);
                        return webResponse.OK();
                    case "xj":          //下降
                    DeviceProParamName = "RGV_Descentsignal";
                    DeviceProParamType = "DeviceCommand";
                    zhi = parameter;
                    break;
                        DeviceProDTO? RGV_Resetoperationxj1 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, DeviceProParamName, DeviceProParamType);        //下降
                        RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationxj1.DeviceProAddress, (short)zhi);
                        //DeviceProDTO? RGV_Resetoperationxj2 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, "RGV_Descentsignal", "ReadDeviceCommand");        //下降到位信号
                        //int resxj = 0;
                        //while (resxj == 0)
                        //{
                        //    Thread.Sleep(2000);
                        //    resxj = RgvOperationService.GetLine(Commonstacker, RGV_Resetoperationxj2.DeviceProAddress);
                        //}
                        //DeviceProDTO? RGV_Resetoperationxj3 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, DeviceProParamName, DeviceProParamType);        //上升
                        //RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationxj3.DeviceProAddress, 0);
                        return webResponse.OK();
                case "dz":          //地址
                    DeviceProParamName = "RGV_RGVTasklocationt";
                    DeviceProParamType = "DeviceCommand";
@@ -769,6 +865,162 @@
                return webResponse.Error("设备操作失败");
            }
}
        /// <summary>
        /// æŸ¥çœ‹æŠ¥è­¦
        /// </summary>
        public WebResponseContent LogAlarmToDatabase(string JobDeviceName)
        {
            // è®¾å¤‡åˆ†ç±» - åˆå¹¶ç‰ˆæœ¬
            var deviceCategories = new Dictionary<string, List<string>>
            {
                ["MotherCar"] = new List<string> { "RGV112", "RGV110", "RGV114", "RGV115", "RGV103", "RGV105", "RGV108", "RGV109" },
                ["TransferCar"] = new List<string> { "RGV116", "RGV111", "RGV104", "RGV107" },
                ["ExternalRGV"] = new List<string> { "RGV118", "RGV101" }
            };
            WebResponseContent webResponse = new WebResponseContent();
            string DeviceName = JobDeviceName;    //设备名称
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
            if (device == null) return webResponse.Error();
            SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
            DeviceProDTO? RGV_Resetoperation = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Faultcode", "ReadDeviceCommand");
            DeviceProDTO? RGVCurrentlocation = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGVCurrentlocation", "RGVCurrentlocation");
            DeviceProDTO? RGV_Rgvtaskid = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Rgvtaskid", "ReadDeviceCommand");
            int baoj = RgvOperationService.GetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress);
            if (baoj<=0)
            {
                return null;
            }
            int Currentlocation = RgvOperationService.GetLine(Commonstacker, RGVCurrentlocation.DeviceProAddress);
            int Rgvtaskid = RgvOperationService.GetLine(Commonstacker, RGV_Rgvtaskid.DeviceProAddress);
            string alarmMessage = "";
            if (deviceCategories["MotherCar"].Contains(DeviceName))
            {
                // æ¯è½¦ä¸“用报警处理逻辑
                alarmMessage = HandleMotherCarAlarm(baoj);
            }
            else if (deviceCategories["TransferCar"].Contains(DeviceName))
            {
                // å­è½¦ä¸“用报警处理逻辑
                alarmMessage = HandleTransferCarAlarm(baoj);
            }
            else if (deviceCategories["ExternalRGV"].Contains(DeviceName))
            {
                // å¤–口RGV专用报警处理逻辑
                alarmMessage = HandleExternalRGVAlarm(baoj);
            }
            // å†™å…¥æ–‡æœ¬æ—¥å¿—(按设备分组/按日切分)
            var logContent = $"设备:{DeviceName} | æŠ¥è­¦ç :{baoj} | æŠ¥è­¦æè¿°:{alarmMessage} | å½“前位置:{Currentlocation} | ä»»åŠ¡å·:{Rgvtaskid}";
            // groupName: Alarm,logName: è®¾å¤‡å
            WriteLog.Write_Log("Alarm", DeviceName, logContent, new
            {
                DeviceCode = DeviceName,
                AlarmCode = baoj,
                AlarmContent = alarmMessage,
                DeviceLocation = Currentlocation,
                TaskNum = Rgvtaskid,
                Time = DateTime.Now
            });
            return webResponse.OK();
        }
        // æŠ¥è­¦ä»£ç æ˜ å°„方法
        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, "货叉到达初始位但中位传感器未检测到报警"}
            };
            return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "未知报警代码";
        }
        private string HandleTransferCarAlarm(int alarmCode)
        {
            var alarmMessages = new Dictionary<int, string>
    {
        {0, "无报警"},
        {1, "RGV小车急停被按下"},
        {2, "前进限位报警"},
        {3, "后退限位报警"},
        {4, "PLC摸块故障"},
        {5, "PLC扩展模块故障"},
        {6, "扫码定位故障"},
        {7, "RGV长时间空转故障"},
        {8, "目的地不等于实际位置故障"},
        {9, "与总控通讯故障"},
        {10, "行走变频器故障"},
        {11, "液压单元过载保护故障"},
        {12, "液压上升超时报警"},
        {13, "液压下降超时报警"},
        {14, "取货时自身有货物报警"},
        {15, "放货时自身无货物报警"},
        {16, "取货检测不到货物报警"}
    };
            return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "未知报警代码";
        }
        private string HandleMotherCarAlarm(int alarmCode)
        {
            var alarmMessages = new Dictionary<int, string>
    {
        {0, "无报警"},
        {1, "RGV小车急停被按下"},
        {2, "前进限位报警"},
        {3, "后退限位报警"},
        {4, "PLC摸块故障"},
        {5, "PLC扩展模块故障"},
        {6, "RGV长时间空转故障"},
        {7, "目的地不等于实际位置故障"},
        {8, "与总控通讯故障"},
        {9, "行走变频器故障"},
        {10, "取货时自身有货物报警"},
        {11, "放货时自身无货物报警"},
        {12, "停止时位置过冲报警"}
    };
            return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "未知报警代码";
        }
    }
}