1
HuBingJie
5 天以前 99d55d437cc924429bb9589d5afe24f386cf8342
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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<DeviceProDTO> 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<short>(item.DeviceProAddress);
                        propertyInfo.SetValue(conveyorRgvCommand, value);
                    }
                }
            }
            return conveyorRgvCommand;
        }
 
        public AQMReturnnormal AQMStoticCommand(CommonConveyorLine conveyorLine, string kladder)
        {
            AQMReturnnormal conveyorRgvCommand = new AQMReturnnormal();
            List<DeviceProDTO> 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<short>(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);
        }
 
    }
}