Ejemplo n.º 1
0
        private void 设置分拣未完成ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (taskStatus == TaskStatus.Run)
            {
                MessageBox.Show("请先暂停任务下达!");
            }
            else
            {
                if (MessageBox.Show("是否设置状态为未完成", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    SetSortingStatus(0);
                    LoadOrder();
                    FJMainForm.Instance.CBox.LoadCigBox();
                    SortingTaskIssued sortingTaskIssued = SortingTaskIssued.GetSortingTaskIssued("0");
                    sortingTaskIssued.PLCFLAG = 0;
                    sortingTaskIssued.Save();

                    FJMainForm.Instance.CSortingMain.ResetCmain();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 加载烟仓控件
        /// </summary>
        public void LoadLinBox()
        {
            //建立空的烟仓控件
            SortingLineBoxList sortingLineBoxList = SortingLineBoxList.GetLineBoxList();

            c_Cubes  = new List <C_Cube>();
            cShelves = new Dictionary <string, C_Shelf>();
            //cbefortUpShelves = new List<C_Shelf>();
            //cbefortDownShelves =  new List<C_Shelf>();
            //cafterUpShelves = new List<C_Shelf>();
            //cafterDownShelves = new List<C_Shelf>();


            f1.Controls.Clear();
            f2.Controls.Clear();
            f3.Controls.Clear();
            f4.Controls.Clear();
            f5.Controls.Clear();
            f6.Controls.Clear();
            f7.Controls.Clear();
            f8.Controls.Clear();

            SortingSubLineList sortingSubLineList = SortingSubLineList.GetSubSortingLineList();

            if (sortingSubLineList.Count == 1)
            {
                f1.Width += f2.Width;
                top.SetColumnSpan(f1, 3);
                panel1.Visible = false;
                top.SetColumnSpan(f3, 3);
                panel2.Visible = false;
                bottom.SetColumnSpan(f5, 3);
                panel4.Visible = false;
                bottom.SetColumnSpan(f7, 3);
                panel5.Visible = false;
                f2.Visible     = false;
                f4.Visible     = false;
                f6.Visible     = false;
                f8.Visible     = false;
            }


            if (sortingLineBoxList.Count > 0)
            {
                foreach (SortingLineBox sortingLineBox in sortingLineBoxList)
                {
                    if (sortingLineBox.PARENTLINEBOX == "1" && sortingLineBox.ABANDONPARENT == "2" && sortingLineBox.SublineSeq == 1)
                    {
                        C_Shelf cShelf = CreateShelf(sortingLineBox);
                        cShelves.Add(cShelf.Name, cShelf);


                        cShelf.Margin = new Padding(0, 0, 1, 0);
                        InitLineBoxControl(cShelf, f1);
                    }
                    else if (sortingLineBox.PARENTLINEBOX == "1" && sortingLineBox.ABANDONPARENT == "2" && sortingLineBox.SublineSeq == 2)
                    {
                        C_Shelf cShelf = CreateShelf(sortingLineBox);
                        cShelves.Add(cShelf.Name, cShelf);

                        cShelf.Margin = new Padding(0, 0, 1, 0);
                        InitLineBoxControl(cShelf, f1);
                    }
                    else if (sortingLineBox.PARENTLINEBOX == "1" && sortingLineBox.ABANDONPARENT == "1" && sortingLineBox.SublineSeq == 1)
                    {
                        C_Shelf cShelf = CreateShelf(sortingLineBox);
                        cShelves.Add(cShelf.Name, cShelf);

                        cShelf.Margin = new Padding(0, 0, 1, 0);
                        InitLineBoxControl(cShelf, f3);
                    }
                    else if (sortingLineBox.PARENTLINEBOX == "1" && sortingLineBox.ABANDONPARENT == "1" && sortingLineBox.SublineSeq == 2)
                    {
                        C_Shelf cShelf = CreateShelf(sortingLineBox);
                        cShelves.Add(cShelf.Name, cShelf);

                        cShelf.Margin = new Padding(0, 0, 1, 0);
                        InitLineBoxControl(cShelf, f3);
                    }
                    else if (sortingLineBox.PARENTLINEBOX == "2" && sortingLineBox.ABANDONPARENT == "2" && sortingLineBox.SublineSeq == 1)
                    {
                        C_Shelf cShelf = CreateShelf(sortingLineBox);
                        cShelves.Add(cShelf.Name, cShelf);

                        cShelf.Margin = new Padding(0, 0, 1, 0);
                        InitLineBoxControl(cShelf, f5);
                    }
                    else if (sortingLineBox.PARENTLINEBOX == "2" && sortingLineBox.ABANDONPARENT == "2" && sortingLineBox.SublineSeq == 2)
                    {
                        C_Shelf cShelf = CreateShelf(sortingLineBox);
                        cShelves.Add(cShelf.Name, cShelf);

                        cShelf.Margin = new Padding(0, 0, 1, 0);
                        InitLineBoxControl(cShelf, f5);
                    }
                    else if (sortingLineBox.PARENTLINEBOX == "2" && sortingLineBox.ABANDONPARENT == "1" && sortingLineBox.SublineSeq == 1)
                    {
                        C_Shelf cShelf = CreateShelf(sortingLineBox);
                        cShelves.Add(cShelf.Name, cShelf);

                        cShelf.Margin = new Padding(0, 0, 1, 0);
                        InitLineBoxControl(cShelf, f7);
                    }
                    else if (sortingLineBox.PARENTLINEBOX == "2" && sortingLineBox.ABANDONPARENT == "1" && sortingLineBox.SublineSeq == 2)
                    {
                        C_Shelf cShelf = CreateShelf(sortingLineBox);
                        if (sortingLineBox.LineBoxCode == "123")
                        {
                            cShelf = CreateShelf(sortingLineBox);
                        }
                        else
                        {
                            cShelf = CreateShelf(sortingLineBox);
                        }
                        cShelves.Add(cShelf.Name, cShelf);

                        cShelf.Margin = new Padding(0, 0, 1, 0);
                        InitLineBoxControl(cShelf, f7);
                    }
                }
            }

            //如果不能下达任务根据老的列表,给数码管发信号
            SortingTaskIssued sortingTaskIssued = SortingTaskIssued.GetSortingTaskIssued("0");

            if (sortingTaskIssued.PLCFLAG == 1)
            {
                ATOPTagSdk.instance.SetOrderNixielight(SortingLineTaskQueue.GetInstance().SortingLineTasks);
                UpdateLineboxNum();
            }

            //是否显示烟仓容量
            if (chkshowqty.Checked)
            {
                chkshowqty_CheckedChanged(null, null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 分拣任务到达出口流程
        /// </summary>
        public void FinishTask()
        {
            //到达任务只要开始后就不会停止
            while (true)
            {
                SortingTaskIssued sortingTaskIssued = SortingTaskIssued.GetSortingTaskIssued("0");

                if (ATOPTagSdk.Tags != null)
                {
                    //提示前台界面已按下的数量
                    if (OnUpdateCSortingMainNumEvent != null)
                    {
                        OnUpdateCSortingMainNumEvent.Invoke(null, new UpdateCSortingMainNumEventArgs(ATOPTagSdk.Tags));
                    }
                }


                //按钮按完进行后续操作
                if (ATOPTagSdk.instance.GetPlcPressTagReady())
                {
                    if (sortingTaskIssued.PLCFLAG != 0)
                    {
                        if (ATOPTagSdk.Tags != null)
                        {
                            foreach (KeyValuePair <int, Tag> tag in ATOPTagSdk.Tags)
                            {
                                SortingLineTaskDetail.SaveStatus(tag.Value.TaskNo, tag.Value.LineboxCode.ToString(), 2);
                            }
                            SortingLineTaskQueue.GetInstance().SaveTaskFinish();

                            //更改下达任务标识为可下达
                            sortingTaskIssued = SortingTaskIssued.GetSortingTaskIssued("0");
                            if (sortingTaskIssued.PLCFLAG != 0)
                            {
                                sortingTaskIssued.PLCFLAG = 0;
                                sortingTaskIssued.Save();

                                //播放语音提示
                                SoundPlayer player = new SoundPlayer();
                                player.SoundLocation = Application.StartupPath + "\\Sound\\订单完成.wav";
                                player.Load();
                                player.Play();
                            }
                        }
                    }

                    //发送当前分拣完成信号给PLC,让小车移动
                    //判断是否可以更改PLC的当前分拣完成信号
                    //判断PLC中订单序号等于系统中队尾的序号
                    //if (operateOpcAndSoft.GetCubeRun() == FJMainForm.Instance.CSortingMain.c_Cubes.Last().labindexno)
                    //{
                    //operateOpcAndSoft.SetCubeRun();
                    //}

                    if (OnTaskMoved != null)
                    {
                        OnTaskMoved.Invoke(null, new EventArgs());
                    }

                    //清除所有电子标签内容
                    ATOPTagSdk.Tags = null;
                }

                Thread.Sleep(500);
            }
        }
Ejemplo n.º 4
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();
                }
            }
        }