/**
         * Tries to open the GPIB port and sets flags depending on succes or not
         * */
        override public bool openInstrument( )
        {
            bool retval = false;

            using (var rmSession = new ResourceManager())
            {
                try
                {
                    GPIBPSUDriverInstrumentSettings setts = (GPIBPSUDriverInstrumentSettings)driverSettings;

                    /* mbSession = (SerialSession)rmSession.Open(setts.address);
                     * mbSession.BaudRate = 9600;
                     * mbSession.DataBits = 8;
                     * mbSession.FlowControl = Ivi.Visa.SerialFlowControlModes.None;
                     * mbSession.Parity = Ivi.Visa.SerialParity.None;
                     * mbSession.StopBits = Ivi.Visa.SerialStopBitsMode.One;
                     */
                    mbSession = (GpibSession)rmSession.Open(setts.address);


                    retval      = true;
                    initialized = true;
                }
                catch (InvalidCastException)
                {
                }
                catch (Exception exp)
                {
                }
            }

            return(retval);
        }
Exemple #2
0
 public override void Connect()
 {
     if (!Environs.Debug)
     {
         session = new GpibSession(address);
     }
 }
        public override void Connect()
        {
            if (!Environs.Debug)
            {
                session = new GpibSession(address);

            }
        }
Exemple #4
0
 public override void Connect()
 {
     if (!Environs.Debug)
     {
         session = new GpibSession(address);
         session.TimeoutMilliseconds = VisaConstants.InfiniteTimeout;
     }
 }
Exemple #5
0
        public List <Device> FindInstruments()
        {
            List <Device>   resources = new List <Device>();
            ResourceManager manager   = ResourceManager.GetLocalManager();

            string[] resourceList = manager.FindResources("GPIB?*");
            foreach (string a in resourceList)
            {
                HardwareInterfaceType intFaceType;
                short  intFaceNum;
                string resourceClass = string.Empty;
                string reply         = string.Empty;
                manager.ParseResource(a, out intFaceType, out intFaceNum, out resourceClass);
                if (resourceClass == "INTFC")
                {
                    try
                    {
                        GpibInterface gFace = new GpibInterface(a);
                        gFace.SendInterfaceClear();
                    }
                    catch (ArgumentException ex)
                    {
                        // The INTFC cannot be init.
                        // Throw an Exception here
                        //throw new GPIBException("inner exception occured in GPIBLib at FindInstruments() the INTFC cannot be init. " + ex);
                    }
                    catch (Exception ex)
                    {
                        // Other exception occured
                        //throw new GPIBException("inner exception occured in GPIBLib at FindInstruments()." + ex);
                    }
                }
                else if (resourceClass == "INSTR")
                {
                    try
                    {
                        GpibSession sesh = new GpibSession(a);
                        reply = sesh.Query("*IDN?\n");
                        string[] info = reply.Split(',');
                        resources.Add(new Device(info[0], info[1], a));
                        sesh.Dispose();
                    }
                    catch (Exception ex)
                    {
                        throw new GPIBException("Inner exception occured in GPIBLib at FindInstruments(): " + ex);
                    }
                }
            }
            return(resources);
        }
Exemple #6
0
        private void closeMySession()
        {
            if (mbSession == null)
            {
                return;
            }

            // Toggle the hardware GPIB REN line. Return to Local.
            GpibSession gpib = (GpibSession)mySession;

            gpib.ControlRen(RenMode.DeassertAfterGtl);

            //Close the Session
            mbSession.Dispose();
            mbSession = null;
        }
Exemple #7
0
 public void Init()
 {
     try
     {
         if (mbSession != null)
         {
             mbSession.Dispose();
         }
         mbSession = new GpibSession(this.address);
     }
     catch (Exception ex)
     {
         // Exception occured
         throw new GPIBException("inner exception occured in GPIBLib at Init().", ex);
     }
 }
 public string Connect()
 {
     session = new GpibSession(address);
     session.ReaddressingEnabled         = true;
     session.IOProtocol                  = Ivi.Visa.IOProtocol.Normal;
     session.SendEndEnabled              = true;
     session.TerminationCharacterEnabled = false;
     try
     {
         Ivi.Visa.StatusByteFlags flag = session.ReadStatusByte();
         return(flag.ToString());
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
Exemple #9
0
 private void radButton_connect_Click(object sender, EventArgs e)
 {
     if (radButton_connect.Text == "Connect")
     {
         string CONNECT_STR = comboBox_device.Text;
         session = new GpibSession(CONNECT_STR);
         string result = session.Query("*IDN?");
         label_device_name.Text = result;
         radButton_connect.Text = "Disconnect";
         enable_components();
         radButton_get_setting_Click(this, new EventArgs());
     }
     else
     {
         session.Clear();
         session.Dispose();
         radButton_connect.Text = "Connect";
         disable_components();
     }
 }