1
huanghongfeng
2025-10-22 8d558cb173873004cd8a0d6c12f37865f03d7a4f
´úÂë¹ÜÀí/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvOperationService.cs
@@ -48,6 +48,7 @@
using WIDESEAWCS_QuartzJob.Service;
using System.Net;
using WIDESEAWCS_ISystemServices;
using System.Security.Claims;
namespace WIDESEAWCS_TaskInfoService
{
@@ -104,17 +105,17 @@
                case "1":  // å·¥ä½œæ¨¡å¼ï¼ˆ0手动、1自动)
                           //获取实例
                    DeviceProDTO? RGV_DWorkingmode = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_DWorkingmode", "DeviceCommand");        //任务类型
                      //第一步写入任务
                                                                                                                                                //第一步写入任务
                    RgvSetLine(Commonstacker, RGV_DWorkingmode.DeviceProAddress, WriteRGVvalue);
                    break;
                case "2":   //复位操作(0不复位、1复位)
                    DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Resetoperation", "DeviceCommand");        //任务类型
                                                                                                                                                //第一步写入任务
                                                                                                                                                    //第一步写入任务
                    RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, WriteRGVvalue);
                    break;
                case "3":   //任务确认完成(0不确定,1确定)
                    DeviceProDTO? RGV_taskcomplete = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_taskcomplete", "RGV_taskcomplete");        //任务类型
                                                                                                                                                //第一步写入任务
                                                                                                                                                   //第一步写入任务
                    RgvSetLine(Commonstacker, RGV_taskcomplete.DeviceProAddress, WriteRGVvalue);
                    break;
                case "4":   //任务类型(4清除)
@@ -205,6 +206,52 @@
            return webResponse.OK();
        }
        /// <summary>
        /// ä¸€é”®æš‚停
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        public WebResponseContent WriteOutbuttonpause(SaveModel saveModel)
        {
            WebResponseContent webResponse = new WebResponseContent();
            List<AGVStation> rgvdata = _gvStationService.GetOutStroller();
            foreach (AGVStation rgvstation in rgvdata)
            {
                string DeviceName = rgvstation.ChildPosiDeviceCode;    //设备名称
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
                if (device == null) continue;
                SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
                //获取需要复位的设备
                DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_DWorkingmode", "DeviceCommand");        //复位报警信息
                RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, (short)0);
            }
            return webResponse.OK();
        }
        /// <summary>
        /// ä¸€é”®å¯åЍ
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        public WebResponseContent WriteOuttouchstart(SaveModel saveModel)
        {
            WebResponseContent webResponse = new WebResponseContent();
            List<AGVStation> rgvdata = _gvStationService.GetOutStroller();
            foreach (AGVStation rgvstation in rgvdata)
            {
                string DeviceName = rgvstation.ChildPosiDeviceCode;    //设备名称
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
                if (device == null) continue;
                SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
                //获取需要复位的设备
                DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_DWorkingmode", "DeviceCommand");        //复位报警信息
                RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, (short)1);
            }
            return webResponse.OK();
        }
        /// <summary>
@@ -224,7 +271,7 @@
        /// <param name="conveyorLine"></param>
        /// <param name="DeviceProDataBlock"></param>
        /// <returns></returns>
        public static int GetLine(CommonConveyorLine Commonstacker, string DeviceProDataBlock)
        public static int GetLine(SpeStackerCrane Commonstacker, string DeviceProDataBlock)
        {
            return Commonstacker.Communicator.Read<short>(DeviceProDataBlock);
        }
@@ -241,6 +288,125 @@
        }
        /// <summary>
        /// æŸ¥çœ‹æŠ¥è­¦
        /// </summary>
        public WebResponseContent ReadAlarminformation(SaveModel saveModel)
        {
            WebResponseContent webResponse = new WebResponseContent();
            string DeviceName = saveModel.DelKeys[0].ToString();    //设备名称
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
            if (device == null) return webResponse.Error();
            SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
            DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Faultcode", "ReadDeviceCommand");
            int baoj = GetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress);
            string alarmMessage = "";
            if (DeviceName == "RGV118")
            {
                 alarmMessage = GetAlarmMessage(baoj);
            }
            else if (DeviceName == "RGV111" || DeviceName == "RGV116")
            {
                 alarmMessage = GetAlarmMessage2(baoj);
            }
            else if (DeviceName == "RGV110" || DeviceName == "RGV112" || DeviceName == "RGV114" || DeviceName == "RGV115")
            {
                 alarmMessage = GetAlarmMessage3(baoj);
            }
            return webResponse.OK(data: alarmMessage);
        }
        // æŠ¥è­¦ä»£ç æ˜ å°„方法
        private string GetAlarmMessage(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 GetAlarmMessage2(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 GetAlarmMessage3(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] : "未知报警代码";
        }
    }
}