示例#1
0
        public void ReSendTask()
        {
            if (ConnectState == true)
            {
                lock (this)
                {
                    if (CurrentTask != null && CurrentTask.GetFinish)
                    {
                        if (Write("b_O_Get_Permit", false)
                            && Write("b_O_Put_Permit", false)
                            && Write("b_I_Get_Finish", false)
                            && Write("b_I_Put_Finish", false)
                            && Write("b_O_Cancel_Task", true)
                            && WriteCancelTaskState())
                        {
                            Thread.Sleep(1000);
                            StorageDal storageDal = new StorageDal();

                            int storageQuantity = CurrentTask.TaskType == "02"
                                        && CurrentTask.NextPositionID == CurrentTask.EndPositionID ?
                                        storageDal.GetStorageQuantity(CurrentTask.EndPositionID) : 0;

                            int[] position1 = new int[2];
                            int[] type1 = new int[1];
                            int[] position2 = new int[2];
                            int[] type2 = new int[1];
                            position1[0] = CurrentTask.TravelPos2;
                            position1[1] = (int)(CurrentTask.LiftPos2 + (storageQuantity * Global.PALLET_HEIGHT));
                            type1[0] = 0;//无操作
                            position2[0] = CurrentTask.TravelPos2;
                            position2[1] = (int)(CurrentTask.LiftPos2 + (storageQuantity * Global.PALLET_HEIGHT));
                            CurrentTask.RealLiftPos2 = position2[1];
                            type2[0] = CurrentTask.NextPositionExtension + 2;//放货

                            Write("n_O_Task_Data_Position1", position1);
                            Write("n_O_Task_Data_Type1", type1[0]);
                            Write("n_O_Task_Data_Position2", position2);
                            Write("n_O_Task_Data_Type2", type2[0]);
                            Write("b_O_New_Task", true);
                            XtraMessageBox.Show("当前任务已重发!");
                        }
                        else
                        {
                            XtraMessageBox.Show("当前任务重发失败,可能无法连接到堆垛机或密集库PLC!");
                        }  
                    }
                    else if (CurrentTask != null && !CurrentTask.GetFinish && !CurrentTask.PutFinish)
                    {
                        if (Write("b_O_Get_Permit", false)
                            && Write("b_O_Put_Permit", false)
                            && Write("b_I_Get_Finish", false)
                            && Write("b_I_Put_Finish", false)
                            && Write("b_O_Cancel_Task", true)
                            && WriteCancelTaskState())
                        {
                            Thread.Sleep(1000);
                            StorageDal storageDal = new StorageDal();

                            int storageQuantity = CurrentTask.TaskType == "02"
                                        && CurrentTask.NextPositionID == CurrentTask.EndPositionID ?
                                        storageDal.GetStorageQuantity(CurrentTask.EndPositionID) : 0;

                            int[] position1 = new int[2];
                            int[] type1 = new int[1];
                            int[] position2 = new int[2];
                            int[] type2 = new int[1];
                            position1[0] = CurrentTask.TravelPos1;
                            position1[1] = CurrentTask.LiftPos1;
                            type1[0] = CurrentTask.CurrentPositionExtension + 1;//取货
                            position2[0] = CurrentTask.TravelPos2;
                            position2[1] = (int)(CurrentTask.LiftPos2 + (storageQuantity * Global.PALLET_HEIGHT));
                            CurrentTask.RealLiftPos2 = position2[1];
                            type2[0] = CurrentTask.NextPositionExtension + 2;//放货

                            Write("n_O_Task_Data_Position1", position1);
                            Write("n_O_Task_Data_Type1", type1[0]);
                            Write("n_O_Task_Data_Position2", position2);
                            Write("n_O_Task_Data_Type2", type2[0]);
                            Write("b_O_New_Task", true);
                            XtraMessageBox.Show("当前任务已重发!");
                        }
                        else
                        {
                            XtraMessageBox.Show("当前任务重发失败,可能无法连接到堆垛机或密集库PLC!");
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("当前任务不存在,或不可重发!");
                    }
                }
            }
        }
示例#2
0
        private void NewTask()
        {
            if (CurrentTask == null && Auto && !Local && !ManualControl && taskFinish)
            {
                TaskDal taskDal = new TaskDal();
                StorageDal storageDal = new StorageDal();

                foreach (var taskFactory in TaskFactories)
                {
                    if (WaitingTask.Count > 0)
                    {
                        CurrentTask = taskFactory.GetTask(Name, this.TravelPos, WaitingTask.Dequeue());
                    }
                    else
                    {
                        CurrentTask = taskFactory.GetTask(Name, this.TravelPos);
                    }

                    if (CurrentTask != null && !CheckPath())
                    {
                        WaitingTask.Enqueue(CurrentTask.ID);
                        CurrentTask = taskFactory.GetTask(Name, this.TravelPos, WaitingTask.ToArray());
                    }

                    if (CurrentTask != null && !CheckPath())
                    {
                        WaitingTask.Enqueue(CurrentTask.ID);
                        CurrentTask = null;
                    }

                    if (CurrentTask != null)
                    {
                        if (Write("b_O_Get_Permit", false)
                            && Write("b_O_Put_Permit", false)
                            && Write("b_I_Get_Finish", false)
                            && Write("b_I_Put_Finish", false)
                            && Write("b_O_Cancel_Task", true)
                            && WriteCancelTaskState())
                        {
                            int storageQuantity = CurrentTask.TaskType == "02"
                                && CurrentTask.NextPositionID == CurrentTask.EndPositionID ?
                                storageDal.GetStorageQuantity(CurrentTask.EndPositionID) : 0;

                            int[] position1 = new int[2];
                            int[] type1 = new int[1];
                            int[] position2 = new int[2];
                            int[] type2 = new int[1];
                            position1[0] = CurrentTask.TravelPos1;
                            position1[1] = CurrentTask.LiftPos1;
                            type1[0] = CurrentTask.CurrentPositionExtension + 1;//取货
                            position2[0] = CurrentTask.TravelPos2;
                            position2[1] = (int)(CurrentTask.LiftPos2 + (storageQuantity * Global.PALLET_HEIGHT));
                            CurrentTask.RealLiftPos2 = position2[1];
                            type2[0] = CurrentTask.NextPositionExtension + 2;//放货

                            Write("n_O_Task_Data_Position1", position1);
                            Write("n_O_Task_Data_Type1", type1[0]);
                            Write("n_O_Task_Data_Position2", position2);
                            Write("n_O_Task_Data_Type2", type2[0]);
                            Write("b_O_New_Task", true);

                            taskDal.UpdateTaskStateToExecuting(CurrentTask.ID);
                            CurrentTaskFactory = taskFactory;
                            break;
                        }
                        else
                        {                            
                            Logger.Error(string.Format("{0} 当前任务 [{1}] 发送失败,可能无法连接到堆垛机或密集库PLC!", Name, CurrentTask.ID));
                            CurrentTask = null;
                        }                        
                    }
                }
            }
        }