/// <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);
            }
        }
Beispiel #2
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;
            }
            }
        }