Package gda.device.serial
Class SerialComm
java.lang.Object
gda.factory.ConfigurableBase
gda.factory.FindableConfigurableBase
gda.device.DeviceBase
gda.device.serial.SerialBase
gda.device.serial.SerialComm
- All Implemented Interfaces:
CharReadableDev,CharWriteableDev,Device,Serial,Configurable,Findable,gda.observable.IObservable
An implementation of the Serial class
-
Field Summary
Fields inherited from class gda.device.DeviceBase
DEFAULT_PROTECTION_LEVEL_PROPERTYFields inherited from interface gda.device.Serial
BAUDRATE_0, BAUDRATE_110, BAUDRATE_115200, BAUDRATE_1200, BAUDRATE_128000, BAUDRATE_134, BAUDRATE_14400, BAUDRATE_150, BAUDRATE_1800, BAUDRATE_19200, BAUDRATE_200, BAUDRATE_2000, BAUDRATE_2400, BAUDRATE_256000, BAUDRATE_300, BAUDRATE_3600, BAUDRATE_38400, BAUDRATE_4800, BAUDRATE_50, BAUDRATE_56000, BAUDRATE_57600, BAUDRATE_600, BAUDRATE_7200, BAUDRATE_75, BAUDRATE_9600, BYTESIZE_5, BYTESIZE_6, BYTESIZE_7, BYTESIZE_8, FLOWCONTROL_NONE, FLOWCONTROL_RTSCTS, FLOWCONTROL_XONXOFF, PARITY_EVEN, PARITY_MARK, PARITY_NONE, PARITY_ODD, PARITY_SPACE, STOPBITS_1, STOPBITS_1_5, STOPBITS_2 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close and unconfigure the device.voidDefault 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.voidflush()Flushes any unread characters from the device.intintintGets the timeout value for single character readsintcharreadChar()Reads a character from the device.voidRe-initialisation of values and states.voidsetBaudRate(int baudRate) set the baudratevoidsetByteSize(int byteSize) Set the number of data bits for data transfervoidsetFlowControl(String flowControl) Sets the flow controlvoidThis method only exists for castor instantiation, it does not physically set the parityvoidsetPortName(String portName) voidsetReadTimeout(int time) Sets the maximum length of time to wait for a character to become available to read.voidsetStopBits(int stopBits) set the number of stop bits to be used in data transfervoidwriteChar(char c) Writes a character to the device.Methods inherited from class gda.device.DeviceBase
addIObserver, deleteIObserver, deleteIObservers, getAttribute, getName, getProtectionLevel, isBeingObserved, isConfigureAtStartup, notifyIObservers, setAttribute, setConfigureAtStartup, setName, setProtectionLevelMethods inherited from class gda.factory.ConfigurableBase
isConfigured, setConfiguredMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface gda.factory.Configurable
isConfigureAtStartup, isConfiguredMethods inherited from interface gda.device.Device
getAttribute, getProtectionLevel, setAttribute, setProtectionLevelMethods inherited from interface gda.observable.IObservable
addIObserver, deleteIObserver, deleteIObservers
-
Constructor Details
-
SerialComm
public SerialComm()Constructor
-
-
Method Details
-
configure
Description copied from class:ConfigurableBaseDefault 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:
configurein interfaceConfigurable- Overrides:
configurein classConfigurableBase- Throws:
FactoryException- if there is an error in configuration e.g. required variable not set or cannot connect to device
-
setPortName
- Parameters:
portName- String name of the serial port
-
getPortName
- Returns:
- String name of the serial port
-
setBaudRate
set the baudrate- Parameters:
baudRate-- Throws:
DeviceException
-
getBaudRate
public int getBaudRate()- Returns:
- int the baud rate
-
setByteSize
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
This method only exists for castor instantiation, it does not physically set the parity- Parameters:
parity-- Throws:
DeviceException
-
getParity
- Returns:
- String parity of serial port
-
setStopBits
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
Description copied from interface:SerialSets the flow control- Parameters:
flowControl-- Throws:
DeviceException
-
getFlowControl
- Returns:
- String flow control
-
getReadTimeout
Description copied from interface:SerialGets the timeout value for single character reads- Returns:
- the timeout in milliseconds
- Throws:
DeviceException
-
close
public void close()Description copied from interface:DeviceClose and unconfigure the device. -
reconfigure
Description copied from interface:ConfigurableRe-initialisation of values and states.Moved from Reconfigurable which has been deleted
- Specified by:
reconfigurein interfaceConfigurable- Overrides:
reconfigurein classConfigurableBase- Throws:
FactoryException
-
setReadTimeout
Description copied from interface:CharReadableDevSets 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
Description copied from interface:CharReadableDevReads a character from the device.- Returns:
- the character read
- Throws:
DeviceException
-
flush
Description copied from interface:CharReadableDevFlushes any unread characters from the device.- Throws:
DeviceException
-
writeChar
Description copied from interface:CharWriteableDevWrites a character to the device.- Parameters:
c- The character to write- Throws:
DeviceException
-