コード例 #1
0
        /// <summary>
        /// CALIB TẦN SỐ *********************************************
        /// 1. Calibrate_Freq -------------//Calib tần số
        /// 2. Calculate_NewValue ---------//
        ///
        /// </summary>
        #region CALIB FREQUENCY

        //OK
        private bool Calibrate_Freq(testinginfo _ti, ModemTelnet ModemTelnet, Instrument instrument, int retry)
        {
            Stopwatch st = new Stopwatch();

            st.Start();
            _ti.LOGSYSTEM += "------------------------------------------------------------\r\n";
            string  F4F6   = "";
            string  F4     = "";
            string  F4_6_0 = "";
            decimal F4_6_0_DEC;
            string  F6     = "";
            string  F6_5_0 = "";
            decimal F6_5_0_DEC;
            decimal FreOffset_new;
            string  Current_Freq_Offset = "";
            string  Freq_Err            = "";
            string  F7 = "";
            decimal F6_5_0_new_DEC;

            //if (!Connect_Function()) {
            //    Hien_Thi.Hienthi.SetText(rtb, "Không thực hiện được quá trình Calib tần số.");
            //    return false;
            //    //return "STOP";
            //}
            //else {
            try {
                _ti.LOGSYSTEM += "Bắt đầu quá trình Calib tần số." + "\r\n";
                _ti.LOGSYSTEM += "Đang đọc thanh ghi F4,F6..." + "\r\n";
                ModemTelnet.WriteLine("iwpriv ra0 e2p F4");
                Thread.Sleep(50);
                ModemTelnet.WriteLine("iwpriv ra0 e2p F6");
                Thread.Sleep(50);
                F4F6 = ModemTelnet.Read();
                for (int i = 0; i < F4F6.Split('\n').Length; i++)
                {
                    if (F4F6.Split('\n')[i].Contains("[0x00F4]"))
                    {
                        F4 = F4F6.Split('\n')[i].Split(':')[1].Trim();
                    }

                    if (F4F6.Split('\n')[i].Contains("[0x00F6]"))
                    {
                        F6 = F4F6.Split('\n')[i].Split(':')[1].Trim();
                    }
                }

                _ti.LOGSYSTEM += "0x00F4 = " + F4 + "; " + "0x00F6 = " + F6 + "\r\n";
                F4_6_0         = FunctionSupport.HextoBin(F4.Substring(4, 2)).Substring(1, 7);
                //MessageBox.Show(F4_6_0);
                F4_6_0_DEC          = Convert.ToInt64(F4_6_0, 2);
                F6_5_0              = FunctionSupport.HextoBin(F6.Substring(4, 2)).Substring(2, 6);
                F6_5_0_DEC          = Convert.ToInt64(F6_5_0, 2);
                _ti.LOGSYSTEM      += "F4[6:0] = " + F4_6_0 + "; " + "F6[5:0] = " + F6_5_0 + "\r\n";
                _ti.LOGSYSTEM      += "F4[6:0]_DEC = " + F4_6_0_DEC + "; " + "F6[5:0]_DEC = " + F6_5_0_DEC + "\r\n";
                Current_Freq_Offset = FunctionSupport.Plus_F4_With_F6(F4, F6); //Tính giá trị FreqOffset ban đầu
                _ti.LOGSYSTEM      += "Giá trị Frequency Offset hiện tại = F4[6,0] +/- F6[5,0] = " + Current_Freq_Offset + "\r\n";

                //Gửi lệnh phát tín hiệu kèm Frequency Offset
                _ti.LOGSYSTEM += "Gửi lệnh phát tín hiệu kèm Current_Freq_Offset: " + Current_Freq_Offset + "\r\n";
                _ti.LOGSYSTEM += string.Format("Đang cấu hình lần đầu cho máy đo {0}...", Name_measurement) + "\r\n";

                bool _configInstrIsOk = false;
                int  _index           = 0;
                while (_configInstrIsOk == false)
                {
                    string _error = "";
                    _configInstrIsOk = instrument.config_Instrument_Total(RF_Port, "g", ref _error);
                    if (_error != "")
                    {
                        _ti.LOGSYSTEM += string.Format("{0}\r\n", _error);
                    }
                    _error           = "";
                    _configInstrIsOk = instrument.config_Instrument_Channel("2437000000", ref _error);
                    if (_error != "")
                    {
                        _ti.LOGSYSTEM += string.Format("{0}\r\n", _error);
                    }
                    _index++;
                    if (_index > 20)
                    {
                        break;
                    }
                }
                if (_configInstrIsOk == false)
                {
                    return(false);
                }

                _ti.LOGSYSTEM += string.Format("Đang phát tín hiệu ở Anten 1 - Channel 6 - Máy đo {0} - Offset = {1}", Name_measurement, Current_Freq_Offset) + "\r\n";
                ModemTelnet.CalibFrequency_SendCommand("1", "7", "0", "6", "1", Current_Freq_Offset); //(mode,rate,bw,channel,anten,freqOffset)
                                                                                                      //Thread.Sleep(500);
                                                                                                      //for (int i = 0; i < 2; i++) {
                Freq_Err = instrument.config_Instrument_get_FreqErr("RFB", "g");                      //Lệnh đọc giá trị về từ máy đo
                                                                                                      //MessageBox.Show(Freq_Err);
                _ti.LOGSYSTEM += "..." + "\r\n";
                _ti.LOGSYSTEM += "Lấy kết quả đo lần thứ: " + retry.ToString() + "\r\n";
                if (!Freq_Err.Contains("999"))
                {
                    if (Convert.ToDouble(Freq_Err) > -2000 && Convert.ToDouble(Freq_Err) < 2000)
                    {
                        _ti.LOGSYSTEM += "Frequency Err = " + Freq_Err + "\r\n";
                        _ti.LOGSYSTEM += "Frequency Error đã đạt Target." + "\r\n";
                        _ti.LOGSYSTEM += "---------------------------------" + "\r\n";
                        FreOffset_new  = Decimal.Parse(Current_Freq_Offset);
                        //Result_FreqErr_Calib = "PASS";
                        //break;
                    }
                    else
                    {
                        _ti.LOGSYSTEM += "Giá trị Frequency Error = " + Freq_Err + "\r\n";
                        if (Convert.ToDouble(Freq_Err) < 0)
                        {
                            _ti.LOGSYSTEM += "Frequency Error < 0 -> Cần giảm Frequency Offset" + "\r\n";
                        }
                        else
                        {
                            _ti.LOGSYSTEM += "Frequency Error > 0 -> Cần tăng Frequency Offset" + "\r\n";
                        }

                        _ti.LOGSYSTEM += "Mỗi 1500 Khz bị lệch tương ứng với 1 giá trị Decimal => Giá trị DEC mà Current_Freq_Offset và F6[5,0] cần thay đổi = Freq_Err / 1500 = " + Math.Round((Decimal.Parse(Freq_Err)) / 1500) + "\r\n"; //2350
                        FreOffset_new  = Math.Round(Decimal.Parse(Current_Freq_Offset) + Math.Round(Decimal.Parse(Freq_Err) / 1500));                                                                                                       //2350
                        _ti.LOGSYSTEM += "Freq_Offset_new = Current_Freq_Offset + Freq_Err/1500 = " + FreOffset_new + "\r\n";
                        string F6_DEC   = FunctionSupport.HextoDec(F6.Substring(4, 2));
                        string F6_toBin = "";
                        if (Int32.Parse(F6_DEC) == 0)
                        {
                            F6_toBin = "00000000";
                        }
                        else
                        {
                            F6_toBin = FunctionSupport.DECtoBin(Int32.Parse(F6_DEC));
                        }
                        string  F6_5_0_old       = F6_toBin.Substring(2);
                        Decimal F6_5_0_old_toDEC = Convert.ToInt32(F6_5_0_old, 2);
                        _ti.LOGSYSTEM += "F6[5,0] cũ ở dạng DEC = " + F6_5_0_old_toDEC + "\r\n";

                        //F6_5_0_new_DEC = FreOffset_new - F4_6_0_DEC;
                        if (FreOffset_new > F4_6_0_DEC)
                        {
                            F6_5_0_new_DEC = FreOffset_new - F4_6_0_DEC;
                        }
                        else
                        {
                            F6_5_0_new_DEC = F4_6_0_DEC - FreOffset_new;
                        }

                        //F6_5_0_new_DEC = Math.Round(F6_5_0_old_toDEC - (Decimal.Parse(Freq_Err) / 1500)); //2350
                        _ti.LOGSYSTEM += "F6[5,0] mới ở dạng DEC = " + F6_5_0_new_DEC + "\r\n";
                        string F6_full_new_BIN = "";
                        F7 = F6.Substring(2, 2);

                        if (FreOffset_new < Convert.ToDecimal(Current_Freq_Offset))
                        {
                            F6_full_new_BIN = FunctionSupport.KiemtraF6("Can Giam", Int32.Parse(F6_5_0_new_DEC.ToString()));
                            _ti.LOGSYSTEM  += "F6_Full_Bin_New = " + F6_full_new_BIN + "\r\n";
                            _ti.LOGSYSTEM  += "Giá trị F6 mới cần truyền: " + FunctionSupport.BintoHexOnly(F6_full_new_BIN) + "\r\n";;

                            _ti.LOGSYSTEM += "iwpriv ra0 e2p F6=" + F7 + FunctionSupport.BintoHexOnly(F6_full_new_BIN) + "\r\n";
                            ModemTelnet.WriteLine("iwpriv ra0 e2p F6=" + F7 + FunctionSupport.BintoHexOnly(F6_full_new_BIN));
                            //break;
                        }
                        else if (FreOffset_new > Convert.ToDecimal(Current_Freq_Offset))
                        {
                            F6_full_new_BIN = FunctionSupport.KiemtraF6("Can Tang", Int32.Parse(F6_5_0_new_DEC.ToString()));
                            _ti.LOGSYSTEM  += "F6_Full_Bin_New = " + F6_full_new_BIN + "\r\n";
                            _ti.LOGSYSTEM  += "Giá trị F6 mới cần truyền: " + FunctionSupport.BintoHexOnly(F6_full_new_BIN) + "\r\n";

                            _ti.LOGSYSTEM += "iwpriv ra0 e2p F6=" + F7 + FunctionSupport.BintoHexOnly(F6_full_new_BIN) + "\r\n";
                            ModemTelnet.WriteLine("iwpriv ra0 e2p F6=" + F7 + FunctionSupport.BintoHexOnly(F6_full_new_BIN));
                            //break;
                        }
                        else
                        {
                            ModemTelnet.WriteLine("iwpriv ra0 e2p F6=" + F6);
                            //break;
                        }
                        _ti.LOGSYSTEM += "-------------------------------------------" + "\r\n";
                        //_ti.LOGSYSTEM += "Thực hiện Write to Flash.");
                        //Save_Flash();

                        _ti.LOGSYSTEM += "-------------------------------------------" + "\r\n";
                        _ti.LOGSYSTEM += "Bắt đầu thực hiện Verify Frequency Error." + "\r\n";
                        _ti.LOGSYSTEM += string.Format("Đang phát tín hiệu ở Anten 1 - Channel 6") + "\r\n";
                        ModemTelnet.CalibFrequency_SendCommand("1", "7", "0", "6", "1", FreOffset_new.ToString()); //(mode,rate,bw,channel,anten,freqOffset)
                        Freq_Err       = instrument.config_Instrument_get_FreqErr("RFB", "g");                     //Lệnh đọc giá trị về từ máy đo
                        _ti.LOGSYSTEM += "Frequency Error = " + Freq_Err + "\r\n";
                        //break;
                    }
                }
                else
                {
                    //continue;
                }
                //}
                st.Stop();
                _ti.LOGSYSTEM += string.Format("Thời gian calib Freq : {0} ms\r\n", st.ElapsedMilliseconds);
                return(Math.Abs(Convert.ToDouble(Freq_Err)) < 2000);
            }
            catch {
                st.Stop();
                _ti.LOGSYSTEM += string.Format("Thời gian calib Freq : {0} ms\r\n", st.ElapsedMilliseconds);
                return(false);
                //MessageBox.Show(Ex.ToString());
                //return "STOP";
            }
            //}
        }
コード例 #2
0
        private bool AutoTestSensivitity(testinginfo _ti, ModemTelnet ModemTelnet, Instrument instrument, string _CarrierFreq)
        {
            List <sensivitity> list = null;

            _ti.LOGSYSTEM += "------------------------------------------------------------\r\n";
            _ti.LOGSYSTEM += string.Format("Bắt đầu thực hiện Test Sensitivity {0}.\r\n", _CarrierFreq);
            list           = _CarrierFreq == "2G" ? GlobalData.listSensivitity2G : GlobalData.listSensivitity5G;

            if (list.Count == 0)
            {
                return(false);
            }
            bool result = true;

            foreach (var item in list)
            {
                Stopwatch st = new Stopwatch();
                st.Start();

                string _channelNo = Attenuator.getChannelNumber(item.channelfreq);

                _ti.LOGSYSTEM += "*************************************************************************\r\n";
                _ti.LOGSYSTEM += string.Format("{0} - {1} - {2} - MCS{3} - BW{4} - Anten {5} - Channel {6}\r\n", _CarrierFreq, RF_Port, FunctionSupport.Get_WifiStandard_By_Mode(item.wifi, item.bandwidth), item.rate, 20 * Math.Pow(2, double.Parse(item.bandwidth)), item.anten, _channelNo);
                int count = 0;
REP:
                count++;
                if (!Test_Sensivitity_Detail(_ti, ModemTelnet, instrument, _CarrierFreq, item.wifi, item.rate, item.bandwidth, item.channelfreq, item.anten, item.packet))
                {
                    if (count < 3)
                    {
                        _ti.LOGSYSTEM += string.Format("RETRY = {0}\r\n", count);
                        goto REP;
                    }
                    else
                    {
                        _ti.LOGSYSTEM += string.Format("Phán định = {0}", "FAIL\r\n");
                        result         = false;
                    }
                    //result = false;
                }
                else
                {
                    _ti.LOGSYSTEM += string.Format("Phán định = {0}", "PASS\r\n");
                }
                st.Stop();
                _ti.LOGSYSTEM += string.Format("Thời gian test độ nhạy thu : {0} ms\r\n", st.ElapsedMilliseconds);
                _ti.LOGSYSTEM += "\r\n";
            }
            return(result);
        }