1
huanghongfeng
10 天以前 0b4792ff8245f9eac16e6d02452eb9a091f6f72b
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
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<AGVStation> 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<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;
        }
 
        /// <summary>
        /// 安全门信号
        /// </summary>
        public AQMReturnnormal AQMStoticCommand(CommonConveyorLine conveyorLine, string kladder)
        {
            try
            {
                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 == "short")
                        {
                            var value = conveyorLine.Communicator.Read<short>(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<DeviceProDTO> 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<short>(item.DeviceProAddress);
                        propertyInfo.SetValue(conveyorRgvCommand, value);
                    }
                }
            }
            return conveyorRgvCommand;
        }
 
 
    }
}