Beispiel #1
0
 private void btnDownload_Click(object sender, EventArgs e)
 {
     if (FJMainForm.Instance.cSortingTask.taskStatus != TaskStatus.Stop)
     {
         MessageBox.Show("下达任务未停止无法下载新的任务!");
         return;
     }
     btnDownload.Enabled = false;
     btnExport.Enabled   = false;
     thread = new Thread(new ParameterizedThreadStart(DownloadData.Start));
     if (thread != null && IsSelectSortingLine())
     {
         if (SortingLineTaskList.IsSortingFinish())
         {
             StartDownloads();
         }
         else
         {
             if (SortingLineTaskList.IsSortingStart())
             {
                 if (MessageBox.Show("分拣已开始,重新下载新清除数据是否继续?", "警告", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     StartDownloads();
                 }
             }
             else
             {
                 if (MessageBox.Show("当前订单还未开始分拣,重新下载新清除数据是否继续?", "警告", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     StartDownloads();
                 }
             }
         }
     }
     else
     {
         MessageBox.Show("任务条件未选择");
         btnDownload.Enabled = true;
         btnExport.Enabled   = true;
     }
 }
Beispiel #2
0
        /// <summary>
        /// 分拣任务下达流程
        /// </summary>
        private void ScanTask()
        {
            SortingLineTask sortingLineTask = null;

            while (taskStatus == TaskStatus.Run)
            {
                try
                {
                    //是否有未完成的订单
                    if (!SortingLineTaskList.IsSortingFinish())
                    {
                        //判断标识是否可以下达任务,表示上一次任务是否已经完成
                        SortingTaskIssued sortingTaskIssued = SortingTaskIssued.GetSortingTaskIssued("0");
                        if (sortingTaskIssued.PLCFLAG == 0)
                        {
                            //PLC信息小车是否走到位,或者已扫描到分户盒
                            //分拣工可能先放分户盒,但程序必须判断上次任务是否完成
                            //if (operateOpcAndSoft.GetCubeReady())
                            //{
                            // if(operateOpcAndSoft.GetCubeIndexno > FJMainForm.Instance.CSortingMain.c_Cubes.Last().labindexno)
                            //    int a = operateOpcAndSoft.GetCubeReady() -
                            //            FJMainForm.Instance.CSortingMain.c_Cubes.Last().labindexno;
                            //}
                            if (operateOpcAndSoft.GetCubeReady())
                            {
                                SortingLineTaskQueue.GetInstance().Move();

                                //重新加载一次任务队列
                                SortingLineTaskQueue.GetInstance().LoadSortingLineTasks();

                                //获取最小排序号的订单
                                sortingLineTask = SortingLineTask.GetMinSortingLineTask();

                                //将最小订单放入队列中进行分拣
                                SortingLineTaskQueue.GetInstance().Enqueue(sortingLineTask);
                                SortingLineTaskQueue.GetInstance().CreateCubesModel();


                                //发送卷烟数量到数码管
                                ATOPTagSdk.instance.SetOrderNixielight(SortingLineTaskQueue.GetInstance().SortingLineTasks);

                                //通知前台界面显示数码管数量
                                if (OnUpdateCSortingMainNumEvent != null)
                                {
                                    OnUpdateCSortingMainNumEvent.Invoke(null,
                                                                        new UpdateCSortingMainNumEventArgs(ATOPTagSdk.Tags));
                                }


                                //如果不是用用来补足的空任务
                                if (sortingLineTask.INDEXNO > 0)
                                {
                                    //保存任务状态为已下达
                                    sortingLineTask.Status = 1;
                                    sortingLineTask.SaveSortingTaskProcess(sortingLineTask.ID);
                                }

                                //将下达任务标志位设置成已下达
                                sortingTaskIssued.PLCFLAG     = 1;
                                sortingTaskIssued.PLCTASKNO   = sortingLineTask.INDEXNO.ToString();
                                sortingTaskIssued.ORDERNUMBER = sortingLineTask.SumOrderNumber();
                                sortingTaskIssued.Save();

                                //写日志
                                monitorLog             = MonitorLog.NewMonitorLog();
                                monitorLog.LOGNAME     = "任务下达";
                                monitorLog.LOGINFO     = "  任务号:" + sortingLineTask.INDEXNO.ToString().PadRight(10);
                                monitorLog.LOGLOCATION = "数据库";
                                monitorLog.LOGTYPE     = 0;
                                monitorLog.Save();
                                this.BeginInvoke(new MethodInvoker(LoadOrder));
                                //FJMainForm.Instance.CSortingMain.UpdateLineboxCapacity();
                            }
                        }
                    }
                    else
                    {
                        //写日志
                        MonitorLog monitorLog = MonitorLog.NewMonitorLog();
                        monitorLog.LOGNAME     = "任务下达";
                        monitorLog.LOGINFO     = "分拣任务全部完成";
                        monitorLog.LOGLOCATION = "数据库";
                        monitorLog.LOGTYPE     = 0;
                        monitorLog.Save();

                        //发送分拣完成到上位机
                        //FJMainForm.Instance.SortingFinish();
                        SortingLineTaskQueue.GetInstance().CubesModel.Clear();
                        Array.Clear(SortingLineTaskQueue.GetInstance().SortingLineTasks, 0, SortingLineTaskQueue.GetInstance().QueueMaxCount);
                        SortingLineTaskQueue.GetInstance().InvokeOnUpdateCubeEvent();

                        SoundPlayer player = new SoundPlayer();
                        player.SoundLocation = Application.StartupPath + "\\Sound\\分拣结束.wav";
                        player.Load();
                        player.Play();

                        break;//跳出下达循环
                    }
                    Thread.Sleep(500);
                }
                catch (Exception e)
                {
                    //写日志
                    monitorLog = MonitorLog.NewMonitorLog();
                    if (sortingLineTask != null)
                    {
                        monitorLog.LOGNAME = "任务号" + sortingLineTask.INDEXNO + " 分拣任务下达异常";
                    }
                    else
                    {
                        monitorLog.LOGNAME = "任务号未知" + " 分拣任务下达异常";
                    }
                    monitorLog.LOGINFO     = e.Message;
                    monitorLog.LOGLOCATION = "数据库";
                    monitorLog.LOGTYPE     = 0;
                    monitorLog.Save();
                }
            }
        }