Exemplo n.º 1
0
        public async void Start(StartProcessedDelegate callback)
        {
            Stopwatch   sw        = new Stopwatch();
            Func <Task> startTask = () =>
            {
                return(Task.Run(() =>
                {
                    idleswflag = false;
                    idlesw.Stop();
                    Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "TestIdle", TestIdle.ToString());
                    TestCycle = TestSpan + TestIdle;
                    Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "TestCycle", TestCycle.ToString());
                    sw.Start();
                    TestStatus = TestStatus.Testing;
                    TestResult = TestResult.Unknow;
                    while (TestStatus == TestStatus.Testing)
                    {
                        TestSpan = Math.Round(sw.Elapsed.TotalSeconds, 2);
                        System.Threading.Thread.Sleep(100);
                    }
                }));
            };

            await startTask();

            callback(Index);
            if (!IsInSampleMode && !IsInGRRMode)
            {
                UpdateNormal();
            }

            idleswflag = true;
            idlesw.Restart();
        }
Exemplo n.º 2
0
        public async void Start1(StartProcessedDelegate callback)
        {
            Stopwatch   sw        = new Stopwatch();
            int         mResult   = -2;
            Func <Task> startTask = () =>
            {
                return(Task.Run(async() =>
                {
                    //开始动作

                    StepFlag[0] = 0;
                    TestActionSwitch[0] = true;

                    sw.Start();
                    testResult[0] = TestResult.Unknow;
                    testStatus[0] = TestStatus.Testing;
                    while (StepFlag[0] != 3)
                    {
                        if (mResult == 2)
                        {
                            TestActionSwitch[0] = false;
                            return;
                        }
                        TestSpan[0] = Math.Round(sw.Elapsed.TotalSeconds, 2);
                        await Task.Delay(50);
                    }
                    TestActionSwitch[0] = false;


                    if (result_flag[0])
                    {
                        mResult = 1;
                    }
                    else
                    {
                        mResult = 0;
                    }
                }));
            };
            Task taskDelay    = Task.Delay(TestTimeout);
            var  completeTask = await Task.WhenAny(startTask(), taskDelay);

            if (completeTask == taskDelay)
            {
                //超时退出
                mResult = 2;
            }
            UpdateTester(mResult, 0);
            callback(Index * 4 + 0);
        }
Exemplo n.º 3
0
        public async void Start1(StartProcessedDelegate callback)
        {
            Stopwatch sw      = new Stopwatch();
            int       mResult = 1;

            sw.Start();
            testResult = TestResult.Unknow;
            testStatus = TestStatus.Testing;
            for (int i = 0; i < 35; i++)
            {
                await Task.Delay(1000);

                TestSpan = Math.Round(sw.Elapsed.TotalSeconds, 2);
            }
            //UpdateTester(mResult);
            callback(Index);
        }
Exemplo n.º 4
0
        public async void Start2(StartProcessedDelegate callback)
        {
            Stopwatch   sw         = new Stopwatch();
            int         mResult    = -2;
            String      inibar     = "";
            bool        needRecord = false;
            Func <Task> startTask  = () =>
            {
                return(Task.Run(async() =>
                {
                    //开始动作

                    StepFlag[1] = 0;
                    TestActionSwitch[1] = true;

                    idleswflag2 = false;
                    idlesw2.Stop();
                    Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index * 2 + 1).ToString(), "TestIdle", TestIdle[1].ToString());
                    TestCycle[1] = TestSpan[1] + TestIdle[1];
                    Inifile.INIWriteValue(iniTesterResutPath, "Tester" + (Index * 2 + 1).ToString(), "TestCycle", TestCycle[1].ToString());

                    sw.Start();
                    testResult[1] = TestResult.Unknow;
                    testStatus[1] = TestStatus.Testing;
                    testRemarks[1] = "Normal";
                    while (StepFlag[1] != 6)
                    {
                        if (mResult == 2)
                        {
                            TestActionSwitch[1] = false;
                            return;
                        }
                        TestSpan[1] = Math.Round(sw.Elapsed.TotalSeconds, 2);
                        if (TestSpan[1] > timenomal * 1000)
                        {
                            TimeoutStauts = true;
                        }
                        await Task.Delay(50);
                    }
                    TestActionSwitch[1] = false;


                    if (pc[1] == prePassCount[1] + 1)
                    {
                        mResult = 1;
                    }
                    else
                    {
                        if (fc[1] == preFailCount[1] + 1)
                        {
                            mResult = 0;
                        }
                    }

                    if (errorcode[1].Contains("5065") || errorcode[1].Contains("5073"))
                    {
                        needRecord = false;
                    }
                    else
                    {
                        needRecord = true;
                    }
                    //if (errorcode[1].Contains("5177") || errorcode[1].Contains("5315") || errorcode[1].Contains("5316"))
                    //{
                    //    inibar = Inifile.INIGetStringValue(iniFilepath, sectionName2, "bar", "ABCDEFG");
                    //    while (inibar != TesterBracode[1])
                    //    {
                    //        await Task.Delay(500);
                    //        inibar = Inifile.INIGetStringValue(iniFilepath, sectionName2, "bar", "ABCDEFG");
                    //        if (mResult == 2)
                    //        {
                    //            return;
                    //        }
                    //    }
                    //    if (inibar == TesterBracode[1])
                    //    {
                    //        string failitem = Inifile.INIGetStringValue(iniFilepath, sectionName2, "FIRST_FAILED_SPEC", "ABCDEFG");
                    //        if (failitem == "VD_CM_RMS" || failitem == "CORR2_VD_RMS_Shape" || failitem == "CORR2_DI_DQ_Median" || failitem == "CORR2_DI_DQ_noCM_Median" || failitem == "NA")
                    //        {
                    //            testRemarks[1] = "Noise";
                    //        }
                    //        else
                    //        {
                    //            testRemarks[1] = "Normal";
                    //        }
                    //    }
                    //}
                    //else
                    //{
                    //    testRemarks[1] = "Normal";
                    //}
                }));
            };
            Task taskDelay    = Task.Delay(TestTimeout);
            var  completeTask = await Task.WhenAny(startTask(), taskDelay);

            if (completeTask == taskDelay)
            {
                //超时退出
                mResult = 2;
            }
            TimeoutStauts = false;
            if (needRecord)
            {
                UpdateTester(mResult, 1);
            }
            else
            {
                UpdateTester2(mResult, 1);
            }

            callback(Index * 2 + 1);

            idleswflag2 = true;
            idlesw2.Restart();
        }
Exemplo n.º 5
0
        public async void Start(StartProcessedDelegate callback)
        {
            Stopwatch sw           = new Stopwatch();
            int       mResult      = -2;
            int       prePassCount = 0;
            int       preFailCount = 0;
            int       pc           = 0;
            int       fc           = 0;
            string    s;

            string[]    ss;
            bool        isRestarted = false;
            Func <Task> startTask   = () =>
            {
                return(Task.Run(async() =>
                {
                    try
                    {
                        //s = udp.UdpSendthenReceive(CHKUploadStr);
                        //ss = s.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                        //await Task.Delay(100);
                        //if (ss[0] != "停止上传")
                        //{
                        //    s = udp.UdpSendthenReceive(CHKUploadStr);
                        //    ss = s.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                        //    await Task.Delay(100);
                        //    if (ss[0] != "停止上传")
                        //    {
                        //        TesterNoticEventArgs te = new TesterNoticEventArgs(Index);
                        //        OnTesterNotic(te);
                        //    }
                        //}
                        sw.Start();
                        testResult = TestResult.Unknow;
                        testStatus = TestStatus.Testing;
                        //await Task.Delay(20);
                        //mResult = 1;
                        //读当前PASS
                        s = udp.UdpSendthenReceive(PassCountStr);
                        ss = s.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                        await Task.Delay(100);
                        while (ss[0] == "nil" || ss[0] == "Udp 发送或接收错误")
                        {
                            TestSpan = Math.Round(sw.Elapsed.TotalSeconds, 2);
                            if (mResult == 2)
                            {
                                return;
                            }

                            s = udp.UdpSendthenReceive(PassCountStr);
                            ss = s.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                            await Task.Delay(100);
                        }

                        try
                        {
                            prePassCount = pc = int.Parse(ss[0]);
                        }
                        catch (Exception e)
                        {
                            Log.Default.Error("Pass转码错误", e.Message);
                        }
                        //读当前FAIL
                        s = udp.UdpSendthenReceive(FailCountStr);
                        ss = s.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                        await Task.Delay(100);
                        while (ss[0] == "nil" || ss[0] == "Udp 发送或接收错误")
                        {
                            TestSpan = Math.Round(sw.Elapsed.TotalSeconds, 2);
                            if (mResult == 2)
                            {
                                return;
                            }

                            s = udp.UdpSendthenReceive(FailCountStr);
                            ss = s.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                            await Task.Delay(100);
                        }

                        try
                        {
                            preFailCount = fc = int.Parse(ss[0]);
                        }
                        catch (Exception e)
                        {
                            Log.Default.Error("Fail转码错误", e.Message);
                        }
                        //写条码
                        while (udp.UdpSendthenReceive("setvalue:(AXValue:" + TesterBracode + ")" + BarcodeStr) != "SetValue Success")
                        {
                            TestSpan = Math.Round(sw.Elapsed.TotalSeconds, 2);
                            if (mResult == 2)
                            {
                                return;
                            }
                            await Task.Delay(200);
                        }
                        await Task.Delay(50);
                        //按开始按钮
                        while (udp.UdpSendthenReceive(StartStr) != "Action Success")
                        {
                            TestSpan = Math.Round(sw.Elapsed.TotalSeconds, 2);
                            if (mResult == 2)
                            {
                                return;
                            }
                            await Task.Delay(200);
                        }
                        await Task.Delay(200);
                        while (!(pc == prePassCount + 1 || fc == preFailCount + 1))
                        {
                            if (mResult == 2)
                            {
                                return;
                            }
                            //读PASS
                            s = udp.UdpSendthenReceive(PassCountStr);
                            ss = s.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                            await Task.Delay(100);
                            while (ss[0] == "nil" || ss[0] == "Udp 发送或接收错误")
                            {
                                TestSpan = Math.Round(sw.Elapsed.TotalSeconds, 2);
                                if (mResult == 2)
                                {
                                    return;
                                }

                                s = udp.UdpSendthenReceive(PassCountStr);
                                ss = s.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                                await Task.Delay(100);
                            }

                            try
                            {
                                pc = int.Parse(ss[0]);
                            }
                            catch (Exception e)
                            {
                                Log.Default.Error("Pass转码错误", e.Message);
                            }

                            //if (PassCount < prePassCount && PassCount == 0)
                            //{
                            //    prePassCount = PassCount;
                            //}

                            //读FAIL
                            s = udp.UdpSendthenReceive(FailCountStr);
                            ss = s.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                            await Task.Delay(100);
                            while (ss[0] == "nil" || ss[0] == "Udp 发送或接收错误")
                            {
                                TestSpan = Math.Round(sw.Elapsed.TotalSeconds, 2);
                                if (mResult == 2)
                                {
                                    return;
                                }

                                s = udp.UdpSendthenReceive(FailCountStr);
                                ss = s.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                                await Task.Delay(100);
                            }

                            try
                            {
                                fc = int.Parse(ss[0]);
                            }
                            catch (Exception e)
                            {
                                Log.Default.Error("Fail转码错误", e.Message);
                            }



                            //if (FailCount < preFailCount && FailCount == 0)
                            //{
                            //    preFailCount = FailCount;
                            //}
                            TestSpan = Math.Round(sw.Elapsed.TotalSeconds, 2);
                        }
                        if (pc == prePassCount + 1)
                        {
                            mResult = 1;
                        }
                        else
                        {
                            if (fc == preFailCount + 1)
                            {
                                mResult = 0;
                            }
                        }
                    }
                    catch
                    {
                        mResult = -1;//出错
                    }
                }
                                ));
            };
            //label_reStart:
            Task taskDelay    = Task.Delay(TestTimeout);
            var  completeTask = await Task.WhenAny(startTask(), taskDelay);

            if (completeTask == taskDelay)
            {
                //超时退出
                mResult = 2;
                if (isRestarted == false)
                {
                    //isRestarted = true;
                    //await Task.Delay(200);

                    //if (await ReStartApp())
                    //{
                    //    AppReStartEventArgs e = new AppReStartEventArgs(true, Index);
                    //    OnAppReStarted(e);
                    //    mResult = -2;
                    //    goto label_reStart;


                    //}
                    //else
                    //{
                    //    AppReStartEventArgs e = new AppReStartEventArgs(false, Index);
                    //    OnAppReStarted(e);
                    //}
                }
                Log.Default.Error("测试机" + Index.ToString() + "测试超时");
            }
            UpdateTester(mResult);
            callback(Index);
        }