Class SerialComm

All Implemented Interfaces:
CharReadableDev, CharWriteableDev, Device, Serial, Configurable, Findable, gda.observable.IObservable

public class SerialComm extends SerialBase
An implementation of the Serial class
  • Constructor Details

    • SerialComm

      public SerialComm()
      Constructor
  • Method Details

    • configure

      public void configure() throws FactoryException
      Description copied from class: ConfigurableBase
      Default implementation for classes that do not have to do any specific configuration.
      Classes that do their own configuration should *not* call this superclass function, as it may cause the object to appear configured before it really is.
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class ConfigurableBase
      Throws:
      FactoryException - if there is an error in configuration e.g. required variable not set or cannot connect to device
    • setPortName

      public void setPortName(String portName)
      Parameters:
      portName - String name of the serial port
    • getPortName

      public String getPortName()
      Returns:
      String name of the serial port
    • setBaudRate

      public void setBaudRate(int baudRate) throws DeviceException
      set the baudrate
      Parameters:
      baudRate -
      Throws:
      DeviceException
    • getBaudRate

      public int getBaudRate()
      Returns:
      int the baud rate
    • setByteSize

      public void setByteSize(int byteSize) throws DeviceException
      Set the number of data bits for data transfer
      Parameters:
      byteSize -
      Throws:
      DeviceException
    • getByteSize

      public int getByteSize()
      Returns:
      the no. data bits for data transfer
    • setParity

      public void setParity(String parity) throws DeviceException
      This method only exists for castor instantiation, it does not physically set the parity
      Parameters:
      parity -
      Throws:
      DeviceException
    • getParity

      public String getParity()
      Returns:
      String parity of serial port
    • setStopBits

      public void setStopBits(int stopBits) throws DeviceException
      set the number of stop bits to be used in data transfer
      Parameters:
      stopBits - int the no. stop bits
      Throws:
      DeviceException
    • getStopBits

      public int getStopBits()
      Returns:
      int no. stop bits
    • setFlowControl

      public void setFlowControl(String flowControl) throws DeviceException
      Description copied from interface: Serial
      Sets the flow control
      Parameters:
      flowControl -
      Throws:
      DeviceException
    • getFlowControl

      public String getFlowControl()
      Returns:
      String flow control
    • getReadTimeout

      public int getReadTimeout() throws DeviceException
      Description copied from interface: Serial
      Gets the timeout value for single character reads
      Returns:
      the timeout in milliseconds
      Throws:
      DeviceException
    • close

      public void close()
      Description copied from interface: Device
      Close and unconfigure the device.
      Specified by:
      close in interface Device
      Specified by:
      close in interface Serial
      Overrides:
      close in class DeviceBase
    • reconfigure

      public void reconfigure() throws FactoryException
      Description copied from interface: Configurable
      Re-initialisation of values and states.

      Moved from Reconfigurable which has been deleted

      Specified by:
      reconfigure in interface Configurable
      Overrides:
      reconfigure in class ConfigurableBase
      Throws:
      FactoryException
    • setReadTimeout

      public void setReadTimeout(int time) throws DeviceException
      Description copied from interface: CharReadableDev
      Sets the maximum length of time to wait for a character to become available to read.
      Parameters:
      time - the length of time in milliseconds.
      Throws:
      DeviceException
    • readChar

      public char readChar() throws DeviceException
      Description copied from interface: CharReadableDev
      Reads a character from the device.
      Returns:
      the character read
      Throws:
      DeviceException
    • flush

      public void flush() throws DeviceException
      Description copied from interface: CharReadableDev
      Flushes any unread characters from the device.
      Throws:
      DeviceException
    • writeChar

      public void writeChar(char c) throws DeviceException
      Description copied from interface: CharWriteableDev
      Writes a character to the device.
      Parameters:
      c - The character to write
      Throws:
      DeviceException