Class ReferenceDriverCommunications
- java.lang.Object
-
- org.openpnp.machine.reference.driver.ReferenceDriverCommunications
-
- Direct Known Subclasses:
SerialPortCommunications,SimulatedCommunications,TcpCommunications
public abstract class ReferenceDriverCommunications extends java.lang.ObjectDefines the interface for a simple communications IO driver, for example A serial port. This Driver interface is intended to model the minimum required functions to transfer data from OpenPnP to a hardware controller.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReferenceDriverCommunications.LineEndingType
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringdriverNameprotected ReferenceDriverCommunications.LineEndingTypelineEndingType
-
Constructor Summary
Constructors Constructor Description ReferenceDriverCommunications()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidconnect()abstract voiddisconnect()abstract java.lang.StringgetConnectionName()GcodeServergetGcodeServer()ReferenceDriverCommunications.LineEndingTypegetLineEndingType()abstract intread()java.lang.StringreadLine()Read a line from the input stream.protected java.lang.StringreadUntil(java.lang.String characters)Read the input stream until one of the characters is found.voidsetDriverName(java.lang.String driverName)Set the driver name, so the connection can be easily associated with the driver.voidsetLineEndingType(ReferenceDriverCommunications.LineEndingType lineEndingType)voidwrite(int d)protected abstract voidwriteBytes(byte[] data)voidwriteLine(java.lang.String data)
-
-
-
Field Detail
-
lineEndingType
protected ReferenceDriverCommunications.LineEndingType lineEndingType
-
driverName
protected java.lang.String driverName
-
-
Method Detail
-
connect
public abstract void connect() throws java.lang.Exception- Throws:
java.lang.Exception
-
disconnect
public abstract void disconnect() throws java.lang.Exception- Throws:
java.lang.Exception
-
setDriverName
public void setDriverName(java.lang.String driverName)
Set the driver name, so the connection can be easily associated with the driver.
-
getConnectionName
public abstract java.lang.String getConnectionName()
-
writeBytes
protected abstract void writeBytes(byte[] data) throws java.io.IOException- Throws:
java.io.IOException
-
read
public abstract int read() throws java.util.concurrent.TimeoutException, java.io.IOException- Throws:
java.util.concurrent.TimeoutExceptionjava.io.IOException
-
readLine
public java.lang.String readLine() throws java.util.concurrent.TimeoutException, java.io.IOExceptionRead a line from the input stream. Blocks for the default timeout. If the read times out a TimeoutException is thrown. Any other failure to read results in an IOExeption;- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.io.IOException
-
writeLine
public void writeLine(java.lang.String data) throws java.io.IOException- Throws:
java.io.IOException
-
readUntil
protected java.lang.String readUntil(java.lang.String characters) throws java.util.concurrent.TimeoutException, java.io.IOExceptionRead the input stream until one of the characters is found. Blocks for the default timeout. If the read times out a TimeoutException is thrown. Any other failure to read results in an IOExeption;- Parameters:
characters- list of ending characters- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.io.IOException
-
write
public void write(int d) throws java.io.IOException- Throws:
java.io.IOException
-
setLineEndingType
public void setLineEndingType(ReferenceDriverCommunications.LineEndingType lineEndingType)
-
getLineEndingType
public ReferenceDriverCommunications.LineEndingType getLineEndingType()
-
getGcodeServer
public GcodeServer getGcodeServer()
-
-