|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object device.Device
public class Device
A Device represents an abstract entity, i.e. device node, that can have other devices in its internal list. It will start and shutdown these devices (if any) and itself in a dedicated thread per device.
Field Summary | |
---|---|
(package private) java.util.concurrent.ConcurrentLinkedQueue<Device> |
deviceList
The internal device list can contain other devices. |
(package private) java.lang.String |
host
The host string, i.e. network name. |
(package private) int |
id
The numerical identifiers of this device. |
(package private) int |
index
The numerical device number. |
(package private) boolean |
isRunning
Indicating if this device is currently in an action cycle. |
(package private) boolean |
isThreaded
Indicating if this device is started in its own thread. |
(package private) java.util.logging.Logger |
logger
Logging support |
(package private) int |
port
The port number, i.e. host port. |
(package private) long |
sleeptime
The periodical idle time in ms this device sleeps between action cycles. |
(package private) java.lang.Thread |
thread
Every class of this type has it's own thread |
Constructor Summary | |
---|---|
Device()
Creates a Device and initializes the internal device list. |
|
Device(Device device)
Creates a device with the given properties. |
|
Device(int id,
java.lang.String host,
int port,
int index)
This constructor is used to create a data device object and has no internal devicelist or thread |
Method Summary | |
---|---|
boolean |
equals(Device aDevice)
Compares a Device according to its properties to another one |
Device |
getDevice(Device dev)
Searches the internal device list for the device with the properties given. |
java.util.Iterator<Device> |
getDeviceIterator()
|
java.util.concurrent.ConcurrentLinkedQueue<Device> |
getDeviceList()
Returns a list of devices that this robot client provides. |
Device[] |
getDeviceListArray()
|
java.lang.String |
getHost()
|
int |
getId()
|
int |
getIndex()
|
java.util.logging.Logger |
getLogger()
|
int |
getPort()
|
long |
getSleepTime()
|
java.lang.String |
getThreadName()
|
boolean |
isInList(Device[] aDevList)
Checks if this device properties is in the given device list. |
boolean |
isRunning()
|
boolean |
isSupported()
|
boolean |
isThreaded()
|
boolean |
matches(Device aDevice)
Matches this device with the given one. |
boolean |
matchesList(Device[] aDevList)
Checks if this device properties matches against any of the given device list. |
void |
run()
Manages the periodical action cycles and idle times. |
void |
runThreaded()
Starts this device (and its sub-devices) in a thread each. |
protected void |
setDeviceList(java.util.concurrent.ConcurrentLinkedQueue<Device> deviceList)
|
void |
setHost(java.lang.String host)
Sets this device' host string. |
void |
setName(int name)
Sets this device' numerical identifier. |
void |
setPort(int port)
Sets this device' host port. |
void |
setSleepTime(long time)
|
void |
shutdown()
Shuts down this (and any sub-) device. |
java.lang.String |
toString()
|
protected void |
update()
Might be to be implemented by subclass to do something |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
java.util.logging.Logger logger
java.util.concurrent.ConcurrentLinkedQueue<Device> deviceList
int id
java.lang.String host
int port
int index
java.lang.Thread thread
long sleeptime
boolean isRunning
boolean isThreaded
Constructor Detail |
---|
public Device()
public Device(int id, java.lang.String host, int port, int index)
id
- The Device id.host
- The host to which this Device is connected.port
- The port to which this Device is connected.index
- The Device number (aka index) of the Device.public Device(Device device)
device
- A device template to create a new deviceMethod Detail |
---|
protected void update()
public void runThreaded()
runThreaded
in interface IDevice
public void run() throws java.lang.IllegalStateException
run
in interface java.lang.Runnable
java.lang.IllegalStateException
- When updating the device fails.public void shutdown()
shutdown
in interface IDevice
public final java.util.concurrent.ConcurrentLinkedQueue<Device> getDeviceList()
protected final void setDeviceList(java.util.concurrent.ConcurrentLinkedQueue<Device> deviceList)
deviceList
- the deviceList to setpublic final Device[] getDeviceListArray()
public final java.util.Iterator<Device> getDeviceIterator()
public final Device getDevice(Device dev)
dev
- Device template (0 or null for args not to take care of).
public java.lang.String getHost()
public void setHost(java.lang.String host)
host
- The host string.public int getPort()
public void setPort(int port)
port
- public int getId()
public void setName(int name)
name
- The identifier.public int getIndex()
public java.lang.String getThreadName()
public void setSleepTime(long time)
time
- The idle time of this device.public long getSleepTime()
public boolean isRunning()
public boolean isThreaded()
public java.util.logging.Logger getLogger()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(Device aDevice)
aDevice
- The device to compare to.
public boolean matches(Device aDevice)
aDevice
- The device to match against.
public boolean matchesList(Device[] aDevList)
aDevList
- The list to search in.
public boolean isInList(Device[] aDevList)
aDevList
- The list to search in.
public boolean isSupported()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |