예제 #1
0
        public static SpectrumAnalyzer Connect(string currentAddress, SpectrumAnalyzer.ValidateSupportDelegate supportDelegate, bool interactive)
        {
            SpectrumAnalyzer spectrumAnalyzer = null;
            string           str = (currentAddress != null ? currentAddress : "GPIB0::18::INSTR");

            SpectrumAnalyzer.m_validateSupportDelegate = supportDelegate;
            if (interactive)
            {
                throw new Exception("不支持交互模式");
            }
            try
            {
                if (SpectrumAnalyzer.DetermineSupport(str) == null)
                {
                    spectrumAnalyzer = SpectrumAnalyzer.CreateDetectedSpectrumAnalyzer(str);
                }
            }
            catch
            {
                // MessageBox.Show("设备连接异常!");
            }
            SpectrumAnalyzer.m_validateSupportDelegate = null;
            if (spectrumAnalyzer != null)
            {
                spectrumAnalyzer.Connected = true;
            }
            return(spectrumAnalyzer);
        }
예제 #2
0
        private static string DetermineSupport(string address)
        {
            if (SpectrumAnalyzer.m_validateSupportDelegate == null)
            {
                return(null);
            }
            SpectrumAnalyzer spectrumAnalyzer = null;

            try
            {
                spectrumAnalyzer = SpectrumAnalyzer.CreateDetectedSpectrumAnalyzer(address);
            }
            catch
            {
                throw;
            }
            if (spectrumAnalyzer == null)
            {
                return("无法识别对应的频谱仪");
            }
            return(SpectrumAnalyzer.m_validateSupportDelegate(spectrumAnalyzer));
        }