コード例 #1
0
        public static PowerMeter Connect(string currentAddress, PowerMeter.ValidateSupportDelegate supportDelegate, bool interactive)
        {
            PowerMeter APowerMeter = null;
            string     str         = (currentAddress != null ? currentAddress : "GPIB0::18::INSTR");

            PowerMeter.m_validateSupportDelegate = supportDelegate;
            if (interactive)
            {
                throw new Exception("不支持交互模式");
            }
            try
            {
                if (PowerMeter.DetermineSupport(str) == null)
                {
                    APowerMeter = PowerMeter.CreateDetectedPowerMeter(str);
                }
            }
            catch
            {
                //throw;
            }
            PowerMeter.m_validateSupportDelegate = null;
            if (APowerMeter != null)
            {
                APowerMeter.Connected = true;
            }
            return(APowerMeter);
        }
コード例 #2
0
        private static string DetermineSupport(string address)
        {
            if (PowerMeter.m_validateSupportDelegate == null)
            {
                return(null);
            }
            PowerMeter APowerMeter = null;

            try
            {
                APowerMeter = PowerMeter.CreateDetectedPowerMeter(address);
            }
            catch
            {
                throw;
            }
            if (APowerMeter == null)
            {
                return("无法识别对应的功率计");
            }
            return(PowerMeter.m_validateSupportDelegate(APowerMeter));
        }