Package jisa.visa

Class VISADevice

    • Constructor Summary

      Constructors 
      Constructor Description
      VISADevice​(Address address)  
      VISADevice​(Address address, java.lang.Class<? extends Driver> prefDriver)
      Opens the device at the specified address
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAutoRemove​(java.lang.String... phrases)  
      protected void checkLimit​(java.lang.String valueName, java.lang.Number value, java.lang.Number lower, java.lang.Number upper)  
      protected void checkLimit​(java.lang.String valueName, java.lang.Number value, java.lang.Number lower, java.lang.Number upper, java.lang.String unit)
      Method to check limits of instruments values, throws DeviceException exceeded.
      void clearBuffers()  
      void close()
      Close the connection to the device
      Address getAddress()
      Returns the address used to connect to the device
      Connection getConnection()  
      java.lang.String getIDN()
      Sends the standard identifications query to the device (*IDN?)
      java.lang.String getName()
      Returns the name of the instrument or channel.
      void manuallyClearReadBuffer()
      Continuously reads from the read buffer until there's nothing left to read.
      java.lang.String query​(java.lang.String command, java.lang.Object... args)
      Write the given string, then immediately read the response
      double queryDouble​(java.lang.String command, java.lang.Object... args)
      Write the given string, then immediately read the response as a double
      int queryInt​(java.lang.String command, java.lang.Object... args)
      Write the given string, then immediately read the response as an integer
      java.lang.String read()
      Read a string from the device
      java.lang.String read​(int attempts)
      Read a string from the device
      byte[] readBytes​(int numBytes)  
      double readDouble()
      Read a double from the device
      int readInt()
      Read an integer from the device
      void setIOLimit​(int interval, boolean read, boolean write)
      Sets whether this VISADevice object should wait a minimum amount of time between successive read/write operations.
      void setReadBufferSize​(int bytes)
      What default number of bytes should we expect to get when reading from the device?
      void setReadTerminator​(long term)  
      void setReadTerminator​(java.lang.String term)  
      void setRetryCount​(int count)  
      void setTimeout​(int msec)
      Sets the timeout for read/write operations to this instrument (if applicable).
      void setWriteTerminator​(java.lang.String term)
      Set a termination character to tell the device when we've stopped talking to it
      void write​(java.lang.String command, java.lang.Object... args)
      Write the given string to the device
      void writeBytes​(byte[] bytes)  
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • VISADevice

        public VISADevice​(Address address)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • VISADevice

        public VISADevice​(Address address,
                          java.lang.Class<? extends Driver> prefDriver)
                   throws java.io.IOException
        Opens the device at the specified address
        Parameters:
        address - Some form of InstrumentAddress (eg GPIBAddress, USBAddress etc)
        prefDriver - Preferred driver to try first
        Throws:
        java.io.IOException - Upon communications error
    • Method Detail

      • getConnection

        public Connection getConnection()
      • clearBuffers

        public void clearBuffers()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • manuallyClearReadBuffer

        public void manuallyClearReadBuffer()
                                     throws java.io.IOException
        Continuously reads from the read buffer until there's nothing left to read. (Clears the read buffer for the more stubborn of instruments). Do not use on GPIB instruments programmed to respond to TALK requests (it will never terminate).
        Throws:
        java.io.IOException - Upon communications error
      • setIOLimit

        public void setIOLimit​(int interval,
                               boolean read,
                               boolean write)
        Sets whether this VISADevice object should wait a minimum amount of time between successive read/write operations.
        Parameters:
        interval - The minimum interval, in milliseconds (0 will disable this feature)
        read - Whether this wait should apply to read operations
        write - Whether this wait should apply to write operations
      • setReadBufferSize

        public void setReadBufferSize​(int bytes)
        What default number of bytes should we expect to get when reading from the device?
        Parameters:
        bytes - The number of bytes, yikes.
      • addAutoRemove

        public void addAutoRemove​(java.lang.String... phrases)
      • setRetryCount

        public void setRetryCount​(int count)
      • setTimeout

        public void setTimeout​(int msec)
                        throws java.io.IOException
        Description copied from interface: Instrument
        Sets the timeout for read/write operations to this instrument (if applicable).
        Specified by:
        setTimeout in interface Instrument
        Parameters:
        msec - Timeout, in milliseconds
        Throws:
        java.io.IOException - Upon communications error
      • getAddress

        public Address getAddress()
        Returns the address used to connect to the device
        Specified by:
        getAddress in interface Instrument
        Returns:
        Address object
      • setWriteTerminator

        public void setWriteTerminator​(java.lang.String term)
        Set a termination character to tell the device when we've stopped talking to it
        Parameters:
        term - The character to use (eg "\n" or "\r")
      • write

        public void write​(java.lang.String command,
                          java.lang.Object... args)
                   throws java.io.IOException
        Write the given string to the device
        Parameters:
        command - The string to write
        args - Any formatting arguments
        Throws:
        java.io.IOException - Upon communications error
      • writeBytes

        public void writeBytes​(byte[] bytes)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public java.lang.String read()
                              throws java.io.IOException
        Read a string from the device
        Returns:
        The string returned by the device
        Throws:
        java.io.IOException - Upon communications error
      • read

        public java.lang.String read​(int attempts)
                              throws java.io.IOException
        Read a string from the device
        Parameters:
        attempts - Number of failed attempts to read before throwing an exception
        Returns:
        The string returned by the device
        Throws:
        java.io.IOException - Upon communications error
      • readBytes

        public byte[] readBytes​(int numBytes)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • readDouble

        public double readDouble()
                          throws java.io.IOException
        Read a double from the device
        Returns:
        The number returned by the device
        Throws:
        java.io.IOException - Upon communications error
      • readInt

        public int readInt()
                    throws java.io.IOException
        Read an integer from the device
        Returns:
        Integer read from the device
        Throws:
        java.io.IOException - Upon communications error
      • queryDouble

        public double queryDouble​(java.lang.String command,
                                  java.lang.Object... args)
                           throws java.io.IOException
        Write the given string, then immediately read the response as a double
        Parameters:
        command - String to write
        args - Formatting arguments
        Returns:
        Numerical response
        Throws:
        java.io.IOException - Upon communications error
      • queryInt

        public int queryInt​(java.lang.String command,
                            java.lang.Object... args)
                     throws java.io.IOException
        Write the given string, then immediately read the response as an integer
        Parameters:
        command - String to write
        args - Formatting arguments
        Returns:
        Numerical response
        Throws:
        java.io.IOException - Upon communications error
      • query

        public java.lang.String query​(java.lang.String command,
                                      java.lang.Object... args)
                               throws java.io.IOException
        Write the given string, then immediately read the response
        Parameters:
        command - String to write
        args - Formatting arguments
        Returns:
        String response
        Throws:
        java.io.IOException - Upon communications error
      • getIDN

        public java.lang.String getIDN()
                                throws java.io.IOException
        Sends the standard identifications query to the device (*IDN?)
        Specified by:
        getIDN in interface Instrument
        Returns:
        The resposne of the device
        Throws:
        java.io.IOException - Upon communications error
      • getName

        public java.lang.String getName()
        Description copied from interface: Instrument
        Returns the name of the instrument or channel.
        Specified by:
        getName in interface Instrument
        Returns:
        Name
      • close

        public void close()
                   throws java.io.IOException
        Close the connection to the device
        Specified by:
        close in interface Instrument
        Throws:
        java.io.IOException - Upon communications error
      • checkLimit

        protected void checkLimit​(java.lang.String valueName,
                                  java.lang.Number value,
                                  java.lang.Number lower,
                                  java.lang.Number upper,
                                  java.lang.String unit)
                           throws DeviceException
        Method to check limits of instruments values, throws DeviceException exceeded.
        Parameters:
        valueName - parameter to be checked (e.g. Voltage range)
        value - value to set
        lower - lower limit
        upper - upper limit
        unit - unit of value
        Throws:
        DeviceException
      • checkLimit

        protected void checkLimit​(java.lang.String valueName,
                                  java.lang.Number value,
                                  java.lang.Number lower,
                                  java.lang.Number upper)
                           throws DeviceException
        Throws:
        DeviceException