예제 #1
0
        /// <summary>
        /// 货道测试工作主线程
        /// </summary>
        private void AsileTestTrd()
        {
            int intErrCode = 0;

            m_IsTrdOper = true;

            this.tbTitle.Dispatcher.Invoke(new Action(() =>
            {
                ControlForm(false);
            }));

            switch (m_TestType)
            {
            case "0":    // 单货道测试
                m_TestTotalNum++;
                intErrCode = PubHelper.p_BusinOper.TestAsile(m_TestCode);
                this.tbTitle.Dispatcher.Invoke(new Action(() =>
                {
                    tbTestTotalNum.Text = m_TestTotalNum.ToString();
                    if (intErrCode == 0)
                    {
                        currentGoodsWay.SetSecondText(m_Title_AsileNormal);
                    }
                    else
                    {
                        currentGoodsWay.SetSecondText(m_Title_AsileFail_Code.Replace("{N}", intErrCode.ToString()));
                    }
                }));

                break;

            case "1":    // 托盘测试
            case "2":    // 整机测试
                if (m_TestType == "2")
                {
                    this.tbTitle.Dispatcher.Invoke(new Action(() =>
                    {
                        m_TrayCount = panelTray.Children.Count;
                    }));
                }
                bool blnAsileIsNull = false;    // 货道格子是否为空 False:不为空 True:为空
                for (int trayIndex = 0; trayIndex < m_TrayCount; trayIndex++)
                {
                    if (m_IsStopTest)
                    {
                        break;
                    }

                    if (m_TestType == "2")
                    {
                        this.tbTitle.Dispatcher.Invoke(new Action(() =>
                        {
                            var palletButton       = panelTray.Children[trayIndex] as RadioButton;
                            palletButton.IsChecked = true;
                        }));

                        if (m_IsLoopTest)
                        {
                            // 整机测试做循环测试
                            if (trayIndex == m_TrayCount - 1)
                            {
                                trayIndex = -1;
                            }
                        }
                    }

                    Thread.Sleep(200);
                    for (int asileIndex = 0; asileIndex < m_AsileCount; asileIndex++)
                    {
                        if (m_IsStopTest)
                        {
                            break;
                        }
                        blnAsileIsNull = true;
                        m_TestTotalNum++;
                        this.tbTitle.Dispatcher.Invoke(new Action(() =>
                        {
                            GoodsWayProduct productControl = (GoodsWayProduct)panelAsile.Children[asileIndex];
                            if (productControl.CurrentGoodsWayProduct != null)
                            {
                                blnAsileIsNull = false;
                                if (currentGoodsWay != null)
                                {
                                    currentGoodsWay.ToNormal();
                                }
                                //
                                currentGoodsWay = productControl;
                                currentGoodsWay.ToCheck();

                                m_TestCode          = currentGoodsWay.CurrentGoodsWayProduct.PaCode;
                                tbNowAsileCode.Text = m_TestCode;
                                currentGoodsWay.SetSecondText(m_Testing);
                            }
                        }));
                        if (m_TestType == "1")
                        {
                            // 如果是托盘循环测试
                            if (m_IsLoopTest)
                            {
                                if (asileIndex == m_AsileCount - 1)
                                {
                                    asileIndex = -1;
                                }
                            }
                        }

                        if (!blnAsileIsNull)
                        {
                            intErrCode = PubHelper.p_BusinOper.TestAsile(m_TestCode);
                            this.tbTitle.Dispatcher.Invoke(new Action(() =>
                            {
                                tbTestTotalNum.Text = m_TestTotalNum.ToString();
                                if (intErrCode == 0)
                                {
                                    currentGoodsWay.SetSecondText(m_Title_AsileNormal);
                                }
                                else
                                {
                                    currentGoodsWay.SetSecondText(m_Title_AsileFail_Code.Replace("{N}", intErrCode.ToString()));
                                }
                            }));
                        }
                    }
                }

                break;
            }

            this.tbTitle.Dispatcher.Invoke(new Action(() =>
            {
                ControlForm(true);
            }));

            m_IsTrdOper = false;
        }