Exemplo n.º 1
0
        public static TestInfo DoSeq5_6(VSLeakDetector myLD, ref TestInfo myTestInfo, ref UUTData myuutdata)
        {
            Boolean status = false;
            //VSLeakDetector myLD = new VSLeakDetector(comPort);
            //myLD.iteSlot = iteSlot;
            string retval = string.Empty;
            int    step   = 1;

            Helper.comPort = comPort;

            try
            {
                switch (myTestInfo.TestLabel)
                {
                case "5.6.1 Internal_cal-leak":
                {
                    //Access full command

                    Helper.SendCommand(myLD, ref status, "XYZZY", "ok");


                    //@@ Define the internal helium standard leak rate @@//

                    Trace.WriteLine(iteSlot + "Define the internal helium standard leak rate...");
                    if (myLD.iteSlot.Contains("P1"))
                    {
                        status = Helper.DoThis(myLD, ref myTestInfo, UUT_Parameters.Stdleak1 + " INIT-STDLEAK", "ok", 1, "ok");
                    }
                    else
                    {
                        status = Helper.DoThis(myLD, ref myTestInfo, UUT_Parameters.Stdleak2 + " INIT-STDLEAK", "ok", 1, "ok");
                    }

                    break;
                }

                case "5.6.2 Stdleak_expiration":
                {
                    //@@ Enter the internal helium standard leak expiration date @@//

                    Trace.WriteLine(iteSlot + "Enter the internal helium standard leak expiration date...");
                    if (myLD.iteSlot.Contains("P1"))
                    {
                        status = Helper.DoThis(myLD, ref myTestInfo, UUT_Parameters.Stdleak_Exp_date1 + " INIT-LKEXPIRE", "ok", 1, "ok");
                    }
                    else
                    {
                        status = Helper.DoThis(myLD, ref myTestInfo, UUT_Parameters.Stdleak_Exp_date2 + " INIT-LKEXPIRE", "ok", 1, "ok");
                    }
                    break;
                }

                case "5.6.3 Cal-leak_setup":
                {
                    step = 1;


                    //@@ Verify the expiration date @@//

                    Trace.WriteLine(iteSlot + "Verify the configured expiration date...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "?LKEXPIRE", "ok", step, "ok");
                    step++;
                    // add checking allowable expiration period. Fresh Cal leak must be more than 13 months usable period: Hairus added
                    //myLD = new VSLeakDetector(comPort);
                    //myLD.iteSlot = iteSlot;
                    //myLD.Open();
                    string expiryDateStr = myLD.Query("?LKEXPIRE", ref status);
                    var    arrays        = expiryDateStr.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                    var    month         = Convert.ToInt32(Convert.ToInt32(arrays[0]).ToString("00"));
                    var    day           = Convert.ToInt32(Convert.ToInt32(arrays[1]).ToString("00"));
                    var    year          = Convert.ToInt32(arrays[2]);
                    if (status)
                    {
                        var expiryDate = new DateTime(year, month, day);
                        var monthDiff  = expiryDate.Subtract(DateTime.Now).TotalDays / 30;
                        myTestInfo.ResultsParams[step].Result = Convert.ToInt32(monthDiff).ToString();
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "-1";
                    }
                    //myLD.Close();

                    step++;


                    //@@ Enter leak temperature @@//

                    Trace.WriteLine(iteSlot + "Enter the leak temperature...");
                    if (myLD.iteSlot.Contains("P1"))
                    {
                        status = Helper.DoThis(myLD, ref myTestInfo, UUT_Parameters.Stdleak_temp1 + " INIT-LEAKTEMP", "ok", step, "ok");
                    }
                    else
                    {
                        status = Helper.DoThis(myLD, ref myTestInfo, UUT_Parameters.Stdleak_temp2 + " INIT-LEAKTEMP", "ok", step, "ok");
                    }
                    step++;


                    //@@ Verify leak temperature @@//

                    Trace.WriteLine(iteSlot + "Verify the configured leak temperature...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "?LEAKTEMP", "ok", step, "ok");
                    step++;
                    //myLD = new VSLeakDetector(comPort);
                    //myLD.iteSlot = iteSlot;
                    //myLD.Open();
                    var tempStr = myLD.Query("?LEAKTEMP", ref status);
                    //myLD.Close();
                    //myTestInfo.ResultsParams[step].Nominal = UUT_Parameters.Stdleak_temp;
                    //myTestInfo.ResultsParams[step].SpecMax = UUT_Parameters.Stdleak_temp;
                    //myTestInfo.ResultsParams[step].SpecMin = UUT_Parameters.Stdleak_temp;
                    if (status)
                    {
                        myTestInfo.ResultsParams[step].Result = tempStr.Replace("ok", "").Trim();
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "ERROR";
                    }
                    step++;


                    //@@ Enter leak temperature factor @@//

                    Trace.WriteLine(iteSlot + "Enter the leak temperature factor...");
                    if (myLD.iteSlot.Contains("P1"))
                    {
                        status = Helper.DoThis(myLD, ref myTestInfo, UUT_Parameters.Stdleak_factor1 + " INIT-TEMPFACTOR", "ok", step, "ok");
                    }
                    else
                    {
                        status = Helper.DoThis(myLD, ref myTestInfo, UUT_Parameters.Stdleak_factor2 + " INIT-TEMPFACTOR", "ok", step, "ok");
                    }
                    step++;


                    //@@ Verify the leak temperature factor @@//

                    Trace.WriteLine(iteSlot + "Verify the leak temperature factor...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "?TEMPFACTOR", "ok", step, "ok");
                    step++;
                    //myLD = new VSLeakDetector(comPort);
                    //myLD.iteSlot = iteSlot;
                    //myLD.Open();
                    var tempFactorStr = myLD.Query("?TEMPFACTOR", ref status);
                    // myLD.Close();
                    if (status)
                    {
                        myTestInfo.ResultsParams[step].Result = tempFactorStr.Replace("ok", "").Trim();
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "ERROR";
                    }
                    step++;


                    //@@ Set to full calibration @@//

                    Trace.WriteLine(iteSlot + "Run full calibration...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "0 INIT-QUICK-CAL", "ok", step, "0");
                    step++;


                    break;
                }

                case "5.6.4 Ion_source":
                {
                    step = 1;

                    while (step <= myTestInfo.ResultsParams.NumResultParams)
                    {
                        //@@ Sets the ion voltage of the ion source. Preceded by a three-digit number (counts) in the range 0-255. @@//

                        Trace.WriteLine(iteSlot + "Sets the ion voltage of the ion source...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "90 INIT-ION", "ok", step, "ok");
                        step++;


                        /*@@ Sets the value of the gain used for adjusting the helium signal to match a calibration standard leak.
                         * Preceded by a two-digit number with a decimal point after the first digit, in the range 1.0 to 6.0 @@*/

                        Trace.WriteLine(iteSlot + "Sets the value of the gain used for adjusting the helium signal to match a calibration standard leak...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "1.0 INIT-GAIN", "ok", step, "ok");
                        step++;


                        //@@ Send command 'LINEAR' to the UUT @@//

                        Trace.WriteLine(iteSlot + "Sets the leak rate analog output voltage to Linear...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "LINEAR", "ok", step, "ok");
                        step++;


                        //@@ Sets the Internal Calibrated Leak as the leak to be used during calibration. @@//

                        Trace.WriteLine(iteSlot + "Sets the Internal Calibrated Leak as the leak to be used during calibration.");

                        status = Helper.DoThis(myLD, ref myTestInfo, "INTERNAL", "ok", step, "ok");
                        step++;
                    }

                    break;
                }

                case "5.6.5 Setup_Parameters":
                {
                    step = 1;

                    /*@@ Reports seven lines, each begins with a <cr><lf>.
                     * The first line reports the turbo pump speed with the RPM value or OFF.
                     * The second line reports the selected manual leak rate range, and the ranging method as auto or manual.
                     * The third line reports the least sensitive leak rate range.
                     * The fourth line reports the reject set point leak rate.
                     * The fifth line reports the internal calibrated leak rate value.
                     * The sixth line reports the DAC output method as Linear, Log(2V), or Log(3V).
                     * The seventh line reports the active filament status as One or Two, followed by Lit or Out. @@*/

                    Trace.WriteLine(iteSlot + "Obtain and verify the setup parameters of the UUT...");
                    retval = Helper.SendCommand(myLD, ref status, "?SETUP", "ok");

                    if (status == true)
                    {
                        //Obtain turbo speed in RPM
                        string[] response1 = retval.Split(new string[] { "(RPM): ", " \n\rrange" }, StringSplitOptions.RemoveEmptyEntries);
                        //Obtain stdleak rate
                        string[] response2 = retval.Split(new string[] { "stdleak     ", "\n\routput" }, StringSplitOptions.RemoveEmptyEntries);

                        Setup_turbospeed = Convert.ToInt32(response1[1]);
                        Setup_stdleak    = response2[1];

                        //Retrieve the data for setup parameters from the UUT and compare them with the values that wished to be set
                        if (myLD.iteSlot.Contains("P1"))
                        {
                            if (Setup_turbospeed == Seq5_4.Speed && Setup_stdleak == UUT_Parameters.Stdleak1)
                            {
                                myTestInfo.ResultsParams[step].Result = "ok";
                                Trace.WriteLine(iteSlot + "Test point complete.");
                            }
                            else
                            {
                                myTestInfo.ResultsParams[step].Result = "FAILED";
                                throw new Exception("Test point failed.");
                            }
                        }
                        else
                        {
                            if (Setup_turbospeed == Seq5_4.Speed && Setup_stdleak == UUT_Parameters.Stdleak2)
                            {
                                myTestInfo.ResultsParams[step].Result = "ok";
                                Trace.WriteLine(iteSlot + "Test point complete.");
                            }
                            else
                            {
                                myTestInfo.ResultsParams[step].Result = "FAILED";
                                throw new Exception("Test point failed.");
                            }
                        }
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                        throw new Exception("Test point failed.");
                    }

                    break;
                }

                case "5.6.6 System_Recheck":
                {
                    //@@ Wait for system ready. if the system is ready, value '-1' will be returned, else '0' . The timeout is 3 mins. @@//

                    Trace.WriteLine(iteSlot + "Wait for system to get ready...");

                    status = Helper.Wait_SystemReady(myLD);

                    if (status == true)
                    {
                        myTestInfo.ResultsParams[1].Result = "ok";
                    }
                    else
                    {
                        myTestInfo.ResultsParams[1].Result = "FAILED";
                    }


                    /*@@ Verify the reading of the initialization parameters
                     * Responds with four lines. Each begins with a <cr><lf>.
                     * The first line reports the ion chamber value.
                     * The second line reports the emission value.
                     * The third line reports the value of the offset variable.
                     * The fourth line reports the gain value. @@*/

                    Trace.WriteLine(iteSlot + "Obtain and verify the initialization parameters of the UUT...");
                    retval = Helper.SendCommand(myLD, ref status, "?ALL", "ok");
                    retval = retval.Replace("\r", "");
                    retval = retval.Replace("\n", "");

                    if (status == true)
                    {
                        //Obtain ionchamber value
                        string[] response1 = retval.Split(new string[] { "IONCHAMBER ", "EMISSION" }, StringSplitOptions.RemoveEmptyEntries);
                        //Obtain emmision current
                        string[] response2 = retval.Split(new string[] { "EMISSION ", "OFFSET" }, StringSplitOptions.RemoveEmptyEntries);
                        //Obtain midstage offset variable
                        string[] response3 = retval.Split(new string[] { "OFFSET ", "GAIN" }, StringSplitOptions.RemoveEmptyEntries);
                        string[] response5 = response3[1].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                        //Obtain gain value
                        string[] response4 = retval.Split(new string[] { "GAIN ", "ok" }, StringSplitOptions.RemoveEmptyEntries);


                        Ionchamber       = Convert.ToSingle(response1[1]);
                        Emmisioncurrent  = Convert.ToSingle(response2[1]);
                        OffsetContraflow = Convert.ToInt32(response5[0]);
                        OffsetMidstage   = Convert.ToInt32(response5[1]);
                        Gain             = Convert.ToSingle(response4[1]);

                        Trace.WriteLine(iteSlot + "Ionchamber = " + Ionchamber + "   Emmission Current = " + Emmisioncurrent + "   Offset = " + OffsetMidstage + "   Gain = " + Gain);
                        myTestInfo.ResultsParams[2].Result = Ionchamber.ToString();
                        myTestInfo.ResultsParams[3].Result = Emmisioncurrent.ToString();
                        myTestInfo.ResultsParams[4].Result = Gain.ToString();
                        myTestInfo.ResultsParams[5].Result = OffsetContraflow.ToString();
                        myTestInfo.ResultsParams[6].Result = OffsetMidstage.ToString();

                        //Retrieve the data for initialization parameters from the UUT and compare them with the values that wished to be set
                        //if (Ionchamber >= Convert.ToSingle(myTestInfo.TestParams[1].Value) && Ionchamber <= Convert.ToSingle(myTestInfo.TestParams[2].Value) && Emmisioncurrent >= Convert.ToSingle(myTestInfo.TestParams[3].Value) && Emmisioncurrent <= Convert.ToSingle(myTestInfo.TestParams[4].Value) && Offset >= Convert.ToInt32(myTestInfo.TestParams[5].Value) && Offset <= Convert.ToInt32(myTestInfo.TestParams[6].Value) && Gain == Convert.ToSingle(myTestInfo.TestParams[7].Value))
                        //{
                        //    myTestInfo.ResultsParams[step].Result = "ok";
                        //    Trace.WriteLine(iteSlot + "Test point complete.");
                        //}
                        //else
                        //{
                        //    myTestInfo.ResultsParams[step].Result = "FAILED";
                        //    throw new Exception("Test point failed.");
                        //}
                    }
                    else
                    {
                        myTestInfo.ResultsParams[0].Result = "FAILED";
                        throw new Exception("Error sending ?ALL command");
                    }
                }
                break;

                case "5.6.7 Rough_&_Stablize4cal":
                {
                    step = 1;

                    //while (step <= myTestInfo.ResultsParams.NumResultParams)
                    //{
                    //@@ Vent the UUT to atmosphere @@//

                    Trace.WriteLine(iteSlot + "Vent the UUT to atmosphere...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "VENT", "ok", step, "ok");
checkagain:
                    retval = Helper.SendCommand(myLD, ref status, "?PRESSURES", "ok");

                    string[] resp     = retval.Split(new string[] { "(mTorr): ", "\r\nSpectrometer" }, StringSplitOptions.RemoveEmptyEntries);
                    int      Pressure = Convert.ToInt32(resp[1]);


                    Trace.WriteLine(iteSlot + "Pressure: " + Pressure + "mTorr   System Pressure: ");
                    // commented out below manual limit checking, use test executive to do the limit checking and display the result correctly
                    if (!(Pressure >= 700000 && Pressure <= 760000))
                    {
                        Thread.Sleep(2000);
                        goto checkagain;
                    }
                    // Hairus added to make sure vented properly
                    //myLD.Open();
                    Thread.Sleep(1000);
                    step++;

                    //myLD.WaitForAtmosphericPressure(700000, 30000);
                    //double pressure = myLD.GetTestPortPressure();
                    //while (pressure < 700000)
                    //{
                    //    pressure = myLD.GetTestPortPressure();

                    //}
                    //if (myLD.trigger == false)
                    //myTestInfo.ResultsParams[step].Result = "notok";

                    //myLD.Close();


                    //@@ Rough the UUT @@//

                    Trace.WriteLine(iteSlot + "Rough the UUT...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "ROUGH", "ok", step, "ok");

                    Thread.Sleep(2000);
                    step++;

                    //@@ Wait for a stable leak rate reading. Reports the current Leak Rate, Pressures and Valve state. The timeout is 5 mins @@//

                    Trace.WriteLine(iteSlot + "Wait for a stable leak rate reading during FINE TEST...");
                    //myLD = new VSLeakDetector(comPort);
                    //myLD.iteSlot = iteSlot;
                    //myLD.Open();

                    Thread.Sleep(500);

                    int count = 1;
repeat:

                    // status = Helper.DoThis(myLD, ref myTestInfo, "?VALVESTATE", "MIDSTAGE", step, "ok");
                    string check = Helper.SendCommand(myLD, ref status, "?VALVESTATE", "MIDSTAGE");

                    if (check.Contains("MIDSTAGE"))
                    {
                    }
                    else
                    {
                        Thread.Sleep(1000);
                        count++;
                        if (count == 60)
                        {
                            goto failed;
                        }
                        goto repeat;
                    }
                    //bool returnValue = myLD.WaitForFineTest(ref retval);

                    // Wait for stabilized reading
                    //bool isStabilized = myLD.WaitForStabilizedReading(ref retval);
                    //double leakReading = Convert.ToDouble(retval);
                    //if (isStabilized)
failed:
                    if (status)
                    {
                        myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        bool   isStabilized = myLD.WaitForStabilizedReading(ref retval);
                        double leakReading  = Convert.ToDouble(retval);
                        if (isStabilized)
                        {
                            if (leakReading > 5E-9)
                            {
                                myTestInfo.ResultsParams[step].Result = "notok";
                            }
                            else
                            {
                                myTestInfo.ResultsParams[step].Result = "ok";
                            }
                        }
                    }

                    //myLD.Close();

                    //    int timeout = 1;

                    //while (timeout > 0)
                    //{
                    //    myLD.Write("?LPV");

                    //    retval = myLD.Read();

                    //    if (retval.Contains("MIDSTAGE"))
                    //    {
                    //        int stability = 1;

                    //        string[] response = retval.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                    //        double previous_leakrate = Convert.ToDouble(response[1]);

                    //        while (timeout <= Convert.ToInt32(myTestInfo.TestParams[1].Value))
                    //        {
                    //            myLD.Write("?LPV");
                    //            retval = myLD.Read();

                    //            response = retval.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                    //            string[] response2 = response[1].Split(new string[] { "E" }, StringSplitOptions.RemoveEmptyEntries);

                    //            Leakrate = Convert.ToDouble(response[1]);
                    //            Exponent = Convert.ToDouble(response2[1]);

                    //            //Acceptable range
                    //            if (Exponent >= -10 && Exponent <= -9)
                    //            {
                    //                if (Leakrate >= (previous_leakrate - 2 * Math.Pow(10, Exponent)) && Leakrate <= (previous_leakrate + 2 * Math.Pow(10, Exponent)))
                    //                {
                    //                    stability++;
                    //                }
                    //                else
                    //                {
                    //                    previous_leakrate = Leakrate;
                    //                    stability = 0;
                    //                }
                    //                //If the leak rate maintain and stabilize within the acceptable range declared above, the test will pass
                    //                if (stability > Convert.ToInt32(myTestInfo.TestParams[2].Value))
                    //                {
                    //                    myTestInfo.ResultsParams[step].Result = "ok";
                    //                    Trace.WriteLine(iteSlot + "Test point complete.");

                    //                    goto Done;
                    //                }
                    //                //timer
                    //                timeout++;
                    //                Thread.Sleep(1000);
                    //            }
                    //            else
                    //                timeout++;
                    //        }
                    //    }
                    //    //if the leak rate is still unstable after 4 minutes, the test will fail
                    //    if (timeout > Convert.ToInt32(myTestInfo.TestParams[1].Value))
                    //    {
                    //        myTestInfo.ResultsParams[step].Result = "FAILED";
                    //        throw new Exception("Test point failed.");
                    //    }
                    //    //timer
                    //    Thread.Sleep(1000);
                    //    timeout++;
                    //}

                    //Done:
                    //step++;
                }
                break;

                //}
                case "5.6.8 Calibration":
                {
                    step = 1;

                    while (step <= myTestInfo.ResultsParams.NumResultParams)
                    {
                        /*@@ Initiates a Full or Fast calibration depending on system settings.
                         * The CPU software tunes, then adjusts the gain so that the current helium signal causes the current leak rate measurement to be the same
                         * as the most recently input using INIT-STDLEAK. If the gain is 2.9 or higher, a normal calibration is performed. Success is indicated by
                         * the normal ok response. @@*/

                        Trace.WriteLine(iteSlot + "Initiates a FULL or FAST calibration based on system configurations...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "CALIBRATE", "ok", step, "ok");
                        step++;


                        //@@ Wait for 979 Calibration VI @@//

                        status = Helper.Wait_FineTest(myLD);

                        if (status == true)
                        {
                            myTestInfo.ResultsParams[step].Result = "ok";
                        }
                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                        }

                        step++;
                    }

                    break;
                }

                case "5.6.9 Internal-leak_Calibration":
                {
                    step   = 1;
                    retval = "";
                    bool isStdLeakState = false;
                    //while (step <= myTestInfo.ResultsParams.NumResultParams)
                    //{
                    //@@ Report and verify the status of the last calibration. @@//

                    Trace.WriteLine(iteSlot + "Report and verify the status of the last calibration...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "?CALOK", "Yesok", step, "ok");
                    step++;


                    //@@ Turn ON internal calibrate leak @@//
                    Thread.Sleep(5000);
                    Trace.WriteLine(iteSlot + "Open the stdleak...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "STDLEAK", "ok", step, "ok");
                    step++;


                    //@@ Gives UUT time to read the STD Leak @@// Read_Delay
                    //myLD = new VSLeakDetector(comPort);
                    //myLD.iteSlot = iteSlot;
                    //myLD.Open();
                    int count = 0;
again:
                    //    bool isStdLeakState = myLD.WaitForStdLeakState(ref retval);
                    Thread.Sleep(8000);
                    isStdLeakState = Helper.DoThis(myLD, ref myTestInfo, "?VALVESTATE", "STDLEAK", step, "ok");

                    if (!isStdLeakState)
                    {
                        Thread.Sleep(1000);
                        count++;
                        if (count == 5)
                        {
                            isStdLeakState = false;
                        }
                        else
                        {
                            goto again;
                        }
                    }
                    //     myLD.WaitForStabilizedReading(ref retval, 60, 0.97, 10);
                    //myLD.Close();
                    Trace.WriteLine(iteSlot + "Provide time for the UUT to read the Stdleak...");
                    Thread.Sleep(5000);
                    //      if (isStdLeakState)
                    //          myTestInfo.ResultsParams[step].Result = "ok";
                    //      else
                    //          myTestInfo.ResultsParams[step].Result = "not StdLeak";
                    //      Trace.WriteLine(iteSlot + "Test point complete.");

                    step++;

                    int stdleakfailcount = 1;
                    //@@ Get leak rate @@//
recheckstdleak:
                    Trace.WriteLine(iteSlot + "Obtain the leak rate...");
                    retval = Helper.SendCommand(myLD, ref status, "?LEAK", "ok");
                    string[] response = retval.Split(new string[] { "?LEAK ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                    Leakrate = Convert.ToDouble(response[0]);

                    Trace.WriteLine(iteSlot + "Measured leakrate = " + Leakrate + "Std .cc/s");
                    // changes to recheck before test YS Wong 18 Jul 2018

                    /*
                     *                          if (status == true)
                     *                          {
                     *                              string[] response = retval.Split(new string[] { "?LEAK ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                     *                              Leakrate = Convert.ToDouble(response[0]);
                     *
                     *                              Trace.WriteLine(iteSlot + "Measured leakrate = " + Leakrate + "Std .cc/s");
                     *                              myTestInfo.ResultsParams[step].Result = "ok";
                     *                              Trace.WriteLine(iteSlot + "Test point complete.");
                     *                          }
                     *
                     *                          else
                     *                          {
                     *                              myTestInfo.ResultsParams[step].Result = "FAILED";
                     *                              throw new Exception("Test point failed.");
                     *                          }
                     *
                     *                          step++;
                     */


                    //@@ Compare the leak rate with stdleak rate @@//

                    Trace.WriteLine(iteSlot + "Compare the obtained leak rate with the stdleak installed...");
                    retval = Helper.SendCommand(myLD, ref status, "?STDLEAKt", "ok");

                    double stdleakt    = 0;
                    double exp_stdleak = 0;

                    if (status == true)
                    {
                        string[] resp      = retval.Split(new string[] { "?STDLEAKt ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                        string[] response2 = response[0].Split(new string[] { "E" }, StringSplitOptions.RemoveEmptyEntries);

                        stdleakt    = Convert.ToDouble(resp[0]);
                        exp_stdleak = Convert.ToDouble(response2[1]);
                    }
                    // hairus added to get comparison stdleak properly
                    double maxLeakDiff = stdleakt + 0.2E-7;
                    double minLeakDiff = stdleakt - 0.2E-7;



                    if (!((Leakrate >= minLeakDiff) & (Leakrate <= maxLeakDiff)))
                    {
                        if (stdleakfailcount >= 4)
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                            step++;
                            myTestInfo.ResultsParams[step].SpecMax = maxLeakDiff.ToString();
                            myTestInfo.ResultsParams[step].SpecMin = minLeakDiff.ToString();
                            myTestInfo.ResultsParams[step].Nominal = stdleakt.ToString();
                            myTestInfo.ResultsParams[step].Result  = Leakrate.ToString();
                            break;
                        }
                        Thread.Sleep(2000);
                        stdleakfailcount++;
                        goto recheckstdleak;
                    }

                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "ok";
                        step++;
                        myTestInfo.ResultsParams[step].SpecMax = maxLeakDiff.ToString();
                        myTestInfo.ResultsParams[step].SpecMin = minLeakDiff.ToString();
                        myTestInfo.ResultsParams[step].Nominal = stdleakt.ToString();
                        myTestInfo.ResultsParams[step].Result  = Leakrate.ToString();
                    }

                    // set the result
                    //myTestInfo.ResultsParams[step].Result = Leakrate.ToString();

                    //if (Leakrate >= (stdleakt - 0.2 * Math.Pow(10, exp_stdleak)) && Leakrate <= (stdleakt + 0.2 * Math.Pow(10, exp_stdleak)))
                    //{
                    //    myTestInfo.ResultsParams[step].Result = "ok";
                    //    Trace.WriteLine(iteSlot + "Test point complete.");
                    //}

                    //else
                    //{
                    //    myTestInfo.ResultsParams[step].Result = "FAILED";
                    //    throw new Exception("Test point failed.");
                    //}
                    step++;
                    //}

                    break;
                }

                case "5.6.10 Final_verification":
                {
                    /*@@ Verify the reading of the initialization parameters
                     * Responds with four lines. Each begins with a <cr><lf>.
                     * The first line reports the ion chamber value.
                     * The second line reports the emission value.
                     * The third line reports the value of the offset variable.
                     * The fourth line reports the gain value. @@*/

                    Trace.WriteLine(iteSlot + "Obtain and verify the initialization parameters of the UUT...");
                    Thread.Sleep(1000);
                    retval = Helper.SendCommand(myLD, ref status, "?ALL", "ok");

                    if (status == true)
                    {
                        //Obtain ionchamber value
                        string[] response1 = retval.Split(new string[] { "IONCHAMBER ", "EMISSION" }, StringSplitOptions.RemoveEmptyEntries);
                        //Obtain emmision current
                        string[] response2 = retval.Split(new string[] { "EMISSION ", "OFFSET" }, StringSplitOptions.RemoveEmptyEntries);
                        //Obtain midstage offset variable
                        string[] response3 = retval.Split(new string[] { "OFFSET ", "GAIN" }, StringSplitOptions.RemoveEmptyEntries);
                        string[] response5 = response3[1].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                        //Obtain gain value
                        string[] response4 = retval.Split(new string[] { "GAIN ", "ok" }, StringSplitOptions.RemoveEmptyEntries);

                        Ionchamber       = Convert.ToSingle(response1[1]);
                        Emmisioncurrent  = Convert.ToSingle(response2[1]);
                        OffsetContraflow = Convert.ToInt32(response5[0]);
                        OffsetMidstage   = Convert.ToInt32(response5[1]);
                        Gain             = Convert.ToSingle(response4[1]);

                        Trace.WriteLine(iteSlot + "Ionchamber = " + Ionchamber + "   Emmission Current = " + Emmisioncurrent + "   Offset = " + OffsetMidstage + "   Gain = " + Gain);
                        myTestInfo.ResultsParams[1].Result = "ok";
                        myTestInfo.ResultsParams[2].Result = Ionchamber.ToString();
                        myTestInfo.ResultsParams[3].Result = Emmisioncurrent.ToString();
                        myTestInfo.ResultsParams[4].Result = Gain.ToString();
                        myTestInfo.ResultsParams[5].Result = OffsetContraflow.ToString();
                        myTestInfo.ResultsParams[6].Result = OffsetMidstage.ToString();
                        //Retrieve the data for initialization parameters from the UUT and compare them with the values that wished to be set
                        //if (Ionchamber >= Convert.ToSingle(myTestInfo.TestParams[1].Value) && Ionchamber <= Convert.ToSingle(myTestInfo.TestParams[2].Value) && Emmisioncurrent >= Convert.ToSingle(myTestInfo.TestParams[3].Value) && Emmisioncurrent <= Convert.ToSingle(myTestInfo.TestParams[4].Value) && Offset >= Convert.ToInt32(myTestInfo.TestParams[5].Value) && Offset <= Convert.ToInt32(myTestInfo.TestParams[6].Value) && Gain >= Convert.ToSingle(myTestInfo.TestParams[7].Value))
                        //{
                        //    myTestInfo.ResultsParams[step].Result = "ok";
                        //    Trace.WriteLine(iteSlot + "Test point complete.");
                        //}
                        //else
                        //{
                        //    myTestInfo.ResultsParams[step].Result = "FAILED";
                        //    throw new Exception("Test point failed.");
                        //}
                    }
                    else
                    {
                        myTestInfo.ResultsParams[1].Result = "FAILED";
                        throw new Exception("Test point failed.");
                    }
                }
                break;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                //Helper.Fail_Test(ref myTestInfo, ex.Message, step);
                //if (myLD != null)
                //myLD.Close();
                throw;
            }

            return(myTestInfo);
        }
Exemplo n.º 2
0
        public static TestInfo DoSeq5_11(VSLeakDetector myLD, ref TestInfo myTestInfo, ref UUTData myuutdata)
        {
            Boolean status = false;
            string  retval;
            //VSLeakDetector myLD = new VSLeakDetector(comPort);
            //myLD.iteSlot = iteSlot;
            string Display;
            string Reading;
            int    step = 1;

            Helper.comPort = comPort;

            try
            {
                switch (myTestInfo.TestLabel)
                {
                case "5.11.1 Rough":
                {
                    //Access to full command

                    Trace.WriteLine(iteSlot + "Access to full command...");
                    Helper.SendCommand(myLD, ref status, "XYZZY", "ok");

                    //Obtain stdleak rate

                    Trace.WriteLine(iteSlot + "Obtain the stdleak rate...");
                    retval = Helper.SendCommand(myLD, ref status, "?STDLEAK", "ok");


                    //@@ Rough the UUT @@//

                    Trace.WriteLine(iteSlot + "Roughing the UUT...");
                    status = Helper.DoThis(myLD, ref myTestInfo, "ROUGH", "ok", step, "ok");

                    step++;


                    //@@ Wait for FINETEST @@//

                    status = Helper.Wait_FineTest(myLD);

                    if (status == true)
                    {
                        myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                    }

                    break;
                }

                case "5.11.2 OpenStdleak_btn":
                {
                    step = 1;

                    //@@ Prompt user to open stdleak @@//

                    Trace.WriteLine(iteSlot + "Waiting for user to open the stdleak...");

                    Display = "Seq 5.11.2: OPEN the stdleak through the LCD screen of the UUT.\n\nThe option can be found in the CONTROL PANEL. 'STDLEAK' will be displayed on the bottom left corner of the LCD screen\n\nEnter 'ok' after the stdleak is OPEN.";
                    Reading = Helper.LabelDisplay(Display);

                    if (Reading == "ok")
                    {
                        Trace.WriteLine(iteSlot + "Test point complete.");
                        myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                        //throw new Exception("Test point failed.");
                    }

                    break;
                }

                case "5.11.3 Audio_btn":
                {
                    step = 1;

                    //@@ Prompt user to press audio up button @@//

                    Trace.WriteLine(iteSlot + "Waiting for user to press the audio up button...");

                    Display = "Seq 5.11.3: Press the AUDIO UP button.\n\nThe option can be found in the CONTROL PANEL. An alarm will triggered.\n\nEnter 'ok' when done.";
                    Reading = Helper.LabelDisplay(Display);

                    if (Reading == "ok")
                    {
                        Trace.WriteLine(iteSlot + "Test point complete.");
                        myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                        //throw new Exception("Test point failed.");
                    }

                    break;
                }

                case "5.11.4 CloseStdleak_btn":
                {
                    step = 1;

                    //@@ Prompt user to close stdleak @@//

                    Trace.WriteLine(iteSlot + "Waiting for user to close the stdleak...");

                    Display = "Seq 5.11.4: CLOSE the stdleak through the LCD screen of the UUT.\n\nThe option can be found in the CONTROL PANEL. 'STDLEAK' will disappear after STDLEAK has fully closed.\n\nEnter 'ok' after the stdleak is CLOSE.";
                    Reading = Helper.LabelDisplay(Display);

                    if (Reading == "ok")
                    {
                        Trace.WriteLine(iteSlot + "Test point complete.");
                        myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                        //throw new Exception("Test point failed.");
                    }

                    break;
                }

                case "5.11.5 Audio_btn":
                {
                    step = 1;

                    //@@ Prompt user to press audio down button @@//

                    Trace.WriteLine(iteSlot + "Waiting for user to press the audio down button...");

                    Display = "Seq 5.11.5: Press the AUDIO DOWN button.\n\nThe option can be found in the CONTROL PANEL. An alarm will be triggered.\n\nEnter 'ok' when done.";
                    Reading = Helper.LabelDisplay(Display);

                    if (Reading == "ok")
                    {
                        Trace.WriteLine(iteSlot + "Test point complete.");
                        myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                        //throw new Exception("Test point failed.");
                    }

                    break;
                }

                case "5.11.1-5 btn_confirmation":
                {
                    step = 1;

                    //@@ Prompt user whether to continue or fail the test @@//

                    Trace.WriteLine(iteSlot + "Waiting for user for confirmation...");

                    Display = "Is everything working as expected?\n\nIf yes, enter 'ok' to proceed. Else, enter 'no'.";
                    Reading = Helper.LabelDisplay(Display);

                    if (Reading == "ok")
                    {
                        Trace.WriteLine(iteSlot + "Test point complete.");
                        myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                        //throw new Exception("Test point failed.");
                    }

                    break;
                }

                case "5.11.6_Init_FIL2":
                {
                    step = 1;

                    //@@ Sets the operating filament in the ion source. @@//

                    Trace.WriteLine(iteSlot + "Sets the operating filament in the ion source...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "2 INIT-FILAMENT", "ok", step, "ok");
                    Thread.Sleep(2000);                         //MOD: Provide some time for the filament to initialize.

                    break;
                }

                case "5.11.7_WaitSystemReady_FIL2":
                {
                    step = 1;

                    //@@ Wait for system ready. if the system is ready, value '-1' will be returned, else '0' . The timeout is 3 mins. @@//

                    Trace.WriteLine(iteSlot + "Wait for system to get ready...");

                    status = Helper.Wait_SystemReady(myLD);

                    if (status == true)
                    {
                        myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                    }

                    break;
                }

                case "5.11.8_Rough_Zero_FIL2":
                {
                    step = 1;

                    while (step <= myTestInfo.ResultsParams.NumResultParams)
                    {
                        //@@ Rough the UUT @@//

                        Trace.WriteLine(iteSlot + "Roughing the UUT...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "ROUGH", "ok", step, "ok");
                        step++;

                        Thread.Sleep(20000);


                        //@@ Sets the current leak rate measurement to be 0.0 atm .cc/s in the most sensitive range. @@//

                        Trace.WriteLine(iteSlot + "Sets the current leak rate measurement to be 0.0 atm .cc/s in the most sensitive range...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "ZERO", "ok", step, "ok");
                        step++;

                        Thread.Sleep(5000);


                        //@@ Wait for FINETEST mode @@//

                        Trace.WriteLine(iteSlot + "Wait for system to enter FINETEST mode...");

                        status = Helper.Wait_FineTest(myLD);

                        if (status == true)
                        {
                            myTestInfo.ResultsParams[step].Result = "ok";
                        }
                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                        }

                        step++;
                    }

                    break;
                }

                case "5.11.9_Calibration_FIL2":
                {
                    int num = 1;

                    //@@ Calibrate the UUT. If fail, auto recalibrate. If fail 3 times consistently, fail the test @@//
                    //@@ MOD: Test 5.11.10.1 and 5.11.10.2 are combine together with 5.11.9 to create a recalibration loop. Therefore, if the initial calibration process failed, recalibration process will take places for up to maximum of 3 times.
                    while (num <= Convert.ToInt32(myTestInfo.TestParams[1].Value))
                    {
                        status = Helper.Recalibrate(myLD);

                        if (status == true)
                        {
                            Trace.WriteLine(iteSlot + "Test point complete.");

                            myTestInfo.ResultsParams[1].Result = "ok";                              //Result param = Calibrate
                            myTestInfo.ResultsParams[2].Result = "ok";                              //Result param = Wait_Finetest
                            myTestInfo.ResultsParams[3].Result = "ok";                              //Result param = Report_cal_status

                            goto pass;
                        }
                        else
                        {
                            Trace.WriteLine(iteSlot + "Number of time(s) failed: " + num);
                            num++;
                        }
                    }

                    if (num > Convert.ToInt32(myTestInfo.TestParams[1].Value))
                    {
                        myTestInfo.ResultsParams[1].Result = "FAILED";                                  //Result param = Calibrate
                        myTestInfo.ResultsParams[2].Result = "FAILED";                                  //Result param = Wait_Finetest
                        myTestInfo.ResultsParams[3].Result = "FAILED";                                  //Result param = Report_cal_status

                        //throw new Exception("Recalibration failed three times.");
                    }

pass:
                    break;
                }

                case "5.11.10_Gain_FIL2":
                {
                    step = 1;

                    while (step <= myTestInfo.ResultsParams.NumResultParams)
                    {
                        //@@ Open the stdleak @@//

                        Trace.WriteLine(iteSlot + "Open the stdleak...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "STDLEAK", "ok", step, "ok");
                        step++;


                        Trace.WriteLine(iteSlot + "Provide time for the UUT to read the stdleak...");
                        Thread.Sleep(60000);


                        //@@ Obtain the gain value of the UUT @@//

                        Trace.WriteLine(iteSlot + "Obtain the gain value of the UUT...");

                        retval = Helper.SendCommand(myLD, ref status, "?GAIN", "ok");

                        if (status == true)
                        {
                            string[] response = retval.Split(new string[] { "?GAIN ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                            Gain = Convert.ToSingle(response[0]);

                            Trace.WriteLine(iteSlot + "Gain = " + Gain);
                            Trace.WriteLine(iteSlot + "Test point complete.");

                            myTestInfo.ResultsParams[step].Result = "ok";
                        }
                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                            //throw new Exception("Test point failed.");
                        }

                        step++;


                        //@@ Verify the gain value obtained 0.2 ~2.5 @@//

                        Trace.WriteLine(iteSlot + "Verify the gain value of filament 2...");

                        if (Gain >= Convert.ToSingle(myTestInfo.ResultsParams[step].SpecMin) && Gain <= Convert.ToSingle(myTestInfo.ResultsParams[step].SpecMax))
                        {
                            Trace.WriteLine(iteSlot + "Test point complete.");
                            myTestInfo.ResultsParams[step].Result = Convert.ToString(Gain);
                        }
                        else
                        {
                            myTestInfo.ResultsParams[step].Result = Convert.ToString(Gain);
                            //throw new Exception("Test point failed.");
                        }

                        step++;


                        //@@ Obtain the leak rate @@//

                        Trace.WriteLine(iteSlot + "Obtain the leak rate...");
                        retval = Helper.SendCommand(myLD, ref status, "?LEAK", "ok");

                        if (status == true)
                        {
                            string[] response = retval.Split(new string[] { "?LEAK ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                            Leakrate = Convert.ToDouble(response[0]);

                            Trace.WriteLine(iteSlot + "Measured leakrate = " + Leakrate + "Std .cc/s");
                            myTestInfo.ResultsParams[step].Result = "ok";
                            Trace.WriteLine(iteSlot + "Test point complete.");
                        }

                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                            //throw new Exception("Test point failed.");
                        }

                        step++;


                        //@@ Compare the leak rate with stdleak rate @@//
                        Trace.WriteLine(iteSlot + "Compare the obtained leak rate with the stdleak installed...");
                        retval = Helper.SendCommand(myLD, ref status, "?STDLEAKt", "ok");

                        double stdleakt    = 0;
                        double exp_stdleak = 0;

                        if (status == true)
                        {
                            string[] response  = retval.Split(new string[] { "?STDLEAKt ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                            string[] response2 = response[0].Split(new string[] { "E" }, StringSplitOptions.RemoveEmptyEntries);

                            stdleakt    = Convert.ToDouble(response[0]);
                            exp_stdleak = Convert.ToDouble(response2[1]);
                        }
                        // hairus added to get comparison stdleak properly
                        double maxLeakDiff = stdleakt + 0.2E-7;
                        double minLeakDiff = stdleakt - 0.2E-7;
                        myTestInfo.ResultsParams[step].SpecMax = maxLeakDiff.ToString();
                        myTestInfo.ResultsParams[step].SpecMin = minLeakDiff.ToString();
                        myTestInfo.ResultsParams[step].Nominal = stdleakt.ToString();

                        // set the result
                        myTestInfo.ResultsParams[step].Result = Leakrate.ToString();

                        //Trace.WriteLine(iteSlot + "Compare the obtained leak rate with the stdleak installed...");
                        //retval = Helper.SendCommand(myLD, ref status, "?STDLEAKt", "ok");

                        //double stdleak = 0;
                        //double exp_stdleak = 0;

                        //if (status == true)
                        //{
                        //    string[] response = retval.Split(new string[] { "?STDLEAKt ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                        //    string[] response2 = response[0].Split(new string[] { "E" }, StringSplitOptions.RemoveEmptyEntries);

                        //    stdleak = Convert.ToDouble(response[0]);
                        //    exp_stdleak = Convert.ToDouble(response2[1]);
                        //}

                        //if (Leakrate >= (stdleak - 0.2 * Math.Pow(10, exp_stdleak)) && Leakrate <= (stdleak + 0.2 * Math.Pow(10, exp_stdleak)))
                        //{
                        //    myTestInfo.ResultsParams[step].Result = "ok";
                        //    Trace.WriteLine(iteSlot + "Test point complete.");
                        //}

                        //else
                        //{
                        //    myTestInfo.ResultsParams[step].Result = "FAILED";
                        //    //throw new Exception("Test point failed.");
                        //}

                        step++;
                    }

                    break;
                }

                case "5.11.11_Stdleak_FIL2":
                {
                    step = 1;

                    //@@ Close the stdleak @@//

                    Trace.WriteLine(iteSlot + "Close the stdleak...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "STDLEAK", "ok", step, "ok");
                    Thread.Sleep(3000);

                    int counter = 1;                //YS WONG
recheck:
                    string checker = Helper.SendCommand(myLD, ref status, "?VALVESTATE", "MIDSTAGE");
                    if (!checker.Contains("MIDSTAGE"))
                    {
                        Thread.Sleep(2000);
                        counter++;
                        if (counter > 5)
                        {
                            Trace.WriteLine("MIDSTAGE FAIL"); break;
                        }
                        else
                        {
                            goto recheck;
                        }
                    }                               // YS WONG


                    break;
                }

                case "5.11.12_Vent_FIL2":
                {
                    step = 1;

                    //@@ Vent the UUT @@//

                    Trace.WriteLine(iteSlot + "Venting the UUT...");
                    status = Helper.DoThis(myLD, ref myTestInfo, "VENT", "ok", step, "ok");

                    int counter = 1;                    // YS WONG
recheck:
                    string checker = Helper.SendCommand(myLD, ref status, "?VALVESTATE", "VENT");
                    if (!checker.Contains("VENT"))
                    {
                        Thread.Sleep(2000);
                        counter++;
                        if (counter > 5)
                        {
                            Trace.WriteLine("VENT FAIL"); break;
                        }
                        else
                        {
                            goto recheck;
                        }
                    }
                    Thread.Sleep(2000);             // YS WONG

                    break;
                }



                //Filament 1 will be selected and the tests above will repeat again from 5.11.7 to 5.11.12

                case "5.11.13_Init_FIL1":
                {
                    step = 1;

                    //@@ Sets the operating filament in the ion source. @@//

                    Trace.WriteLine(iteSlot + "Sets the operating filament in the ion source...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "1 INIT-FILAMENT", "ok", step, "ok");
                    Thread.Sleep(2000);                         //MOD: Provide some time for the filament to initialize
                    break;
                }

                case "5.11.7_WaitSystemReady_FIL1":
                {
                    step = 1;

                    //@@ Wait for system ready. if the system is ready, value '-1' will be returned, else '0' . The timeout is 3 mins. @@//

                    Trace.WriteLine(iteSlot + "Wait for system to get ready...");

                    status = Helper.Wait_SystemReady(myLD);

                    if (status == true)
                    {
                        myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                    }

                    break;
                }

                case "5.11.8_Rough_Zero_FIL1":
                {
                    //@@ Rough the UUT @@//

                    step = 1;

                    while (step <= myTestInfo.ResultsParams.NumResultParams)
                    {
                        //@@ Rough the UUT @@//

                        Trace.WriteLine(iteSlot + "Roughing the UUT...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "ROUGH", "ok", step, "ok");
                        step++;

                        Thread.Sleep(20000);


                        //@@ Sets the current leak rate measurement to be 0.0 atm .cc/s in the most sensitive range. @@//

                        Trace.WriteLine(iteSlot + "Sets the current leak rate measurement to be 0.0 atm .cc/s in the most sensitive range...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "ZERO", "ok", step, "ok");
                        step++;

                        Thread.Sleep(5000);


                        //@@ Wait for FINETEST mode @@//

                        Trace.WriteLine(iteSlot + "Wait for system to enter FINETEST mode...");

                        status = Helper.Wait_FineTest(myLD);

                        if (status == true)
                        {
                            myTestInfo.ResultsParams[step].Result = "ok";
                        }
                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                        }

                        step++;
                    }

                    break;
                }

                case "5.11.9_Calibration_FIL1":
                {
                    step = 1;
                    int num = 1;

                    //@@ Calibrate the UUT. If fail, auto recalibrate. If fail 3 times consistently, fail the test @@//

                    while (num <= Convert.ToInt32(myTestInfo.TestParams[1].Value))
                    {
                        status = Helper.Recalibrate(myLD);

                        if (status == true)
                        {
                            Trace.WriteLine(iteSlot + "Test point complete.");

                            myTestInfo.ResultsParams[1].Result = "ok";
                            myTestInfo.ResultsParams[2].Result = "ok";
                            myTestInfo.ResultsParams[3].Result = "ok";

                            goto pass;
                        }
                        else
                        {
                            Trace.WriteLine(iteSlot + "Number of time(s) failed: " + num);
                            num++;
                        }
                    }

                    if (num > Convert.ToInt32(myTestInfo.TestParams[1].Value))
                    {
                        myTestInfo.ResultsParams[1].Result = "FAILED";
                        myTestInfo.ResultsParams[2].Result = "FAILED";
                        myTestInfo.ResultsParams[3].Result = "FAILED";

                        //throw new Exception("Recalibration failed three times.");
                    }

pass:
                    break;
                }

                case "5.11.10_Gain_FIL1":
                {
                    step = 1;

                    while (step <= myTestInfo.ResultsParams.NumResultParams)
                    {
                        //@@ Open the stdleak @@//

                        Trace.WriteLine(iteSlot + "Open the stdleak...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "STDLEAK", "ok", step, "ok");
                        step++;


                        Trace.WriteLine(iteSlot + "Provide time for the UUT to read the stdleak...");
                        Thread.Sleep(60000);


                        //@@ Obtain the gain value of the UUT @@//

                        Trace.WriteLine(iteSlot + "Obtain the gain value of the UUT...");

                        retval = Helper.SendCommand(myLD, ref status, "?GAIN", "ok");

                        if (status == true)
                        {
                            string[] response = retval.Split(new string[] { "?GAIN ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                            Gain = Convert.ToSingle(response[0]);

                            Trace.WriteLine(iteSlot + "Gain = " + Gain);
                            Trace.WriteLine(iteSlot + "Test point complete.");

                            myTestInfo.ResultsParams[step].Result = "ok";
                        }
                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                            //throw new Exception("Test point failed.");
                        }

                        step++;


                        //@@ Verify the gain value obtained 0.2~2.5 @@//

                        Trace.WriteLine(iteSlot + "Verify the gain value of filament 1...");

                        if (Gain >= Convert.ToSingle(myTestInfo.ResultsParams[step].SpecMin) && Gain <= Convert.ToSingle(myTestInfo.ResultsParams[step].SpecMax))
                        {
                            Trace.WriteLine(iteSlot + "Test point complete.");
                            myTestInfo.ResultsParams[step].Result = Convert.ToString(Gain);
                        }
                        else
                        {
                            myTestInfo.ResultsParams[step].Result = Convert.ToString(Gain);
                            //throw new Exception("Test point failed.");
                        }

                        step++;


                        //@@ Obtain the leak rate @@//

                        Trace.WriteLine(iteSlot + "Obtain the leak rate...");
                        retval = Helper.SendCommand(myLD, ref status, "?LEAK", "ok");

                        if (status == true)
                        {
                            string[] response = retval.Split(new string[] { "?LEAK ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                            Leakrate = Convert.ToDouble(response[0]);

                            Trace.WriteLine(iteSlot + "Measured leakrate = " + Leakrate + "Std .cc/s");
                            myTestInfo.ResultsParams[step].Result = "ok";
                            Trace.WriteLine(iteSlot + "Test point complete.");
                        }

                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                            //throw new Exception("Test point failed.");
                        }

                        step++;


                        //@@ rate with stdleak rate @@//
                        Trace.WriteLine(iteSlot + "Compare the obtained leak rate with the stdleak installed...");
                        retval = Helper.SendCommand(myLD, ref status, "?STDLEAKt", "ok");

                        double stdleakt    = 0;
                        double exp_stdleak = 0;

                        if (status == true)
                        {
                            string[] response  = retval.Split(new string[] { "?STDLEAKt ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                            string[] response2 = response[0].Split(new string[] { "E" }, StringSplitOptions.RemoveEmptyEntries);

                            stdleakt    = Convert.ToDouble(response[0]);
                            exp_stdleak = Convert.ToDouble(response2[1]);
                        }
                        // hairus added to get comparison stdleak properly
                        double maxLeakDiff = stdleakt + 0.2E-7;
                        double minLeakDiff = stdleakt - 0.2E-7;
                        myTestInfo.ResultsParams[step].SpecMax = maxLeakDiff.ToString();
                        myTestInfo.ResultsParams[step].SpecMin = minLeakDiff.ToString();
                        myTestInfo.ResultsParams[step].Nominal = stdleakt.ToString();

                        // set the result
                        myTestInfo.ResultsParams[step].Result = Leakrate.ToString();
                        //Trace.WriteLine(iteSlot + "Compare the obtained leak rate with the stdleak installed...");
                        //retval = Helper.SendCommand(myLD, ref status, "?STDLEAKt", "ok");

                        //double stdleak = 0;
                        //double exp_stdleak = 0;

                        //if (status == true)
                        //{
                        //    string[] response = retval.Split(new string[] { "?STDLEAKt ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                        //    string[] response2 = response[0].Split(new string[] { "E" }, StringSplitOptions.RemoveEmptyEntries);

                        //    stdleak = Convert.ToDouble(response[0]);
                        //    exp_stdleak = Convert.ToDouble(response2[1]);
                        //}

                        //if (Leakrate >= (stdleak - 0.2 * Math.Pow(10, exp_stdleak)) && Leakrate <= (stdleak + 0.2 * Math.Pow(10, exp_stdleak)))
                        //{
                        //    myTestInfo.ResultsParams[step].Result = "ok";
                        //    Trace.WriteLine(iteSlot + "Test point complete.");
                        //}

                        //else
                        //{
                        //    myTestInfo.ResultsParams[step].Result = "FAILED";
                        //    //throw new Exception("Test point failed.");
                        //}

                        step++;
                    }

                    break;
                }

                case "5.11.11_Stdleak_FIL1":
                {
                    step = 1;

                    //@@ Close the stdleak @@//

                    Trace.WriteLine(iteSlot + "Close the stdleak...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "STDLEAK", "ok", step, "ok");
                    Thread.Sleep(3000);
                    int counter = 1;                    // YS WONG
recheck:
                    string checker = Helper.SendCommand(myLD, ref status, "?VALVESTATE", "MIDSTAGE");
                    if (!checker.Contains("MIDSTAGE"))
                    {
                        Thread.Sleep(2000);
                        counter++;
                        if (counter > 5)
                        {
                            Trace.WriteLine("MIDSTAGE FAIL"); break;
                        }
                        else
                        {
                            goto recheck;
                        }
                    }                                   // YS WONG

                    break;
                }

                case "5.11.12_Vent_FIL1":
                {
                    step = 1;

                    //@@ Vent the UUT @@//

                    Trace.WriteLine(iteSlot + "Venting the UUT...");

                    status = Helper.DoThis(myLD, ref myTestInfo, "VENT", "ok", step, "ok");
                    int counter = 1;                    // YS WONG
recheck:
                    string checker = Helper.SendCommand(myLD, ref status, "?VALVESTATE", "VENT");
                    if (!checker.Contains("VENT"))
                    {
                        Thread.Sleep(2000);
                        counter++;
                        if (counter > 5)
                        {
                            Trace.WriteLine("VENT FAIL"); break;
                        }
                        else
                        {
                            goto recheck;
                        }
                    }
                    Thread.Sleep(2000);             // YS WONG


                    break;
                }

                case "5.11.15 Final_verification":
                {
                    step = 1;

                    //@@ Get initialization parameters from the UUT and verify them @@//

                    /*@@ Verify the reading of the initialization parameters
                     * Responds with four lines. Each begins with a <cr><lf>.
                     * The first line reports the ion chamber value.
                     * The second line reports the emission value.
                     * The third line reports the value of the offset variable.
                     * The fourth line reports the gain value. @@*/

                    Trace.WriteLine(iteSlot + "Obtain and verify the initialization parameters of the UUT...");
                    retval = Helper.SendCommand(myLD, ref status, "?ALL", "ok");

                    if (status == true)
                    {
                        //Obtain ionchamber value
                        string[] response1 = retval.Split(new string[] { "IONCHAMBER ", "EMISSION" }, StringSplitOptions.RemoveEmptyEntries);
                        //Obtain emmision current
                        string[] response2 = retval.Split(new string[] { "EMISSION ", "OFFSET" }, StringSplitOptions.RemoveEmptyEntries);
                        //Obtain midstage offset variable
                        string[] response3 = retval.Split(new string[] { "OFFSET ", "GAIN" }, StringSplitOptions.RemoveEmptyEntries);
                        string[] response5 = response3[1].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                        //Obtain gain value
                        string[] response4 = retval.Split(new string[] { "GAIN ", "ok" }, StringSplitOptions.RemoveEmptyEntries);

                        var Ionchamber       = Convert.ToSingle(response1[1]);
                        var Emmisioncurrent  = Convert.ToSingle(response2[1]);
                        var OffsetContraFlow = Convert.ToInt32(response5[0]);
                        var OffsetMidstage   = Convert.ToInt32(response5[1]);
                        var Gain             = Convert.ToSingle(response4[1]);

                        Trace.WriteLine(iteSlot + "Ionchamber = " + Ionchamber + "   Emmission Current = " + Emmisioncurrent + "   Offset = " + OffsetMidstage + "   Gain = " + Gain);
                        myTestInfo.ResultsParams[1].Result = "ok";
                        myTestInfo.ResultsParams[2].Result = Ionchamber.ToString();
                        myTestInfo.ResultsParams[3].Result = Emmisioncurrent.ToString();
                        myTestInfo.ResultsParams[4].Result = Gain.ToString();
                        myTestInfo.ResultsParams[5].Result = OffsetContraFlow.ToString();
                        myTestInfo.ResultsParams[6].Result = OffsetMidstage.ToString();
                        //Retrieve the data for initialization parameters from the UUT and compare them with the values that wished to be set
                        //if (Ionchamber >= Convert.ToSingle(myTestInfo.TestParams[1].Value) && Ionchamber <= Convert.ToSingle(myTestInfo.TestParams[2].Value) && Emmisioncurrent >= Convert.ToSingle(myTestInfo.TestParams[3].Value) && Emmisioncurrent <= Convert.ToSingle(myTestInfo.TestParams[4].Value) && Offset >= Convert.ToInt32(myTestInfo.TestParams[5].Value) && Offset <= Convert.ToInt32(myTestInfo.TestParams[6].Value) && Gain >= Convert.ToSingle(myTestInfo.TestParams[7].Value))
                        //{
                        //    myTestInfo.ResultsParams[step].Result = "ok";
                        //    Trace.WriteLine(iteSlot + "Test point complete.");
                        //}
                        //else
                        //{
                        //    myTestInfo.ResultsParams[step].Result = "FAILED";
                        //    throw new Exception("Test point failed.");
                        //}
                    }
                    else
                    {
                        myTestInfo.ResultsParams[1].Result = "FAILED";
                        throw new Exception("Test point failed.");
                    }
                    break;
                }

                case "5.11.16 Verify_Setup":
                {
                    step = 1;

                    //@@ Retrieve the setup parameters from the UUT and compare it to the current detected leak rate @@//

                    Trace.WriteLine(iteSlot + "Obtain and verify the setup parameters of the UUT...");
                    retval = Helper.SendCommand(myLD, ref status, "?SETUP", "ok");

                    if (status == true)
                    {
                        //Obtain stdleak rate
                        string[] response  = retval.Split(new string[] { "stdleak     ", "\n\routput" }, StringSplitOptions.RemoveEmptyEntries);
                        string[] response2 = response[1].Split(new string[] { "E" }, StringSplitOptions.RemoveEmptyEntries);

                        double Setup_stdleak = Convert.ToDouble(response[1]);
                        int    Setup_exp     = Convert.ToInt32(response2[1]);

                        //Retrieve the data for setup parameters from the UUT and compare them with the values that wished to be set
                        if (Leakrate >= (Setup_stdleak - 0.2 * Math.Pow(10, Setup_stdleak)) && Leakrate <= (Setup_stdleak + 0.2 * Math.Pow(10, Setup_stdleak)))
                        {
                            myTestInfo.ResultsParams[step].Result = "ok";
                            Trace.WriteLine(iteSlot + "Test point complete.");
                        }
                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                            //throw new Exception("Test point failed.");
                        }
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                        //throw new Exception("Test point failed.");
                    }

                    break;
                }

                case "5.11.17 Vent":
                {
                    //@@ Vent the UUT @@//

                    step = 1;

                    Trace.WriteLine(iteSlot + "Vent the UUT...");
                    status = Helper.DoThis(myLD, ref myTestInfo, "VENT", "ok", step, "ok");
checkagain:
                    retval = Helper.SendCommand(myLD, ref status, "?PRESSURES", "ok");

                    string[] resp     = retval.Split(new string[] { "(mTorr): ", "\r\nSpectrometer" }, StringSplitOptions.RemoveEmptyEntries);
                    int      Pressure = Convert.ToInt32(resp[1]);


                    Trace.WriteLine(iteSlot + "Pressure: " + Pressure + "mTorr   System Pressure: ");
                    if (!(Pressure >= 700000 && Pressure <= 760000))
                    {
                        Thread.Sleep(2000);
                        goto checkagain;
                    }
                    // YS Wong added to make sure vented properly

                    Thread.Sleep(1000);
                    break;
                }
                }
            }

            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                Helper.Fail_Test(ref myTestInfo, ex.Message, step);
                throw;
            }


            return(myTestInfo);
        }
Exemplo n.º 3
0
        public static TestInfo DoSeq5_9(VSLeakDetector myLD, ref TestInfo myTestInfo, ref UUTData myuutdata)
        {
            Boolean status = false;
            string  retval = "";
            int     step   = 1;

            //VSLeakDetector myLD = new VSLeakDetector(comPort);
            //myLD.iteSlot = iteSlot;
            Helper.comPort = comPort;

            try
            {
                switch (myTestInfo.TestLabel)
                {
                case "5.9.1 Calibration":
                {
                    step = 1;

                    //Access to full command

                    Trace.WriteLine(iteSlot + "Access to full command...");
                    Helper.SendCommand(myLD, ref status, "XYZZY", "ok");


                    //Obtain stdleak reading

                    Trace.WriteLine(iteSlot + "Obtain the stdleak reading...");
                    retval = Helper.SendCommand(myLD, ref status, "?STDLEAK", "ok");

                    if (status == true)
                    {
                        string[] response = retval.Split(new string[] { "?STDLEAK ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                        Stdleak = Convert.ToDouble(response[0]);
                    }

                    /*@@ Initiates a Full or Fast calibration depending on system settings. The CPU software tunes,
                     * then adjusts the gain so that the current helium signal causes the current leak rate measurement
                     * to be the same as the most recently input using INIT-STDLEAK. If the gain is 2.9 or higher, a normal
                     * calibration is performed. Success is indicated by the normal ok response. @@*/

                    Trace.WriteLine(iteSlot + "Rough process will be triggered if UUT is not in FINE TEST mode.");

                    //myLD.Open();
                    myLD.Write("?VALVESTATE");
                    retval = myLD.Read();
                    //myLD.Close();

                    if (!retval.Contains("MIDSTAGE"))
                    {
                        Trace.WriteLine(iteSlot + "Roughing the UUT...");
                        Helper.SendCommand(myLD, ref status, "ROUGH", "ok");
                    }

                    status = Helper.Wait_FineTest(myLD);
                    //Wait for stabilization
                    Trace.WriteLine(iteSlot + "Wait for stabilization...");
                    Thread.Sleep(60000);


                    if (status == true)
                    {
                        Trace.WriteLine(iteSlot + "Initiates a FULL or FAST calibration based on system configurations...");
                        status = Helper.DoThis(myLD, ref myTestInfo, "CALIBRATE", "ok", step, "ok");
                    }

                    step++;
                    Thread.Sleep(3000);


                    //@@ Wait for 979 Calibration VI @@//

                    status = Helper.Wait_FineTest(myLD);

                    if (status == true)
                    {
                        myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                    }

                    break;
                }

                case "5.9.2 Verify_Calibration":
                {
                    step = 1;

                    //@@ Report and verify the status of the last calibration. @@//

                    Trace.WriteLine(iteSlot + "Report and verify the status of the last calibration...");
                    status = Helper.DoThis(myLD, ref myTestInfo, "?CALOK", "Yesok", step, "ok");

                    break;
                }

                case "5.9.3 Verify_LeakReading":
                {
                    step = 1;

                    while (step <= myTestInfo.ResultsParams.NumResultParams)
                    {
                        //@@ Turn ON internal calibrated leak @@//
                        Thread.Sleep(2000);
                        Trace.WriteLine(iteSlot + "Open the stdleak...");

                        Helper.SendCommand(myLD, ref status, "STDLEAK", "ok");
                        if (status == false)
                        {
                            break;
                        }
                        //Helper.DoThis(myLD, ref myTestInfo, "STDLEAK", "ok", step, "ok");
                        //Thread.Sleep(13000);
stdleakcheck:
                        status = Helper.DoThis(myLD, ref myTestInfo, "?VALVESTATE", "STDLEAK", step, "ok");
                        if (status == false)
                        {
                            //ys wong
                            Thread.Sleep(1000);
                            goto stdleakcheck;
                        }
                        step++;


                        Trace.WriteLine(iteSlot + "Provide time for the UUT to read the Stdleak...");
                        // Hairus added to dynamically wait until the stdleak reading is stabilized.
                        //myLD = new VSLeakDetector(comPort);
                        // myLD.iteSlot = iteSlot;
                        // myLD.Open();
                        //bool isStdLeakState = myLD.WaitForStdLeakState(ref retval);
                        // Thread.Sleep(5000);
                        //bool isLeakStabilized = myLD.WaitForStabilizedReading(ref retval, 120, 0.97, 10);
                        Thread.Sleep(6000);
                        //myLD.Close();

                        //@@ Obtain the leakrate reading @@//
readleakagain:
                        Trace.WriteLine(iteSlot + "Obtain the leakrate...");
                        retval = Helper.SendCommand(myLD, ref status, "?LEAK", "ok");

                        if (status == true)
                        {
                            string[] response = retval.Split(new string[] { "?LEAK ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                            Leakrate = Convert.ToDouble(response[0]);

                            Trace.WriteLine(iteSlot + "Measured leak rate = " + Leakrate + "Std .cc/s");
                            myTestInfo.ResultsParams[step].Result = "ok";
                            Trace.WriteLine(iteSlot + "Test point complete.");
                        }

                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                            //throw new Exception("Test point failed.");
                        }

                        step++;


                        //@@ Compare the leak rate with stdleak rate @@//

                        Trace.WriteLine(iteSlot + "Compare the obtained leak rate with the stdleak installed...");
                        retval = Helper.SendCommand(myLD, ref status, "?STDLEAKt", "ok");

                        double stdleakt     = 0;
                        double exp_stdleakt = 0;

                        if (status == true)
                        {
                            string[] response  = retval.Split(new string[] { "?STDLEAKt ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                            string[] response2 = response[0].Split(new string[] { "E-" }, StringSplitOptions.RemoveEmptyEntries);

                            stdleakt     = Convert.ToDouble(response[0]);
                            exp_stdleakt = Convert.ToDouble(response2[1]);
                        }

                        // set max and minimum limit reading for the leak rate verification compared to stdleakt
                        // The displayed leak rate value shall be no more than +-0.2 from the ?STDLEAKt (temperature compensated cal leak) value.
                        double maxLeakDiff = stdleakt + 0.2E-7;
                        double minLeakDiff = stdleakt - 0.2E-7;
                        myTestInfo.ResultsParams[step].SpecMax = maxLeakDiff.ToString();
                        myTestInfo.ResultsParams[step].SpecMin = minLeakDiff.ToString();
                        myTestInfo.ResultsParams[step].Nominal = stdleakt.ToString();
                        // set the result
                        int cycle = 1;
recheckintcal:
                        if (!((minLeakDiff <= Leakrate) & (Leakrate <= maxLeakDiff)))
                        {
                            status = false;

                            retval = Helper.SendCommand(myLD, ref status, "?LEAK", "ok");

                            if (status == true)
                            {
                                string[] response = retval.Split(new string[] { "?LEAK ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                                Leakrate = Convert.ToDouble(response[0]);
                                Trace.WriteLine(iteSlot + "Measured leak rate = " + Leakrate + "Std .cc/s");
                                if (cycle >= 4)
                                {
                                    myTestInfo.ResultsParams[step].Result = "FAILED";
                                    break;
                                }
                                goto recheckintcal;
                            }

                            else
                            {
                                myTestInfo.ResultsParams[step].Result = "FAILED";
                                //throw new Exception("Test point failed.");
                            }
                        }
                        myTestInfo.ResultsParams[step].Result = Leakrate.ToString();
                        //if (Leakrate >= (stdleak - 0.2 * Math.Pow(10, exp_stdleakt)) && Leakrate <= (stdleak + 0.2 * Math.Pow(10, exp_stdleakt)))
                        //{
                        //    myTestInfo.ResultsParams[step].Result = "ok";
                        //    Trace.WriteLine(iteSlot + "Test point complete.");
                        //}
                        //else
                        //{
                        //    myTestInfo.ResultsParams[step].Result = "FAILED";
                        //    //throw new Exception("Test point failed.");
                        //}

                        step++;
                    }

                    break;
                }

                case "5.9.4":
                {
                    step = 1;

                    //@@ Close the internal calibrate leak @@//

                    Trace.WriteLine(iteSlot + "Close the stdleak...");
                    status = Helper.DoThis(myLD, ref myTestInfo, "STDLEAK", "ok", step, "ok");

                    step++;

                    int counter = 1;             //YS WONG
recheck:
                    string checker = Helper.SendCommand(myLD, ref status, "?VALVESTATE", "MIDSTAGE");
                    if (!checker.Contains("MIDSTAGE"))
                    {
                        Thread.Sleep(2000);
                        counter++;
                        if (counter > 5)
                        {
                            Trace.WriteLine("MIDSTAGE FAIL");
                        }                                            //break; }
                        else
                        {
                            goto recheck;
                        }
                    }
                    // YS WONG

                    // wait until the LD fully closed STDLEAK before vent to atmospheric
                    //Thread.Sleep(5000);

                    ////////////@@ Vent the UUT @@//
                    Thread.Sleep(1000);
                    Trace.WriteLine(iteSlot + "Venting the UUT...");
                    status = Helper.DoThis(myLD, ref myTestInfo, "VENT", "ok", step, "ok");

checkagain:
                    retval = Helper.SendCommand(myLD, ref status, "?PRESSURES", "ok");

                    string[] resp     = retval.Split(new string[] { "(mTorr): ", "\r\nSpectrometer" }, StringSplitOptions.RemoveEmptyEntries);
                    int      Pressure = Convert.ToInt32(resp[1]);


                    Trace.WriteLine(iteSlot + "Pressure: " + Pressure + "mTorr   System Pressure: ");
                    // commented out below manual limit checking, use test executive to do the limit checking and display the result correctly
                    if (!(Pressure >= 700000 && Pressure <= 760000))
                    {
                        Thread.Sleep(2000);
                        goto checkagain;
                    }

                    Thread.Sleep(1000);

                    break;
                }

                case "5.9.5 Init_Extleak":
                {
                    step = 1;
                    //while (step <= myTestInfo.ResultsParams.NumResultParams)// again why need to do while loop here..
                    //{
                    //@@ Initiate external calibrated leak @@//
                    Trace.WriteLine(iteSlot + "Roughing the UUT...");
                    status = Helper.DoThis(myLD, ref myTestInfo, "ROUGH", "ok", step, "ok");

                    Thread.Sleep(5000);
                    status = Helper.DoThis(myLD, ref myTestInfo, "KEEP", "ok", step, "ok");
                    Thread.Sleep(3000);
                    Trace.WriteLine(iteSlot + "Initiate external leak rate...");
                    if (myLD.iteSlot.Contains("P1"))
                    {
                        Helper.DoThis(myLD, ref myTestInfo, External_leak_Parameters.Ext_leakrate1 + " INIT-EXTLEAK", "ok", step, "ok");
                    }
                    else
                    {
                        Helper.DoThis(myLD, ref myTestInfo, External_leak_Parameters.Ext_leakrate2 + " INIT-EXTLEAK", "ok", step, "ok");
                    }
                    step++;

                    Trace.WriteLine(iteSlot + "Open the external calibrated leak...");
                    InstrumentIO.Open_Extleak(slotNum); //Open external calibrated leak valve
                    Thread.Sleep(2000);                 // give some time to valve to fully open before roughing.



                    //@@ Rough the UUT @@//

                    Trace.WriteLine(iteSlot + "Roughing the UUT...");
                    status = Helper.DoThis(myLD, ref myTestInfo, "ROUGH", "ok", step, "ok");
                    step++;


                    //@@ Wait for fine test @@//

                    int repeat = 1;
again:
                    Thread.Sleep(7000);
                    //status = Helper.Wait_FineTest(myLD, 120);
                    string check = Helper.SendCommand(myLD, ref status, "?VALVESTATE", "MIDSTAGE");


                    if (check.Contains("MIDSTAGE"))
                    {
                        myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        //InstrumentIO.Close_Extleak(slotNum);
                        //Thread.Sleep(2000);
                        //InstrumentIO.Open_Extleak(slotNum);
                        if (repeat >= 4)
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                            break;
                        }
                        repeat++;
                        goto again;
                    }


                    step++;


                    Trace.WriteLine(iteSlot + "Gives UUT time to read the leak rate...");
                    //myLD = new VSLeakDetector(comPort);
                    //myLD.iteSlot = iteSlot;
                    //myLD.Open();
                    // bool isLeakrateStabilized = myLD.WaitForStabilizedReading(ref retval, 120, 0.97, 10);
                    //myLD.Close();
                    //Thread.Sleep(20000);

                    //@@ Midstage leak rate? @@//
                    // recheck:
                    Trace.WriteLine(iteSlot + "Obtain midstage leak rate...");
                    Thread.Sleep(10000);
                    //retval = Helper.SendCommand(myLD, ref status, "?LEAK", "ok");

                    if (status == true)
                    {
                        int i = 1;
recheck:
                        Thread.Sleep(4000);
                        retval = Helper.SendCommand(myLD, ref status, "?LEAK", "ok");
                        string[] response = retval.Split(new string[] { "?LEAK ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                        Midstage_leak = Convert.ToDouble(response[0]);

                        Trace.WriteLine(iteSlot + "Measured leak rate = " + Midstage_leak + "Std .cc/s");

                        //myTestInfo.ResultsParams[step].Result = "ok"; // display midstage leak value instead of 'ok' text.
                        double extStdLeakRate = 0;
                        if (myLD.iteSlot.Contains("P1"))
                        {
                            extStdLeakRate = Convert.ToDouble(External_leak_Parameters.Ext_leakrate1);
                        }
                        else
                        {
                            extStdLeakRate = Convert.ToDouble(External_leak_Parameters.Ext_leakrate2);
                        }
                        double maxLeakRate = extStdLeakRate + 0.00000002;
                        double minLeakRate = extStdLeakRate - 0.00000002;
                        myTestInfo.ResultsParams[step].Result  = Midstage_leak.ToString();
                        myTestInfo.ResultsParams[step].SpecMax = maxLeakRate.ToString();
                        myTestInfo.ResultsParams[step].SpecMin = minLeakRate.ToString();
                        myTestInfo.ResultsParams[step].Nominal = extStdLeakRate.ToString();

                        if ((minLeakRate < Midstage_leak) && (Midstage_leak < maxLeakRate))
                        {
                            myTestInfo.ResultsParams[step].Result = Midstage_leak.ToString();
                        }
                        else
                        {
                            i++;
                            if (i < 120)
                            {
                                Helper.DoThis(myLD, ref myTestInfo, "ROUGH", "ok", step, "ok");
                                Thread.Sleep(4000);
                                goto recheck;
                            }
                        }
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                        //throw new Exception("Test point failed.");
                    }
                    step++;
                }
                break;
                //}

                case "5.9.6 Fastvgain":
                {
                    step = 1;

                    /*@@ An integer that scales the leak rate to account for deviations in helium compression ratios between contraflow and midstage modes
                     * in fast turbo speed. @@*/

                    Trace.WriteLine(iteSlot + "Scales the leak rate to account for deviations in helium compression ratios between contraflow and midstage modes...");
                    status = Helper.DoThis(myLD, ref myTestInfo, "1 INIT-FAST-VGAIN", "ok", step, "ok");

                    break;
                }

                case "5.9.7 Sniff":
                {
                    step = 1;

                    //@@ Turns the HIGH PRESSURE TEST mode ON. @@//

                    Trace.WriteLine(iteSlot + "Turns the HIGH PRESSURE TEST mode ON....");
                    status = Helper.DoThis(myLD, ref myTestInfo, "SNIFF", "ok", step, "ok");

                    // 6 Nov 17: With London FW rev L01.01, the SNIFF command will not change LD from Fine-Test to Test mode.
                    // If we send ROUGH command it will change it to Test mode. This is some kind of bug in this LD01.01 revision.
                    // below code only for temporary.
                    string val = Helper.SendCommand(myLD, ref status, "ROUGH", "ok");
                    Thread.Sleep(2000);
                    // end temporary

                    break;
                }

                case "5.9.8 Measure_Contra":
                {
                    step = 1;

                    //@@ Wait for Contraflow mode @@//
                    Thread.Sleep(20000);
                    status = Helper.Wait_Test(myLD);

                    if (status == true)
                    {
                        myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                    }
                    step++;

                    // experiment, for VGain enhancement. #1
                    var listOfVGainLimits = new List <string>();
                    listOfVGainLimits.Add(myTestInfo.TestParams[1].Value);                       // portable LD 110
                    listOfVGainLimits.Add(myTestInfo.TestParams[2].Value);                       // portable LD 220
                    listOfVGainLimits.Add(myTestInfo.TestParams[3].Value);                       // mobile/bench RVP LD 110
                    listOfVGainLimits.Add(myTestInfo.TestParams[4].Value);                       // mobile/bench RVP LD 220
                    listOfVGainLimits.Add(myTestInfo.TestParams[5].Value);                       // mobile/bench Scroll Pump LD 110
                    listOfVGainLimits.Add(myTestInfo.TestParams[6].Value);                       // mobile/bench Scroll Pump LD 220
                    string[] limitsArray   = listOfVGainLimits.ToArray();
                    string   csvVGainLimit = Helper.GetVgainLimit(myuutdata.Model, limitsArray); // Get VGain limits for specific LD model
                    double   vGainLsl      = Convert.ToDouble(csvVGainLimit.Split(',').FirstOrDefault());
                    double   vGainUsl      = Convert.ToDouble(csvVGainLimit.Split(',').LastOrDefault());
                    double   vGainNominal  = vGainLsl + ((vGainUsl - vGainLsl) / 2);
                    // expected contra-leak for vgain at nominal
                    double expContraSniffLeak = vGainNominal * Midstage_leak;
                    Trace.WriteLine(iteSlot + "Provide time for the UUT to read the leak rate...");
                    //myLD = new VSLeakDetector(comPort);
                    //myLD.iteSlot = iteSlot;
                    //myLD.Open();
                    //bool isReadingMet = myLD.WaitForSpecificReading(ref retval, 120, expContraSniffLeak, 1);   //ys wong
                    //myLD.Close();

                    //// EXPERIMENT #2 WAIT FOR STABILIZED LEAK RATE AT E-6
                    //Trace.WriteLine(iteSlot + "Provide time for the UUT to read the leak rate...");
                    //myLD = new VSLeakDetector(comPort);
                    //myLD.iteSlot = iteSlot;
                    //myLD.Open();
                    //isReadingMet = myLD.WaitForStabilizedReading(ref retval, 120, 0.9, 5);
                    //myLD.Close();

                    // Original from ATP
                    //Trace.WriteLine(iteSlot + "Provide time for the UUT to read the leak rate...");
                    Thread.Sleep(20000);

                    //@@ Contraflow leak value @@//
again:
                    Trace.WriteLine(iteSlot + "Obtain contraflow leak rate...");
                    retval = Helper.SendCommand(myLD, ref status, "?LEAK", "ok");

                    if (status == true)
                    {
                        string[] response = retval.Split(new string[] { "?LEAK ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                        Contra_leak = Convert.ToDouble(response[0]);

                        Trace.WriteLine(iteSlot + "Measured leak rate = " + Contra_leak + "Std .cc/s");

                        if (Contra_leak == 0.00E-00)
                        {
                            goto again;
                        }
                        myTestInfo.ResultsParams[step].Result              =
                            myTestInfo.ResultsParams[step].SpecMax         =
                                myTestInfo.ResultsParams[step].SpecMin     =
                                    myTestInfo.ResultsParams[step].Nominal = Contra_leak.ToString();
                        //myTestInfo.ResultsParams[step].Result = "ok";
                    }
                    else
                    {
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                        //throw new Exception("Test point failed.");
                    }
                    break;
                }

                case "5.9.11 Fastvgain":
                {
                    step = 1;

                    /*@@ An integer that scales the leak rate to account for deviations in helium compression ratios between contraflow and midstage modes
                     * in fast turbo speed. @@*/

                    Vgain = Math.Round(Contra_leak / Midstage_leak, 0, MidpointRounding.AwayFromZero);

                    Trace.WriteLine(iteSlot + "Scales the leak rate to account for deviations in helium compression ratios between contraflow and midstage modes...");
                    Trace.WriteLine(iteSlot + "Vgain = " + Vgain);

                    status = Helper.DoThis(myLD, ref myTestInfo, Vgain + " INIT-FAST-VGAIN", "ok", step, "ok");

                    Thread.Sleep(2000);
                    break;
                }

                case "5.9.12 Measure_Contra":
                {
                    step = 1;

                    while (step <= myTestInfo.ResultsParams.NumResultParams)
                    {
                        //@@ Vent the UUT @@//

                        Trace.WriteLine(iteSlot + "Venting the UUT...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "VENT", "ok", step, "ok");
                        step++;

                        //add in pressures //YS Wong
checkagain:
                        retval = Helper.SendCommand(myLD, ref status, "?PRESSURES", "ok");

                        string[] resp     = retval.Split(new string[] { "(mTorr): ", "\r\nSpectrometer" }, StringSplitOptions.RemoveEmptyEntries);
                        int      Pressure = Convert.ToInt32(resp[1]);


                        Trace.WriteLine(iteSlot + "Pressure: " + Pressure + "mTorr   System Pressure: ");
                        // commented out below manual limit checking, use test executive to do the limit checking and display the result correctly
                        if (!(Pressure >= 700000 && Pressure <= 760000))
                        {
                            Thread.Sleep(2000);
                            goto checkagain;
                        }

                        Thread.Sleep(1000);


                        //@@ Rough the UUT @@//

                        Trace.WriteLine(iteSlot + "Roughing the UUT...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "ROUGH", "ok", step, "ok");
                        step++;


                        //@@ Wait for Contraflow mode @@//

                        status = Helper.Wait_Test(myLD);

                        if (status == true)
                        {
                            myTestInfo.ResultsParams[step].Result = "ok";
                        }
                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                        }

                        step++;


                        Trace.WriteLine(iteSlot + "Provide time for the UUT to read the leak rate...");
                        //myLD = new VSLeakDetector(comPort);
                        //myLD.iteSlot = iteSlot;
                        //myLD.Open();
                        //  bool isreadingStabilized = myLD.WaitForStabilizedReading(ref retval, 120, 0.97, 10);   YS Wong
                        //myLD.Close();

                        Thread.Sleep(25000);


                        //@@ Contraflow leak value @@//

                        Trace.WriteLine(iteSlot + "Obtain contraflow leak rate...");
                        retval = Helper.SendCommand(myLD, ref status, "?LEAK", "ok");

                        if (status == true)
                        {
                            string[] response = retval.Split(new string[] { "?LEAK ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                            Contra_leak = Convert.ToDouble(response[0]);

                            Trace.WriteLine(iteSlot + "Measured leak rate = " + Contra_leak + "Std .cc/s");
                            myTestInfo.ResultsParams[step].Result              =
                                myTestInfo.ResultsParams[step].SpecMax         =
                                    myTestInfo.ResultsParams[step].SpecMin     =
                                        myTestInfo.ResultsParams[step].Nominal = Contra_leak.ToString();
                        }
                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                            //throw new Exception("Test point failed.");
                        }
                        step++;
                    }

                    break;
                }

                case "5.9.13 Measure_Midstage":
                {
                    step = 1;

                    while (step <= myTestInfo.ResultsParams.NumResultParams)
                    {
                        //@@ Turns the HIGH PRESSURE TEST function OFF @@//

                        Trace.WriteLine(iteSlot + "Turns the HIGH PRESSURE TEST function OFF...");

                        status = Helper.DoThis(myLD, ref myTestInfo, "NOSNIFF", "ok", step, "ok");
                        step++;


                        //@@ Wait for FINETEST MODE @@//

                        status = Helper.Wait_FineTest(myLD);

                        if (status == true)
                        {
                            myTestInfo.ResultsParams[step].Result = "ok";
                        }
                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                        }

                        step++;


                        Trace.WriteLine(iteSlot + "Gives UUT time to read the leak rate...");
                        //myLD = new VSLeakDetector(comPort);
                        //myLD.iteSlot = iteSlot;
                        //myLD.Open();
                        // ys wong              //bool isreadingStabilized = myLD.WaitForStabilizedReading(ref retval, 120, 0.97, 10);
                        //myLD.Close();

                        Thread.Sleep(20000);

//midstage check not exist??
                        //@@ Midstage leak? @@//

                        Trace.WriteLine(iteSlot + "Obtain midstage leak rate...");;
                        retval = Helper.SendCommand(myLD, ref status, "?LEAK", "ok");

                        if (status == true)
                        {
                            string[] response = retval.Split(new string[] { "?LEAK ", "ok" }, StringSplitOptions.RemoveEmptyEntries);
                            Midstage_leak = Convert.ToDouble(response[0]);

                            Trace.WriteLine(iteSlot + "Measured leak rate = " + Midstage_leak + "Std .cc/s");
                            myTestInfo.ResultsParams[step].Result              =
                                myTestInfo.ResultsParams[step].SpecMax         =
                                    myTestInfo.ResultsParams[step].SpecMin     =
                                        myTestInfo.ResultsParams[step].Nominal = Midstage_leak.ToString();
                        }
                        else
                        {
                            myTestInfo.ResultsParams[step].Result = "FAILED";
                            //throw new Exception("Test point failed.");
                        }
                        step++;
                    }

                    break;
                }

                case "5.9.14 Verify_Contra_Midstage":
                {
                    step = 1;

                    //@@ Compare the contraflow leak rate and the midstage leak rate @@//

                    Trace.WriteLine(iteSlot + "Compare the contraflow leak rate and the midstage leak rate...");
                    if (Midstage_leak < 1E-07)
                    {
                        double diff = Math.Abs(Midstage_leak - Contra_leak);

                        myTestInfo.ResultsParams[step].Result = diff.ToString();
                        // good result, difference must be <=0.2E-08
                        myTestInfo.ResultsParams[step].SpecMax = "0.000000002";
                        myTestInfo.ResultsParams[step].SpecMin = "0";
                        myTestInfo.ResultsParams[step].Nominal = "0";
                    }
                    else if (Midstage_leak >= 1E-07)
                    {
                        double diff = Math.Abs(Midstage_leak - Contra_leak);

                        myTestInfo.ResultsParams[step].Result = diff.ToString();
                        // good result, difference must be <=0.2E-07
                        myTestInfo.ResultsParams[step].SpecMax = "0.00000002";
                        myTestInfo.ResultsParams[step].SpecMin = "0";
                        myTestInfo.ResultsParams[step].Nominal = "0";
                    }

                    //if((Midstage_leak < 1E-07 && Math.Abs(Midstage_leak - Contra_leak) <= 0.2E-8) || (Midstage_leak >= 1E-07 && Math.Abs(Midstage_leak - Contra_leak) <= 0.2E-7))
                    //{
                    //    Trace.WriteLine(iteSlot + "Test point complete.");
                    //    myTestInfo.ResultsParams[step].Result = "ok";
                    //}
                    else
                    {
                        // only magic will reach here
                        myTestInfo.ResultsParams[step].Result = "FAILED";
                        //throw new Exception("Test point failed.");
                    }

                    break;
                }

                case "5.9.15 Verify_Vgain":
                {
                    step = 1;
                    // Hairus added to get VGain from PluginSequence test params instead of hardcoded
                    var listOfVGainLimits = new List <string>();
                    listOfVGainLimits.Add(myTestInfo.TestParams[1].Value);          // portable LD 110
                    listOfVGainLimits.Add(myTestInfo.TestParams[2].Value);          // portable LD 220
                    listOfVGainLimits.Add(myTestInfo.TestParams[3].Value);          // mobile/bench RVP LD 110
                    listOfVGainLimits.Add(myTestInfo.TestParams[4].Value);          // mobile/bench RVP LD 220
                    listOfVGainLimits.Add(myTestInfo.TestParams[5].Value);          // mobile/bench Scroll Pump LD 110
                    listOfVGainLimits.Add(myTestInfo.TestParams[6].Value);          // mobile/bench Scroll Pump LD 220
                    string[] limitsArray = listOfVGainLimits.ToArray();
                    //@@ Based on model number, verify the vgain value @@//

                    Trace.WriteLine(iteSlot + "Verify the vgain value based on the model number of the UUT...");
                    //status = Helper.GetModel_Vgain(myuutdata.Model, Vgain);   // remove hardcoded value
                    string csvVGainLimit = Helper.GetVgainLimit(myuutdata.Model, limitsArray);
                    double vGainLsl      = Convert.ToDouble(csvVGainLimit.Split(',').FirstOrDefault());
                    double vGainUsl      = Convert.ToDouble(csvVGainLimit.Split(',').LastOrDefault());
                    double vGainNominal  = vGainLsl + ((vGainUsl - vGainLsl) / 2);
                    // set result spec limits dynamically
                    myTestInfo.ResultsParams[step].SpecMin = vGainLsl.ToString();
                    myTestInfo.ResultsParams[step].Nominal = vGainNominal.ToString();
                    myTestInfo.ResultsParams[step].SpecMax = vGainUsl.ToString();

                    // retreive the calculated vgain and set as result
                    myTestInfo.ResultsParams[step].Result = Vgain.ToString();

                    //if (status == true)
                    //{
                    //    Trace.WriteLine(iteSlot + "Test point complete.");
                    //    myTestInfo.ResultsParams[step].Result = "ok";
                    //}
                    //else
                    //{

                    //    myTestInfo.ResultsParams[step].Result = "FAILED";
                    //    //throw new Exception("Test point failed.");
                    //}

                    break;
                }

                case "5.9.16 Vent":
                {
                    step = 1;

                    //@@ Vent the UUT @@//

                    Trace.WriteLine(iteSlot + "Venting the UUT...");
                    status = Helper.DoThis(myLD, ref myTestInfo, "VENT", "ok", step, "ok");
checkagain:
                    retval = Helper.SendCommand(myLD, ref status, "?PRESSURES", "ok");

                    string[] resp     = retval.Split(new string[] { "(mTorr): ", "\r\nSpectrometer" }, StringSplitOptions.RemoveEmptyEntries);
                    int      Pressure = Convert.ToInt32(resp[1]);


                    Trace.WriteLine(iteSlot + "Pressure: " + Pressure + "mTorr   System Pressure: ");
                    // commented out below manual limit checking, use test executive to do the limit checking and display the result correctly
                    if (!(Pressure >= 700000 && Pressure <= 760000))
                    {
                        Thread.Sleep(2000);
                        goto checkagain;
                    }

                    Thread.Sleep(800);
                    break;
                }

                case "5.9.17 Remove_Extleak":
                {
                    step = 1;

                    //@@ Close the external calibrated leak on the test port @@//

                    Trace.WriteLine(iteSlot + "Closing the external calibrated leak on the test port...");
                    InstrumentIO.Close_Extleak(slotNum);

                    Trace.WriteLine(iteSlot + "Test point complete.");
                    myTestInfo.ResultsParams[step].Result = "ok";

                    break;
                }
                }
            }

            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                Helper.Fail_Test(ref myTestInfo, ex.Message, step);
                throw;
            }

            return(myTestInfo);
        }