using Autofac.Core; 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_Tasks.ConveyorLineJob; using WIDESEAWCS_Tasks.StackerCraneJob; using static System.Collections.Specialized.BitVector32; namespace WIDESEAWCS_Tasks { [DisallowConcurrentExecution] public class CommonConveyorLineJob : IJob { private readonly ITaskService _taskService; private readonly ITaskExecuteDetailService _taskExecuteDetailService; private readonly IRouterService _routerService; private readonly IAgvStationService _agvStationService; private readonly IMapper _mapper; private readonly IRgvOperationService _gvOperationService; private readonly IEquipmentStatusService _equipmentStatusService; public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IAgvStationService agvStation, IMapper mapper, IRgvOperationService gvOperationService, IEquipmentStatusService equipmentStatusService) { _taskService = taskService; _taskExecuteDetailService = taskExecuteDetailService; _routerService = routerService; _agvStationService = agvStation; _mapper = mapper; _gvOperationService = gvOperationService; _equipmentStatusService=equipmentStatusService; } public async Task Execute(IJobExecutionContext context) { try { CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); if (conveyorLine != null) { //根据设备查找出对应的站台信息 List aGVStations = _agvStationService.GetYljSide(conveyorLine.DeviceCode); foreach (var Stations in aGVStations) { /*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); } //安全门急停状态 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 { 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); } } }*/ } } } catch (Exception ex) { WriteLog.Write_Log("安全门", "运行状况", "故障", new { 信息 = ex.Message }); } return; } public AQMConveyorRgvommand AQMCommand(CommonConveyorLine conveyorLine, string kladder) { AQMConveyorRgvommand conveyorRgvCommand = new AQMConveyorRgvommand(); List deviceProDTO6 = conveyorLine.DeviceProDTOs .Where(x => x.DeviceChildCode == kladder && DBLine.ConveyorAQMCommand.Contains(x.DeviceProParamName) && x.DeviceProParamType == "ReadDeviceCommand") .ToList(); foreach (var item in deviceProDTO6) { var paramName = item.DeviceProParamName; var propertyInfo = typeof(AQMConveyorRgvommand).GetProperty(paramName); if (propertyInfo != null) { if (item.DeviceDataType == "int") { var value = conveyorLine.Communicator.Read(item.DeviceProAddress); propertyInfo.SetValue(conveyorRgvCommand, value); } } } return conveyorRgvCommand; } /// /// 安全门信号 /// public AQMReturnnormal AQMStoticCommand(CommonConveyorLine conveyorLine, string kladder) { try { AQMReturnnormal conveyorRgvCommand = new AQMReturnnormal(); List deviceProDTO6 = conveyorLine.DeviceProDTOs .Where(x => x.DeviceChildCode == kladder //&& DBLine.ConveyorAQMReturnnormal.Contains(x.DeviceProParamName) && x.DeviceProParamType == "ReadDeviceCommand") .ToList(); foreach (var item in deviceProDTO6) { var paramName = item.DeviceProParamName; var propertyInfo = typeof(AQMReturnnormal).GetProperty(paramName); if (propertyInfo != null) { if (item.DeviceDataType == "short") { var value = conveyorLine.Communicator.Read(item.DeviceProAddress); propertyInfo.SetValue(conveyorRgvCommand, value); } } } return conveyorRgvCommand; } catch (Exception ex) { return null; throw; } } public DeviceProDTO? GetDeviceProDTO(CommonConveyorLine conveyorLine, string PLCmanipula, string DeviceProParamName, string DeviceProParamType) { return conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == PLCmanipula && x.DeviceProParamName == DeviceProParamName && x.DeviceProParamType == DeviceProParamType); } public PlatformStatus StoticCommand(CommonConveyorLine conveyorLine, string kladder) { PlatformStatus conveyorRgvCommand = new PlatformStatus(); List deviceProDTO6 = conveyorLine.DeviceProDTOs .Where(x => x.DeviceChildCode == kladder && x.DeviceProParamType == "ReadDeviceCommand") .ToList(); foreach (var item in deviceProDTO6) { var paramName = item.DeviceProParamName; var propertyInfo = typeof(PlatformStatus).GetProperty(paramName); if (propertyInfo != null) { if (item.DeviceDataType == "int") { var value = conveyorLine.Communicator.Read(item.DeviceProAddress); propertyInfo.SetValue(conveyorRgvCommand, value); } } } return conveyorRgvCommand; } } }