예제 #1
1
        public void CheckDMMError(FormattedIO488 myDmm)
        {
            myDmm.WriteString("SYST:ERR?", true);
            string errStr = myDmm.ReadString();

            if (errStr.Contains("No error")) //If no error, then return
            {
                return;
            }
            //If there is an error, read out all of the errors and return them in an exception
            else
            {
                string errStr2 = "";
                do
                {
                    myDmm.WriteString("SYST:ERR?", true);
                    errStr2 = myDmm.ReadString();
                    if (!errStr2.Contains("No error"))
                    {
                        errStr = errStr + "\n" + errStr2;
                    }
                } while (!errStr2.Contains("No error"));
                throw new Exception("Exception: Encountered system error(s)\n" + errStr);
            }
        }
예제 #2
0
        //Open the VISA session using a socket port:
        //  VSA on a PC:                        Port=5025
        //  VSA on an X-Series Signal Analyzer: Port=5024



        #region constructors
        public ScpiDemo(string openString)
        {
            IVisaSession session = null;

            try
            {
                session       = ioMgr.Open(openString, AccessMode.NO_LOCK, 3000, "");
                instrument.IO = (IMessage)session;
                instrument.IO.SendEndEnabled = false;
                instrument.IO.Timeout        = 10000;               //in milliseconds
                instrument.IO.TerminationCharacterEnabled = true;   //Defaults to false

                //Determine whether the VSA process is running
                bool isCreated = false;
                instrument.WriteString("*IDN?");
                IdnString = instrument.ReadString();
            }
            catch (COMException ex)
            {
                Console.WriteLine("Failed to connect to the VSA SCPI interface.");
                Console.WriteLine("   Ensure that the SCPI interface has been started from the");
                Console.WriteLine("      VSA=>Utilities=>SCPI Configuration menu.");
                Console.WriteLine("   Refer to the SCPI Getting Started documentation for instructions on enabling SCPI.");
                Console.WriteLine("Details:");
                Console.WriteLine(ex.Message);

                Console.WriteLine("Press enter to exit demo");
                Console.ReadLine();

                return;
            }
        }
예제 #3
0
        public virtual bool Initialize(out string outMessage)
        {
            IVisaSession session = null;

            try
            {
                session       = ioMgr.Open(m_openString, AccessMode.NO_LOCK, 3000, "");
                instrument.IO = (IMessage)session;
                instrument.IO.SendEndEnabled = false;
                instrument.IO.Timeout        = 10000;               //in milliseconds
                instrument.IO.TerminationCharacterEnabled = true;   //Defaults to false

                //Determine whether the VSA process is running
                bool isCreated = false;
                instrument.WriteString("*IDN?");
                IdnString  = instrument.ReadString();
                outMessage = string.Empty;
                return(true);
            }
            catch (COMException ex)
            {
                outMessage = ex.Message;
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// set N1092
        /// </summary>
        public void SetN1092()
        {
            try
            {
                myN1010A.WriteString(":SYSTem:MODE EYE", true);                   //choose eye/mask mode

                myN1010A.WriteString($":CHANnel{this.Channel}:DISPlay ON", true); //enable channel
                myN1010A.WriteString($":TRIGger:PLOCk  ON", true);                //pattern lock on

                myN1010A.WriteString($":LTESt:ACQuire:STATe ON", true);           //enable limits
                myN1010A.WriteString($":LTESt:ACQuire:CTYPe:WAVeforms 1", true);  //set number of waveforms

                myN1010A.WriteString($":CHANnel{this.Channel}:SIRC ON", true);    //enable SIRC

                //myN1010A.WriteString($":CHANnel{this.Channel}:SIRC:FRATe {this.Filter_rate}", true);
                //myN1010A.WriteString($":CHANnel{this.Channel}:SIRC:FRATe?", true);
                //var a = myN1010A.ReadString();
                myN1010A.WriteString($":CHANnel{this.Channel}:SIRC:FBANdwidth {this.Channel_bandWidth}", true);
                myN1010A.WriteString($":CHANnel{this.Channel}:SIRC:FBANdwidth?", true);
                var a = myN1010A.ReadString();
                myN1010A.WriteString($":FUNCtion1:FOPerator TEQualizer", true);                         //设置TEDCQ

                myN1010A.WriteString(":SPRocess1:TEQualizer:PRESets \"IEEE 802.3bs Draft 3.2\"", true); //设置TEDCQ

                myN1010A.WriteString($":SPRocess:DFEQualizer:PRESets:SELections? ", true);              //设置TEDCQ
                var t = myN1010A.ReadString();
                myN1010A.WriteString($":FUNCtion1:DISPlay ON", true);                                   //
                myN1010A.WriteString($":DISPlay:WINDow:TIME1:DMODe STILed", true);                      //眼图和TEDCQ分开显示
            }
            catch (Exception ex)
            {
                throw new Exception($"根据Test plan 对N1092进行设置时出错,{ex.Message}");
            }
        }
예제 #5
0
        public bool OpenPort()
        {
            string addrtype, option;

            option = "";
            try
            {
                if (addr.Length < 5)
                {
                    MessageBox.Show("Incorrect address: Check address", "SwitchCommandCenter Class Error");
                    return(false);
                }
                else
                {
                    addrtype = addr.Substring(0, 4);
                }
                if (addrtype == "GPIB")
                {
                    data_logger.IO = (IMessage)mgr.Open(addr, AccessMode.NO_LOCK, 2000, option);
                }
                else
                {
                    MessageBox.Show("No Resources found");
                }
                data_logger.WriteString("*IDN?", true);
                currmsg = data_logger.ReadString();
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "\nPort Couldn't be Opened at SwitchCommandCenter", "SwitchCommandCenter");
                return(false);
            }
        }
        public string DoQueryString(string strQuery)
        { // Send the query.
            m_IoObject.WriteString(strQuery, true);
            // Get the result string.
            string strResults;

            strResults = m_IoObject.ReadString();
            // Check for inst errors.
            CheckInstrumentErrors(strQuery);
            // Return results string.
            return(strResults);
        }
예제 #7
0
 float IIPowerSupply.MeasI(string strSelection, EPSupplyChannel channel, EPSupplyIRange range)
 {
     try
     {
         _myVisaKeithley.IO.WriteString("print(smu" + channel.ToString() + ".measure.i())");
         return((float)Convert.ToDouble(_myVisaKeithley.ReadString()));
     }
     catch (Exception ex)
     {
         throw new Exception("KeithleySMU: MeasI -> " + ex.Message);
     }
 }
 void IISiggen.Initialize()
 {
     try
     {
         _myVisaSg.WriteString("*IDN?", true);
         string result = _myVisaSg.ReadString();
     }
     catch (Exception ex)
     {
         throw new Exception("EquipN5182A: Initialization -> " + ex.Message);
     }
 }
예제 #9
0
        private async void button_Move2_Click(object sender, EventArgs e)
        {
            double POSITION;
            double DISTINATION;
            double SPAN;
            string DISTCOMMAND;


            try
            {
                INST_Table.IO.Clear();
                INST_Table.WriteString("SPD00002.00");

                INST_Table.WriteString("CP");
                CPOS = INST_Table.ReadString().Substring(0, 8);

                POSITION    = double.Parse(CPOS.Substring(0, 8));
                DISTINATION = double.Parse(textBox_Distination.Text);

                //		POSISTR	"00000.00,0\r\r"	string


                SPAN = DISTINATION - POSITION;
                if (SPAN < 0)
                {
                    SPAN = SPAN + 360;
                }
                else if (SPAN == 0)
                {
                    return;
                }

                DISTCOMMAND = "CWP" + String.Format("{0:00000.00}", SPAN);
                INST_Table.WriteString(DISTCOMMAND);


                do
                {
                    await Task.Run(() => readposition());

                    textBox_Angle.Text = CPOS;
                } while (DISTSTR != CPOS);

                INST_Table.WriteString(SPD);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #10
0
        public void button2_Click_1(object sender, EventArgs e)
        {
            string srcAddress = label1.Text;

            src.IO = (IMessage)rMgr.Open(srcAddress, AccessMode.NO_LOCK, 2000, "");

            try
            {
                textBox2.Text += src.ReadString() + "\r\n";
            }
            catch (TimeoutException)
            {
                textBox2.Text = "timeout exception";
            }
        }
예제 #11
0
        private string WriteThenReadFromGPIB(string GPIBCommand, string GPIBAddress)
        {
            string GPIBRead       = "";
            var    resourceString = ("GPIB0::" + GPIBAddress + "::INSTR");

            try
            {
                _io488Con.IO = (IMessage)_rm.Open(resourceString, AccessMode.NO_LOCK, 0);
                _io488Con.IO.Clear();
                _io488Con.WriteString(GPIBCommand);
                {
                    GPIBRead = _io488Con.ReadString();
                    Housecleaning();
                    richTextBox1.BackColor = Color.LimeGreen;
                    richTextBox1.Text      = @"Command Execution Completed";
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                _io488Con.IO.Close();
            }
            return(GPIBRead);
        }
        public bool InitializeU2751A_WELLA(string ConnectString)
        {
            bool   devReady = false;
            string idnTemp;

            ioRelayWellACntrl = new FormattedIO488();     // Create the formatted I/O object
            devReady          = U2751A_WellA_Connect(ConnectString);
            if (devReady == false)
            {
                devReadyStatus = false;
                //throw new Exception("Connect to U2751A_WELLA failed on " + ConnectString);
                //MessageBox.Show("Connect to U2751A_WELLA failed on " + ConnectString);
            }
            else
            {
                devReadyStatus = true;
                ioRelayWellACntrl.WriteString("*RST", true);        // Reset
                ioRelayWellACntrl.WriteString("*CLS", true);        // Clear
                ioRelayWellACntrl.WriteString("*IDN?", true);       // Read ID string
                idnTemp = ioRelayWellACntrl.ReadString();

                IDN_SwitchA = idnTemp;

                OnAgilentMessage(new AgilentMessageEventArgs("Connect to U2751A WellA suceess! U2751A WellA IDN: " + idnTemp.ToString()));
            }

            return(devReadyStatus);
        }
예제 #13
0
        private void btnConnect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.IsEnabled = false;

                if (Connect(tbIP_Address.Text))
                {
                    inst.WriteString("*IDN?");
                    String strIdn = inst.ReadString();
                    MessageBox.Show("Connected" + Environment.NewLine + strIdn);

                    btnReset.IsEnabled = true;
                    //SetAutoScale.Enabled = true;
                    //GetError.Enabled = true;
                    btnStart.IsEnabled = true;
                }
            }
            catch (Exception ex)
            {
                //Reset.Enabled = false;
                btnStart.IsEnabled = false;
                MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace);
            }
            finally
            {
                this.IsEnabled = true;
            }
        }
예제 #14
0
        private void button5_Click(object sender, EventArgs e)
        {
            ResourceManager rm;
            FormattedIO488  myDmm;

            rm    = new ResourceManager();
            myDmm = new FormattedIO488();
            string DutAddr = "USB0::0x2A8D::0x5418::MY57190037::0::INSTR";

            myDmm.IO = (IMessage)rm.Open(DutAddr, AccessMode.NO_LOCK, 2000, "");
            myDmm.IO.Clear();
            ////myDmm.WriteString("SYST:PRES");
            //myDmm.WriteString("INIT:CONT OFF");
            myDmm.WriteString("FETC1:POW:AC?");

            //myDmm.WriteString("MEAS2:POW:AC? -70DBM,1,(@1)");
            string Pow;

            Pow = "gdfdg";
            Pow = Pow + " ";
            Pow = myDmm.ReadString();
            double d;

            d = Conversion.Val(Pow);
            string k;

            k             = "ghg";
            k             = d.ToString("0.##E+0");
            textBox1.Text = k;
        }
예제 #15
0
        private void InitializeU3606A(string ConnectString)
        {
            bool devReady = false;
            string idnTemp;

            ioMultiMeterCntrl = new FormattedIO488Class();   // Create the formatted I/O object

            devReady = U3606A_Connect(ConnectString);
            if (devReady == false)
            {
                throw new Exception("Connect to U3606A failed on " + ConnectString);
            }
            else
            {
                ioMultiMeterCntrl.WriteString("*RST", true);              // Reset
                ioMultiMeterCntrl.WriteString("*CLS", true);              // Clear
                ioMultiMeterCntrl.WriteString("*IDN?", true);             // Read ID string
                idnTemp = ioMultiMeterCntrl.ReadString();

                Trace.WriteLine("Connect to U3606A suceess! U3606A IDN: " + idnTemp.ToString());

                ioMultiMeterCntrl.WriteString("SYST:BEEP:STAT OFF", true);

                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.0001", true); // 10mA range with 100uA resolution

                ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.000001", true);  // 10mA range with 1uA resolution
            }
        }
예제 #16
0
 public virtual string Initial(string Adress)
 {
     try
     {
         this.Adress = Adress;
         rm          = new ResourceManager();
         Device      = new FormattedIO488();
         Device.IO   = (IMessage)rm.Open(Adress, AccessMode.NO_LOCK, 2000, "");
         Device.IO.Clear();
         Device.WriteString("*IDN?");
         string RD = Device.ReadString();
         Name         = RD;
         Model        = Name.Split(',')[1];
         SerialNumber = RD;
         if (Model == "U2000A")
         {
             //Device.WriteString("CAL:ZERO:TYPE INT");
             //Device.WriteString("CAL:ALL");
             //Device.WriteString("*OPC?");
             //int i = 0;
             //while(Conversion.Val(Device.ReadString())==0)
             //{
             //    i++;
             //    if (i > 10000000) break;
             //}
             Device.WriteString("UNIT:POW W");
         }
         return("Ok_" + RD);
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
예제 #17
0
        public string Measure()
        {
            string dbResult;

            try
            {
                System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                //Reset the dmm
                ioDmm.WriteString("*RST", true);
                //Clear the dmm registers

                ioDmm.WriteString("*CLS", true);
                ioDmm.WriteString("TRIG:SOUR BUS", true);
                ioDmm.WriteString("ABORT", true);
                ioDmm.WriteString("INIT", true);
                ioDmm.WriteString("TRIGGER:IMMEDIATE", true);

                ioDmm.WriteString("TRIG:SOUR BUS", true);

                // Set meter to 1 amp ac range
                ioDmm.WriteString("FETCH?", true);
                Thread.Sleep(1);
                //dbResult = (double)ioDmm.ReadNumber(IEEEASCIIType.ASCIIType_Any, true);

                dbResult = ioDmm.ReadString();
                System.Windows.Forms.Cursor.Current = Cursors.Default;
                return(dbResult);
            }
            catch (SystemException ex)
            {
                MessageBox.Show("Measure command failed. " + ex.Source + "  " + ex.Message, "GPIB_Meas_Config", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }
예제 #18
0
        private void InitializeU3606A(string ConnectString)
        {
            bool   devReady = false;
            string idnTemp;

            ioMultiMeterCntrl = new FormattedIO488Class();   // Create the formatted I/O object

            devReady = U3606A_Connect(ConnectString);
            if (devReady == false)
            {
                throw new Exception("Connect to U3606A failed on " + ConnectString);
            }
            else
            {
                ioMultiMeterCntrl.WriteString("*RST", true);              // Reset
                ioMultiMeterCntrl.WriteString("*CLS", true);              // Clear
                ioMultiMeterCntrl.WriteString("*IDN?", true);             // Read ID string
                idnTemp = ioMultiMeterCntrl.ReadString();

                Trace.WriteLine("Connect to U3606A suceess! U3606A IDN: " + idnTemp.ToString());


                ioMultiMeterCntrl.WriteString("SYST:BEEP:STAT OFF", true);

                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.0001", true); // 10mA range with 100uA resolution

                ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.000001", true);  // 10mA range with 1uA resolution
            }
        }
예제 #19
0
        private void button1_Click(object sender, EventArgs e)
        {
            var resourceString = ("GPIB0::" + GPIB.Text + "::INSTR");

            richTextBox1.Clear();
            richTextBox1.BackColor = Color.White;
            try
            {
                _io488Con.IO = (IMessage)_rm.Open(resourceString, AccessMode.NO_LOCK, 0);
                _io488Con.IO.Clear();
                _io488Con.WriteString(richTextBox2.Text);
                if (checkBox1.CheckState == CheckState.Checked)
                {
                    richTextBox1.Text = _io488Con.ReadString();
                }
                else
                {
                    richTextBox1.BackColor = Color.LimeGreen;
                    richTextBox1.Text      = @"Command Execution Completed";
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                _io488Con.IO.Close();
            }
        }
예제 #20
0
        public static bool Read(byte address, out string valueRead)
        {
            resourceManager = new ResourceManager();
            ioObject        = new FormattedIO488();
            string addr = $"GPIB::{address.ToString()}::INSTR";

            try
            {
                ioObject.IO = (IMessage)resourceManager.Open(addr, AccessMode.NO_LOCK, 0, "");
                Thread.Sleep(20);
                valueRead = ioObject.ReadString();
                return(true);
            }
            catch
            {
                valueRead = "";
                return(false);
            }
            finally
            {
                try { ioObject.IO.Close(); }
                catch { }
                try { Marshal.ReleaseComObject(ioObject); }
                catch { }
                try { Marshal.ReleaseComObject(resourceManager); }
                catch { }
            }
        }
예제 #21
0
        public string ReadVISACommandResult(string command)
        {
            string strReadVISACommandResult = "";

            try
            {
                instrument.IO = (IMessage)session;
                //instrument.IO.SendEndEnabled = false;
                //instrument.IO.Timeout = 1000;                       //in milliseconds
                //instrument.IO.TerminationCharacterEnabled = true;   //Defaults to false
                instrument.WriteString(command);
                strReadVISACommandResult = instrument.ReadString();
                string[] arrTemp = (strReadVISACommandResult).Split(new[] { "\n" }, StringSplitOptions.None);
                strReadVISACommandResult = arrTemp[0];
                //instrument.IO.Close();
            }
            catch (COMException ex)
            {
                connectAbnormal = true;
                if (connectAbnormal == false)
                {
                    MessageBox.Show("ReadVISACommandResult(" + command + ") Error" + ex.Message);
                }
            }
            return(strReadVISACommandResult);
        }
        public bool InitializeU3606A(string ConnectString)
        {
            string idnTemp;

            ioMultiMeterCntrl = new FormattedIO488();   // Create the formatted I/O object

            if (ConnectString == "")
            {
                //MessageBox.Show("Error Due to invalid instrument alias: " + ConnectString);
                //return "Error Due to invalid instrument alias: null";
                devReadyStatus = false;
                return(devReadyStatus);
            }

            devReadyStatus = U3606A_Connect(ConnectString);
            if (devReadyStatus)
            {
                ioMultiMeterCntrl.WriteString("*RST", true);              // Reset
                ioMultiMeterCntrl.WriteString("*CLS", true);              // Clear
                ioMultiMeterCntrl.WriteString("*IDN?", true);             // Read ID string
                idnTemp = ioMultiMeterCntrl.ReadString();

                IDN_MultiMeter = idnTemp;

                Trace.WriteLine("Connect to U3606A suceess! U3606A IDN: " + idnTemp.ToString());
                //MessageBox.Show("Connect to U3606A suceess! U3606A IDN: " + idnTemp.ToString());

                ioMultiMeterCntrl.WriteString("SYST:BEEP:STAT OFF", true);

                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.000001", true); // 10mA range with 1uA resolution
                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.0000001", true);  // 10mA range with 0.1uA resolution

                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.1,0.00001", true); // 100mA range with 10uA resolution
                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.1,0.000001", true);  // 100mA range with 1uA resolution

                if (CyBLE_MTK_Application.Properties.Settings.Default.DMM_ConfigCmd.StartsWith("CONF:CURR"))
                {
                    ioMultiMeterCntrl.WriteString(CyBLE_MTK_Application.Properties.Settings.Default.DMM_ConfigCmd, true);
                }
                else
                {
                    ioMultiMeterCntrl.WriteString("CONF:CURR 1,0.0001", true);  // 1A range with 100uA resolution
                }
                //ioMultiMeterCntrl.WriteString("CONF:CURR 1,0.00001", true);  // 1A range with 10uA resolution;

                /*
                 * By my test, "CONF:CURR 1, 0.00001" can't set resolution to 10uA.
                 * But use the following command can't reset resolution to 10uA
                 */
                //ioMultiMeterCntrl.WriteString("CURR:RES 1E-05", true);

                //ioMultiMeterCntrl.WriteString("CONF:CURR 3,0.001", true);  // 3A range with 1mA resolution
                //ioMultiMeterCntrl.WriteString("CONF:CURR 3,0.0001", true);  // 3A range with 100uA resolution; By my test it is not supported

                //return "Connect to U3606A Successfully!!! U3606A IDN: " + idnTemp.ToString();
            }

            return(devReadyStatus);
        }
예제 #23
0
        private void AsyncVNARead()
        {
            String[] ReadResults;

            for (int AY = 0; AY < CHKNUM; AY++)
            {
                if (TESTMK[AY] == 1)
                {
                    int measnum = AY + 1;
                    INST_VNA.WriteString(":CALC1:MARK" + measnum.ToString() + ":Y?");
                    ReadResults = INST_VNA.ReadString().Split(',');
                    //Console.WriteLine(ReadResults[0]);
                    double num = double.Parse(ReadResults[0], NumberStyles.Float);
                    results[MESPOS, AY] = num.ToString();
                }
            }
        }
예제 #24
0
        public void initfreq()
        {
            string STAR = ":SENS1:FREQ:STAR?";
            string STOP = ":SENS1:FREQ:STOP?";
            string CENT = ":SENS1:FREQ:CENT?";
            string SPAN = ":SENS1:FREQ:SPAN?";

            try
            {
                double num;
                INST.IO         = (IMessage)RM.Open(E5071C, AccessMode.NO_LOCK, 2000, "");
                INST.IO.Timeout = 5000;
                INST.IO.Clear();

                INST.WriteString(STAR, true);
                num = double.Parse(INST.ReadString(), NumberStyles.Float);
                num = num / 1000000;
                textBox_start.Text = num.ToString();

                INST.WriteString(STOP, true);
                num = double.Parse(INST.ReadString(), NumberStyles.Float);
                num = num / 1000000;
                textBox_stop.Text = num.ToString();

                INST.WriteString(CENT, true);
                num = double.Parse(INST.ReadString(), NumberStyles.Float);
                num = num / 1000000;
                textBox_center.Text = num.ToString();

                INST.WriteString(SPAN, true);
                num = double.Parse(INST.ReadString(), NumberStyles.Float);
                num = num / 1000000;
                textBox_span.Text = num.ToString();
            }
            catch
            {
                MessageBox.Show("ERROR");
            }
            finally
            {
                if (INST.IO != null)
                {
                    INST.IO.Close();
                }
            }
        }
        internal string Visa_GPIBQuery(string cmdstr)
        {
            string VisaStr = string.Empty;

            visaGPIB.WriteString(cmdstr, true);
            VisaStr = visaGPIB.ReadString();
            return(VisaStr);
        }
예제 #26
0
        public override string Visa_GPIBQuery(FormattedIO488 iO488, string cmdstr)
        {
            string VisaStr = string.Empty;

            iO488.WriteString(cmdstr, true);
            VisaStr = iO488.ReadString();
            return(VisaStr);
        }
예제 #27
0
        /// <summary>
        /// 查询命令
        /// </summary>
        public string QueryString(string cmd)
        {
            string messageReCmd = "";

            messageBased.WriteString(cmd);
            messageReCmd = messageBased.ReadString();
            if (messageReCmd == "")//容错机制
            {
                messageBased.WriteString(cmd);
                messageReCmd = messageBased.ReadString();
                return(messageReCmd);
            }
            else
            {
                return(messageReCmd);
            }
        }
예제 #28
0
파일: P9375A.cs 프로젝트: figoba/S32PSave
        /// <summary>
        /// 仪器连接
        /// </summary>
        /// <param name="Address">仪器visa地址</param>
        public void Connect(string Address)
        {
            if (!connect)
            {
                ResourceManager resourceManagerIv = new ResourceManager();
                gPNA            = new FormattedIO488();
                gPNA.IO         = (IMessage)resourceManagerIv.Open(Address, AccessMode.NO_LOCK, 0x7d0, "");
                gPNA.IO.Timeout = 0xea60;
                connect         = true;
            }

            gPNA.WriteString("*IDN?", true);
            IDNinfo = gPNA.ReadString();
        }
예제 #29
0
        protected string ReadInstrumentIDN()
        {
            // Retrieve the string from instrument
            string idn_value;

            try
            {
                //Gets the instrument model number
                ioDmm.WriteString("IDN?", true);
                idn_value = ioDmm.ReadString();
            }
            catch (SystemException ex)
            {
                error_status = "Failed to retrieve default settings. Error: " + ex.Message;
                return(error_status);
            }
            error_status = "No Error";
            return(idn_value);
        }
예제 #30
0
        private void button1_Click(object sender, EventArgs e)
        {
            var rm   = new ResourceManager();
            var conn = new FormattedIO488();

            conn.IO = (IMessage)rm.Open(textboxAddress.Text);
            conn.IO.Clear();
            conn.WriteString("*IDN?", true);
            MessageBox.Show(conn.ReadString());
        }
예제 #31
0
파일: 33220.cs 프로젝트: vikramuk/Sample
        public void CheckDMMError(FormattedIO488 myDmm)
        {
            myDmm.WriteString("SYST:ERR?", true);
            string errStr = myDmm.ReadString();
            if (errStr.Contains("No error")) //If no error, then return
                return;
            //If there is an error, read out all of the errors and return them in an exception
            else
            {
                string errStr2 = "";
                do
                {
                    myDmm.WriteString("SYST:ERR?", true);
                    errStr2 = myDmm.ReadString();
                    if (!errStr2.Contains("No error")) errStr = errStr + "\n" + errStr2;

                } while (!errStr2.Contains("No error"));
                throw new Exception("Exception: Encountered system error(s)\n" + errStr);
            }
        }
예제 #32
0
 public string ReadString()
 {
     try
     {
         return(ioobj.ReadString());
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
예제 #33
0
        public void InitializeU2722A(string ConnectString)
        {
            bool devReady = false;
            string idnTemp;

            ioVoltCntrl = new FormattedIO488Class();   // Create the formatted I/O object

            devReady = U2722A_Connect(ConnectString);
            if (devReady == false)
            {
                throw new Exception("Connect to U2722A failed on " + ConnectString);
            }
            else
            {
                ioVoltCntrl.WriteString("*RST", true);              // Reset
                ioVoltCntrl.WriteString("*CLS", true);              // Clear
                ioVoltCntrl.WriteString("*IDN?", true);             // Read ID string
                idnTemp = ioVoltCntrl.ReadString();                 

                OnAgilentMessage(new AgilentMessageEventArgs("Connect to U2722A suceess! U2722A IDN: " + idnTemp.ToString()));

                //VICD - Set line frequency to 50Hz (This effects measurement accuracy)
                //VICD - Future Dev - Low - Check U2722 for errors at initialization
                //VICD - Future Dev - Med - Add VOLT:LIM command to set a maximum output voltage
                ioVoltCntrl.WriteString("SYST:LFREQ F50HZ", true);
                // Set the inital voltage range to 20V
                ioVoltCntrl.WriteString("VOLT:RANG R20V, (@1)", true);
                ioVoltCntrl.WriteString("VOLT:RANG R20V, (@2)", true);
                ioVoltCntrl.WriteString("VOLT:RANG R20V, (@3)", true);
                // Set the initial output voltage to 0.0V
                ioVoltCntrl.WriteString("VOLT 0, (@1)", true);
                ioVoltCntrl.WriteString("VOLT 0, (@2)", true);
                ioVoltCntrl.WriteString("VOLT 0, (@3)", true);
                // VICD - Set the current ranges
                ioVoltCntrl.WriteString("CURR:RANG " + CURRENT_RANGE_CH1 + " , (@1)", true);
                ioVoltCntrl.WriteString("CURR:RANG " + CURRENT_RANGE_CH2 + " , (@2)", true);
                ioVoltCntrl.WriteString("CURR:RANG " + CURRENT_RANGE_CH3 + " , (@3)", true);
                // VICD - Set the current limits
                ioVoltCntrl.WriteString("CURR:LIM " + CURRENT_LIMIT_CH1 + " , (@1)", true);
                ioVoltCntrl.WriteString("CURR:LIM " + CURRENT_LIMIT_CH2 + " , (@2)", true);
                ioVoltCntrl.WriteString("CURR:LIM " + CURRENT_LIMIT_CH3 + " , (@3)", true);
            }
        }
예제 #34
0
        public void InitializeU2651A(string ConnectString)
        {
            bool devReady = false;
            string idnTemp;

            ioSwitchCntrl = new FormattedIO488Class();    // Create the formatted I/O object

            devReady = U2651A_Connect(ConnectString);
            if (devReady == false)
            {
                throw new Exception("Connect to U2651A failed on " + ConnectString);
            }
            else
            {
                ioSwitchCntrl.WriteString("*RST", true);            // Reset
                ioSwitchCntrl.WriteString("*CLS", true);            // Clear
                ioSwitchCntrl.WriteString("*IDN?", true);           // Read ID string
                idnTemp = ioSwitchCntrl.ReadString();               

                OnAgilentMessage(new AgilentMessageEventArgs("Connect to U2651A suceess! U2651A IDN: " + idnTemp.ToString()));
            }
        }