Package jisa.visa.connections
Interface Connection
-
- All Known Subinterfaces:
GPIBConnection,LXIConnection,SerialConnection,TCPIPConnection,USBConnection
- All Known Implementing Classes:
GPIBDriver.GPIBConnection,SerialDriver.JSSCConnection,TCPIPDriver.TCPIPConnection,VISADriver.VISAConnection,VISADriver.VISAGPIBConnection,VISADriver.VISALXIConnection,VISADriver.VISASerialConnection,VISADriver.VISATCPIPConnection,VISADriver.VISAUSBConnection
public interface Connection
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclear()voidclose()Closes the connection, freeing up the resources used by it.java.nio.charset.CharsetgetEncoding()default java.lang.Stringread()Reads from the connection (max buffer of 1024 bytes), returning the data as a Stringdefault java.lang.Stringread(int bufferSize)Reads from the connection, using the specified maximum buffer size.byte[]readBytes(int bufferSize)Attempts to read the given number of bytes from the connection.voidsetEncoding(java.nio.charset.Charset charset)voidsetReadTerminator(long terminator)Sets the "End of String" terminator, in numerical form.default voidsetReadTerminator(java.lang.String terminator)Sets the "End of String" terminator, in String form.voidsetTimeout(int duration)Sets the time-out, in milli-seconds, to use on this connection.default voidwrite(java.lang.String toWrite)Writes the specified string over the connection.voidwriteBytes(byte[] bytes)
-
-
-
Method Detail
-
writeBytes
void writeBytes(byte[] bytes) throws VISAException- Throws:
VISAException
-
clear
void clear() throws VISAException- Throws:
VISAException
-
setEncoding
void setEncoding(java.nio.charset.Charset charset)
-
getEncoding
java.nio.charset.Charset getEncoding()
-
write
default void write(java.lang.String toWrite) throws VISAExceptionWrites the specified string over the connection.- Parameters:
toWrite- String to write- Throws:
VISAException- Upon something going wrong with VISA
-
read
default java.lang.String read(int bufferSize) throws VISAExceptionReads from the connection, using the specified maximum buffer size. Returns data as a String- Parameters:
bufferSize- Buffer size, in bytes- Returns:
- Read data, as a String
- Throws:
VISAException- Upon something going wrong with VISA
-
read
default java.lang.String read() throws VISAExceptionReads from the connection (max buffer of 1024 bytes), returning the data as a String- Returns:
- Read data, as a String
- Throws:
VISAException- Upon something going wrong
-
readBytes
byte[] readBytes(int bufferSize) throws VISAExceptionAttempts to read the given number of bytes from the connection. Will return if either the number of bytes is reached or the specified EOS terminator is found. Will time-out if neither of these conditions are met within the value specified by setTMO(...).- Parameters:
bufferSize- The number of bytes to read- Returns:
- Array of bytes read (trimmed)
- Throws:
VISAException- Upon something going wrong
-
setReadTerminator
void setReadTerminator(long terminator) throws VISAExceptionSets the "End of String" terminator, in numerical form. This is the terminator used for reading from the connection, to specify the end of a message from the instrument. For example:line-feed: \n = 0x0A carriage-return \r = 0x0D CR-LF \r\n = 0x0D0A
- Parameters:
terminator- The terminator to look for (numerical representation)- Throws:
VISAException- Upon something going wrong
-
setReadTerminator
default void setReadTerminator(java.lang.String terminator) throws VISAExceptionSets the "End of String" terminator, in String form. This is the terminator used for reading from the connection, to specify the end of a message from the instrument.- Parameters:
terminator- The terminator to look from (String representation)- Throws:
VISAException- Upon something going wrong
-
setTimeout
void setTimeout(int duration) throws VISAExceptionSets the time-out, in milli-seconds, to use on this connection.- Parameters:
duration- Time-out, in milli-seconds- Throws:
VISAException- Upon something going wrong
-
close
void close() throws VISAExceptionCloses the connection, freeing up the resources used by it.- Throws:
VISAException- Upon something going wrong
-
-