fr.esrf.tangoatk.core
Class DeviceFactory

java.lang.Object
  extended by fr.esrf.tangoatk.core.DeviceFactory
All Implemented Interfaces:
IRefreshee, java.io.Serializable

public class DeviceFactory
extends java.lang.Object
implements IRefreshee, java.io.Serializable

See Also:
Serialized Form

Field Summary
protected static boolean autoStart
           
protected  Refresher refresher
           
protected  int refreshInterval
           
static int TRACE_ALL
           
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
           
 
Method Summary
 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE_NONE

public static final int TRACE_NONE
See Also:
Constant Field Values

TRACE_FAIL

public static final int TRACE_FAIL
See Also:
Constant Field Values

TRACE_SUCCESS

public static final int TRACE_SUCCESS
See Also:
Constant Field Values

TRACE_REFRESHER

public static final int TRACE_REFRESHER
See Also:
Constant Field Values

TRACE_ATTREFRESHER

public static final int TRACE_ATTREFRESHER
See Also:
Constant Field Values

TRACE_COMMAND

public static final int TRACE_COMMAND
See Also:
Constant Field Values

TRACE_CHANGE_EVENT

public static final int TRACE_CHANGE_EVENT
See Also:
Constant Field Values

TRACE_STATE_REFRESHER

public static final int TRACE_STATE_REFRESHER
See Also:
Constant Field Values

TRACE_PERIODIC_EVENT

public static final int TRACE_PERIODIC_EVENT
See Also:
Constant Field Values

TRACE_DEVFACTORY

public static final int TRACE_DEVFACTORY
See Also:
Constant Field Values

TRACE_ATTFACTORY

public static final int TRACE_ATTFACTORY
See Also:
Constant Field Values

TRACE_CMDFACTORY

public static final int TRACE_CMDFACTORY
See Also:
Constant Field Values

TRACE_ALL

public static final int TRACE_ALL
See Also:
Constant Field Values

refreshInterval

protected int refreshInterval

refresher

protected Refresher refresher

autoStart

protected static boolean autoStart

traceUnexpected

protected boolean traceUnexpected
Method Detail

getInstance

public static DeviceFactory getInstance()
Returns an instance of the singleton device factory class


setTraceMode

public void setTraceMode(int level)
Set the trace level of ATK device calls.

Parameters:
level - Trace level. Can be a combination of the following value:
See Also:
TRACE_NONE, TRACE_FAIL, TRACE_SUCCESS, TRACE_REFRESHER, TRACE_ATTREFRESHER, TRACE_COMMAND, TRACE_ALL

getTraceMode

public int getTraceMode()
Returns the current trace level.

See Also:
setTraceMode(int)

trace

public void trace(int level,
                  java.lang.String msg,
                  long startTime)
Print trace.

Parameters:
level - Level of trace
startTime - Time of execution in ms. (pass negative to ignore)
msg - Message to display

setRefreshInterval

public 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.

Parameters:
milliSeconds - an int value

getRefreshInterval

public long getRefreshInterval()
getRefreshInterval gets the refresh-interval for the entity list. The default value is 1000 milliseconds.

Returns:
an int value which is the refresh-interval

stopRefresher

public void stopRefresher()
stopRefresher stops the refresher.


startRefresher

public void startRefresher()
startRefresher starts the default refresher thread for the Device which sleeps for refreshInterval seconds.

See Also:
setRefreshInterval(int), Thread

isRefreshing

public boolean isRefreshing()
Returns true if the global device refresher is running.


setRefresher

public void setRefresher(Refresher r)
setRefresher sets the resher thread for this Device.

Parameters:
r - an ARefresher value
See Also:
Refresher

isDevice

public boolean isDevice(java.lang.String name)
Check wether the given name correspond to an existing device.

Parameters:
name - Device name.
Returns:
true if the deivce exists.

getDevice

public Device getDevice(java.lang.String name)
                 throws ConnectionException
Get a handle to a device and add it to the global state/status refresher list.

Parameters:
name - Device name
Returns:
Device handle
Throws:
ConnectionException - In case of failure.

refresh

public void refresh()
Executes the global state/status refresh on all device registered.

Specified by:
refresh in interface IRefreshee
See Also:
getDevice(java.lang.String)

deleteDevice

public void deleteDevice(java.lang.String name)
Remove the given device from the global refresher list.

Parameters:
name - Device to remove.

getDeviceNames

public java.util.List<java.lang.String> getDeviceNames()
Returns an array of string containing all device name of this factory.

Returns:
A list of device name.

getDevices

public Device[] getDevices()
Returns an array containing all device of this factory.


setAutoStart

public static void setAutoStart(boolean b)
Sets the autostart property.

Parameters:
b - True to start automaticaly the state/status refresher.

isAutoStart

public static boolean isAutoStart()
Returns the autostart property.

Returns:
True if the state/status refresher is started automaticaly.

containsDevice

public boolean containsDevice(java.lang.String name)
Check whether the given name corresponds to an already existing device in the factory

Parameters:
name - Device name.
Returns:
true if the device has already been created in the factory

addDevice

public void addDevice(Device dev)
Adds a device instance in the factory if the device name is not already existant in the factory

Parameters:
dev - Device instance to add.

getVersion

public java.lang.String getVersion()

isTraceUnexpected

public boolean isTraceUnexpected()

setTraceUnexpected

public void setTraceUnexpected(boolean traceUnexpected)