Esempio n. 1
0
        public string VisaSessionQuery(string commandLine)
        {
            string response;

            AWGVisaSession.Query(commandLine, out response);
            ReadResponse = response;
            return(response);
        }
Esempio n. 2
0
        public string ExtSourceVisaSessionQuery(string commandLine)
        {
            string response;

            EXTSOURCEVisaSession.Query(commandLine, out response);
            ExtSourceReadResponse = response;
            return(response);
        }
Esempio n. 3
0
        public string ScopeVisaSessionQuery(string commandLine)
        {
            string response;

            SCOPEVisaSession.Query(commandLine, out response);
            ScopeReadResponse = response;
            return(response);
        }
        // Unknown 01/01/01
        /// <summary>
        /// Instantiate the %AWG class for the session requested by the<para>
        /// index value by default, </para>
        /// create a new session unless we pass false
        /// </summary>
        /// <param name="index">Index value of the session</param>
        /// <returns>%AWG visa session</returns>
        static IAWG GetAWG(int index)
        {
            //Sharmila - 01/04/2015
            //To retrieve the SourceXpress button status to decide whether connection should be with GPIB8 or not
            bool isSXSelected = false;

            if (index >= 3)
            {
                Assert.Fail("AWG index value out of range, only 4 AWGs are allowed with index 0-3.");
            }

            // If the value at the requested index is null, then a new session is created and returned, otherwise the
            // existing session at that index is returned and the session remains open.
            if (_AWGList[index] == null)
            {
                /* If the DUT configuration is completed then the DUT UI Dialog should not pop up. Hence the below check is done.
                 * Another way of stating this is only show the UI once, gather all the information for possible user later
                 * as what resources are used are dependent on the test being run at the moment. */
                if (_testconfigcomplete != true)
                {
                    var dutConfigUi = new dutui();
                    dutConfigUi.ShowDialog();
                    if (dutConfigUi.TopMost == false) //Bring to DUT Dialog to front focus
                    {                                 //These four lines of code have earned its writer a whole $1 coin
                        dutConfigUi.TopMost = true;   //May it be spent wisely
                    }

                    if (dutui.pc_pbu_state) // is true
                    {
                        /* If the user selects PC App then the DUT IP Address is fixed as 127.0.0.1*/
                        _awgConnection = "TCPIP::127.0.0.1";
                    }
                    else
                    {
                        //Sharmila - 01/04/2015
                        //Retrieve the SourceXpress radio button status by deserializing the MySettings.xml
                        //If SourceXpress is selected, establish the connection with GPIB8
                        isSXSelected = dutConfigUi.deserdata[0].sx_state;
                        if (dutui.AWG1Controller_set || isSXSelected)
                        {
                            _connection1 = "TCPIP::localhost";
                        }
                        else if (dutui.dut1_ip_name_address_selected)   // is true
                        {
                            /* If user enters DUT IP Address then deserialized data for IP Adress is used to establish connection*/
                            _connection1 = dutConfigUi.deserdata[0].DUTIP;
                            _connType    = dutConfigUi.deserdata[0].AwgConnType;
                        }
                        else
                        {
                            _connection1 = dutConfigUi.deserdata[0].DutName;
                            _connType    = dutConfigUi.deserdata[0].AwgConnType;
                        }

                        _connection2 = dutui.dut2_ip_name_address_selected ? dutConfigUi.deserdata[1].DUTIP : dutConfigUi.deserdata[1].DutName;

                        _connection3 = dutui.dut3_ip_name_address_selected ? dutConfigUi.deserdata[2].DUTIP : dutConfigUi.deserdata[2].DutName;

                        _connection4 = dutui.dut4_ip_name_address_selected ? dutConfigUi.deserdata[3].DUTIP : dutConfigUi.deserdata[3].DutName;
                    }

                    // Setup IP for scope (if there is one)
                    ScopeConnectionIP = dutui.scope_ip_address_name_selected ? dutConfigUi.deserdata[0].ScopeIP : dutConfigUi.deserdata[0].ScopeName;
                    // Setup IP for external source clock (if there is one)
                    ExtSourceConnectionIP = dutui.extsource_ip_address_name_selected ? dutConfigUi.deserdata[0].ExtSourceIP : dutConfigUi.deserdata[0].ExtSourceName;

                    _testconfigcomplete = true;
                }

                if (dutui.pc_pbu_state) // is true
                {
                    _awgConnection = "TCPIP::127.0.0.1";
                }
                else
                {
                    switch (index)
                    {
                    case 0:
                        // PWH - Need this in case the test case calls out an AWG number that was not set in the dialog. I'd like for any error checks to have something like this level of detail sent back to the user on failures.
                        //Sharmila - 01/04/2015
                        //If Controller or SourceXpress is selectedd in UI, establish the connection with GPIB8
                        Assert.AreNotEqual("", _connection1,
                                           "The connect string for VISA was empty (e.g. TCPIP::::INSTR) - check configuration dialog for correct instrument setup.");
                        _awgConnection = (dutui.AWG1Controller_set || isSXSelected) ? "GPIB8::1" : "TCPIP" + "::" + _connection1;
                        break;

                    case 1:
                        Assert.AreNotEqual("", _connection2,
                                           "The connect string for VISA was empty - check configuration dialog for correct instrument setup.");
                        _awgConnection = "TCPIP" + "::" + _connection2;
                        break;

                    case 2:
                        Assert.AreNotEqual("", _connection3,
                                           "The connect string for VISA was empty - check configuration dialog for correct instrument setup.");
                        _awgConnection = "TCPIP" + "::" + _connection3;
                        break;

                    case 3:
                        Assert.AreNotEqual("", _connection4,
                                           "The connect string for VISA was empty - check configuration dialog for correct instrument setup.");
                        _awgConnection = "TCPIP" + "::" + _connection4;
                        break;
                    }
                }

                /*For Socket connection the String is as follows TCPIP::134.64.236.77::4000::SOCKET. Hence ::INSTR should be replaced with AwgConnectionType */
                /*For VXI-11 connection the String is as follows TCPIP::134.64.236.77::INSTR*/
                if (_connType == "SOCKET")
                {
                    _awgConnection = _awgConnection + "::4001::SOCKET";
                    //PWH - Shouldn't this have the "TCPIP" replaced by AwgConnectionType?
                }
                else
                {
                    _awgConnection = _awgConnection + "::INSTR";
                }

                if (dutui.AWG1Controller_set)
                {
                    IgnoreUi = dutui.IgnoreUI;
                }
                // Before creating an AWG, it is necessary to know the type of AWG that the
                // address is associated with.  Try to make a connection.  If the connection
                // is successful, then an specific AWG can be created with the just made
                // connection.
                TekVISANet.VISA visaSession = new TekVISANet.VISA();

                //  Try and have the visaSession make a connection to the resource
                bool openSuccessFul;

                int retry = 5;
                do
                {
                    openSuccessFul = visaSession.Open(_awgConnection);
                } while ((--retry >= 0) && (!openSuccessFul));

                string status = visaSession.ErrorDescription;

                //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.Fail("Attempt to Open connection failed: " + status);
                }

                // After a successful connection, do an *idn? query and get model id.
                // Once there is an model number, the correct and proper AWG can be
                // created and added to the list.  Right?
                string response = null;
                visaSession.Query("*IDN?", out response);

                if (response == null)
                {
                    Assert.Fail("Attempt to get ID string failed.");
                }

                // Success, right, we have an ID string.  Pull it apart to determine the family
                IdResponse decomposed = GetAwgInformation(response);

                if (decomposed.Family == Family70k)
                {
                    //  Now create an AWG.
                    _AWGList[index] = new AWG(visaSession);
                    _AWGList[index].LogicalAWGNumber = (index + 1).ToString(CultureInfo.InvariantCulture);    // Let the AWG know its place in the world.
                }
                else if (decomposed.Family == Family50k)
                {
                    // Create the new 50K here!
                }
                else
                {
                    Assert.Fail("Cannot support unknown Family " + decomposed.Family);
                }
            }

            //  If it failed, then an assert happened, so we didn't get here.
            //  Was this requested awg discovered?
            if (_AWGList[index] == null)
            {
                Assert.Fail("No AWG was found!");
            }
            return(_AWGList[index]);
        }