/// <summary> /// 连接某直流电源,并返回对应的控制对象; /// </summary> /// <param name="currentAddress"></param> /// <param name="supportDelegate"></param> /// <param name="interactive"></param> /// <returns></returns> public static DCPowerBase Connect(string currentAddress, DCPowerBase.ValidateSupportDelegate supportDelegate, bool interactive) { DCPowerBase ADCPower = null; string str = (currentAddress != null ? currentAddress : "GPIB0::18::INSTR"); DCPowerBase.m_validateSupportDelegate = supportDelegate; if (interactive) { throw new Exception("不支持交互模式"); } try { if (DCPowerBase.DetermineSupport(str) == null) { ADCPower = DCPowerBase.CreateDetectedDCPowerSupply(str); } } catch { throw; } DCPowerBase.m_validateSupportDelegate = null; if (ADCPower != null) { ADCPower.Connected = true; } return(ADCPower); }
/// <summary> /// 判断是否可以支持对应型号的直流电源 /// </summary> /// <param name="address"></param> /// <returns></returns> private static string DetermineSupport(string address) { if (DCPowerBase.m_validateSupportDelegate == null) { return(null); } DCPowerBase ADCPower = null; try { ADCPower = DCPowerBase.CreateDetectedDCPowerSupply(address); } catch { throw; } if (ADCPower == null) { return("不是一个可以识别的直流电源"); } return(DCPowerBase.m_validateSupportDelegate(ADCPower)); }