| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core; |
| | |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(childDeviceCode); |
| | | if (command != null) |
| | | { |
| | | List<int> signalTypes = Enum.GetValues(typeof(PLCSignalType)).Cast<int>().ToList(); |
| | | if (!signalTypes.Contains(command.InteractiveSignal)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | DeviceProtocolDetailDTO? deviceProtocolDetail = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.ProtocalDetailValue == command.InteractiveSignal.ToString() && x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal)); |
| | | if (deviceProtocolDetail != null) |
| | | { |
| | | PLCSignalType signalType = Enum.Parse<PLCSignalType>(deviceProtocolDetail.ProtocolDetailType); |
| | | switch (signalType) |
| | | MethodInfo? method = GetType().GetMethod(deviceProtocolDetail.ProtocolDetailType); |
| | | if (method != null) |
| | | { |
| | | case PLCSignalType.RequestInbound: |
| | | { |
| | | if (_taskService.RequestWMsTask(command.Barcode, childDeviceCode).Status) |
| | | { |
| | | Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | bool t = conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode }); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case PLCSignalType.RequestInNextAddress: |
| | | else |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); |
| | | if (newTask != null) |
| | | { |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | bool t = conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case PLCSignalType.ConveyorLineInFinish: |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | bool t = conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode); |
| | | WebResponseContent content = _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | Console.Out.WriteLine(content.Serialize()); |
| | | } |
| | | } |
| | | break; |
| | | case PLCSignalType.RequestOutbound: |
| | | { |
| | | Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | bool t = conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | } |
| | | } |
| | | break; |
| | | case PLCSignalType.RequestOutNextAddress: |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); |
| | | if (newTask != null) |
| | | { |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | bool t = conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case PLCSignalType.ConveyorLineOutFinish: |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | bool t = conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode); |
| | | WebResponseContent content = _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | Console.Out.WriteLine(content.Serialize()); |
| | | } |
| | | } |
| | | break; |
| | | //todo 未找到对应处理方法 |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command,string childDeviceCode) |
| | | { |
| | | if (_taskService.RequestWMsTask(command.Barcode, childDeviceCode).Status) |
| | | { |
| | | Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | bool t = conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); |
| | | if (newTask != null) |
| | | { |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | bool t = conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode); |
| | | WebResponseContent content = _taskService.UpdateTaskStatusToNext(task); |
| | | Console.Out.WriteLine(content.Serialize()); |
| | | } |
| | | } |
| | | |
| | | public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | bool t = conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | } |
| | | |
| | | public void RequestOutNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); |
| | | if (newTask != null) |
| | | { |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | bool t = conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | bool t = conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode); |
| | | WebResponseContent content = _taskService.UpdateTaskStatusToNext(task); |
| | | Console.Out.WriteLine(content.Serialize()); |
| | | } |
| | | } |
| | | } |
| | | } |