| | |
| | | SpeStackerCrane commonStackerCrane = (SpeStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (commonStackerCrane != null) |
| | | { |
| | | commonStackerCrane.Communicator.IsReadAfterWrite = false; |
| | | #region ä¿¡å·äº¤äºå¤ç |
| | | //Heartbeat(commonStackerCrane); |
| | | ShuttleCarSignal(commonStackerCrane); |
| | | #endregion |
| | | |
| | | #region ä»»å¡é»è¾å¤ç |
| | | if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.Onlinestate) == (short)Onlinestate.online |
| | | && commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WriteStatus) == (short)WriteStatus.Permit) |
| | | #region ä»»å¡å®æ |
| | | DeviceProtocolDetailDTO? deviceProtocolDetail = commonStackerCrane.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.ProtocalDetailValue == commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.CompleteStatus).ToString() && x.DeviceProParamName == nameof(StackerCraneTaskCommandR.CompleteStatus)); |
| | | if (deviceProtocolDetail != null) |
| | | { |
| | | #region ä»»å¡å®æ |
| | | DeviceProtocolDetailDTO? deviceProtocolDetail = commonStackerCrane.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.ProtocalDetailValue == commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.CompleteStatus).ToString() && x.DeviceProParamName == nameof(StackerCraneTaskCommandR.CompleteStatus)); |
| | | if (deviceProtocolDetail != null) |
| | | { |
| | | MethodInfo? method = GetType().GetMethod(deviceProtocolDetail.ProtocolDetailType); |
| | | if (method != null) method.Invoke(this, new object[] { commonStackerCrane }); |
| | | } |
| | | #endregion |
| | | |
| | | MethodInfo? method = GetType().GetMethod(deviceProtocolDetail.ProtocolDetailType); |
| | | if (method != null) method.Invoke(this, new object[] { commonStackerCrane }); |
| | | } |
| | | #endregion |
| | | #region ä»»å¡é»è¾å¤ç |
| | | var onlinestate = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.Onlinestate); |
| | | var writeStatus = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WriteStatus); |
| | | if (onlinestate == (short)Onlinestate.online && writeStatus == (short)WriteStatus.Permit) |
| | | { |
| | | #region æ¥è¯¢ä»»å¡,é»è¾å¤ç |
| | | if (Enum.Parse<RunStatus>(commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.RunStatus).ToString()) == RunStatus.Standby) |
| | | { |
| | | var Task = _taskService.GetTaskState(TaskType: (int)TaskOtherTypeEnum.RelocationCar);//è·åç§»è½¦ä»»å¡ |
| | | var Task1 = _taskService.GetTaskState((int)CarChargingTask.ShuttleCar_Finish, (int)TaskOtherTypeEnum.RelocationCarCharging);//è·å移车å
çµä»»å¡ |
| | | if (Task != null) |
| | | { |
| | | if (Task.TaskState == (int)TaskCarStatusEnum.ShuttleCar_Finish) SendTask(commonStackerCrane, Task); |
| | | } |
| | | else if (Task1 != null) |
| | | { |
| | | SendTask(commonStackerCrane, Task1); |
| | | } |
| | | else |
| | | { |
| | | Dt_Task? task = GetTask(commonStackerCrane);//è·åå åæºåºå
¥åºä»»å¡ |
| | | if (task != null) |
| | | { |
| | | if (task.TaskType == (int)TaskInboundTypeEnum.Inbound) |
| | | if (task.TaskType == (int)TaskRelocationTypeEnum.Relocation)//ç§»åºä»»å¡å¤æç»ç¹æ¯å¦æç©¿æ¢è½¦ |
| | | { |
| | | var ShuttleCar = GetShuttleCarInfo(task.TargetAddress);//å
¥åºä»»å¡å¤ææ¯å¦åå¨ç©¿æ¢è½¦ |
| | | if (task.IsPickPlace && ShuttleCar != null)//移走 |
| | | var ShuttleCar = GetShuttleCarInfo(task.TargetAddress);//ç§»åºä»»å¡å¤æç»ç¹æ¯å¦æç©¿æ¢è½¦ |
| | | if (task.TargetIsPickPlace && ShuttleCar != null)//移走 |
| | | { |
| | | _taskService.AddRelocationCarTask(task.TargetAddress, "", ShuttleCar.ShuttleCarCode); |
| | | } |
| | | else if (!task.IsPickPlace && ShuttleCar == null) |
| | | else if (!task.TargetIsPickPlace && ShuttleCar == null) |
| | | { |
| | | _taskService.AddRelocationCarTask("", task.TargetAddress); |
| | | } |
| | | else |
| | | { |
| | | task.ShuttleCarCode = ShuttleCar?.ShuttleCarCode; |
| | | _taskService.UpdateData(task); |
| | | SendTask(commonStackerCrane, task);//ä¸åå åæºä»»å¡ |
| | | } |
| | | } |
| | | else if (task.TaskType == (int)TaskInboundTypeEnum.Inbound) |
| | | { |
| | | var ShuttleCar = GetShuttleCarInfo(task.TargetAddress);//å
¥åºä»»å¡å¤æç»ç¹æ¯å¦æç©¿æ¢è½¦ |
| | | if (task.TargetIsPickPlace && ShuttleCar != null)//移走 |
| | | { |
| | | _taskService.AddRelocationCarTask(task.TargetAddress, "", ShuttleCar.ShuttleCarCode); |
| | | } |
| | | else if (!task.TargetIsPickPlace && ShuttleCar == null) |
| | | { |
| | | _taskService.AddRelocationCarTask("", task.TargetAddress); |
| | | } |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(nameof(CommonStackerCraneJob) + ":" + ex.ToString()); |
| | | //Console.WriteLine(nameof(CommonStackerCraneJob) + ":" + ex.ToString()); |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | |
| | | if (stackerCraneTaskCommand != null) |
| | | { |
| | | bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); |
| | | bool worktype = commonStackerCrane.SetValue(StackerCraneDBName.WorkType, task.TaskType == (int)TaskOtherTypeEnum.RelocationCar ? (short)WorkType.Car : (short)WorkType.Cargo); |
| | | bool worktype = commonStackerCrane.SetValue(StackerCraneDBName.WorkType, task.TaskType >= (int)TaskOtherTypeEnum.RelocationCar ? (short)WorkType.Car : (short)WorkType.Cargo); |
| | | if (sendFlag && worktype) |
| | | { |
| | | if (commonStackerCrane.SetValue(StackerCraneDBName.CommandSend, sendFlag)) |
| | | { |
| | | if (task.TaskType != (int)TaskOtherTypeEnum.RelocationCar) commonStackerCrane.LastTaskType = task.TaskType; |
| | | //if (task.TaskType != (int)TaskOtherTypeEnum.RelocationCar) |
| | | commonStackerCrane.LastTaskType = task.TaskType; |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | } |
| | | // DeviceProDTO? deviceProDTO = commonStackerCrane.DeviceProDTOs.FirstOrDefault((DeviceProDTO x) => x.DeviceProParamName == StackerCraneDBName.CommandSend.ToString()); |
| | | //if (deviceProDTO != null) |
| | | //{ |
| | | // if (commonStackerCrane.Communicator.Write<bool>(deviceProDTO.DeviceProAddress, sendFlag)) |
| | | // { |
| | | // if (task.TaskType != (int)TaskOtherTypeEnum.RelocationCar) commonStackerCrane.LastTaskType = task.TaskType; |
| | | // _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | // } |
| | | //} |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | //if (_taskService.GetTaskInfo(commonStackerCrane.CurrentTaskNum) != null) |
| | | //{ |
| | | Console.Out.WriteLine($"å åæºä»»å¡å®æï¼[{commonStackerCrane.CurrentTaskNum}]ï¼{DateTime.Now}"); |
| | | var Status = _taskService.StackCraneTaskCompleted(commonStackerCrane.CurrentTaskNum).Status; |
| | | commonStackerCrane.SetValue(StackerCraneDBName.ConfirmComplete, Status); |
| | | //Console.Out.WriteLine($"å åæºä»»å¡å®æï¼[{commonStackerCrane.CurrentTaskNum}]ï¼{DateTime.Now}"); |
| | | _taskService.StackCraneTaskCompleted(commonStackerCrane.CurrentTaskNum); |
| | | commonStackerCrane.SetValue(StackerCraneDBName.ConfirmComplete, true); |
| | | //} |
| | | } |
| | | } |
| | |
| | | /// <returns></returns> |
| | | private Dt_Task? GetTask(SpeStackerCrane commonStackerCrane) |
| | | { |
| | | Dt_Task task; |
| | | Dt_Task task = _taskService.QueryStackerCraneRelocationTask(commonStackerCrane.DeviceCode);//è·åç§»åºä»»å¡ |
| | | if (task != null) return task; |
| | | if (commonStackerCrane.LastTaskType == null) |
| | | { |
| | | task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode); |
| | |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | if (conveyorLine.IsOccupied(router.ChildPosi))//åºåºç«å°æªè¢«å ç¨ |
| | | ConveyorLineTaskCommandR command = conveyorLine.ReadCustomer<ConveyorLineTaskCommandR>(router.ChildPosi); |
| | | if (command.Status == 4) |
| | | { |
| | | return task; |
| | | } |
| | | //if (conveyorLine.IsOccupied(router.ChildPosi))//åºåºç«å°æªè¢«å ç¨ |
| | | //{ |
| | | // return task; |
| | | //} |
| | | } |
| | | else |
| | | { |