| | |
| | | _taskService=taskService; |
| | | } |
| | | private static readonly object _taskProcessLock = new object(); |
| | | private const int TASK_PROCESS_TIMEOUT = 2000; // 2ç§è¶
æ¶ |
| | | |
| | | private static readonly object _taskProcessLockPLC = new object(); |
| | | private const int TASK_PROCESS_TIMEOUTPLC = 3000; // 2ç§è¶
æ¶ |
| | | |
| | | |
| | | private const int TASK_PROCESS_TIMEOUT = 1000; // 2ç§è¶
æ¶ |
| | | private readonly Queue<int> _deviceQueueSC = new Queue<int>(); |
| | | |
| | | public Task StartAsync(CancellationToken cancellationToken) |
| | |
| | | _deviceQueueSC.Enqueue(i); |
| | | } |
| | | |
| | | _timer = new Timer(SCProcessNextDevice, null, TimeSpan.Zero, TimeSpan.FromSeconds(2)); |
| | | _timer2 = new Timer(PLCDoDeciceWork, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2)); |
| | | _timer = new Timer(SCProcessNextDevice, null, TimeSpan.Zero, TimeSpan.FromSeconds(1)); |
| | | //_timer2 = new Timer(PLCDoDeciceWork, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2)); |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | |
| | | try |
| | | { |
| | | SCDoDeviceWork(deviceId); |
| | | _deviceQueueSC.Enqueue(deviceId); |
| | | _deviceQueueSC.Enqueue(deviceId); |
| | | PLCDoDeciceWork(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | foreach (Dt_Task task in taskList) |
| | | { |
| | | WebResponseContent webResponse = JudgmentIsRelocations(task); |
| | | if (!webResponse.Status) return; |
| | | if (!webResponse.Status) |
| | | { |
| | | WriteLog.Write_Log("WMS_ç§»åºæ
é", $"ç§»åºè¿å失败å
容", "失败", $"ç§»åºå¤±è´¥,åå ï¼{webResponse.Message}"); |
| | | return; |
| | | } |
| | | |
| | | WCSginseng result = _taskService.SC_IssueTasks( |
| | | task.TaskId, |
| | |
| | | } |
| | | } |
| | | |
| | | private void PLCDoDeciceWork(object state) |
| | | private void PLCDoDeciceWork() |
| | | { |
| | | if (!Monitor.TryEnter(_taskProcessLockPLC, TASK_PROCESS_TIMEOUTPLC)) return; |
| | | try |
| | | { |
| | | // è·åå½å任塿°æ® |
| | |
| | | foreach (var task in allTasks) |
| | | { |
| | | // ä¸åPLCä»»å¡ |
| | | WCSginseng result = _taskService.PLC_IssueTasks(task.TaskId, int.Parse(task.Roadway), task.TaskNum, task.PalletCode, int.Parse(task.PalletType), task.CurrentAddress, task.NextAddress, ""); |
| | | WCSginseng result = _taskService.PLC_IssueTasks(task.TaskId, task.WarehouseId, task.TaskNum, task.PalletCode, int.Parse(task.PalletType), task.CurrentAddress, task.NextAddress, ""); |
| | | UpdateTaskStatus(task, result, (int)OutTaskStatusEnum.PLC_OutExecuting, 2); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine($"å åæºå®æï¼ä¸åè¾é线æ§è¡ä»»å¡å¤±è´¥ï¼ åå : {ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | Monitor.Exit(_taskProcessLockPLC); |
| | | } |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | task.Remark = result.Message; |
| | | task.NumberSsuances++; |
| | | //task.NumberSsuances++; |
| | | } |
| | | |
| | | _taskService.Repository.UpdateData(task); |