| | |
| | | using Autofac.Core; |
| | | using AutoMapper; |
| | | using AutoMapper; |
| | | using Quartz; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Reflection; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.Log; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.Enum; |
| | | using WIDESEAWCS_ISystemServices; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_Model.Models.System; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_TaskInfoService; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using WIDESEAWCS_Tasks.StackerCraneJob; |
| | | using static System.Collections.Specialized.BitVector32; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | |
| | | private readonly IMapper _mapper; |
| | | private readonly IRgvOperationService _gvOperationService; |
| | | private readonly IEquipmentStatusService _equipmentStatusService; |
| | | //private readonly TaskService _task; |
| | | |
| | | public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IAgvStationService agvStation, IMapper mapper, IRgvOperationService gvOperationService, IEquipmentStatusService equipmentStatusService) |
| | | { |
| | |
| | | _mapper = mapper; |
| | | _gvOperationService = gvOperationService; |
| | | _equipmentStatusService=equipmentStatusService; |
| | | //_task = task; |
| | | } |
| | | |
| | | public async Task Execute(IJobExecutionContext context) |
| | |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (conveyorLine != null) |
| | | { |
| | | |
| | | |
| | | //æ ¹æ®è®¾å¤æ¥æ¾åºå¯¹åºçç«å°ä¿¡æ¯ |
| | | List<AGVStation> aGVStations = _agvStationService.GetYljSide(conveyorLine.DeviceCode); |
| | | foreach (var Stations in aGVStations) |
| | | { |
| | | /*if (Stations.Station_material == (int)RGVEquipment.AQMexit) |
| | | if (Stations.Station_material == (int)RGVEquipment.AQMexit) |
| | | { |
| | | //è·åå°å®å
¨é¨ä¿¡æ¯ |
| | | AQMReturnnormal aQMConveyor = AQMStoticCommand(conveyorLine, Stations.ChildPosiDeviceCode); |
| | | if(Stations.Station_tasktype== (int)RGVTasktype.Outbound) |
| | | { |
| | | //读åå åæºä¸RGVæ¯å¦å¨æ¥è¦ï¼å¦æå¨æ¥è¦ï¼ååå
¥å®å
¨é¨æ¥è¦ |
| | | if (_gvOperationService.AQMReadAlarminform(2) && _equipmentStatusService.GetSCstatus()) |
| | | { |
| | | //åå
¥æ¥è¦ |
| | | GetDeviceAddress.WriteSecurityDoorpolice(Stations.ChildPosiDeviceCode, "AlarmSummary", 1); |
| | | } |
| | | |
| | | bool Security = SecurityDoorEquipment(conveyorLine, Stations); //å®å
¨é¨ |
| | | if (Security) continue; |
| | | |
| | | //å®å
¨é¨æ¥åç¶æ |
| | | if (aQMConveyor.EmergencyStopStatus == 0) |
| | | { |
| | | //ç«é©¬åæ¢å
¨é¨RGV(å¾å¤æRGVç¶æ,æ²¡åæ¢çå忢) |
| | | _gvOperationService.WriteOutbuttonpause(null); |
| | | |
| | | } |
| | | |
| | | //å®å
¨é¨è¿è¡è¯·æ± |
| | | if (aQMConveyor.DoorRequest == 1 && aQMConveyor.IndicatorStatus== (int)SafetyDoorStatus.YellowBlink2Hz) |
| | | { |
| | | //读åå°è¯·æ±åï¼æ ¹æ®ç¶ææç¤ºç¯è¿è¡æä½ |
| | | if (aQMConveyor.EmergencyStopStatus == 1 && aQMConveyor.EmergencyStopStatus == 0) //æªæ¥åï¼éè¦ç³è¯·è¿å
¥è®¾å¤ |
| | | { |
| | | //ç´æ¥åæ¢RGVå¨ä½ |
| | | _gvOperationService.WriteOutbuttonpause(null); |
| | | |
| | | //读ååæ¯è½¦æ¯å¦é½å¨ç©ºé²ç¶æ |
| | | if (GetDeviceAddress.OutRGVStatice()) //读ååæ¯è½¦ç¶æ |
| | | { |
| | | //åå
¥å¼é¨ä¿¡å· |
| | | GetDeviceAddress.WriteSecurityDoorpolice(Stations.ChildPosiDeviceCode, "OpenDoor", 1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (_gvOperationService.AQMReadAlarminform(1) && _equipmentStatusService.GetSCstatus()) |
| | | { |
| | | //åå
¥æ¥è¦ |
| | | GetDeviceAddress.WriteSecurityDoorpolice(Stations.ChildPosiDeviceCode, "AlarmSummary", 1); |
| | | } |
| | | |
| | | |
| | | //å®å
¨é¨æ¥åç¶æ |
| | | if (aQMConveyor.EmergencyStopStatus == 0) |
| | | { |
| | | //ç«é©¬åæ¢å
¨é¨RGV(å¾å¤æRGVç¶æ,æ²¡åæ¢çå忢) |
| | | _gvOperationService.InWriteOutbuttonpause(null); |
| | | |
| | | } |
| | | |
| | | //å®å
¨é¨è¿è¡è¯·æ± |
| | | if (aQMConveyor.DoorRequest == 1 && aQMConveyor.IndicatorStatus == (int)SafetyDoorStatus.YellowBlink2Hz) |
| | | { |
| | | //读åå°è¯·æ±åï¼æ ¹æ®ç¶ææç¤ºç¯è¿è¡æä½ |
| | | if (aQMConveyor.EmergencyStopStatus == 1 && aQMConveyor.EmergencyStopStatus == 0) //æªæ¥åï¼éè¦ç³è¯·è¿å
¥è®¾å¤ |
| | | { |
| | | //ç´æ¥åæ¢RGVå¨ä½ |
| | | _gvOperationService.InWriteOutbuttonpause(null); |
| | | |
| | | //读ååæ¯è½¦æ¯å¦é½å¨ç©ºé²ç¶æ |
| | | if (GetDeviceAddress.OutRGVStatice()) //读ååæ¯è½¦ç¶æ |
| | | { |
| | | //åå
¥å¼é¨ä¿¡å· |
| | | GetDeviceAddress.WriteSecurityDoorpolice(Stations.ChildPosiDeviceCode, "OpenDoor", 1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }*/ |
| | | /*else |
| | | } |
| | | else |
| | | { |
| | | PlatformStatus aQMConveyor = StoticCommand(conveyorLine, Stations.ChildPosiDeviceCode); |
| | | if (aQMConveyor.HCJ_GoodsStatus == 0) //å¯è¿è¡æ¾è´§ |
| | | { |
| | | WebResponseContent webResponseContent = new WebResponseContent(); |
| | | //æ ¹æ®ç±»åæ¥æ¾ä»»å¡ |
| | | if (Stations.Station_material == (int)RGVEquipment.AbnormalOutbound) |
| | | { |
| | | //æ¥æ¾æ¯å¦æå¼å¸¸æ¬è¿ä»»å¡ |
| | | webResponseContent = _taskService.UpdateDeliveryAddress(Stations.HCJStorageaddress.ToString(), 1); //è¿éè¦ä¼ å
¥å°å |
| | | } |
| | | else |
| | | { |
| | | //åºåºç«å°çä»»å¡ |
| | | webResponseContent = _taskService.UpdateDeliveryAddress(Stations.HCJStorageaddress.ToString(), 2); |
| | | } |
| | | } |
| | | }*/ |
| | | bool HCJPlat=PlatformEquipmentInformation(conveyorLine, Stations); //å¼å¸¸ç«å°ï¼åºåºç«å° |
| | | if (HCJPlat) continue; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | |
| | | public AQMConveyorRgvommand AQMCommand(CommonConveyorLine conveyorLine, string kladder) |
| | | |
| | | //å¤çå®å
¨é¨çé»è¾ |
| | | private void HandleDoorRequest(AQMReturnnormal aQMConveyor, AGVStation aGVStation,int tasktype) //1ï¼å
¥åº 2ï¼åºåº |
| | | { |
| | | AQMConveyorRgvommand conveyorRgvCommand = new AQMConveyorRgvommand(); |
| | | List<DeviceProDTO> deviceProDTO6 = conveyorLine.DeviceProDTOs |
| | | .Where(x => x.DeviceChildCode == kladder |
| | | && DBLine.ConveyorAQMCommand.Contains(x.DeviceProParamName) |
| | | && x.DeviceProParamType == "ReadDeviceCommand") |
| | | .ToList(); |
| | | foreach (var item in deviceProDTO6) |
| | | /*bool RGValarm = _gvOperationService.AQMReadAlarminform(tasktype); |
| | | bool SCstatus = _equipmentStatusService.GetSCstatus(); |
| | | if (RGValarm || SCstatus) |
| | | { |
| | | var paramName = item.DeviceProParamName; |
| | | var propertyInfo = typeof(AQMConveyorRgvommand).GetProperty(paramName); |
| | | //åå
¥æ¥è¦ |
| | | GetDeviceAddress.WriteSecurityDoorpolice(aGVStation.ChildPosiDeviceCode, "AlarmSummary", 1); |
| | | |
| | | if (propertyInfo != null) |
| | | bool RGVRGV_DWorkingmode = tasktype == 1 ? _gvOperationService.InWriteOutbuttonpause(null).Status : _gvOperationService.WriteOutbuttonpause(null).Status; |
| | | }*/ |
| | | |
| | | if (aQMConveyor.DoorRequest == 1 && aQMConveyor.IndicatorStatus == (int)SafetyDoorStatus.YellowBlink2Hz) |
| | | { |
| | | if (aQMConveyor.EmergencyStopStatus == 1) //请æ±å¼é¨çå¾
ä»»å¡å®æ |
| | | { |
| | | if (item.DeviceDataType == "int") |
| | | bool AQMzckm = tasktype == 1 ? GetDeviceAddress.InRGVRGVStepprocess() : GetDeviceAddress.OutRGVRGVStepprocess(); //夿æ¯å¦æè¿ç¨ä»»å¡ |
| | | if (AQMzckm) |
| | | { |
| | | var value = conveyorLine.Communicator.Read<short>(item.DeviceProAddress); |
| | | propertyInfo.SetValue(conveyorRgvCommand, value); |
| | | //åå
¥åæ¢çä¿¡æ¯ |
| | | bool RGVRGV_DWorkingmode = tasktype == 1 ? _gvOperationService.InWriteOutbuttonpause(null).Status : _gvOperationService.WriteOutbuttonpause(null).Status; |
| | | |
| | | bool RGVstate = tasktype == 1 ? GetDeviceAddress.InRGVStatice() : GetDeviceAddress.OutRGVStatice(); //夿æ¯å¦å
¨ä¸ºæå¨ |
| | | WebResponseContent webResponse = _taskService.StkRunStatus(); |
| | | if (RGVstate && webResponse.Status == true) |
| | | { |
| | | //åå
¥å¼é¨ä¿¡å· |
| | | GetDeviceAddress.WriteSecurityDoorpolice(aGVStation.ChildPosiDeviceCode, "OpenDoor", 1); |
| | | } |
| | | } |
| | | |
| | | } |
| | | else //æ¥åç«é©¬æåè®¾å¤ |
| | | { |
| | | bool AQMkm = tasktype == 1 ? GetDeviceAddress.InRGVStatice() : GetDeviceAddress.OutRGVStatice(); |
| | | WebResponseContent webResponse = _taskService.StkRunStatus(); |
| | | |
| | | if (AQMkm && webResponse.Status == true) |
| | | { |
| | | GetDeviceAddress.WriteSecurityDoorpolice(aGVStation.ChildPosiDeviceCode, "OpenDoor", 1); |
| | | } |
| | | |
| | | } |
| | | } |
| | | return conveyorRgvCommand; |
| | | } |
| | | |
| | | //å®å
¨é¨è®¾å¤ä¿¡æ¯ç®¡ç |
| | | private bool SecurityDoorEquipment(CommonConveyorLine conveyorLine, AGVStation Stations) |
| | | { |
| | | try |
| | | { |
| | | // è·åå®å
¨é¨ä¿¡æ¯ |
| | | AQMReturnnormal aQMConveyor = AQMStoticCommand(conveyorLine, Stations.ChildPosiDeviceCode); |
| | | if(aQMConveyor != null) |
| | | { |
| | | if (aQMConveyor.SafetyLockStatus == 1) |
| | | { |
| | | //åå
¥æ¥è¦ |
| | | GetDeviceAddress.WriteSecurityDoorpolice(Stations.ChildPosiDeviceCode, "AlarmSummary", 0); |
| | | //åå
¥å¼é¨ä¿¡å· |
| | | GetDeviceAddress.WriteSecurityDoorpolice(Stations.ChildPosiDeviceCode, "OpenDoor", 0); |
| | | } |
| | | |
| | | // æ ¹æ®ä»»å¡ç±»åéæ©å¤ççç¥ |
| | | if (Stations.Station_tasktype == (int)RGVTasktype.Outbound) |
| | | { |
| | | if (aQMConveyor.EmergencyStopStatus == 0 || aQMConveyor.SafetyLockStatus==0) _gvOperationService.WriteOutbuttonpause(null); |
| | | HandleDoorRequest(aQMConveyor, Stations, 2); |
| | | } |
| | | else |
| | | { |
| | | if (aQMConveyor.EmergencyStopStatus == 0 || aQMConveyor.SafetyLockStatus == 0) _gvOperationService.InWriteOutbuttonpause(null); |
| | | HandleDoorRequest(aQMConveyor, Stations, 1); |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return true; |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | private bool PlatformEquipmentInformation(CommonConveyorLine conveyorLine, AGVStation Stations) |
| | | { |
| | | try |
| | | { |
| | | if (StoticCommand(conveyorLine, Stations.HCJStorageaddress.ToString())) //å¯è¿è¡æ¾è´§ |
| | | { |
| | | WebResponseContent webResponseContent = new WebResponseContent(); |
| | | //æ ¹æ®ç±»åæ¥æ¾ä»»å¡ |
| | | if (Stations.Station_material == (int)RGVEquipment.AbnormalOutbound) |
| | | { |
| | | //æ¥æ¾æ¯å¦æå¼å¸¸æ¬è¿ä»»å¡ |
| | | webResponseContent = _taskService.UpdateDeliveryAddress(Stations.HCJStorageaddress.ToString(), 1); //è¿éè¦ä¼ å
¥å°å |
| | | } |
| | | else |
| | | { |
| | | //åºåºç«å°çä»»å¡ |
| | | webResponseContent = _taskService.UpdateDeliveryAddress(Stations.HCJStorageaddress.ToString(), 2); |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return true; |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | return conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == PLCmanipula && x.DeviceProParamName == DeviceProParamName && x.DeviceProParamType == DeviceProParamType); |
| | | } |
| | | |
| | | public PlatformStatus StoticCommand(CommonConveyorLine conveyorLine, string kladder) |
| | | //ç«å°ä¿¡å· |
| | | /* public bool StoticCommand(CommonConveyorLine conveyorLine, string kladder) |
| | | { |
| | | PlatformStatus conveyorRgvCommand = new PlatformStatus(); |
| | | List<DeviceProDTO> deviceProDTO6 = conveyorLine.DeviceProDTOs |
| | | .Where(x => x.DeviceChildCode == kladder |
| | | && x.DeviceProParamType == "ReadDeviceCommand") |
| | | .ToList(); |
| | | foreach (var item in deviceProDTO6) |
| | | DeviceProDTO? deviceProDTO6 = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == kladder |
| | | && x.DeviceProParamName == "HCJ_GoodsStatus" |
| | | && x.DeviceProParamType == "ReadDeviceCommand"); |
| | | if(deviceProDTO6 == null) { return false; } |
| | | |
| | | if (deviceProDTO6.DeviceChildCode == "2016"||deviceProDTO6.DeviceChildCode == "2017"|| deviceProDTO6.DeviceChildCode == "2018"|| deviceProDTO6.DeviceChildCode == "2019" |
| | | || deviceProDTO6.DeviceChildCode == "1001"|| deviceProDTO6.DeviceChildCode == "1002") |
| | | { |
| | | var paramName = item.DeviceProParamName; |
| | | var propertyInfo = typeof(PlatformStatus).GetProperty(paramName); |
| | | |
| | | if (propertyInfo != null) |
| | | { |
| | | if (item.DeviceDataType == "int") |
| | | { |
| | | var value = conveyorLine.Communicator.Read<short>(item.DeviceProAddress); |
| | | propertyInfo.SetValue(conveyorRgvCommand, value); |
| | | } |
| | | } |
| | | var value1 = conveyorLine.Communicator.Read<short>(deviceProDTO6.DeviceProAddress); |
| | | //å»¶æ¶5ç§ |
| | | System.Threading.Thread.Sleep(5000); |
| | | var value2 = conveyorLine.Communicator.Read<short>(deviceProDTO6.DeviceProAddress); |
| | | if (value1 != value2 && (value1 !=0 && value2 !=0)) { return false; }; |
| | | return true; |
| | | } |
| | | return conveyorRgvCommand; |
| | | var value = conveyorLine.Communicator.Read<short>(deviceProDTO6.DeviceProAddress); |
| | | |
| | | if (value == 0) { return true; } |
| | | return false; |
| | | }*/ |
| | | |
| | | |
| | | |
| | | //ç«å°ä¿¡å· |
| | | public bool StoticCommand(CommonConveyorLine conveyorLine, string kladder) |
| | | { |
| | | DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == kladder |
| | | && x.DeviceProParamName == "HCJ_GoodsStatus" |
| | | && x.DeviceProParamType == "ReadDeviceCommand"); |
| | | // è¿äºç«å°éè¦âå»¶æ¶5ç§å¹¶æ¯è¾ç¬¬ä¸æ¬¡ä¸æå䏿¬¡ç»æâ |
| | | bool isPlatformCode = |
| | | kladder == "2016" || kladder == "2017" || kladder == "2018" || kladder == "2019" || |
| | | kladder == "1001" || kladder == "1002"; |
| | | |
| | | if (isPlatformCode) |
| | | { |
| | | // ç¬¬ä¸æ¬¡è¯»å |
| | | short first = conveyorLine.Communicator.Read<short>(deviceProDTO.DeviceProAddress); |
| | | |
| | | // å»¶æ¶5ç§ |
| | | System.Threading.Thread.Sleep(5000); |
| | | |
| | | // æå䏿¬¡è¯»å |
| | | short last = conveyorLine.Communicator.Read<short>(deviceProDTO.DeviceProAddress); |
| | | |
| | | // åè®®ï¼0=æ ä¿¡å·=æ è´§=ç©ºä½ |
| | | return first == 0 && last == 0; |
| | | } |
| | | else |
| | | { |
| | | short value = conveyorLine.Communicator.Read<short>(deviceProDTO.DeviceProAddress); |
| | | return value == 0; // 0=空ä½å¯æ¾ï¼1=æè´§ä¸å¯æ¾ |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |