Example #1
0
        public Dictionary <string, double> BeginTest(DUT dut, Dictionary <string, IEquipment> equipments, Dictionary <string, string> inPara)
        {
            try
            {
                //get the current test channel
                int channel = ConditionParaByTestPlan.Channel;
                Log.SaveLogToTxt("Start to do quick check test for channel " + channel);
                //get equipment object
                PowerSupply   supply        = (PowerSupply)equipments["POWERSUPPLY"];
                Attennuator   attennuator   = (Attennuator)equipments["ATTENNUATOR"];
                OpticalSwitch opticalSwitch = (OpticalSwitch)equipments["OPTICALSWITCH"];
                PowerMeter    powerMeter    = (PowerMeter)equipments["POWERMETER"];
                //get in parameters
                string[] BiasDACs   = inPara["BIASDACS"].Split(',');
                string[] ModDACs    = inPara["MODDACS"].Split(',');
                double   ratio      = Convert.ToDouble(inPara["RATIO"]);
                double   U_Ref      = Convert.ToDouble(inPara["UREF"]);
                double   resolution = Convert.ToDouble(inPara["RESOLUTION"]);
                double   R_rssi     = Convert.ToDouble(inPara["RRSSI"]);

                //read current of power supply
                double current = supply.GetCurrent();

                // close apc
                Log.SaveLogToTxt("Close apc for module.");
                dut.CloseAndOpenAPC(Convert.ToByte(DUT.APCMODE.IBAISandIMODOFF));

                //disable attennuator and Tx to read Rx/TxDarkADC
                Log.SaveLogToTxt("Shut down attennuator and disable Tx to read Tx/RxDark ADC for channel " + channel);
                attennuator.OutPutSwitch(false);
                ushort RxDarkADC = dut.ReadADC(DUT.NameOfADC.RXPOWERADC, channel);
                dut.SetSoftTxDis();
                ushort TxDarkADC = dut.ReadADC(DUT.NameOfADC.TXPOWERADC, channel);
                Log.SaveLogToTxt("TxDarkADC is " + TxDarkADC);
                Log.SaveLogToTxt("RxDarkADC is " + RxDarkADC);

                //enable attennuator and Tx
                Log.SaveLogToTxt("Power on attennuator and set value to 0");
                attennuator.OutPutSwitch(true);
                attennuator.SetAttnValue(0);
                Log.SaveLogToTxt("Light on all Tx channel.");
                dut.TxAllChannelEnable();

                ConfigXmlIO myXml = new ConfigXmlIO(FilePath.ConfigXml);
                //get scope/powermeter's offset
                string[] offsetArray = myXml.ScopeOffset.Split(',');
                double   offset      = Convert.ToDouble(offsetArray[channel - 1]);
                //get attenator's ofset
                string[] lightSourceArray = myXml.AttennuatorOffset.Split(',');
                double   lightSource      = Convert.ToDouble(lightSourceArray[channel - 1]);
                //calculate RxRes
                double RxRes = dut.CalRxRes(lightSource, channel, ratio, U_Ref, resolution, R_rssi);
                Log.SaveLogToTxt("Calculate RES of Rx is " + RxRes.ToString("f3"));

                //set default Bias/ModDAC
                Log.SaveLogToTxt("Set BiasDAC is " + BiasDACs[channel - 1]);
                Log.SaveLogToTxt("Set ModDAC is " + ModDACs[channel - 1]);
                dut.WriteChipDAC(DUT.NameOfChipDAC.BIASDAC, channel, BiasDACs[channel - 1]);
                dut.WriteChipDAC(DUT.NameOfChipDAC.MODDAC, channel, ModDACs[channel - 1]);
                //change to related change, and read Tx power
                opticalSwitch.ChangeChannel(channel);
                double TxP = powerMeter.ReadPower(channel) + offset;
                Log.SaveLogToTxt("Get Tx power is " + TxP.ToString("f3"));

                //read SN again and check its format
                string dut_SN = dut.ReadSN();
                if (!Algorithm.CheckSerialNumberFormat(dut_SN))
                {
                    Log.SaveLogToTxt("Module' serial number is not correct");
                    return(null);
                }

                Log.SaveLogToTxt("Again. Read module' serial number is " + dut_SN);

                //save test data to TestData class
                DataRow dr = testData.NewRow();
                dr["Family"]         = GlobalParaByPN.Family;
                dr["PartNumber"]     = GlobalParaByPN.PN;
                dr["SerialNumber"]   = dut_SN;
                dr["Channel"]        = channel;
                dr["Current"]        = current.ToString("f3");
                dr["Temp"]           = ConditionParaByTestPlan.Temp;
                dr["Station"]        = GlobalParaByPN.Station;
                dr["Time"]           = DateTime.Now;
                dr["TxDarkADC"]      = TxDarkADC;
                dr["TxPower"]        = TxP.ToString("f3");
                dr["RxDarkADC"]      = RxDarkADC;
                dr["RxRes"]          = RxRes.ToString("f3");
                dr["DeltaTxDarkADC"] = -99999;
                dr["DeltaTxPower"]   = "-99999";
                dr["DeltaRxDarkADC"] = -99999;
                dr["DeltaRxRes"]     = "-99999";
                dr["Result"]         = -1;

                if (GlobalParaByPN.Station == "PreModule")
                {
                    dr["Result"] = 0;
                }
                else
                {
                    Log.SaveLogToTxt("Try to get test data of pre module station to calculate delta.");
                    //conect to mysql database to get test recording of pre module station
                    string          mysqlconCommand = "Database=my_databases;Data Source=localhost;User Id=root;Password=abc@123;pooling=false;CharSet=utf8;port=3306";
                    MySqlConnection mycon           = new MySqlConnection();
                    mycon.ConnectionString = mysqlconCommand;
                    mycon.Open();

                    string table      = "my_databases.quickcheck_testdata";
                    string experisson = "SELECT * FROM my_databases.quickcheck_testdata where PartNumber = '" + GlobalParaByPN.PN + "' and Serialnumber = '" +
                                        dut_SN + "' and Channel = " + channel + " and Temp = " + ConditionParaByTestPlan.Temp + " and Station = 'PreModule' order by ID";

                    MySqlDataAdapter    da = new MySqlDataAdapter(experisson, mycon);
                    MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
                    DataSet             ds = new DataSet(table);
                    da.Fill(ds, table);
                    DataTable dt = ds.Tables[table];
                    mycon.Close();

                    if (dt.Rows.Count != 0)
                    {
                        //calculate delta: post - pre
                        dr["DeltaTxDarkADC"] = Convert.ToInt32(dr["TxDarkADC"]) - Convert.ToInt32(dt.Rows[dt.Rows.Count - 1]["TxDarkADC"]);
                        dr["DeltaTxPower"]   = (Convert.ToDouble(dr["TxPower"]) - Convert.ToDouble(dt.Rows[dt.Rows.Count - 1]["TxPower"])).ToString("f3");
                        dr["DeltaRxDarkADC"] = Convert.ToInt32(dr["RxDarkADC"]) - Convert.ToInt32(dt.Rows[dt.Rows.Count - 1]["RxDarkADC"]);
                        double orgRxRes = Convert.ToDouble(dt.Rows[dt.Rows.Count - 1]["RxRes"]);
                        //orgRxRes can't be zero
                        dr["DeltaRxRes"] = (orgRxRes == 0) ? "-99999" : (100.0 * (Convert.ToDouble(dr["RxRes"]) - orgRxRes) / orgRxRes).ToString("f2") + "%";
                        dr["Result"]     = 0;
                        Log.SaveLogToTxt("Sucessfully get test data of pre module station.");
                        Log.SaveLogToTxt("DeltaTxDarkADC is " + dr["DeltaTxDarkADC"]);
                        Log.SaveLogToTxt("DeltaTxPower is " + dr["DeltaTxPower"]);
                        Log.SaveLogToTxt("DeltaRxDarkADC is " + dr["DeltaRxDarkADC"]);
                        Log.SaveLogToTxt("DeltaRxRes is " + dr["DeltaRxRes"]);
                    }
                    else
                    {
                        Log.SaveLogToTxt("Failed to get test data of pre module station.");
                        //return false;
                    }
                }
                testData.Rows.Add(dr);
                dr = null;
                Log.SaveLogToTxt("End quick check test for channel " + channel + "\r\n");

                //save testdata
                Dictionary <string, double> dic = new Dictionary <string, double>();
                dic.Add("Result", 1);
                return(dic);
            }
            catch
            {
                Log.SaveLogToTxt("Failed quickcheck test.");
                return(null);
            }
        }
Example #2
0
        public Dictionary <string, double> BeginTest(DUT dut, Dictionary <string, IEquipment> equipments, Dictionary <string, string> inPara)
        {
            //get the current test channel
            int channel = ConditionParaByTestPlan.Channel;

            try
            {
                //get equipment object
                Scope scope = (Scope)equipments["SCOPE"];

                //change to Tx path, if have this equipment, it can not run parallel test, just to do one by one.
                //due to it is the common equipment between Tx and Rx.
                if (equipments.Keys.Contains("NA_OPTICALSWITCH"))
                {
                    Log.SaveLogToTxt("It can not parallel initial, due to Tx/Rx have common equipment NA_OPTICALSWITCH.");
                    Log.SaveLogToTxt("have to test one by one.");
                    OpticalSwitch opticalSwitch = (OpticalSwitch)equipments["NA_OPTICALSWITCH"];
                    opticalSwitch.CheckEquipmentRole(1, (byte)channel);
                }

                lock (scope)
                {
                    Log.SaveLogToTxt("Start to do TxPowerDmi test for channel " + channel);

                    //prepare environment
                    if (scope.SetMaskAlignMethod(1) &&
                        scope.SetMode(0) &&
                        scope.MaskONOFF(false) &&
                        scope.SetRunTilOff() &&
                        scope.RunStop(true) &&
                        scope.OpenOpticalChannel(true) &&
                        scope.RunStop(true) &&
                        scope.ClearDisplay() &&
                        scope.AutoScale(1)
                        )
                    {
                        Log.SaveLogToTxt("PrepareEnvironment OK!");
                    }
                    else
                    {
                        Log.SaveLogToTxt("PrepareEnvironment Fail!");
                        return(null);
                    }

                    //test dmi
                    Log.SaveLogToTxt("Read DCA TxPower");
                    double txDCAPowerDmi = scope.GetAveragePowerdBm();
                    Log.SaveLogToTxt("txDCAPowerDmi = " + txDCAPowerDmi.ToString("f2"));
                    Log.SaveLogToTxt("Read DUT Txpower");
                    double txPowerDmi = dut.ReadDmiTxP(channel);
                    Log.SaveLogToTxt("txPowerDmi = " + txPowerDmi.ToString("f2"));
                    double txDmiPowerErr = txPowerDmi - txDCAPowerDmi;
                    Log.SaveLogToTxt("txDmiPowerErr = " + txDmiPowerErr.ToString("f2"));

                    //save testdata
                    Dictionary <string, double> dictionary = new Dictionary <string, double>();
                    dictionary.Add("DmiTxPowerErr", txDmiPowerErr);

                    //test disable power
                    //have to lock this object, due to it can't run parallel test with TestIBiasDmi
                    //as this will disable TxPower, ibiasDmi will be defected.
                    lock (dut)
                    {
                        dut.SetSoftTxDis();
                        scope.ClearDisplay();
                        double txDisablePower = scope.GetAveragePowerdBm();
                        Log.SaveLogToTxt("txDisablePower = " + txDisablePower.ToString());
                        dictionary.Add("TxDisablePower", txDisablePower);
                        Thread.Sleep(200);
                        if (!dut.TxAllChannelEnable())
                        {
                            scope.ClearDisplay();
                            Thread.Sleep(200);
                            return(null);
                        }
                    }
                    scope.ClearDisplay();
                    Thread.Sleep(200);
                    Log.SaveLogToTxt("End TxPowerDmi test " + channel + "\r\n");

                    dictionary.Add("Result", 1);
                    return(dictionary);
                }
            }
            catch
            {
                Log.SaveLogToTxt("Failed TxPowerDmi test for channel " + channel + "\r\n");
                return(null);
            }
        }