Ejemplo n.º 1
0
        public void LoadingRX()
        {
            string path1 = exePath + "\\" + setPath + "\\RX_Tables";

            string[] rx_tables_names;
            try
            {
                for (int i = 0; i < length; i++)
                {
                    if (i == 0)
                    {
                        rx_tables_names = new string[] { path1 + "\\pim_rev.txt", path1 + "\\pim_frd.txt" }
                    }
                    ;
                    else
                    {
                        rx_tables_names = new string[] { path1 + (i + 1).ToString() + "\\pim_rev.txt", path1 + (i + 1).ToString() + "\\pim_frd.txt" }
                    };
                    Rx_Tables.NewTables(rx_tables_names);
                    list_st = Rx_Tables.LoadTables_ygq();
                    list_list.Add(list_st);
                }
            }
            catch
            {
                MessageBox.Show("校准文件错误");
                Application.Exit();
            }
        }
Ejemplo n.º 2
0
 public void   GetRX(int i)
 {
     if (i > list_st.Count + 1)
     {
         Rx_Tables.LoadTables_ygq(list_list[0]);
     }
     else
     {
         Rx_Tables.LoadTables_ygq(list_list[i]);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取功放输出功率、频率,频谱分析的场强值,并应用补偿数据
        /// 处理数据,并更新界面
        /// </summary>
        private void SweepProcesing2()
        {
            float          tx_out   = 0.0f;
            float          rx_value = 0.0f;
            Auto_CAL_Items Cal_Carrier;

            //获取功放状态、分析数据、异常信息
            SweepObj.CloneReference(ref ps1, ref ps2, ref sr, ref rfr_errors1, ref rfr_errors2);

            //处理扫频
            if (sweep_or_time == SweepType.Freq_Sweep)
            {
                //功放1扫频
                if (rf_involved == RFInvolved.Rf_1)
                {
                    sweep_points[0].X = ps1.Status2.Freq;

                    Cal_Carrier = RL0_Tables.Cal_Carrier(FuncModule.ISO, RFInvolved.Rf_1);
                    cal_item    = Cal_Carrier.GetItem(ps1.Status2.Freq);

                    if (App_Configure.Cnfgs.Cal_Use_Table)
                    {
                        tx_out   = ps1.Status2.OutP + Tx_Tables.iso_tx1_disp.Offset(ps1.Status2.Freq, ps1.Status2.OutP, Tx_Tables.har_offset1_disp);
                        rx_value = sr.dBmValue + Rx_Tables.Offset(ps1.Status2.Freq, FuncModule.ISO);
                    }
                    else
                    {
                        tx_out   = (float)App_Factors.iso_tx1_disp.ValueWithOffset(ps1.Status2.Freq, ps1.Status2.OutP);
                        rx_value = (float)App_Factors.iso_rx1.ValueWithOffset(ps1.Status2.Freq, sr.dBmValue);
                    }

                    sweep_points[0].Y = (tx_out - rx_value) -
                                        (cal_item.Tx0 - cal_item.Rx0) + cal_item.RL0; // -this.settings.Offset;

                    lblF.Text  = "F:" + sweep_points[0].X.ToString("0.0") + "MHz";
                    lblTx.Text = "Tx:" + tx_out.ToString("0.0") + "dBm";

                    //功放2扫频
                }
                else
                {
                    sweep_points[0].X = ps2.Status2.Freq;

                    Cal_Carrier = RL0_Tables.Cal_Carrier(FuncModule.ISO, RFInvolved.Rf_2);
                    cal_item    = Cal_Carrier.GetItem(ps2.Status2.Freq);

                    if (App_Configure.Cnfgs.Cal_Use_Table)
                    {
                        tx_out   = ps2.Status2.OutP + Tx_Tables.iso_tx2_disp.Offset(ps2.Status2.Freq, ps2.Status2.OutP, Tx_Tables.iso_offset2_disp);
                        rx_value = sr.dBmValue + Rx_Tables.Offset(ps2.Status2.Freq, FuncModule.ISO);
                    }
                    else
                    {
                        tx_out   = (float)App_Factors.iso_tx2_disp.ValueWithOffset(ps2.Status2.Freq, ps2.Status2.OutP);
                        rx_value = (float)App_Factors.iso_rx2.ValueWithOffset(ps2.Status2.Freq, sr.dBmValue);
                    }

                    sweep_points[0].Y = (tx_out - rx_value) -
                                        (cal_item.Tx0 - cal_item.Rx0) + cal_item.RL0; //- this.settings.Offset;

                    lblF.Text  = "F:" + sweep_points[0].X.ToString("0.0") + "MHz";
                    lblTx.Text = "Tx:" + tx_out.ToString("0.0") + "dBm";
                }

                lblRx.Text    = "Rx:" + sr.dBmValue.ToString("0.0") + "dBm";
                lblNoise.Text = "Noise:" + sr.dBmNosie.ToString("0.0") + "dBm";
                pltIso.Add(sweep_points, 0, PointsDone);

                //处理扫时
            }
            else
            {
                sweep_points[0].X = PointsDone;

                //功放1扫时
                if (rf_involved == RFInvolved.Rf_1)
                {
                    Cal_Carrier = RL0_Tables.Cal_Carrier(FuncModule.ISO, RFInvolved.Rf_1);
                    cal_item    = Cal_Carrier.GetItem(ps1.Status2.Freq);

                    if (App_Configure.Cnfgs.Cal_Use_Table)
                    {
                        tx_out   = ps1.Status2.OutP + Tx_Tables.iso_tx1_disp.Offset(ps1.Status2.Freq, ps1.Status2.OutP, Tx_Tables.iso_offset1_disp);
                        rx_value = sr.dBmValue + Rx_Tables.Offset(ps1.Status2.Freq, FuncModule.ISO);
                    }
                    else
                    {
                        tx_out   = (float)App_Factors.iso_tx1_disp.ValueWithOffset(ps1.Status2.Freq, ps1.Status2.OutP);
                        rx_value = (float)App_Factors.iso_rx1.ValueWithOffset(ps1.Status2.Freq, sr.dBmValue);
                    }

                    sweep_points[0].Y = (tx_out - rx_value) -
                                        (cal_item.Tx0 - cal_item.Rx0) + cal_item.RL0; //- this.settings.Offset;

                    lblF.Text  = "F:" + ps1.Status2.Freq.ToString("0.0") + "MHz";
                    lblTx.Text = "Tx:" + tx_out.ToString("0.0") + "dBm";

                    //功放2扫时
                }
                else
                {
                    Cal_Carrier = RL0_Tables.Cal_Carrier(FuncModule.ISO, RFInvolved.Rf_2);
                    cal_item    = Cal_Carrier.GetItem(ps2.Status2.Freq);

                    if (App_Configure.Cnfgs.Cal_Use_Table)
                    {
                        tx_out   = ps2.Status2.OutP + Tx_Tables.iso_tx2_disp.Offset(ps2.Status2.Freq, ps2.Status2.OutP, Tx_Tables.iso_offset2_disp);
                        rx_value = sr.dBmValue + Rx_Tables.Offset(ps2.Status2.Freq, FuncModule.ISO);
                    }
                    else
                    {
                        tx_out   = (float)App_Factors.iso_tx2_disp.ValueWithOffset(ps2.Status2.Freq, ps2.Status2.OutP);
                        rx_value = (float)App_Factors.iso_rx2.ValueWithOffset(ps2.Status2.Freq, sr.dBmValue);
                    }

                    sweep_points[0].Y = (tx_out - rx_value) -
                                        (cal_item.Tx0 - cal_item.Rx0) + cal_item.RL0; //- this.settings.Offset;

                    lblF.Text  = "F:" + ps2.Status2.Freq.ToString("0.0") + "MHz";
                    lblTx.Text = "Tx:" + tx_out.ToString("0.0") + "dBm";
                }

                lblRx.Text    = "Rx:" + rx_value.ToString("0.0") + "dBm";
                lblNoise.Text = "Noise:" + sr.dBmNosie.ToString("0.0") + "dBm";
                pltIso.Add(sweep_points, 0, PointsDone);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 计算频谱补偿
        /// </summary>
        /// <param name="freq">频率</param>
        /// <param name="p">接收到的功率</param>
        /// <returns>补偿后的功率</returns>
        private float OffsetSpec(float freq, float p)
        {
            float revP = p;

            if (App_Configure.Cnfgs.Cal_Use_Table)
            {
                if (rad_rev.Checked)
                {
                    if ((int)comboBoxFun.SelectedValue == 0)
                    {
                        revP = Rx_Tables.Offset(freq, FuncModule.PIM, true) + p;
                    }
                    //else if ((int)comboBoxFun.SelectedValue == 1)
                    //{
                    //    revP = Rx_Tables.Offset(freq, FuncModule.ISO) + p;
                    //}
                    //else if ((int)comboBoxFun.SelectedValue == 2)
                    //{
                    //    revP = Rx_Tables.Offset(freq, FuncModule.VSW) + p;
                    //}
                    //else
                    //{
                    //    revP = Rx_Tables.Offset(freq, FuncModule.HAR) + p;
                    //}
                }
                else
                {
                    if ((int)comboBoxFun.SelectedValue == 0)
                    {
                        revP = Rx_Tables.Offset(freq, FuncModule.PIM, false) + p;
                    }
                }
            }
            else
            {
                if ((int)comboBoxFun.SelectedValue == 0)
                {
                    if (App_Configure.Cnfgs.Channel == 0)
                    {
                        revP = (float)App_Factors.pim_rx1.ValueWithOffset(freq, p);
                    }
                    else if (App_Configure.Cnfgs.Channel == 1)
                    {
                        revP = (float)App_Factors.pim_rx2.ValueWithOffset(freq, p);
                    }
                }
                else if ((int)comboBoxFun.SelectedValue == 1)
                {
                    //revP = (float)App_Factors.iso_rx1.ValueWithOffset(freq, p);
                }
                else if ((int)comboBoxFun.SelectedValue == 2)
                {
                    //revP = (float)App_Factors.vsw_rx1.ValueWithOffset(freq, p);
                }
                else
                {
                    //revP = (float)App_Factors.har_rx1.ValueWithOffset(freq, p);
                }
            }

            return((float)Math.Round(revP, 2));
        }
Ejemplo n.º 5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool  running = false;
            Mutex mt      = new Mutex(true, "jcPimSoftware", out running);

            //获取程序执行路径
            string exePath = Application.StartupPath;

            //加载全局配置文件
            App_Configure.NewConfigure(exePath + "\\Configures.ini");
            App_Configure.Cnfgs.LoadSettings();

            //判断授权文件
            Code c = new Code();

            try
            {
                if (File.Exists(Code.strFilePath))
                {
                    if (!c.CheckFile(App_Configure.Cnfgs.SN.ToLower()))
                    {
                        running = false;
                        MessageBox.Show("授权日期已到!");
                    }
                }
                else
                {
                    running = false;
                    MessageBox.Show("请先生成授权文件!");
                }
            }
            catch
            {
                running = false;
                MessageBox.Show("授权文件缺失或错误,请重新生成授权文件!");
            }

            if (running)
            {
                sf = new StartForm("Initializing......\r\n");
                Thread t = new Thread(new ThreadStart(Show));
                t.IsBackground = true;
                t.Start();
                try
                {
                    //ygq
                    string s = Copy(Application.StartupPath + "\\settings", "D:\\settings");
                    //



                    #region 加载主配置文件,获取配置文件相对路径
                    //获取程序执行路径
                    //string exePath = Application.StartupPath;

                    //加载全局配置文件
                    //App_Configure.NewConfigure(exePath + "\\Configures.ini");
                    //App_Configure.Cnfgs.LoadSettings();


                    //获取配置文件夹路径
                    string setPath = App_Configure.Cnfgs.Path_Def;
                    #endregion

                    #region 建立功放补偿表格文件对象,并加载数据
                    //TX补偿文件
                    if (App_Configure.Cnfgs.Ms_switch_port_count <= 0)
                    {
                        //Tx_Tables.NewTables(exePath + "\\" + setPath + "\\Tx_Tables\\signal_tx_rev.ini",
                        //                    exePath + "\\" + setPath + "\\Tx_Tables\\signal_tx_disp_rev.ini"
                        //                  );


                        if (App_Configure.Cnfgs.Mode >= 2)
                        {
                            Tx_Tables.NewTables(exePath + "\\" + setPath + "\\Tx_Tables\\signal_tx_rev.ini",
                                                exePath + "\\" + setPath + "\\Tx_Tables\\signal_tx_disp_rev.ini",
                                                exePath + "\\" + setPath + "\\Tx_Tables\\signal_tx_rev2.ini",
                                                exePath + "\\" + setPath + "\\Tx_Tables\\signal_tx_disp_rev2.ini"
                                                );

                            Tx_Tables.LoadTables();

                            //RX补偿文件
                            string path1 = exePath + "\\" + setPath + "\\RX_Tables";
                            //string[] rx_tables_names = { path1 + "\\pim_rev.txt", path1 + "\\pim_frd.txt" };
                            string[] rx_tables_names = { path1 + "\\pim_rev.txt",  path1 + "\\pim_frd.txt",
                                                         path1 + "\\pim_rev2.txt", path1 + "\\pim_frd2.txt" };
                            Rx_Tables.NewTables(rx_tables_names);

                            Rx_Tables.LoadTables();
                        }

                        else
                        {
                            Tx_Tables.NewTables(exePath + "\\" + setPath + "\\Tx_Tables\\signal_tx_rev.ini",
                                                exePath + "\\" + setPath + "\\Tx_Tables\\signal_tx_disp_rev.ini"
                                                );

                            Tx_Tables.LoadTables2();

                            //RX补偿文件
                            string   path1           = exePath + "\\" + setPath + "\\RX_Tables";
                            string[] rx_tables_names = { path1 + "\\pim_rev.txt", path1 + "\\pim_frd.txt" };

                            Rx_Tables.NewTables(rx_tables_names);

                            Rx_Tables.LoadTables();
                        }
                    }
                    else
                    {
                        bool com_client = MsSwithc.ClientCom();
                        //mSwitch = new MotorSwitch();
                        //bool com_client = mSwitch.Connect("192.168.1.178", 4001);
                        if (com_client)
                        {
                            sf.GetInfoMation("Load switch successfully!");
                        }
                        else
                        {
                            sf.GetInfoMation("Load switch failed!");
                        }
                        offset = new Offset(App_Configure.Cnfgs.Ms_switch_port_count);
                        int a = int.Parse(IniFile.GetString("cnfgs", "xuhao", "0", exePath + "\\Configures.ini"));
                        offset.LoadingRX();
                        offset.LoadingTX();
                        offset.GetTX(a);
                        offset.GetRX(a);
                    }
                    //建立补偿系数文件对象,并加载文件
                    App_Factors.NewFactors(exePath + "\\" + setPath + "\\Offsets_Tx.ini",
                                           exePath + "\\" + setPath + "\\Offsets_Tx_Disp.ini",
                                           exePath + "\\" + setPath + "\\Offsets_Rx.ini");
                    App_Factors.LoadFactros();

                    #endregion

                    #region 建立频谱补偿表格文件对象,并加载数据
                    //频谱补偿文件
                    string   path2            = exePath + "\\" + setPath + "\\Spectrum_Tables";
                    string[] spc_tables_names = { path2 + "\\Ch1_4KHz.txt", path2 + "\\Ch1_20KHz.txt", path2 + "\\Ch1_100KHz.txt", path2 + "\\Ch1_1000KHz.txt",
                                                  path2 + "\\Ch2_4KHz.txt", path2 + "\\Ch2_20KHz.txt", path2 + "\\Ch2_100KHz.txt", path2 + "\\Ch2_1000KHz.txt" };

                    Spectrum_Tables.NewTables(spc_tables_names);
                    #endregion ;

                    #region 建立RLO校准文件对象,并加载数据
                    //string path4 = exePath + "\\" + setPath + "\\RL0_Tables";
                    //string[] rl0_tables_names = {path4 + "\\iso_tx1.txt", path4 + "\\iso_tx2.txt",
                    //                         path4 + "\\vsw_tx1.txt", path4 + "\\vsw_tx2.txt",
                    //                         path4 + "\\har_tx1.txt", path4 + "\\har_tx2.txt"};

                    //RL0_Tables.NewTables(rl0_tables_names);
                    //RL0_Tables.LoadTables();
                    #endregion

                    #region 建立默认模块配置信息对象,并加载数据
                    //默认模块配置文件
                    string   path3          = "D:\\" + setPath;
                    string[] settings_names = { path3 + "\\Settings_Sgn.ini", path3 + "\\Settings_Pim.ini",
                                                path3 + "\\Settings_Spc.ini",
                                                path3 + "\\Specifics.ini" };

                    App_Settings.NewSettings(settings_names);
                    App_Settings.LoadSettings();
                    #endregion

                    #region 加载皮肤资源
                    FileInfo f    = new FileInfo(exePath + "\\" + App_Configure.Cnfgs.Skin_pack_path);
                    string   name = f.Name.Substring(0, f.Name.LastIndexOf("."));
                    ImagesManage.LoadImageDLL(name);
                    #endregion

                    #region 加载语言包资源

                    #endregion


                    //建立报告文件夹结构
                    App_Configure.CreateReportFolder();

                    //建立用户配置文件夹结构
                    App_Configure.CreateUsrSettingFolder();

                    sf.GetInfoMation("Load default configuration successfully!");
                }
                catch
                {
                    sf.GetInfoMation("Load default configuration failed!");
                }
                NativeMessage.PostMessage(handel, MessageID.SF_WAIT, 0, 0);
                #region 建立程序主窗体
                frmMain = new MainForm();
                NativeMessage.PostMessage(handel, MessageID.SF_CONTINUTE, 0, 0);
                #endregion

                #region 建立射频功放层
                RFSignal.InitRFSignal(frmMain.Handle);
                bool flag      = false;
                int  adrr1     = App_Configure.Cnfgs.ComAddr1;
                int  adrr2     = App_Configure.Cnfgs.ComAddr2;
                int  rfClass   = App_Configure.Cnfgs.RFClass;
                int  rFFormula = App_Configure.Cnfgs.RFFormula;

                flag = RFSignal.NewRFSignal(adrr1, rfClass, rFFormula);
                if (flag)
                {
                    sf.GetInfoMation("Serial " + adrr1.ToString() + " initialized successfully!");
                    sf.status = sf.status & 1;
                }
                else
                {
                    sf.GetInfoMation("Serial " + adrr1.ToString() + " initialized failed!");
                    sf.status = sf.status & 0;
                }
                flag = RFSignal.NewRFSignal(adrr2, rfClass, rFFormula);

                if (flag)
                {
                    sf.GetInfoMation("Serial " + adrr2.ToString() + " initialized successfully!");
                    sf.status = sf.status & 1;
                }
                else
                {
                    sf.GetInfoMation("Serial " + adrr2.ToString() + " initialized failed!");
                    sf.status = sf.status & 0;
                }
                RFSignal.RFOff(adrr1, 2);
                RFSignal.RFOff(adrr2, 2);

                #endregion
                NativeMessage.PostMessage(handel, MessageID.SF_WAIT, 0, 0);
                #region WINIO、GPIO初始化操作

                flag = GPIO.InitWinIo();

                if (!flag)
                {
                    Thread.Sleep(300);
                    flag = GPIO.InitWinIo();
                }

                if (flag)
                {
                    sf.GetInfoMation("WINIO initialized successfully!");
                    sf.status = sf.status & 1;
                }
                else
                {
                    // Log.WriteLog("winIO初始化失败!", Log.EFunctionType.TestMode);
                    sf.GetInfoMation("WINIO initialized failed!");
                    sf.status = sf.status & 0;
                }
                sf.Complete = true;
                //GPIO.Narrowband();
                NativeMessage.PostMessage(handel, MessageID.SF_CONTINUTE, 0, 0);
                #endregion

                #region 判断Bird频谱仪状态

                if (App_Configure.Cnfgs.Spectrum == 1)
                {
                    FunTimeout                   tf           = new FunTimeout();
                    SpectrumLib.ISpectrum        ISpectrumObj = new SpectrumLib.Spectrums.BirdSh(handel, MessageID.SPECTRUEME_SUCCED, MessageID.SPECTRUM_ERROR);
                    SpectrumLib.Models.ScanModel model        = new SpectrumLib.Models.ScanModel();
                    sf.ISpectrumObj = ISpectrumObj;
                    if (ISpectrumObj.ConnectSpectrum() != 1)
                    {
                        GPIO.SetHigh();
                        Thread.Sleep(1000);
                        GPIO.SetLow();
                        ISpectrumObj.ResetStatus();
                        sf.GetInfoMation("Bird connect failed!");
                        Log.WriteLog("Bird connect failed!", Log.EFunctionType.SPECTRUM);
                    }
                    model.StartFreq = 900;
                    model.EndFreq   = 900.5;
                    model.Att       = 0;
                    model.Rbw       = 10 * 1000;
                    model.Vbw       = 3 * 1000;
                    model.Continued = false;
                    model.Unit      = SpectrumLib.Defines.CommonDef.EFreqUnit.MHz;

                    tf.obj = model;
                    tf.Do  = ISpectrumObj.StartAnalysis;
                    if (tf.DoWithTimeout(new TimeSpan(0, 0, 0, 1)))
                    {
                        GPIO.SetHigh();
                        Thread.Sleep(1000);
                        GPIO.SetLow();
                        ISpectrumObj.ResetStatus();
                        Log.WriteLog("Bird get data failed!", Log.EFunctionType.SPECTRUM);
                    }
                }

                #endregion

                #region 判断Deli频谱仪状态

                if (App_Configure.Cnfgs.Spectrum == 2)
                {
                    try
                    {
                        SpectrumLib.ISpectrum        ISpectrumObj = new SpectrumLib.Spectrums.Deli(handel, MessageID.SPECTRUEME_SUCCED, MessageID.SPECTRUM_ERROR);
                        SpectrumLib.Models.ScanModel model        = new SpectrumLib.Models.ScanModel();
                        sf.ISpectrumObj = ISpectrumObj;
                        if (ISpectrumObj.ConnectSpectrum() != 1)
                        {
                            ISpectrumObj.ResetStatus();
                            sf.GetInfoMation("Deli spectrum connect failed !");
                            Log.WriteLog("Deli spectrum connect failed!", Log.EFunctionType.SPECTRUM);
                        }
                        else
                        {
                            object o;
                            model.StartFreq         = App_Settings.pim.F1;
                            model.EndFreq           = model.StartFreq + 2 * App_Settings.pim.Scanband;
                            model.Unit              = SpectrumLib.Defines.CommonDef.EFreqUnit.MHz;
                            model.Att               = App_Settings.pim.Att_Spc;
                            model.Rbw               = App_Settings.pim.Rbw_Spc;
                            model.Vbw               = App_Settings.pim.Vbw_Spc;
                            model.Deli_averagecount = 6;
                            model.Deli_detector     = "AVERage";//检波方式
                            model.Deli_ref          = -50;
                            model.Deli_refoffset    = 0;
                            model.Deli_specing      = "LOGarithmic";
                            model.Deli_sweepmode    = "PERFormance"; //扫描模式
                            model.Deli_source       = "FREERUN";     //触发方式
                            model.Deli_scale        = 10;            //单位/格
                            model.Deli_startspe     = 0;             //频谱仪是否第一次启动
                            model.Deli_isSpectrum   = true;          //频谱模式

                            o = model;
                            if (!ISpectrumObj.Setting(o))
                            {
                                Thread.Sleep(1000);
                                ISpectrumObj.ResetStatus();
                                sf.GetInfoMation("Deli spectrum set failed !");
                                Log.WriteLog("Deli spectrum set failed!", Log.EFunctionType.SPECTRUM);
                            }
                        }
                    }
                    catch
                    {
                        sf.GetInfoMation("Deli spectrum connect failed !");
                        Log.WriteLog("Deli connect failed!", Log.EFunctionType.SPECTRUM);
                    }
                }
                #endregion

                #region 判断FanShuang收信机状态

                if (App_Configure.Cnfgs.Spectrum == SpectrumType.FanShuang)
                {
                    FunTimeout                   tf           = new FunTimeout();
                    SpectrumLib.ISpectrum        ISpectrumObj = new SpectrumLib.Spectrums.FanShuang(handel, MessageID.SPECTRUEME_SUCCED, MessageID.SPECTRUM_ERROR);
                    SpectrumLib.Models.ScanModel model        = new SpectrumLib.Models.ScanModel();
                    sf.ISpectrumObj = ISpectrumObj;
                    if (ISpectrumObj.ConnectSpectrum() != 1)
                    {
                        GPIO.SetHigh();
                        Thread.Sleep(1000);
                        GPIO.SetLow();
                        ISpectrumObj.ResetStatus();
                        sf.GetInfoMation("FanShaung connect failed!");
                        Log.WriteLog("FanShaung connect failed!", Log.EFunctionType.SPECTRUM);
                    }
                }

                #endregion

                mre.WaitOne();

                #region 启动程序

                Application.Run(frmMain);
                mt.ReleaseMutex();
            }
            else
            {
                Application.Exit();
            }
            #endregion

            #region 释放资源
            RFSignal.FinaRFSignal();
            #endregion
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取功放输出功率、频率,频谱分析的场强值,并应用补偿数据
        /// 处理数据,并更新界面
        /// </summary>
        private void SweepProcesing2()
        {
            float tx_out   = 0.0f;
            float rx_value = 0.0f;

            //获取功放状态、分析数据、异常信息
            SweepObj.CloneReference(ref ps1, ref ps2, ref sr, ref rfr_errors1, ref rfr_errors2);

            //处理扫频
            if (sweep_or_time == SweepType.Freq_Sweep)
            {
                //功放1扫频
                if (rf_involved == RFInvolved.Rf_1)
                {
                    sweep_points[0].X = ps1.Status2.Freq * settings.Multiplier;

                    if (App_Configure.Cnfgs.Cal_Use_Table)
                    {
                        tx_out   = ps1.Status2.OutP + Tx_Tables.har_tx1_disp.Offset(ps1.Status2.Freq, ps1.Status2.OutP, Tx_Tables.har_offset1_disp);
                        rx_value = sr.dBmValue + Rx_Tables.Offset(ps1.Status2.Freq * this.settings.Multiplier, FuncModule.HAR);
                    }
                    else
                    {
                        tx_out   = (float)App_Factors.har_tx1_disp.ValueWithOffset(ps1.Status2.Freq, ps1.Status2.OutP);
                        rx_value = (float)App_Factors.har_rx1.ValueWithOffset(ps1.Status2.Freq * this.settings.Multiplier, sr.dBmValue);
                    }

                    sweep_points[0].Y = (rx_value + this.settings.Rev);

                    lblF.Text  = "F:" + sweep_points[0].X.ToString("0.0") + "MHz";
                    lblTx.Text = "Tx:" + tx_out.ToString("0.0") + "dBm";

                    //功放2扫频
                }
                else
                {
                    sweep_points[0].X = ps2.Status2.Freq * settings.Multiplier;

                    if (App_Configure.Cnfgs.Cal_Use_Table)
                    {
                        tx_out   = ps2.Status2.OutP + Tx_Tables.har_tx2_disp.Offset(ps2.Status2.Freq, ps2.Status2.OutP, Tx_Tables.har_offset2_disp);
                        rx_value = sr.dBmValue + Rx_Tables.Offset(ps2.Status2.Freq * this.settings.Multiplier, FuncModule.HAR);
                    }
                    else
                    {
                        tx_out   = (float)App_Factors.har_tx2_disp.ValueWithOffset(ps2.Status2.Freq, ps2.Status2.OutP);
                        rx_value = (float)App_Factors.har_rx2.ValueWithOffset(ps2.Status2.Freq * this.settings.Multiplier, sr.dBmValue);
                    }

                    sweep_points[0].Y = (rx_value + this.settings.Rev);

                    lblF.Text  = "F:" + sweep_points[0].X.ToString("0.0") + "MHz";
                    lblTx.Text = "Tx:" + tx_out.ToString("0.0") + "dBm";
                }

                lblRx.Text    = "Rx:" + sr.dBmValue.ToString("0.0") + "dBm";
                lblNoise.Text = "Noise:" + sr.dBmNosie.ToString("0.0") + "dBm";
                pltHar.Add(sweep_points, 0, PointsDone);

                //处理扫时
            }
            else
            {
                sweep_points[0].X = PointsDone;

                //功放1扫时
                if (rf_involved == RFInvolved.Rf_1)
                {
                    if (App_Configure.Cnfgs.Cal_Use_Table)
                    {
                        tx_out   = ps1.Status2.OutP + Tx_Tables.har_tx1_disp.Offset(ps1.Status2.Freq, ps1.Status2.OutP, Tx_Tables.har_offset1_disp);
                        rx_value = sr.dBmValue + Rx_Tables.Offset(ps1.Status2.Freq * this.settings.Multiplier, FuncModule.HAR);
                    }
                    else
                    {
                        tx_out   = (float)App_Factors.har_tx1_disp.ValueWithOffset(ps1.Status2.Freq, ps1.Status2.OutP);
                        rx_value = (float)App_Factors.har_rx1.ValueWithOffset(ps1.Status2.Freq * this.settings.Multiplier, sr.dBmValue);
                    }

                    sweep_points[0].Y = (rx_value + this.settings.Rev);

                    lblF.Text  = "F:" + ps1.Status2.Freq.ToString("0.0") + "MHz";
                    lblTx.Text = "Tx:" + tx_out.ToString("0.0") + "dBm";

                    //功放2扫时
                }
                else
                {
                    if (App_Configure.Cnfgs.Cal_Use_Table)
                    {
                        tx_out   = ps2.Status2.OutP + Tx_Tables.har_tx2_disp.Offset(ps2.Status2.Freq, ps2.Status2.OutP, Tx_Tables.har_offset2_disp);
                        rx_value = sr.dBmValue + Rx_Tables.Offset(ps2.Status2.Freq, FuncModule.HAR);
                    }
                    else
                    {
                        tx_out   = (float)App_Factors.har_tx2_disp.ValueWithOffset(ps2.Status2.Freq, ps2.Status2.OutP);
                        rx_value = (float)App_Factors.har_rx2.ValueWithOffset(ps2.Status2.Freq, sr.dBmValue);
                    }

                    sweep_points[0].Y = (rx_value + this.settings.Rev);

                    lblF.Text  = "F:" + ps2.Status2.Freq.ToString("0.0") + "MHz";
                    lblTx.Text = "Tx:" + tx_out.ToString("0.0") + "dBm";
                }

                lblRx.Text    = "Rx:" + rx_value.ToString("0.0") + "dBm";
                lblNoise.Text = "Noise:" + sr.dBmNosie.ToString("0.0") + "dBm";
                pltHar.Add(sweep_points, 0, PointsDone);
            }
        }
Ejemplo n.º 7
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            //完成一趟操作
            case MessageID.ISO_SWEEP_DONE:
            {
                Sweeping = false;

                //if (bErrorRf)
                //{
                //    SweepObj.CloneReference(ref ps1, ref ps2, ref sr, ref rfr_errors1, ref rfr_errors2);
                //    bCalsuccess = false;
                //    MessageBox.Show(rfr_errors1.ToString() + "\n\r" + rfr_errors2.ToString());
                //}
                //if (bErrorSpec)
                //{
                //    bCalsuccess = false;
                //    MessageBox.Show("SPECTRUM_Error");
                //}

                if (bErrorRf == true || bErrorSpec == true)
                {
                    bCalsuccess = false;
                    MessageBox.Show(this, "Automatic calibration failed, please check the external attenuator!");
                    this.DialogResult = DialogResult.Cancel;
                }
                else
                {
                    this.DialogResult = DialogResult.OK;
                }

                break;
            }

            //完成单点扫描
            case MessageID.ISO_SUCCED:
            {
                float          tx_out, rx_value;
                Auto_CAL_Items Cal_Carrier;

                SweepObj.CloneReference(ref ps1, ref ps2, ref sr, ref rfr_errors1, ref rfr_errors2);

                if (rf_involved == RFInvolved.Rf_1)
                {
                    if (App_Configure.Cnfgs.Cal_Use_Table)
                    {
                        tx_out   = ps1.Status2.OutP + Tx_Tables.iso_tx1_disp.Offset(ps1.Status2.Freq, ps1.Status2.OutP, Tx_Tables.iso_offset1_disp);
                        rx_value = sr.dBmValue + Rx_Tables.Offset(ps1.Status2.Freq, FuncModule.ISO);
                    }
                    else
                    {
                        tx_out   = (float)App_Factors.iso_tx1_disp.ValueWithOffset(ps1.Status2.Freq, ps1.Status2.OutP);
                        rx_value = (float)App_Factors.iso_rx1.ValueWithOffset(ps1.Status2.Freq, sr.dBmValue);
                    }

                    Cal_Carrier = RL0_Tables.Cal_Carrier(FuncModule.ISO, RFInvolved.Rf_1);
                    Cal_Carrier.GetItem(PointsDone).Tx0 = tx_out;
                    Cal_Carrier.GetItem(PointsDone).Rx0 = rx_value;
                }
                else
                {
                    if (App_Configure.Cnfgs.Cal_Use_Table)
                    {
                        tx_out   = ps2.Status2.OutP + Tx_Tables.iso_tx2_disp.Offset(ps2.Status2.Freq, ps2.Status2.OutP, Tx_Tables.iso_offset2_disp);
                        rx_value = sr.dBmValue + Rx_Tables.Offset(ps2.Status2.Freq, FuncModule.ISO);
                    }
                    else
                    {
                        tx_out   = (float)App_Factors.iso_tx2_disp.ValueWithOffset(ps2.Status2.Freq, ps2.Status2.OutP);
                        rx_value = (float)App_Factors.iso_rx2.ValueWithOffset(ps2.Status2.Freq, sr.dBmValue);
                    }

                    Cal_Carrier = RL0_Tables.Cal_Carrier(FuncModule.ISO, RFInvolved.Rf_2);
                    Cal_Carrier.GetItem(PointsDone).Tx0 = tx_out;
                    Cal_Carrier.GetItem(PointsDone).Rx0 = rx_value;
                }

                PointsDone++;

                pbrCAL.Value = PointsDone;

                break;
            }

            //功放操作错误
            case MessageID.RF_ERROR:
            {
                bErrorRf = true;

                break;
            }

            //频谱分析错误
            case MessageID.SPECTRUM_ERROR:
            {
                bErrorSpec = true;

                break;
            }

            //频谱分析成功
            case MessageID.SPECTRUEME_SUCCED:
            {
                SweepObj.Spectrum_Succed();

                break;
            }

            //功放操作成功
            case MessageID.RF_SUCCED_ALL:
            {
                if (m.WParam.ToInt32() == App_Configure.Cnfgs.ComAddr1)
                {
                    SweepObj.Power1_Succed();
                }

                else if (m.WParam.ToInt32() == App_Configure.Cnfgs.ComAddr2)
                {
                    SweepObj.Power2_Succed();
                }

                break;
            }

            default:
            {
                base.WndProc(ref m);
                break;
            }
            }
        }