Package jisa.visa.drivers
Class VISADriver.VISAConnection
- java.lang.Object
-
- jisa.visa.drivers.VISADriver.VISAConnection
-
- All Implemented Interfaces:
Connection
- Direct Known Subclasses:
VISADriver.VISAGPIBConnection
,VISADriver.VISALXIConnection
,VISADriver.VISASerialConnection
,VISADriver.VISATCPIPConnection
,VISADriver.VISAUSBConnection
- Enclosing class:
- VISADriver
public class VISADriver.VISAConnection extends java.lang.Object implements Connection
-
-
Field Summary
Fields Modifier and Type Field Description protected com.sun.jna.NativeLong
handle
-
Constructor Summary
Constructors Constructor Description VISAConnection(com.sun.jna.NativeLong viHandle)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
void
close()
Closes the connection, freeing up the resources used by it.long
getAttributeLong(long attribute)
java.lang.String
getAttributeString(long attribute)
java.nio.charset.Charset
getEncoding()
byte[]
readBytes(int bufferSize)
Attempts to read the given number of bytes from the connection.void
setAttribute(long attribute, long value)
void
setEncoding(java.nio.charset.Charset charset)
void
setReadTerminator(long character)
Sets the "End of String" terminator, in numerical form.void
setTimeout(int duration)
Sets the time-out, in milli-seconds, to use on this connection.void
write(java.lang.String toWrite)
Writes the specified string over the connection.void
writeBytes(byte[] bytes)
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jisa.visa.connections.Connection
read, read, setReadTerminator
-
-
-
-
Method Detail
-
writeBytes
public void writeBytes(byte[] bytes) throws VISAException
- Specified by:
writeBytes
in interfaceConnection
- Throws:
VISAException
-
clear
public void clear() throws VISAException
- Specified by:
clear
in interfaceConnection
- Throws:
VISAException
-
setEncoding
public void setEncoding(java.nio.charset.Charset charset)
- Specified by:
setEncoding
in interfaceConnection
-
getEncoding
public java.nio.charset.Charset getEncoding()
- Specified by:
getEncoding
in interfaceConnection
-
write
public void write(java.lang.String toWrite) throws VISAException
Description copied from interface:Connection
Writes the specified string over the connection.- Specified by:
write
in interfaceConnection
- Parameters:
toWrite
- String to write- Throws:
VISAException
- Upon something going wrong with VISA
-
readBytes
public byte[] readBytes(int bufferSize) throws VISAException
Description copied from interface:Connection
Attempts 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(...).- Specified by:
readBytes
in interfaceConnection
- Parameters:
bufferSize
- The number of bytes to read- Returns:
- Array of bytes read (trimmed)
- Throws:
VISAException
- Upon something going wrong
-
setReadTerminator
public void setReadTerminator(long character) throws VISAException
Description copied from interface:Connection
Sets 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
- Specified by:
setReadTerminator
in interfaceConnection
- Parameters:
character
- The terminator to look for (numerical representation)- Throws:
VISAException
- Upon something going wrong
-
setTimeout
public void setTimeout(int duration) throws VISAException
Description copied from interface:Connection
Sets the time-out, in milli-seconds, to use on this connection.- Specified by:
setTimeout
in interfaceConnection
- Parameters:
duration
- Time-out, in milli-seconds- Throws:
VISAException
- Upon something going wrong
-
close
public void close() throws VISAException
Description copied from interface:Connection
Closes the connection, freeing up the resources used by it.- Specified by:
close
in interfaceConnection
- Throws:
VISAException
- Upon something going wrong
-
setAttribute
public void setAttribute(long attribute, long value) throws VISAException
- Throws:
VISAException
-
getAttributeLong
public long getAttributeLong(long attribute) throws VISAException
- Throws:
VISAException
-
getAttributeString
public java.lang.String getAttributeString(long attribute) throws VISAException
- Throws:
VISAException
-
-