| | |
| | | #region << ç æ¬ 注 é >> |
| | | #region << ç æ¬ 注 é >> |
| | | /*---------------------------------------------------------------- |
| | | * å½å空é´ï¼WIDESEAWCS_TaskInfoService |
| | | * å建è
ï¼è¡ç«¥åº |
| | |
| | | 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; |
| | |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEA_Common.Log; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | |
| | | private readonly IAgvStationService _gvStationService; |
| | | private readonly IServiceProvider _serviceProvider; |
| | | private static bool _isMonitoring = false; |
| | | private readonly IRepository<DeviceAlarmLog> _deviceAlarmLog; |
| | | //private static CancellationTokenSource _cancellationTokenSource; |
| | | |
| | | // å¨ç±»çº§å«æ·»å ç¬ç«ççæ§ç¶æ |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | |
| | | DeviceProParamName = "RGV_Risingsignalplace"; |
| | | DeviceProParamType = "DeviceCommand"; |
| | | zhi = parameter; |
| | | break; |
| | | 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"; |
| | |
| | | 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] : "æªç¥æ¥è¦ä»£ç "; |
| | | } |
| | | } |
| | | } |
| | | |