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.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; public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IAgvStationService agvStation, IMapper mapper) { _taskService = taskService; _taskExecuteDetailService = taskExecuteDetailService; _routerService = routerService; _agvStationService = agvStation; _mapper = mapper; } public async Task Execute(IJobExecutionContext context) { try { CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); if (conveyorLine != null) { AQMConveyorRgvommand aQMConveyor=AQMCommand(conveyorLine, "AQM001"); //安全门开门申请+安全门状态 1 if(aQMConveyor.DoorRequest==1) { if(aQMConveyor.ResetStatus == 1) { //写入输送线进行切换信号 var deviceProDtqh = GetDeviceProDTO(conveyorLine, "AQM001", "IndicatorStatus", "DeviceCommand"); bool handoffbool = conveyorLine.Communicator.Write(deviceProDtqh.DeviceProDataBlock, (short)3); if (handoffbool) { //需要判断rgv,堆垛机是否允许开门 //如果允许开门,则写入4,表示切换成功, bool Maintenancebool = conveyorLine.Communicator.Write(deviceProDtqh.DeviceProDataBlock, (short)4); } } } else { //读取DBW8=1,DBW6=1,DBW10=1,DBW4=1,符合后,进行写入切换状态DBW0=3 AQMReturnnormal aQMReturnnormal=AQMStoticCommand(conveyorLine, "AQM001"); //判断 } } } 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) { 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 == "int") { var value = conveyorLine.Communicator.Read(item.DeviceProAddress); propertyInfo.SetValue(conveyorRgvCommand, value); } } } return conveyorRgvCommand; } 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); } } }