Beispiel #1
0
        private void OnQueryOCV()
        {
            this.dataGridView1.DataSource = null;
            this.dataGridView2.DataSource = null;
            // ocvAccess.ocvDBConn = this.textBox5.Text;
            string palletID = this.textBox4.Text;

            if (string.IsNullOrWhiteSpace(palletID))
            {
                Console.WriteLine("托盘号为空!");
                return;
            }
            List <int> testSeqIDS = new List <int>();

            if (this.checkBox2.Checked)
            {
                testSeqIDS.Add(1);
            }
            if (this.checkBox3.Checked)
            {
                testSeqIDS.Add(2);
            }
            if (this.checkBox4.Checked)
            {
                testSeqIDS.Add(3);
            }
            if (this.checkBox5.Checked)
            {
                testSeqIDS.Add(4);
            }
            if (this.checkBox6.Checked)
            {
                testSeqIDS.Add(5);
            }
            string    reStr = "";
            DataTable dt    = ocvAccess.GetOcvTestDt(palletID, ref reStr);

            if (dt == null)
            {
                Console.WriteLine("无结果" + reStr);
                return;
            }
            else
            {
                this.dataGridView1.DataSource = dt;
            }
            DataTable dtChannel = new DataTable("通道测试结果");

            dtChannel.Columns.Add("通道号");
            dtChannel.Columns.Add("测试结果");
            List <int> reVals = new List <int>();

            if (ocvAccess.GetCheckResult(palletID, testSeqIDS, ref reVals, ref reStr))
            {
                for (int i = 0; i < reVals.Count(); i++)
                {
                    string val = "合格";
                    if (reVals[i] == 1)
                    {
                        val = "合格";
                    }
                    else if (reVals[i] == 2)
                    {
                        val = "异常";
                    }
                    else
                    {
                        val = "空";
                    }
                    dtChannel.Rows.Add(new string[] { (i + 1).ToString(), val });
                }
                this.dataGridView2.DataSource = dtChannel;
            }
            else
            {
                Console.WriteLine("错误" + reStr);
            }
        }
Beispiel #2
0
        public override bool ExeBusiness(ref string reStr)
        {
            if (!nodeEnabled)
            {
                return(true);
            }
            if (!devStatusRestore)
            {
                devStatusRestore = DevStatusRestore();
            }
            if (!devStatusRestore)
            {
                return(false);
            }
            if (db2Vals[0] != 2)
            {
                db1ValsToSnd[0] = 1;
            }

            //任务撤销
            if (db2Vals[1] == 3 && db1ValsToSnd[1] != 3)
            {
                if (this.currentTask != null && this.currentTaskPhase > 0)
                {
                    this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.任务撤销.ToString();
                    this.currentTask.FinishTime = System.DateTime.Now;
                    ctlTaskBll.Update(this.currentTask);

                    logRecorder.AddDebugLog(this.nodeName, string.Format("分拣任务{0}撤销", this.currentTask.TaskID));
                    currentTaskDescribe   = "分拣任务撤销,等待任务撤销信号复位";
                    this.currentTask      = null;
                    this.currentTaskPhase = 0;
                }
                Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count());
                db1ValsToSnd[1] = 3;//

                return(true);
            }
            if (db1ValsToSnd[1] == 3 && db2Vals[1] != 2)
            {
                //任务撤销命令复位,应答也复位
                db1ValsToSnd[1] = 1;
            }

            if (!GraspTaskRequire(ref reStr))
            {
                return(false);
            }
            if (this.currentTask == null)
            {
                return(true);
            }
            switch (this.currentTaskPhase)
            {
            case 1:
            {
                currentTaskDescribe = "开始执行分拣任务";
                // int ocvProcessID = 1;//zwx,临时
                List <int> ocvTestSeqIDS  = new List <int>();
                int        testValStIndex = 2;
                if (this.nodeID == "6002")
                {
                    testValStIndex = 3;
                    string curMesProcessID = this.productOnlineBll.GetProcessIDOfPallet(this.rfidUID);
                    if (string.IsNullOrWhiteSpace(curMesProcessID))
                    {
                        this.db1ValsToSnd[2] = 1;        //OCV2
                    }
                    else
                    {
                        int curSeq  = SysCfg.SysCfgModel.stepSeqs.IndexOf(curMesProcessID);
                        int ocv2Seq = SysCfg.SysCfgModel.stepSeqs.IndexOf("PS-70");
                        if (curSeq <= ocv2Seq)
                        {
                            this.db1ValsToSnd[2] = 1;        //OCV2
                        }
                        else
                        {
                            this.db1ValsToSnd[2] = 2;        //OCV4
                        }
                    }
                }

                if (this.nodeID == "6001")
                {
                    //检测OCV1数据
                    ocvTestSeqIDS.Add(1);
                }
                else if (this.nodeID == "6002")
                {
                    if (this.db1ValsToSnd[2] == 1)
                    {
                        ocvTestSeqIDS.Add(2);          //检测OCV2数据
                    }
                    else
                    {
                        ocvTestSeqIDS.Add(5);         //检测OCV4数据
                    }
                }
                else
                {
                    //检测分容,OCV3数据
                    ocvTestSeqIDS.Add(3);
                    ocvTestSeqIDS.Add(4);
                }
                //查询测试结果

                List <int> vals = new List <int>();
                if (SysCfg.SysCfgModel.SimMode)
                {
                    for (int i = 0; i < 36; i++)
                    {
                        vals.Add(1);
                    }
                }
                else
                {
                    //List<int> ocvTestSeqIDS = new List<int>();

                    if (!ocvAccess.GetCheckResult(this.rfidUID, ocvTestSeqIDS, ref vals, ref reStr))
                    {
                        if (db1ValsToSnd[0] != 4)
                        {
                            logRecorder.AddDebugLog(nodeName, string.Format("查询OCV测试结果失败,{0},{1}", this.rfidUID, reStr));
                        }
                        db1ValsToSnd[0] = 4;
                        break;
                    }
                }

                //发送分拣参数
                for (int i = 0; i < Math.Max(36, vals.Count()); i++)
                {
                    Int16 re = (short)vals[i];
                    db1ValsToSnd[testValStIndex + i] = re;
                }
                db1ValsToSnd[0]     = 2;
                currentTaskDescribe = "分拣参数发送完成";
                this.currentTaskPhase++;
                this.currentTask.TaskPhase = this.currentTaskPhase;
                this.ctlTaskBll.Update(this.currentTask);
                break;
            }

            case 2:
            {
                //等待任务完成
                currentTaskDescribe = "等待分拣完成";
                if (db2Vals[1] != 2)
                {
                    break;
                }

                //UpdateOnlineProductInfo(this.rfidUID);
                AddProduceRecord(this.rfidUID, string.Format("分拣:{0}", nodeName));
                this.currentTaskPhase++;

                this.currentTask.TaskPhase = this.currentTaskPhase;
                this.ctlTaskBll.Update(this.currentTask);
                db1ValsToSnd[1] = 2;
                break;
            }

            case 3:
            {
                currentTaskDescribe = "分拣流程完成,等待分拣完成信号复位";
                if (this.db2Vals[1] != 1)
                {
                    break;
                }
                DevCmdReset();
                this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.已完成.ToString();
                this.ctlTaskBll.Update(this.currentTask);

                this.currentTask    = null;
                currentTaskPhase    = 0;
                currentTaskDescribe = "等待执行下一个任务";
                break;
            }

            default:
                break;
            }
            return(true);
        }