public abstract class ATransport
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
ATransport.IBufferControlEventListener
The interface for software flow control according to the state of the Transport internal buffer while the Transport instance is communicating with the device.
|
static interface |
ATransport.IConnectStateEventListener
It is an interface to notify the connection status with the equipment.
|
Modifier and Type | Field and Description |
---|---|
protected static int |
DUMP |
protected static int |
INFO |
protected static int |
IO |
protected java.lang.String |
mAddress |
protected ConnectType |
mConnType |
protected java.lang.String |
mDevName |
protected DeviceType |
mDevType |
protected boolean |
mIsAutoConnect |
protected boolean |
mIsDeviceAttached |
protected java.lang.String |
mMacAddress |
protected com.atid.lib.util.collections.ByteQueue |
mQueue |
protected ConnectState |
mState |
protected java.lang.String |
TAG |
Constructor and Description |
---|
ATransport()
Create an instance of the Transport class
|
ATransport(DeviceType type,
java.lang.String name,
java.lang.String address)
Create an instance of the Transport class
|
ATransport(DeviceType type,
java.lang.String name,
java.lang.String address,
boolean autoConnect)
Create an instance of the Transport class
|
ATransport(DeviceType type,
java.lang.String name,
java.lang.String mac,
java.lang.String address)
Create an instance of the Transport class
|
ATransport(DeviceType type,
java.lang.String name,
java.lang.String mac,
java.lang.String address,
boolean autoConnect)
Create an instance of the Transport class
|
Modifier and Type | Method and Description |
---|---|
abstract int |
available()
Returns the length of data that can be read with the read method.
|
protected void |
checkBufferSize(int size) |
abstract boolean |
connect()
Attempts to connect to the appliance using an instance of the Transport class.
|
abstract void |
destroy()
ATransport Destroys the instance and returns the resource.
|
abstract void |
disconnect()
An instance of the Transport class closes the connection to the device to which the device is connected.
|
java.lang.String |
getAddress()
Returns the address of the device to which the ATransport instance is connected.
|
abstract boolean |
getAutoConnect()
Returns whether automatically connect to the appliance using an instance of the Transport class.
|
ConnectType |
getConnectType()
Returns the instance of Transport associated with device.
|
abstract boolean |
getDeviceAttached()
Returns whether attached to the appliance using an instance of the Transport class.
|
java.lang.String |
getDeviceName()
Returns the name of the Device to which the ATransport instance is connected.
|
DeviceType |
getDeviceType()
ATransport Returns the type of device to which the instance will be connected.
|
java.lang.String |
getMacAddress()
Returns the MAC address of the device to which the ATransport instance is connected.
|
ConnectState |
getState()
The instance of ATransport returns the connection status with device.
|
abstract void |
listen()
An instance of the ATransport class waits for the device to connect.
|
int |
read(byte[] data)
Read data received from the device.
|
int |
read(byte[] data,
int length)
Read data received from the device.
|
abstract int |
read(byte[] data,
int offset,
int length)
Read data received from the device.
|
abstract int |
read(byte[] data,
int offset,
int length,
int timeout)
Read data received from the device.
|
void |
setAddress(java.lang.String address)
Sets the address of the device to which the ATransport instance is connected.
|
abstract void |
setAutoConnect(boolean enabled)
Sets whether automatically connect to the appliance using an instance of the Transport class.
|
void |
setBufferControlListener(int min,
ATransport.IBufferControlEventListener listener)
Sets the listener to be notified of buffer status in order for an instance of the Transport class to dynamically control the buffer.
|
void |
setBufferControlListener(int min,
int max,
ATransport.IBufferControlEventListener listener)
Sets the listener to be notified of buffer status in order for an instance of the Transport class to dynamically control the buffer.
|
void |
setDeviceName(java.lang.String name)
Sets the name of the device to which the ATransport instance is connected.
|
void |
setDeviceType(DeviceType type)
ATransport Sets the type of device to which the instance will be connected.
|
void |
setMacAddress(java.lang.String mac)
Sets the MAC address of the device to which the ATransport instance is connected.
|
protected void |
setState(ConnectState state,
java.lang.Object params) |
void |
setStateListener(ATransport.IConnectStateEventListener listener)
Sets the listener to receive the connection status of an instance of the ATransport class.
|
java.lang.String |
toString() |
int |
write(byte[] data)
Transfer data to the device.
|
int |
write(byte[] data,
int length)
Transfer data to the device.
|
abstract int |
write(byte[] data,
int offset,
int length)
Transfer data to the device.
|
abstract int |
write(byte[] data,
int offset,
int length,
int timeout)
Transfer data to the device.
|
protected static final int INFO
protected static final int IO
protected static final int DUMP
protected java.lang.String TAG
protected volatile ConnectState mState
protected volatile ConnectType mConnType
protected volatile DeviceType mDevType
protected volatile java.lang.String mDevName
protected volatile java.lang.String mMacAddress
protected volatile java.lang.String mAddress
protected volatile boolean mIsAutoConnect
protected volatile boolean mIsDeviceAttached
protected com.atid.lib.util.collections.ByteQueue mQueue
public ATransport()
public ATransport(DeviceType type, java.lang.String name, java.lang.String address)
type
- A DeviceType enumeration that specifies the type of connected device using an instance of the Transport class.name
- A string that specifies the name of the connected device using an instance of the Transport class.address
- A string that specifies the address of the connected device by using an instance of the Transport class.public ATransport(DeviceType type, java.lang.String name, java.lang.String address, boolean autoConnect)
type
- A DeviceType enumeration that specifies the type of connected device using an instance of the Transport class.name
- A string that specifies the name of the connected device using an instance of the Transport class.address
- A string that specifies the address of the connected device by using an instance of the Transport class.autoConnect
- A boolean that sets whether automatically connect to the device using an instance of the Transport class.public ATransport(DeviceType type, java.lang.String name, java.lang.String mac, java.lang.String address)
type
- A DeviceType enumeration that specifies the type of connected device using an instance of the Transport class.name
- A string that specifies the name of the connected device using an instance of the Transport class.mac
- A string that specifies the MAC address of the device to be connected using the instance of the ATransport class.address
- A string that specifies the address of the connected device by using an instance of the Transport class.public ATransport(DeviceType type, java.lang.String name, java.lang.String mac, java.lang.String address, boolean autoConnect)
type
- A DeviceType enumeration that specifies the type of connected device using an instance of the Transport class.name
- A string that specifies the name of the connected device using an instance of the Transport class.mac
- A string that specifies the MAC address of the device to be connected using the instance of the ATransport class.address
- A string that specifies the address of the connected device by using an instance of the Transport class.autoConnect
- A boolean that sets whether automatically connect to the device using an instance of the Transport class.public abstract void destroy()
public abstract void setAutoConnect(boolean enabled)
enabled
- A boolean specifying whether the device automatically connect.public abstract boolean getAutoConnect()
public abstract boolean getDeviceAttached()
public abstract boolean connect()
public abstract void listen()
public abstract void disconnect()
public int write(byte[] data)
data
- A byte array that specifies the data to transfer to the Device.public int write(byte[] data, int length)
data
- A byte array that specifies the data to transfer to the Device.length
- An integer indicating the length of the data to be transferred to the Device.public abstract int write(byte[] data, int offset, int length)
data
- A byte array that specifies the data to transfer to the Device.offset
- An integer indicating the start address of the data to be transferred to the Device.length
- An integer indicating the length of the data to be transferred to the Device.public abstract int write(byte[] data, int offset, int length, int timeout)
data
- A byte array that specifies the data to transfer to the Device.offset
- An integer indicating the start address of the data to be transferred to the Device.length
- An integer indicating the length of the data to be transferred to the Device.timeout
- An integer specifying the timeout of data transmission to the device.public abstract int available()
public int read(byte[] data)
data
- A byte array to store the data received from the device.public int read(byte[] data, int length)
data
- A byte array to store the data received from the device.length
- An integer specifying the maximum length at which data received from the device can be stored in a byte array.public abstract int read(byte[] data, int offset, int length)
data
- A byte array to store the data received from the device.offset
- Integer specifying the start address at which data received from device will begin to be stored in a byte array.length
- An integer specifying the maximum length at which data received from the device can be stored in a byte array.public abstract int read(byte[] data, int offset, int length, int timeout)
data
- A byte array to store the data received from the device.offset
- Integer specifying the start address at which data received from device will begin to be stored in a byte array.length
- An integer specifying the maximum length at which data received from the device can be stored in a byte array.timeout
- An integer that specifies the timeout for reading data received from the device.public void setStateListener(ATransport.IConnectStateEventListener listener)
listener
- An instance of ITransportStateEventListener to receive the connection status of an instance of the ATransport class.public void setBufferControlListener(int min, ATransport.IBufferControlEventListener listener)
min
- An integer representing the minimum state of the buffers of the ATransport instance.listener
- An instance of the IBuffer Control Listener interface to receive notification of the state of the Transport class and the buffers of the instance.public void setBufferControlListener(int min, int max, ATransport.IBufferControlEventListener listener)
min
- An integer representing the minimum state of the buffers of the ATransport instance.max
- An integer representing the maximum state of the buffers of the ATransport instance.listener
- An instance of the IBuffer Control Listener interface to receive notification of the state of the Transport class and the buffers of the instance.public ConnectType getConnectType()
public DeviceType getDeviceType()
public void setDeviceType(DeviceType type)
type
- The DeviceType enumeration indicating the type of device.public java.lang.String getDeviceName()
public void setDeviceName(java.lang.String name)
name
- A string representing the name of the Device.public java.lang.String getMacAddress()
public void setMacAddress(java.lang.String mac)
mac
- A string representing the MAC address of the Device.public java.lang.String getAddress()
public void setAddress(java.lang.String address)
address
- A string representing the address of the Device.public ConnectState getState()
protected void setState(ConnectState state, java.lang.Object params)
protected void checkBufferSize(int size)
public java.lang.String toString()
toString
in class java.lang.Object