private static string _extSourceConnection; //!< IP address or name of the Scope // shkv 3/4/2015 Fixing the external source issue. /// <summary> /// Instantiate the %SCOPE class if it is not already open /// </summary> /// <param name="create">Each time you call GetScope(), you need to pass "true" if you want a new session, "false" if you are just looking up the existing session</param> /// <returns>Return new or existing session</returns> public static EXTSOURCE GetExtSource(bool create = true) { if (create == true) { TekVISANet.VISA EXTSOURCEVisaSession = new TekVISANet.VISA(); //_scope = new SCOPE(_scope.SCOPEVisaSession); string status = ""; _extSourceConnection = AwgSetupSteps.ExtSourceConnectionIP; _extSourceConnection = "TCPIP::" + _extSourceConnection + "::INSTR"; //bool openSuccessFul = EXTSOURCEVisaSession.Open(_extSourceConnection); bool openSuccessFul = EXTSOURCEVisaSession.Open(_extSourceConnection, TekVISANet.TekVISADefs.AccessModes.VI_NO_LOCK, 90000, 5); if (!openSuccessFul) { int retry = 4; do { openSuccessFul = EXTSOURCEVisaSession.Open(_extSourceConnection); } while ((--retry >= 0) && (!openSuccessFul)); try { status = _extSource.ErrorDescription(); } catch (Exception) { status = "Object reference not set to an instance of an object."; } //See if the status string contains the word "Success" Regex validatePreMatcher = new Regex(@"Success.+"); Match match = validatePreMatcher.Match(status); // Check the status string to see if the operation was sucessful if (!match.Success) { Assert.Inconclusive("Attempt to Open connection failed: " + status); } } _extSource = new EXTSOURCE(EXTSOURCEVisaSession); //! \TODO: Figure out how to test for a valid session and assert here if false } return(_extSource); // Otherwise, return the existing session }