示例#1
0
        private TVCLib.Tvc CreateAFG3022()
        {
            //刷新设备列表
            TekVRAPI.CRemoteAPI remoteAPI = new TekVRAPI.CRemoteAPI();
            if (!remoteAPI.TekVIsRMUPdateActive())
            {
                remoteAPI.TekVStartRmUpdate("");
            }
            //寻找AFG3022设备
            string descriptor = null;

            TekVISANet.VISA visa       = new TekVISANet.VISA();
            ArrayList       deviceList = new ArrayList();

            if (visa.FindResources("USB?*INSTR", out deviceList))
            {
                descriptor = deviceList[0].ToString();
            }
            afg3022.Descriptor = descriptor;
            if (descriptor != null)
            {
                Log.MessAgeLog(".\\xhtst.log", "找到USB设备" + descriptor);
            }
            else
            {
                Log.MessAgeLog(".\\xhtst.log", "未找到设备");
            }
            //    CreateFM(1, 1700, 0.100, 10.3, 11);
            visa.Dispose();
            visa = null;


            return(afg3022);
        }
示例#2
0
        public EXTSOURCE(TekVISANet.VISA visaSession)
        {
            // New way to set visa timeout
            defaultVISATimeout = 90000;         // GRJ, 2013-10-02: old value, 10000;

            EXTSOURCEVisaSession = visaSession;
            // ReSharper disable UseObjectOrCollectionInitializer
            _visaExt = new VisaExtensions(EXTSOURCEVisaSession);
            // ReSharper restore UseObjectOrCollectionInitializer
            _visaExt.Session = EXTSOURCEVisaSession.Session;

            // ReSharper disable UseObjectOrCollectionInitializer
            _piex = new CPiExtSourceCmds(EXTSOURCEVisaSession, _visaExt);
            // ReSharper restore UseObjectOrCollectionInitializer
            _piex.DefaultVisaTimeout = defaultVISATimeout;
        }
示例#3
0
文件: AWG.cs 项目: tektronix/lab-bot
        public AWG(TekVISANet.VISA visaSession)
        {
            // New way to set visa timeout
            DefaultVisaTimeout = 90000;         // GRJ, 2013-10-02: old value, 10000;

            AWGVisaSession = visaSession;
// ReSharper disable UseObjectOrCollectionInitializer
            _visaExt = new VisaExtensions(AWGVisaSession);
// ReSharper restore UseObjectOrCollectionInitializer
            _visaExt.Session = AWGVisaSession.Session;

            // ReSharper disable UseObjectOrCollectionInitializer
            _pi = new CPi70KCmds(AWGVisaSession, _visaExt);
            // ReSharper restore UseObjectOrCollectionInitializer
            _pi.DefaultVisaTimeout = DefaultVisaTimeout;
        }
示例#4
0
        public SCOPE(TekVISANet.VISA visaSession)
        {
            // New way to set visa timeout
            defaultVISATimeout = 90000;         // GRJ, 2013-10-02: old value, 10000;

            SCOPEVisaSession = visaSession;
            // ReSharper disable UseObjectOrCollectionInitializer
            _visaExt = new VisaExtensions(SCOPEVisaSession);
            // ReSharper restore UseObjectOrCollectionInitializer
            _visaExt.Session = SCOPEVisaSession.Session;

            // ReSharper disable UseObjectOrCollectionInitializer
            _pis = new CPiScopeCmds(SCOPEVisaSession, _visaExt);
            // ReSharper restore UseObjectOrCollectionInitializer
            _pis.DefaultVisaTimeout = defaultVISATimeout;
        }
示例#5
0
 public static ArrayList GetDevDescList()
 {
     deviceList = null;
     TekVRAPI.CRemoteAPI remoteAPI = new TekVRAPI.CRemoteAPI();
     if (!remoteAPI.TekVIsRMUPdateActive())
     {
         remoteAPI.TekVStartRmUpdate("");
     }
     //寻找AFG3022设备
     string descriptor = null;
     TekVISANet.VISA visa = new TekVISANet.VISA();
     if (visa.FindResources("USB?*INSTR", out deviceList))
     {
         descriptor = deviceList[0].ToString();
     }
     visa.Dispose();
     visa = null;
     return deviceList;
 }
示例#6
0
        private static string _scopeConnection; //!< IP address or name of the Scope


        //shkv 3/9/2015 Fixing flag issues for Type-6 instrument
        /// <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 SCOPE GetScope(bool create = true)
        {
            if (create == true)
            {
                TekVISANet.VISA SCOPEVisaSession = new TekVISANet.VISA();
                //_scope = new SCOPE(_scope.SCOPEVisaSession);

                string status = "";
                _scopeConnection = AwgSetupSteps.ScopeConnectionIP;
                _scopeConnection = "TCPIP::" + _scopeConnection + "::INSTR";

                // bool openSuccessFul = SCOPEVisaSession.Open(_scopeConnection);
                bool openSuccessFul = SCOPEVisaSession.Open(_scopeConnection, TekVISANet.TekVISADefs.AccessModes.VI_NO_LOCK, 90000, 5);
                if (!openSuccessFul)
                {
                    int retry = 4;
                    do
                    {
                        openSuccessFul = SCOPEVisaSession.Open(_scopeConnection);
                    } while ((--retry >= 0) && (!openSuccessFul));

                    try
                    {
                        status = _scope.SCOPEVisaSession.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);
                    }
                }
                _scope = new SCOPE(SCOPEVisaSession);
                //! \TODO: Figure out how to test for a valid session and assert here if false
            }
            return(_scope); // Otherwise, return the existing session
        }
示例#7
0
        static public ArrayList GetDevDescList()
        {
            deviceList = null;
            TekVRAPI.CRemoteAPI remoteAPI = new TekVRAPI.CRemoteAPI();
            if (!remoteAPI.TekVIsRMUPdateActive())
            {
                remoteAPI.TekVStartRmUpdate("");
            }
            //寻找AFG3022设备
            string descriptor = null;

            TekVISANet.VISA visa = new TekVISANet.VISA();
            if (visa.FindResources("USB?*INSTR", out deviceList))
            {
                descriptor = deviceList[0].ToString();
            }
            visa.Dispose();
            visa = null;
            return(deviceList);
        }
 public CPiExtSourceCmds(TekVISANet.VISA extSourceVisaSession, VisaExtensions visaExt)
 {
     _mExtSourceVisaSession = extSourceVisaSession;
     _mVISAExt = visaExt;
 }
        // 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]);
        }
示例#10
0
 public CPi70KCmds(TekVISANet.VISA awgVisaSession, VisaExtensions visaExt)
 {
     _mAWGVisaSession = awgVisaSession;
     _mVISAExt        = visaExt;
 }
 public CPiScopeCmds(TekVISANet.VISA scopeVisaSession, VisaExtensions visaExt)
 {
     _mScopeVisaSession = scopeVisaSession;
     _mVISAExt          = visaExt;
 }
 public VisaExtensions(TekVISANet.VISA workingSession)
 {
     WorkingSession = workingSession;
 }
示例#13
0
        private TVCLib.Tvc CreateAFG3022()
        {
            //刷新设备列表
                TekVRAPI.CRemoteAPI remoteAPI = new TekVRAPI.CRemoteAPI();
                if (!remoteAPI.TekVIsRMUPdateActive())
                {
                    remoteAPI.TekVStartRmUpdate("");
                }
                //寻找AFG3022设备
                string descriptor = null;
                TekVISANet.VISA visa = new TekVISANet.VISA();
                ArrayList deviceList = new ArrayList();
                if (visa.FindResources("USB?*INSTR", out deviceList))
                {
                    descriptor = deviceList[0].ToString();

                }
                afg3022.Descriptor = descriptor;
                if (descriptor != null)
                {
                    Log.MessAgeLog(".\\xhtst.log", "找到USB设备" + descriptor);
                }
                else
                {
                    Log.MessAgeLog(".\\xhtst.log", "未找到设备");
                }
            //    CreateFM(1, 1700, 0.100, 10.3, 11);
                visa.Dispose();
                visa = null;

            return afg3022;
        }