public abstract class BaseReader
extends java.lang.Object
implements com.unitech.lib.event.ITransportEventListener
| Modifier and Type | Field and Description |
|---|---|
protected com.unitech.lib.device.BaseDevice |
_baseDevice
The BaseDevice object representing the device.
|
protected BaseEngine |
_baseEngine
The BaseEngine object representing the engine.
|
protected com.unitech.lib.transport.BaseTransport |
_baseTransport
The BaseTransport object used for transport operations.
|
protected int |
_failCount
The number of failed attempts to connect to the device.
|
protected java.lang.String |
_firmwareVersion
The firmware version of the device.
|
protected static int |
_id |
protected boolean |
_isKeepAliveThreadAlive |
protected java.lang.Runnable |
_keepAliveRunnable |
protected java.lang.Thread |
_keepAliveThread |
protected long |
_lastTime |
protected java.lang.String |
_serialNumber
The serial number of the device.
|
protected boolean |
_triggerDisconnect |
protected int |
DEFAULT_BATTERY_CHECK_INTERVAL |
protected int |
RETRY_COUNT |
protected java.lang.String |
TAG
The tag used for logging.
|
| Constructor and Description |
|---|
BaseReader(UnitechDevice device)
Constructs a new BaseReader object with the specified UnitechDevice.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(IReaderEventListener listener)
Adds a listener to the instance of the BaseReader class.
|
protected void |
alive()
Use only within the SDK.
|
void |
checkError()
Use only within the SDK.
|
void |
checkError(boolean resetTime)
Use only within the SDK.
|
void |
clearListener()
Removes all listeners from the instance of the BaseReader class.
|
boolean |
connect()
Establishes a connection with the device.
|
void |
destroy()
Destroys an instance of the BaseReader class and cleans up resources.
|
boolean |
disconnect()
Disconnects from the device.
|
java.lang.String |
getAddress()
Returns the address of the device associated with an instance of the BaseReader class.
|
BaseEngine |
getBaseEngine()
Returns an instance of the BaseEngine class that defines the engine used by the Device.
|
int |
getCheckBatteryInterval()
Returns the interval for checking the battery status.
|
ConnectState |
getConnectState()
Returns the connection status of the device with the instance of the BaseReader class.
|
ConnectType |
getConnectType()
Returns the instance of BaseReader associated with device.
|
java.lang.String |
getDeviceName()
Returns the name of the Device associated with an instance of the BaseReader class.
|
DeviceType |
getDeviceType()
Returns the type of Device to which the instance is connected.
|
com.unitech.lib.protocol.BaseProtocol |
getProtocol()
Returns an instance of the BaseProtocol class that defines the protocol used by the Device.
|
java.lang.String |
getSerialNumber()
Returns the serial number of the device.
|
com.unitech.lib.transport.BaseTransport |
getTransport()
Returns an instance of the BaseTransport class that connects an instance of the BaseReader class
to the Device.
|
java.lang.String |
getVersion()
Returns the firmware version of the device associated with the instance of the BaseReader class.
|
protected abstract boolean |
initReader() |
void |
onTransportConnectStateChanged(ConnectState state,
java.lang.Object params)
Called when the connection state changes.
|
void |
removeListener(IReaderEventListener listener)
Removes a listener from the instance of the BaseReader class.
|
void |
resetError()
Use only within the SDK.
|
void |
setCheckBatteryInterval(int checkBatteryInterval)
Sets the interval for checking the battery status.
|
protected void |
triggerBarcodeEvent(BaseReader reader,
BarcodeID id,
byte[] data,
java.lang.Object params) |
protected void |
triggerBatteryPercentageChanged(BaseReader reader,
byte batteryPercentage,
boolean charging,
java.lang.Object params) |
protected void |
triggerBatteryStateChanged(BaseReader reader,
BatteryState batteryState,
java.lang.Object params) |
protected void |
triggerConnectStateChanged(BaseReader reader,
ConnectState state,
java.lang.Object params) |
protected void |
triggerNotificationEvent(BaseReader reader,
NotificationID id,
java.lang.Object params) |
protected java.lang.String TAG
protected static int _id
protected final int DEFAULT_BATTERY_CHECK_INTERVAL
protected final int RETRY_COUNT
protected com.unitech.lib.transport.BaseTransport _baseTransport
protected com.unitech.lib.device.BaseDevice _baseDevice
protected BaseEngine _baseEngine
protected java.lang.String _serialNumber
protected java.lang.String _firmwareVersion
protected volatile int _failCount
protected volatile long _lastTime
protected volatile boolean _triggerDisconnect
protected volatile boolean _isKeepAliveThreadAlive
protected java.lang.Thread _keepAliveThread
protected java.lang.Runnable _keepAliveRunnable
public BaseReader(UnitechDevice device)
device - The UnitechDevice to use.public void destroy()
public boolean connect()
public boolean disconnect()
public DeviceType getDeviceType()
public java.lang.String getDeviceName()
public java.lang.String getSerialNumber()
public java.lang.String getVersion()
public java.lang.String getAddress()
public ConnectType getConnectType()
public ConnectState getConnectState()
public void addListener(IReaderEventListener listener)
listener - An instance of the IReaderEventListener interface to add to the BaseReader class.public void removeListener(IReaderEventListener listener)
listener - An instance of the IReaderEventListener interface to remove from the BaseReader class.public void clearListener()
public com.unitech.lib.transport.BaseTransport getTransport()
public com.unitech.lib.protocol.BaseProtocol getProtocol()
public BaseEngine getBaseEngine()
public int getCheckBatteryInterval()
public void setCheckBatteryInterval(int checkBatteryInterval)
checkBatteryInterval - The interval for checking the battery status, in milliseconds.protected void triggerBatteryStateChanged(BaseReader reader, BatteryState batteryState, java.lang.Object params)
protected void triggerBatteryPercentageChanged(BaseReader reader, byte batteryPercentage, boolean charging, java.lang.Object params)
protected void triggerBarcodeEvent(BaseReader reader, BarcodeID id, byte[] data, java.lang.Object params)
protected void triggerNotificationEvent(BaseReader reader, NotificationID id, java.lang.Object params)
protected void triggerConnectStateChanged(BaseReader reader, ConnectState state, java.lang.Object params)
public void resetError()
public void checkError()
public void checkError(boolean resetTime)
resetTime - If true, the last time is reset.protected void alive()
public void onTransportConnectStateChanged(ConnectState state, java.lang.Object params)
com.unitech.lib.event.ITransportEventListeneronTransportConnectStateChanged in interface com.unitech.lib.event.ITransportEventListenerstate - The new connection state.params - Any additional parameters associated with the event.protected abstract boolean initReader()