Beispiel #1
0
        private void SetSortingLock(int islock)
        {
            string indexcolname = "";
            string custcolname  = "";

            foreach (DataGridViewColumn column in dataGridViewXs[superTabControl1.SelectedTab.Name].Columns)
            {
                if (column.DataPropertyName.ToUpper() == "INDEXNO")
                {
                    indexcolname = column.Name;
                }
                if (column.DataPropertyName.ToUpper() == "CUSTCODE")
                {
                    custcolname = column.Name;
                }
            }


            foreach (DataGridViewRow selectedRow in dataGridViewXs[superTabControl1.SelectedTab.Name].SelectedRows)
            {
                //改变任务状态
                string          indexcolvalue   = selectedRow.Cells[indexcolname].Value.ToString();
                string          custvalue       = selectedRow.Cells[custcolname].Value.ToString();
                SortingLineTask sortingLineTask = SortingLineTask.GetSortingLineByIndex(indexcolvalue);
                sortingLineTask.ISLOCK = islock;
                sortingLineTask.SaveSortingTaskProcess(sortingLineTask.ID);
            }
            LoadOrder();
        }
Beispiel #2
0
        private void SetSortingStatus(int status)
        {
            string indexcolname = "";
            string custcolname  = "";

            foreach (DataGridViewColumn column in dataGridViewXs[superTabControl1.SelectedTab.Name].Columns)
            {
                if (column.DataPropertyName.ToUpper() == "INDEXNO")
                {
                    indexcolname = column.Name;
                }
                if (column.DataPropertyName.ToUpper() == "CUSTCODE")
                {
                    custcolname = column.Name;
                }
            }


            foreach (DataGridViewRow selectedRow in dataGridViewXs[superTabControl1.SelectedTab.Name].SelectedRows)
            {
                //改变任务状态
                string          indexcolvalue   = selectedRow.Cells[indexcolname].Value.ToString();
                string          custvalue       = selectedRow.Cells[custcolname].Value.ToString();
                SortingLineTask sortingLineTask = SortingLineTask.GetSortingLineByIndex(indexcolvalue);
                sortingLineTask.Status = status;
                if (status == 2)
                {
                    sortingLineTask.PLCADDRESS = 9;
                }
                if (status == 0)
                {
                    sortingLineTask.PLCADDRESS = 0;
                    SortingLineTaskDetail.SaveStatus(sortingLineTask.ID, "", 0);
                }

                sortingLineTask.SaveSortingTaskProcess(sortingLineTask.ID);



                //改变烟包状态
                //List<CigBoxInfo> cigBoxInfoList = CigBoxInfoList.GetBoxInfoByCustiomNo(custvalue, indexcolvalue,
                //    SortingLine.GetNonSortingLineCode());
                //foreach (CigBoxInfo cigBoxInfo in cigBoxInfoList)
                //{
                //    if (status != 2)
                //    {
                //        CigBoxInfo.SaveProcess(cigBoxInfo.ID, 0);
                //    }
                //    else
                //    {
                //        CigBoxInfo.SaveProcess(cigBoxInfo.ID, status);
                //    }
                //}
            }
        }
Beispiel #3
0
        public SortingLineTask TaskFinish()
        {
            bool                   isRun                  = false;
            SortingArrive          sortingArrive          = new SortingArrive();
            SorgingPackingFinished sorgingPackingFinished = new SorgingPackingFinished();
            SortingLineTask        sortingLineTask        = null;

            try
            {
                //扫描烟条到达信号地址区是否有已到达的任务(DB10:DBW50)
                MonitorLog monitorLog;
                for (int i = 1; i <= sortingArrive.Count; i++)
                {
                    int arrivevalue = 0;
                    //获取地址内的值
                    string a = sortingArrive[i];
                    arrivevalue = Convert.ToInt32(plc.GetPlcValue(sortingArrive[i]).Value);
                    //非0表示已有完成的客户订单
                    if (arrivevalue != 0)
                    {
                        //获取DB15中对应的分拣任务号
                        DB15Model mdl    = DB15List.dicArr.FirstOrDefault(o => o.Key == i).Value;
                        string    taskno = plc.GetPlcValue(mdl.taskNo).Value.ToString();

                        //通过任务号关联订单中的序号获取分拣订单保存
                        if (Convert.ToInt32(taskno) > 0)
                        {
                            sortingLineTask        = SortingLineTask.GetSortingLineByIndex(taskno);
                            sortingLineTask.Status = 2;
                            sortingLineTask.SaveSortingTaskProcess(sortingLineTask.ID);
                            sortingLineTask.SaveStatus();


                            //写日志
                            monitorLog             = MonitorLog.NewMonitorLog();
                            monitorLog.LOGNAME     = "INDEXNO:" + sortingLineTask.INDEXNO + " CUSTNO:" + sortingLineTask.CUSTCODE + " 分拣任务到达数据库保存";
                            monitorLog.LOGINFO     = "";
                            monitorLog.LOGLOCATION = "PLC";
                            monitorLog.LOGTYPE     = 0;
                            monitorLog.Save();
                        }
                        //成功后保存发送的烟包信息
                        //List<CigBoxInfo> cigBoxInfoList = CigBoxInfoList.GetBoxInfoByCustiomNo(sortingLineTask.CUSTCODE,
                        //    sortingLineTask.INDEXNO.ToString(), SortingLine.GetNonSortingLineCode());
                        //foreach (CigBoxInfo cigBoxInfo in cigBoxInfoList)
                        //{
                        //    CigBoxInfo.SaveProcess(cigBoxInfo.ID, 2);
                        //}

                        //写日志
                        //monitorLog = MonitorLog.NewMonitorLog();
                        //monitorLog.LOGNAME = "INDEXNO:" + cigBoxInfoList[0].IndexNO + "  分拣烟包到达保存";
                        //monitorLog.LOGINFO = "";
                        //monitorLog.LOGLOCATION = "PLC";
                        //monitorLog.LOGTYPE = 0;
                        //monitorLog.Save();


                        //查看装箱数据块中是否已修改
                        //==0表示未修改可以写数据
                        if (Convert.ToInt32(plc.GetPlcValue(sorgingPackingFinished[i]).Value) == 0)
                        {
                            //将装箱完成信号地址区中对应的出口置1(DB10:DBW0)
                            PlcValue writeVlaue = new PlcValue();
                            writeVlaue.Value = arrivevalue;
                            isRun            = plc.SetPlcValue(sorgingPackingFinished[i], writeVlaue);
                            //写值不成功返回空对象
                            if (!isRun)
                            {
                                sortingLineTask = null;
                            }
                            else
                            {
                                //写日志
                                monitorLog             = MonitorLog.NewMonitorLog();
                                monitorLog.LOGNAME     = "INDEXNO:" + sortingLineTask.INDEXNO + "  地址位" + sorgingPackingFinished[i] + ":装箱修改为1";
                                monitorLog.LOGINFO     = "";
                                monitorLog.LOGLOCATION = "PLC";
                                monitorLog.LOGTYPE     = 0;
                                monitorLog.Save();
                            }
                            break;
                        }
                        //==1表示已修改过继续下一个地址位
                        else
                        {
                            sortingLineTask = null;
                            //写日志
                            monitorLog             = MonitorLog.NewMonitorLog();
                            monitorLog.LOGNAME     = "装箱已经修改过为1";
                            monitorLog.LOGINFO     = "";
                            monitorLog.LOGLOCATION = "PLC";
                            monitorLog.LOGTYPE     = 0;
                            monitorLog.Save();
                        }
                    }
                    Thread.Sleep(50);
                }
                //break后执行
                //写日志
                //monitorLog = MonitorLog.NewMonitorLog();
                //monitorLog.LOGNAME = "分拣任务到达循环结束";
                //monitorLog.LOGINFO = "";
                //monitorLog.LOGLOCATION = "PLC";
                //monitorLog.LOGTYPE = 0;
                //monitorLog.Save();
            }
            catch (Exception ex)
            {
                //写日志
                MonitorLog monitorLog = MonitorLog.NewMonitorLog();
                monitorLog.LOGNAME     = "PLC分拣任务到达异常";
                monitorLog.LOGINFO     = ex.Message;
                monitorLog.LOGLOCATION = "PLC";
                monitorLog.LOGTYPE     = 0;
                monitorLog.Save();
                return(null);
            }

            return(sortingLineTask);
        }
Beispiel #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();
                }
            }
        }