public class DeviceFactory extends java.lang.Object implements IRefreshee, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected static boolean |
autoStart |
protected Refresher |
refresher |
protected int |
refreshInterval |
static int |
TRACE_ALL |
static int |
TRACE_ATT_CONFIG_EVENT |
static int |
TRACE_ATTFACTORY |
static int |
TRACE_ATTREFRESHER |
static int |
TRACE_CHANGE_EVENT |
static int |
TRACE_CMDFACTORY |
static int |
TRACE_COMMAND |
static int |
TRACE_DEVFACTORY |
static int |
TRACE_FAIL |
static int |
TRACE_NONE |
static int |
TRACE_PERIODIC_EVENT |
static int |
TRACE_REFRESHER |
static int |
TRACE_STATE_REFRESHER |
static int |
TRACE_SUCCESS |
protected boolean |
traceUnexpected |
Modifier and Type | Method and Description |
---|---|
void |
addDevice(Device dev)
Adds a device instance in the factory if the device name is not already existant in the factory
|
boolean |
containsDevice(java.lang.String name)
Check whether the given name corresponds to an already existing device in the factory
|
void |
deleteDevice(java.lang.String name)
Remove the given device from the global refresher list.
|
Device |
getConnectionlessDevice(java.lang.String name)
Get a handle to a device and add it to the global state/status refresher list.
|
Device |
getDevice(java.lang.String name)
Get a handle to a device and add it to the global state/status refresher list.
|
java.util.List<java.lang.String> |
getDeviceNames()
Returns an array of string containing all device name of this factory.
|
Device[] |
getDevices()
Returns an array containing all device of this factory.
|
static DeviceFactory |
getInstance()
Returns an instance of the singleton device factory class
|
long |
getRefreshInterval()
getRefreshInterval gets the refresh-interval for
the entity list. |
int |
getTraceMode()
Returns the current trace level.
|
java.lang.String |
getVersion() |
static boolean |
isAutoStart()
Returns the autostart property.
|
boolean |
isDevice(java.lang.String name)
Check wether the given name correspond to an existing device.
|
boolean |
isRefreshing()
Returns true if the global device refresher is running.
|
boolean |
isTraceUnexpected() |
void |
refresh()
Executes the global state/status refresh on all device registered.
|
static void |
setAutoStart(boolean b)
Sets the autostart property.
|
void |
setRefresher(Refresher r)
setRefresher sets the resher thread
for this Device. |
void |
setRefreshInterval(int milliSeconds)
setRefreshInterval sets the refresh interval for
the Device. |
void |
setTraceMode(int level)
Set the trace level of ATK device calls.
|
void |
setTraceUnexpected(boolean traceUnexpected) |
void |
startRefresher()
startRefresher starts the default refresher thread
for the Device which sleeps for refreshInterval seconds. |
void |
stopRefresher()
stopRefresher stops the refresher. |
void |
trace(int level,
java.lang.String msg,
long startTime)
Print trace.
|
public static final int TRACE_NONE
public static final int TRACE_FAIL
public static final int TRACE_SUCCESS
public static final int TRACE_REFRESHER
public static final int TRACE_ATTREFRESHER
public static final int TRACE_COMMAND
public static final int TRACE_CHANGE_EVENT
public static final int TRACE_STATE_REFRESHER
public static final int TRACE_PERIODIC_EVENT
public static final int TRACE_DEVFACTORY
public static final int TRACE_ATTFACTORY
public static final int TRACE_CMDFACTORY
public static final int TRACE_ATT_CONFIG_EVENT
public static final int TRACE_ALL
protected int refreshInterval
protected Refresher refresher
protected static boolean autoStart
protected boolean traceUnexpected
public static DeviceFactory getInstance()
public void setTraceMode(int level)
level
- Trace level. Can be a combination of the following value:TRACE_NONE
,
TRACE_FAIL
,
TRACE_SUCCESS
,
TRACE_REFRESHER
,
TRACE_ATTREFRESHER
,
TRACE_COMMAND
,
TRACE_ALL
public int getTraceMode()
setTraceMode(int)
public void trace(int level, java.lang.String msg, long startTime)
level
- Level of tracestartTime
- Time of execution in ms. (pass negative to ignore)msg
- Message to displaypublic void setRefreshInterval(int milliSeconds)
setRefreshInterval
sets the refresh interval for
the Device. This interval decides how often an entity is polled
to see if its value has changed. The default value is 1000, that is,
the entity is polled once a second.milliSeconds
- an int
valuepublic long getRefreshInterval()
getRefreshInterval
gets the refresh-interval for
the entity list. The default value is 1000 milliseconds.int
value which is the refresh-intervalpublic void stopRefresher()
stopRefresher
stops the refresher.public void startRefresher()
startRefresher
starts the default refresher thread
for the Device which sleeps for refreshInterval seconds.setRefreshInterval(int)
,
Thread
public boolean isRefreshing()
public void setRefresher(Refresher r)
setRefresher
sets the resher thread
for this Device.r
- an ARefresher
valueRefresher
public boolean isDevice(java.lang.String name)
name
- Device name.public Device getDevice(java.lang.String name) throws ConnectionException
name
- Device nameConnectionException
- In case of failure.public Device getConnectionlessDevice(java.lang.String name) throws ConnectionException
name
- Device nameConnectionException
- In case of failure.public void refresh()
refresh
in interface IRefreshee
getDevice(java.lang.String)
public void deleteDevice(java.lang.String name)
name
- Device to remove.public java.util.List<java.lang.String> getDeviceNames()
public Device[] getDevices()
public static void setAutoStart(boolean b)
b
- True to start automaticaly the state/status refresher.public static boolean isAutoStart()
public boolean containsDevice(java.lang.String name)
name
- Device name.public void addDevice(Device dev)
dev
- Device instance to add.public java.lang.String getVersion()
public boolean isTraceUnexpected()
public void setTraceUnexpected(boolean traceUnexpected)