コード例 #1
0
        /// <summary>
        /// Receptacle和准直Lens同时调整。
        /// </summary>
        /// <param name="Apas"></param>
        private static void Step4(SystemServiceClient Apas, Options opts)
        {
            var cycle = 0;

            Apas.__SSC_LogInfo("开始Rept和准直Lens双边调整...");

            Apas.__SSC_Powermeter_SetRange(opts.PowerMeterCaption, SSC_PMRangeEnum.AUTO);

            while (true)
            {
                var pBeforeAlign = Apas.__SSC_Powermeter_Read(opts.PowerMeterCaption);

                #region 调整Receptacle

                if (opts.UseProfileNdInReceptLensDualScan == false)
                {
                    Apas.__SSC_Powermeter_SetRange(opts.PowerMeterCaption, SSC_PMRangeEnum.RANGE4);
                    Apas.__SSC_DoFastND(opts.ProfileNameDualLineScanRecept);
                }
                else
                {
                    Apas.__SSC_Powermeter_SetRange(opts.PowerMeterCaption, SSC_PMRangeEnum.AUTO);
                    Apas.__SSC_DoProfileND(opts.ProfileNameDualLineScanRecept);
                }

                #endregion

                Thread.Sleep(200);

                #region 调整Lens

                Apas.__SSC_Powermeter_SetRange(opts.PowerMeterCaption, SSC_PMRangeEnum.AUTO);
                if (opts.UseHillClimbInLensAlign)
                {
                    Apas.__SSC_DoHillClimb(opts.ProfileNameDualLineScanLens);
                }
                else
                {
                    Apas.__SSC_DoProfileND(opts.ProfileNameDualLineScanLens);
                }
                #endregion

                Thread.Sleep(500);

                var pAfterAlign = Apas.__SSC_Powermeter_Read(opts.PowerMeterCaption);
                var pDiff       = pAfterAlign - pBeforeAlign;

                Apas.__SSC_LogInfo($"Power Diff: {pDiff:F2}dB, {pAfterAlign:F2}dBm, {pBeforeAlign:F2}dBm");

                //if (power > 3.5 && (powerDiff > -0.2 && powerDiff < 0.2))
                if (pDiff > opts.PowerThreDualLineScanN && pDiff < opts.PowerThreDualLineScanP)
                {
                    break;
                }
                if (pAfterAlign >= opts.PowerThreTerminate)
                {
                    break;
                }
                if (pDiff < -0.3)
                {
                    break;               // 如果耦合功率开始变小超过-0.3dBm,则停止扫描
                }
                cycle++;

                if (cycle > 10)
                {
                    var msg = "无法调整稳定功率位置。";
                    Apas.__SSC_LogError(msg);
                    throw new Exception(msg);
                }
            }
        }