Esempio n. 1
0
 private bool FinishPut()
 {
     try
     {
         if (CurrentTask != null)
         {
             if (CurrentTask.NextPositionID == CurrentTask.EndPositionID)
             {
                 WriteFinishPutState(CurrentTask.NextPositionName, "0");
             }
             else
             {
                 TaskDal taskDal = new TaskDal();
                 string nextPositionName = taskDal.GetTaskNextTwoPosition(CurrentTask.ID);
                 WriteFinishPutState(CurrentTask.NextPositionName, nextPositionName);
             }
             return true;
         }
         return false;
     }
     catch (Exception ex)
     {
         Logger.Error("SRM.FinishPut 出错,原因:" + ex.Message + "/n" + ex.StackTrace);
     }
     return false;
 }
 public TaskInfo GetTask(string srmName, int travelPos, int[] waitingTasks)
 {
     TaskDal taskDal = new TaskDal();
     return taskDal.GetNewGeneraTask(srmName, travelPos, waitingTasks);
 }
Esempio n. 3
0
 public void CancelTask()
 {
     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())
                 {
                     TaskDal taskDal = new TaskDal();
                     taskDal.UpdateTaskStateToWaiting(CurrentTask.ID);
                     CurrentTask = null;
                     CurrentTaskFactory = null;
                     XtraMessageBox.Show("当前任务已取消!");
                 }
                 else
                 {
                     XtraMessageBox.Show("当前任务取消失败,可能无法连接到堆垛机或密集库PLC!");
                 }                      
             }
             else if (CurrentTask != null && CurrentTask.GetFinish)
             {
                 XtraMessageBox.Show("当前任务已取货完成,请处理完故障后选择重发任务!");
             }
             else
             {
                 XtraMessageBox.Show("当前任务不存在,或不可取消!");
             }
         }
     }
 }
Esempio n. 4
0
        private void FinishTask()
        {
            try
            {
                if (CurrentTask != null)
                {
                    using (TransactionScopeManager TM = new TransactionScopeManager(true, IsolationLevel.Serializable))
                    {
                        TaskDal taskDal = new TaskDal();
                        PositionDal positionDal = new PositionDal();

                        taskDal.TransactionScopeManager = TM;
                        positionDal.TransactionScopeManager = TM;

                        positionDal.UpdateHasGoodsToFalse(CurrentTask.CurrentPositionID);
                        positionDal.UpdateHasGoodsToTrue(CurrentTask.NextPositionID);

                        taskDal.UpdateTaskPosition(CurrentTask.ID, CurrentTask.NextPositionID);
                        taskDal.UpdateTaskPositionStateToArrived(CurrentTask.ID);
                        taskDal.UpdateTaskStateToWaiting(CurrentTask.ID);                        

                        if (CurrentTask.NextPositionID == CurrentTask.EndPositionID
                            && (CurrentTask.TaskType == "03" || CurrentTask.EndPositionType != "03")
                            && (CurrentTask.TaskType == "03" || CurrentTask.EndPositionType != "04"))//小品种,异型烟,由手持PDA完成;
                        {
                            if (CurrentTask.TaskType == "02")
                            {
                                string orderType = taskDal.GetOrderType(CurrentTask.ID);
                                string orderID = taskDal.GetOrderID(CurrentTask.ID);
                                int allotID = taskDal.GetAllotID(CurrentTask.ID);
                                string originCellCode = taskDal.GetOriginCellCode(CurrentTask.ID);
                                string targetCellCode = taskDal.GetTargetCellCode(CurrentTask.ID);
                                string originStorageCode = taskDal.GetOriginStorageCode(CurrentTask.ID);
                                string targetStorageCode = taskDal.GetTargetStorageCode(CurrentTask.ID);

                                RestClient rest = new RestClient();
                                if (!rest.FinishTask(CurrentTask.ID, orderType, orderID, allotID,originCellCode,targetCellCode, originStorageCode, targetStorageCode))
                                {
                                    Logger.Error(string.Format("{0} 完成[{1}]任务失败!", Name, CurrentTask.ID));
                                    return;
                                }
                                else
                                {
                                    taskDal.UpdateTaskStateToExecuted(CurrentTask.ID);
                                }
                            }
                            else
                            {
                                if (!Ops.Write(memoryServiceName, memoryItemName, CurrentTask.ID))
                                {
                                    Logger.Error(string.Format("{0} 完成[{1}]任务失败!", Name, CurrentTask.ID));
                                    return;
                                }
                            }
                        }
                        TM.Commit();

                        CurrentTask = null;
                        CurrentTaskFactory = null;                        
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("SRM.FinishTask 出错,原因:" + ex.Message + "/n" + ex.StackTrace);
            }
        }
Esempio n. 5
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;
                        }                        
                    }
                }
            }
        }
Esempio n. 6
0
        private bool CheckPath()
        {
            if (Name == "SRM01" && CurrentTask.NextPositionName == "1005")
            {
                TaskDal taskDal = new TaskDal();
                string nextTwoPositionName = taskDal.GetTaskNextTwoPosition(CurrentTask.ID);
                int[] data = new int[] { Convert.ToInt32(nextTwoPositionName), 1 };

                object obj1 = Ops.Read(SrmInfo.PlcServiceName, "O_S01_Path_Request");
                if (obj1 is Array)
                {
                    Array arrayObj1 = (Array)obj1;
                    if (arrayObj1.Length == 2
                           && data[0] == Convert.ToInt32(arrayObj1.GetValue(0))
                           && data[1] == Convert.ToInt32(arrayObj1.GetValue(1)))
                    {
                        object obj2 = Ops.Read(SrmInfo.PlcServiceName, "I_S01_Path_Allow");
                        if (obj2 is Array)
                        {
                            Array arrayObj2 = (Array)obj2;
                            if (arrayObj2.Length == 2
                               && data[0] == Convert.ToInt32(arrayObj2.GetValue(0))
                               && data[1] == Convert.ToInt32(arrayObj2.GetValue(1)))
                            {
                                return true;
                            }
                        }
                    }
                    else if (arrayObj1.Length == 2
                           && 0 == Convert.ToInt32(arrayObj1.GetValue(0))
                           && 0 == Convert.ToInt32(arrayObj1.GetValue(1)))
                    {
                        if (Ops.Write(SrmInfo.PlcServiceName, "O_S01_Path_Request", data))
                        {
                            Thread.Sleep(1000);
                            object obj3 = Ops.Read(SrmInfo.PlcServiceName, SrmInfo.GetAllowName);
                            if (obj3 is Array)
                            {
                                Array arrayObj3 = (Array)obj3;
                                if (arrayObj3.Length == 2
                                   && data[0] == Convert.ToInt32(arrayObj3.GetValue(0))
                                   && data[1] == Convert.ToInt32(arrayObj3.GetValue(1)))
                                {
                                    return true;
                                }
                            }
                        }
                    }
                }
                return false;
            }
            else if (Name == "SRM03" && CurrentTask.NextPositionName == "1002")
            {
                TaskDal taskDal = new TaskDal();
                string nextTwoPositionName = taskDal.GetTaskNextTwoPosition(CurrentTask.ID);
                int[] data = new int[] { Convert.ToInt32(nextTwoPositionName), 1 };

                object obj1 = Ops.Read(SrmInfo.PlcServiceName, "O_S03_Path_Request");
                if (obj1 is Array)
                {
                    Array arrayObj1 = (Array)obj1;
                    if (arrayObj1.Length == 2
                           && data[0] == Convert.ToInt32(arrayObj1.GetValue(0))
                           && data[1] == Convert.ToInt32(arrayObj1.GetValue(1)))
                    {
                        object obj2 = Ops.Read(SrmInfo.PlcServiceName, "I_S03_Path_Allow");
                        if (obj2 is Array)
                        {
                            Array arrayObj2 = (Array)obj2;
                            if (arrayObj2.Length == 2
                               && data[0] == Convert.ToInt32(arrayObj2.GetValue(0))
                               && data[1] == Convert.ToInt32(arrayObj2.GetValue(1)))
                            {
                                return true;
                            }
                        }
                    }
                    else if (arrayObj1.Length == 2
                           && 0 == Convert.ToInt32(arrayObj1.GetValue(0))
                           && 0 == Convert.ToInt32(arrayObj1.GetValue(1)))
                    {
                        if (Ops.Write(SrmInfo.PlcServiceName, "O_S03_Path_Request", data))
                        {
                            Thread.Sleep(1000);
                            object obj3 = Ops.Read(SrmInfo.PlcServiceName, SrmInfo.GetAllowName);
                            if (obj3 is Array)
                            {
                                Array arrayObj3 = (Array)obj3;
                                if (arrayObj3.Length == 2
                                   && data[0] == Convert.ToInt32(arrayObj3.GetValue(0))
                                   && data[1] == Convert.ToInt32(arrayObj3.GetValue(1)))
                                {
                                    return true;
                                }
                            }
                        }
                    }
                }
                return false;
            }
            else
            {
                return true;
            }
        }
Esempio n. 7
0
 private bool CheckPositionTask()
 {
     TaskDal taskDal = new TaskDal();
     if (CurrentTask != null && taskDal.CheckPositionTask(CurrentTask.CurrentPositionID))
     {
         return true;
     }
     else
     {
         Logger.Error(string.Format("{0}取货时检查到当前位置同时存在多个任务或无任务,而当前任务可能是错误或无效任务!",Name));
         return false; 
     }
 }
 internal void Read()
 {
     if (!ScanManagerView.InitCigaretteScanInfoStack()) return;
     TaskDal task = new TaskDal();
     var table = task.FindStockInProduct();
     if (table.Rows.Count > 0)
     {
         foreach (DataRow row in table.Rows)
         {
             ProductDal productDal = new ProductDal();
             CigaretteScanInfo info = productDal.FindProductForScan(Convert.ToString(row["product_code"]));
             if (info != null && !CigaretteScanInfoStack.Keys.Contains(Convert.ToString(row["product_code"])))
             {
                 info.ProductCode = Convert.ToString(row["product_code"]);
                 info.ProductName = Convert.ToString(row["product_name"]);
                 info.Quantity = Convert.ToInt32(row["task_quantity"]);
                 info.Index = 0;
                 info.State = "0";
                 lock (CigaretteScanInfoStack)
                 {
                     CigaretteScanInfoStack.Add(info.ProductCode, info);
                 }
             }
             else if (info == null)
             {
                 XtraMessageBox.Show(string.Format("当前卷烟 {0} : {1} 没有尺寸信息,请先行进行维护!",
                     Convert.ToString(row["product_code"]), Convert.ToString(row["product_name"]))
                     , "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 XtraMessageBox.Show(string.Format("当前卷烟 {0} : {1} 已有扫码任务!",
                     Convert.ToString(row["product_code"]), Convert.ToString(row["product_name"]))
                     , "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         AutomationContext.Write(memoryServiceName, memoryItemName, CigaretteScanInfoStack);
     }
     else
     {
         XtraMessageBox.Show("当前没有卷烟入库任务!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
     }
     Refresh();
 }
 internal void New()
 {
     if (!ScanManagerView.InitCigaretteScanInfoStack()) return;
     TaskDal task = new TaskDal();
     var table = task.FindStockInProduct();
     if (table.Rows.Count > 0)
     {
         CreateScanTaskDialog createScanTaskDialog = new CreateScanTaskDialog(table);
         if (createScanTaskDialog.ShowDialog() == DialogResult.OK && createScanTaskDialog.Quantity > 0)
         {
             ProductDal productDal = new ProductDal();
             CigaretteScanInfo info = productDal.FindProductForScan(createScanTaskDialog.SelectedCigaretteCode);
             if (info != null && !CigaretteScanInfoStack.Keys.Contains(createScanTaskDialog.SelectedCigaretteCode))
             {
                 info.ProductCode = createScanTaskDialog.SelectedCigaretteCode;
                 info.ProductName = createScanTaskDialog.SelectedCigaretteName;
                 info.Quantity = createScanTaskDialog.Quantity;
                 info.Index = 0;
                 info.State = "0";
                 lock (CigaretteScanInfoStack)
                 {
                     CigaretteScanInfoStack.Add(info.ProductCode, info);
                 }
                 AutomationContext.Write(memoryServiceName, memoryItemName, CigaretteScanInfoStack);
             }
             else if (info == null)
             {
                 XtraMessageBox.Show("当前卷烟没有尺寸信息,请先行进行维护!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 XtraMessageBox.Show("当前卷烟已有扫码任务!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     else
     {
         XtraMessageBox.Show("当卷烟没有入库任务!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     Refresh();
 }
 public TaskInfo GetTask(string srmName, int travelPos, int[] waitingTasks)
 {
     TaskDal taskDal = new TaskDal();
     return taskDal.GetNewSmallSpeciesTask(srmName, "");
 }
 public TaskInfo GetTask(string srmName, int travelPos, int[] waitingTasks)
 {
     TaskDal taskDal = new TaskDal();
     return taskDal.GetNewAbnormityTask(srmName);
 }