Beispiel #1
0
 //連接儀器
 public bool InstrumentInitialize(ComboBox ComboBoxInterface, TextBox TextBoxstrAddress)
 {
     connectAbnormal = false;
     try
     {
         interfaceAndAddress = ComboBoxInterface.SelectedItem + "::" + TextBoxstrAddress.Text;
         // , AccessMode.NO_LOCK, 3000, ""
         session    = ioMgr.Open(interfaceAndAddress);
         IDNMassage = ReadVISACommandResult("*IDN?");
         if (IDNMassage == "")
         {
             connectAbnormal = false;
             MessageBox.Show("连接地址为" + interfaceAndAddress + "的设备失败");
         }
         else
         {
             connectAbnormal = true;
             IDNMassageArray = IDNMassage.Split(',');
             //MessageBox.Show("连接地址为" + interfaceAndAddress + "的设备成功");
         }
         return(connectAbnormal);
     }
     catch (COMException ex)
     {
         MessageBox.Show("InstrumentInitialize Error:" + ex.Message + " 没有检测到GPIB串口");
         return(connectAbnormal);
     }
 }
        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);
            }
        }
Beispiel #3
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;
            }
        }
Beispiel #4
0
 public MessageSession(IVisaSession session) : base()
 {
     if (session is IMessageSession messageInterface)
     {
         SetMessageInterface(messageInterface);
     }
     else
     {
         throw new ArgumentException("provided session is not IMessageInterface", nameof(messageInterface));
     }
 }