Esempio n. 1
0
        /// <summary>
        /// GHI DỮ LIỆU VÀO FLASH ONT GW040H
        /// </summary>
        /// <param name="_ti"></param>
        /// <param name="ModemTelnet"></param>
        /// <returns></returns>
        bool Save_Flash(testinginfo _ti, ModemTelnet ModemTelnet)
        {
            try {
                Stopwatch st = new Stopwatch();
                st.Start();
                //write defaut bin
                if (GlobalData.initSetting.ENWRITEBIN == true)
                {
                    _ti.LOGSYSTEM += "------------------------------------------------------------\r\n";
                    _ti.LOGSYSTEM += "Thực hiện write giá trị file BIN.\r\n";
                    if (GlobalData.ListBinRegister.Count > 0)
                    {
                        foreach (var item in GlobalData.ListBinRegister)
                        {
                            ModemTelnet.Write_Register(item.Address, item.newValue);
                            Thread.Sleep(100);
                            _ti.LOGSYSTEM += string.Format("Write Register: {0} = {1}\r\n", item.Address, item.newValue);
                        }
                    }
                }
                //else {
                //    _ti.LOGSYSTEM += "------------------------------------------------------------\r\n";
                //    _ti.LOGSYSTEM += "Thực hiện reset giá trị file BIN.\r\n";
                //    if (GlobalData.oldListBinRegister.Count > 0) {
                //        foreach (var item in GlobalData.oldListBinRegister) {
                //            ModemTelnet.Write_Register(item.Address, item.Value);
                //            Thread.Sleep(100);
                //            _ti.LOGSYSTEM += string.Format("Write Register Back Value: {0} = {1}\r\n", item.Address, item.Value);
                //        }
                //    }
                //}

                //save flash
                _ti.LOGSYSTEM += "------------------------------------------------------------\r\n";
                _ti.LOGSYSTEM += "Thực hiện lưu vào FLASH.\r\n";
                ModemTelnet.Write_into_Flash();
                st.Stop();
                _ti.LOGSYSTEM += string.Format("Thời gian lưu vào FLASH : {0} ms\r\n", st.ElapsedMilliseconds);
                return(true);
            }
            catch {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// CALIB CÔNG SUẤT *******************************************
        /// 1. Calibrate_Pwr_Detail --------//Core
        /// 2. AutoCalibPower --------------//Hỗ trợ tự động test nhiều
        /// 3. Calibrate_Pwr_2G_Total ------//
        /// 4. Calibrate_Pwr_5G_Total ------//
        ///
        /// </summary>
        #region CALIB POWER

        private bool Calibrate_Pwr_Detail(testinginfo _ti, ModemTelnet ModemTelnet, Instrument instrument, string Standard_2G_or_5G, string RFinput, string Anten, string Channel_Freq, string Register, double Attenuator)
        {
            string Register_Old_Value_Pwr = "", Register_New_Value_Pwr = "";
            bool   _flag = true;

            try {
                Register_Old_Value_Pwr = ModemTelnet.Read_Register(Register.Split('x')[1]);
                if (Register_Old_Value_Pwr.Contains(Register.Split('x')[1]))
                {
                    Register_Old_Value_Pwr = ModemTelnet.Read_Register(Register.Split('x')[1]);
                    return(false);
                }
                else
                {
                    _ti.LOGSYSTEM += "Giá trị thanh ghi " + Register + " hiện tại: " + Register_Old_Value_Pwr + "\r\n";
                    ModemTelnet.CalibPower_SendCommand(Standard_2G_or_5G, Anten, Channel_Freq);
                    string _error = "";
                    instrument.config_Instrument_Channel(Channel_Freq, ref _error);
                    ModemTelnet.Read_Register(Register.Split('x')[1]);

                    for (int i = 0; i < 2; i++)
                    {
                        if (i == 0)
                        {
                            if (Standard_2G_or_5G == "2G")
                            {
                                instrument.config_Instrument_get_Power("RFB", "g");
                                Power_Measure = FunctionSupport.RoundDecimal(Convert.ToDouble(instrument.config_Instrument_get_Power("RFB", "g")) + Attenuator);
                                if (Convert.ToDouble(Power_Measure) < 15)
                                {
                                    Power_Measure = FunctionSupport.RoundDecimal(Convert.ToDouble(instrument.config_Instrument_get_Power("RFB", "g")) + Attenuator);
                                }
                                _ti.LOGSYSTEM += "Công suất đo được: " + Power_Measure + " (dBm)" + "\r\n";
                            }
                            else if (Standard_2G_or_5G == "5G")
                            {
                                instrument.config_Instrument_get_Power("VID", "g");
                                Power_Measure = FunctionSupport.RoundDecimal(Convert.ToDouble(instrument.config_Instrument_get_Power("VID", "g")) + Attenuator);
                                if (Convert.ToDouble(Power_Measure) < 15)
                                {
                                    Power_Measure = FunctionSupport.RoundDecimal(Convert.ToDouble(instrument.config_Instrument_get_Power("VID", "g")) + Attenuator);
                                }
                                _ti.LOGSYSTEM += "Công suất đo được: " + Power_Measure + " (dBm)" + "\r\n";
                            }
                        }
                        if (i == 1)
                        {
                            if (Standard_2G_or_5G == "2G")
                            {
                                instrument.config_Instrument_get_Power("VID", "g");
                                Power_Measure = FunctionSupport.RoundDecimal(Convert.ToDouble(instrument.config_Instrument_get_Power("VID", "g")) + Attenuator);
                                if (Convert.ToDouble(Power_Measure) < 15)
                                {
                                    Power_Measure = FunctionSupport.RoundDecimal(Convert.ToDouble(instrument.config_Instrument_get_Power("VID", "g")) + Attenuator);
                                }
                                _ti.LOGSYSTEM += "Công suất đo được: " + Power_Measure + " (dBm)" + "\r\n";
                            }
                            else if (Standard_2G_or_5G == "5G")
                            {
                                instrument.config_Instrument_get_Power("RFB", "g");
                                Power_Measure = FunctionSupport.RoundDecimal(Convert.ToDouble(instrument.config_Instrument_get_Power("RFB", "g")) + Attenuator);
                                if (Convert.ToDouble(Power_Measure) < 15)
                                {
                                    Power_Measure = FunctionSupport.RoundDecimal(Convert.ToDouble(instrument.config_Instrument_get_Power("RFB", "g")) + Attenuator);
                                }
                                _ti.LOGSYSTEM += "Công suất đo được: " + Power_Measure + " (dBm)" + "\r\n";
                            }
                        }

                        if (Standard_2G_or_5G == "2G")
                        {
                            Power_diferent = Power_Measure - Convert.ToDouble(Target_Pwr_2G);
                        }
                        else if (Standard_2G_or_5G == "5G")
                        {
                            Power_diferent = Power_Measure - Convert.ToDouble(Target_Pwr_5G);
                        }

                        _ti.LOGSYSTEM += "Độ lệch công suất: " + Power_diferent + " (dBm)" + "\r\n";

                        if (Power_diferent < 10)
                        {
                            if (Power_diferent == 0)
                            {
                                goto END;
                            }
                            Calculate_NewValue(Register_Old_Value_Pwr, out Register_New_Value_Pwr);

                            if (Register_New_Value_Pwr.Contains("ERROR"))
                            {
                                _ti.LOGSYSTEM += "[FAIL] Bắt đầu thực hiện lại.\r\n";
                                _flag          = false;
                                continue;
                            }
                            else
                            {
                                _ti.LOGSYSTEM += "Giá trị cần truyền: " + Register_New_Value_Pwr + "\r\n";
                                ModemTelnet.Write_Register(Register.Split('x')[1], Register_New_Value_Pwr);
                                _flag = true;
                                break;
                            }
                        }
                        else
                        {
                            //MessageBox.Show("Lỗi đọc Power.");
                            _flag = false;
                        }
                    }
                }
END:
                var propInfo = GlobalData.logRegister.GetType().GetProperty(string.Format("_{0}", Register));
                if (propInfo != null)
                {
                    propInfo.SetValue(GlobalData.logRegister, Register_New_Value_Pwr == "" ? Register_Old_Value_Pwr.Substring(2, 2) : Register_New_Value_Pwr.Substring(2, 2), null);
                }
                return(_flag);
            }
            catch {
                return(false);
            }
        }