Class ReferenceDriverCommunications

  • Direct Known Subclasses:
    SerialPortCommunications, SimulatedCommunications, TcpCommunications

    public abstract class ReferenceDriverCommunications
    extends java.lang.Object
    Defines 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.
    • Constructor Detail

      • ReferenceDriverCommunications

        public ReferenceDriverCommunications()
    • 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.TimeoutException
        java.io.IOException
      • readLine

        public java.lang.String readLine()
                                  throws java.util.concurrent.TimeoutException,
                                         java.io.IOException
        Read 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.TimeoutException
        java.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.IOException
        Read 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.TimeoutException
        java.io.IOException
      • write

        public void write​(int d)
                   throws java.io.IOException
        Throws:
        java.io.IOException