fr.esrf.tangoatk.core
Class Device

java.lang.Object
  extended by fr.esrf.TangoApi.Connection
      extended by fr.esrf.TangoApi.DeviceProxy
          extended by fr.esrf.tangoatk.core.Device
All Implemented Interfaces:
fr.esrf.TangoApi.ApiDefs, IDevice, IRefreshee, java.io.Serializable

public class Device
extends fr.esrf.TangoApi.DeviceProxy
implements IDevice, java.io.Serializable

An object that maps to a Tango Device. It is able to produce the attributes and the commands belonging to this Device.

Normally a Device object is obtained through the DeviceFactoryto make sure that we do not create two instances of the same physical device. The device sends out three events, a Status-change event, a state-change event, and an error event. Objects interested in receiving such events must register as listeners.

See Also:
Serialized Form

Field Summary
protected  boolean devPropertiesLoaded
           
static java.lang.String INSERT_EXTRACT_PROP
           
static java.lang.String OPEN_CLOSE_PROP
           
protected  EventSupport propChanges
           
protected  java.util.Map<java.lang.String,DeviceProperty> propertyMap
           
protected  fr.esrf.TangoApi.DeviceProxy proxy
           
 
Fields inherited from class fr.esrf.TangoApi.DeviceProxy
event_queue, proxy_lock_cnt
 
Fields inherited from class fr.esrf.TangoApi.Connection
access, check_access, classname, dev_src, device, device_2, device_3, device_4, devname, idl_version, ior, taco_device, transparent_reconnection, url
 
Fields inherited from interface fr.esrf.tangoatk.core.IDevice
ALARM, CLOSE, DISABLE, EXTRACT, FAULT, INIT, INSERT, MOVING, OFF, ON, OPEN, RUNNING, STANDBY, UNKNOWN
 
Fields inherited from interface fr.esrf.TangoApi.ApiDefs
ALL_ASYNCH, ATT_R, ATT_W, CALLBACK, CMD, D_TCP, D_UDP, FROM_ATTR, FROM_CMD, FROM_DBASE, FROM_IOR, LOGGING_DEBUG, LOGGING_ERROR, LOGGING_FATAL, LOGGING_INFO, LOGGING_OFF, LOGGING_WARN, MISC, NO_TIMEOUT, POLLING, protocol_name, PULL_CALLBACK, PUSH_CALLBACK, TACO, TANGO
 
Constructor Summary
Device(java.lang.String name)
          Creates a new Device instance.
Device(java.lang.String name, java.lang.String host, java.lang.String port)
           
 
Method Summary
 void addErrorListener(IErrorListener l)
           
 void addListener(IDeviceListener l)
          addListener adds a listener to all device events
 void addStateListener(IStateListener l)
          addStateListener adds a listener to state-events
 void addStatusListener(IStatusListener l)
          addStatusListener adds a listener to status-events
 boolean areDevPropertiesLoaded()
           
protected  void deviceError(java.lang.String s, java.lang.Throwable t)
          deviceError fires of an error event from this device
 boolean doesEvent()
          Returns true if this device supports event.
 fr.esrf.TangoApi.DeviceData executeCommand(java.lang.String command, fr.esrf.TangoApi.DeviceData argin)
          executeCommand
 java.lang.String getAlias()
          getAlias returns the alias of this device.
 fr.esrf.TangoApi.AttributeInfoEx getAttributeInfo(java.lang.String name)
          getAttributeInfo gets the attribute config of an attribute
 fr.esrf.TangoApi.AttributeInfoEx[] getAttributeInfo(java.lang.String[] name)
          getAttributeInfo returns the attribute configs for the attributes named in the parameter.
 fr.esrf.TangoApi.CommandInfo getCommand(java.lang.String name)
          getCommand returns a CommandInfo corresponding to the given name.
 fr.esrf.TangoApi.CommandInfo[] getCommandList()
          getCommandList returns the list of commands known to this device
 int getDevTimeout()
          This method is provided to ATK applications so that they don't need to import fr.esrf.TangoApi.DeviceProxy to get the timeout for the connection to the device.
 int getIdlVersion()
          Returns the IDL version number of this device.
 boolean getInvertedInsertExtract()
           
 boolean getInvertedOpenClose()
           
 AtkEventListenerList getListenerList()
           
 java.lang.String getName()
          getName returns the name of this device.
 EventSupport getPropChanges()
          Returns the EventSupport object which manages ATKEvents for this device.
 DeviceProperty getProperty(java.lang.String propertyName)
           
 java.util.Map getPropertyMap()
           
 long getRefreshCount()
          Returns the number of call to refresh()
 java.lang.String getState()
          getState returns the state of the device as a string.
static fr.esrf.Tango.DevState getStateFromString(java.lang.String st)
           
 java.lang.String getStatus()
          getStatus returns the status of the device.
 java.lang.String getVersion()
           
protected  void init(java.lang.String name)
           
 boolean isAlive()
          isAlive checks to see if this device is reachable
 void loadDevProperties()
           
 fr.esrf.TangoApi.DeviceAttribute readAttribute(java.lang.String name)
          readAttribute reads the value of an attribute.
 fr.esrf.TangoApi.DeviceAttribute readAttributeFromDevice(java.lang.String name)
          readAttributeFromDevice reads the value of an attribute.
 void refresh()
          refresh sends out status and state events.
 void refreshPropertyMap()
          You can use this method if you added or removed a property for this device by using jive.
 void removeErrorListener(IErrorListener l)
           
 void removeListener(IDeviceListener l)
          removeListener removes a listener to this device.
 void removeStateListener(IStateListener l)
          removeStateListener removes a listener to a state-events
 void removeStatusListener(IStatusListener l)
          removeStatusListener removes a status listener
 void setDevTimeout(int tmout_ms)
          This method is provided to ATK applications so that they don't need to import fr.esrf.TangoApi.DeviceProxy to set the timeout for the connection to the device.
 void storeInfo(fr.esrf.TangoApi.AttributeInfoEx c)
          storeInfo
 void storeProperty(java.lang.String propertyName)
          Stores a property in database
 java.lang.String toString()
           
static java.lang.String toString(fr.esrf.Tango.DevState st)
           
 void writeAttribute(fr.esrf.TangoApi.DeviceAttribute a)
          writeAttribute writes an attribute.
 
Methods inherited from class fr.esrf.TangoApi.DeviceProxy
add_device, add_logging_target, add_logging_target, attribute_history, attribute_history, check_asynch_reply, command_history, command_history, command_inout_asynch, command_inout_asynch, command_inout_asynch, command_inout_asynch, command_inout_asynch, command_inout_asynch, command_inout_reply, command_inout_reply, command_query, delete_attribute_property, delete_attribute_property, delete_attribute_property, delete_attribute_property, delete_attribute, delete_device, delete_property, delete_property, delete_property, dev_inform, export_device, finalize, get_adm_dev, get_alias, get_asynch_idl_cmd, get_asynch_replies, get_asynch_replies, get_attribute_config, get_attribute_config, get_attribute_config, get_attribute_info_ex, get_attribute_info_ex, get_attribute_info_ex, get_attribute_info, get_attribute_info, get_attribute_info, get_attribute_list, get_attribute_polling_period, get_attribute_property, get_attribute_property, get_class_inheritance, get_class, get_command_polling_period, get_db_obj, get_event_queue_size, get_event_queue_size, get_events, get_events, get_evt_import_info, get_info, get_last_event_date, get_logging_level, get_logging_target, get_next_event, get_next_event, get_property_list, get_property, get_property, get_property, get_rpc_protocol, getAdm_dev, getAttnames_array, getDb_dev, getDeviceProxy, getEventQueue, getFull_class_name, getLockerInfo, getLockerStatus, import_admin_device, import_admin_device, import_device, isCheck_idl, isLocked, isLockedByMe, lock, lock, main, name, pending_asynch_call, poll_attribute, poll_command, polling_status, put_alias, put_attribute_property, put_attribute_property, put_property, put_property, read_attribute_asynch, read_attribute_asynch, read_attribute_asynch, read_attribute_asynch, read_attribute_reply, read_attribute_reply, read_attribute_value, read_attribute, read_attribute, remove_logging_target, set_attribute_config, set_attribute_info, set_attribute_info, set_evt_import_info, set_logging_level, set_rpc_protocol, setAdm_dev, setAttnames_array, setDb_dev, setDeviceProxy, setEventQueue, setFull_class_name, state, state, status, status, stop_poll_attribute, stop_poll_command, subscribe_event, subscribe_event, subscribe_event, unexport_device, unlock, unsubscribe_event, use_db, write_attribute_asynch, write_attribute_asynch, write_attribute_asynch, write_attribute_asynch, write_attribute_asynch, write_attribute_asynch, write_attribute_reply, write_attribute_reply, write_attribute, write_attribute, write_read_attribute, write_read_attribute
 
Methods inherited from class fr.esrf.TangoApi.Connection
adm_name, black_box, build_connection, checkIfTaco, checkIfTango, command_inout, command_inout, command_list_query, description, dev_import, get_class_name, get_device, get_host_name, get_idl_version, get_ior, get_name, get_server_name, get_source, get_tango_host, get_timeout_millis, get_timeout, get_transparency_reconnection, getAccessControl, getDev_timeout, getIConnection, getObj, getPrev_failed_t0, getPrev_failed, info_3, info, is_taco, isAllowedCommand, isAlready_connected, isDevice_is_dbase, isPrev_failed, ping, set_source, set_timeout_millis, set_transparency_reconnection, setAccessControl, setAlready_connected, setDev_timeout, setDevice_is_dbase, setIConnection, setObj, setPrev_failed_t0, setPrev_failed, throw_dev_failed
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OPEN_CLOSE_PROP

public static final java.lang.String OPEN_CLOSE_PROP
See Also:
Constant Field Values

INSERT_EXTRACT_PROP

public static final java.lang.String INSERT_EXTRACT_PROP
See Also:
Constant Field Values

propChanges

protected EventSupport propChanges

proxy

protected transient fr.esrf.TangoApi.DeviceProxy proxy

propertyMap

protected java.util.Map<java.lang.String,DeviceProperty> propertyMap

devPropertiesLoaded

protected boolean devPropertiesLoaded
Constructor Detail

Device

public Device(java.lang.String name)
       throws fr.esrf.Tango.DevFailed
Creates a new Device instance.

Parameters:
name - a String containing the name of the device to connect to.
Throws:
fr.esrf.Tango.DevFailed - if an error occurs
See Also:
DeviceProxy.DeviceProxy(java.lang.String, java.lang.String, java.lang.String)

Device

public Device(java.lang.String name,
              java.lang.String host,
              java.lang.String port)
       throws fr.esrf.Tango.DevFailed
Throws:
fr.esrf.Tango.DevFailed
Method Detail

init

protected void init(java.lang.String name)
             throws fr.esrf.Tango.DevFailed
Throws:
fr.esrf.Tango.DevFailed

addErrorListener

public void addErrorListener(IErrorListener l)

removeErrorListener

public void removeErrorListener(IErrorListener l)

addStatusListener

public void addStatusListener(IStatusListener l)
addStatusListener adds a listener to status-events

Specified by:
addStatusListener in interface IDevice
Parameters:
l - an IDeviceListener value
See Also:
IDeviceListener

removeStatusListener

public void removeStatusListener(IStatusListener l)
removeStatusListener removes a status listener

Specified by:
removeStatusListener in interface IDevice
Parameters:
l - an IDeviceListener value

addStateListener

public void addStateListener(IStateListener l)
addStateListener adds a listener to state-events

Specified by:
addStateListener in interface IDevice
Parameters:
l - an IDeviceListener value

removeStateListener

public void removeStateListener(IStateListener l)
removeStateListener removes a listener to a state-events

Specified by:
removeStateListener in interface IDevice
Parameters:
l - an IDeviceListener value

addListener

public void addListener(IDeviceListener l)
addListener adds a listener to all device events

Parameters:
l - an IDeviceListener value

removeListener

public void removeListener(IDeviceListener l)
removeListener removes a listener to this device.

Parameters:
l - an IDeviceListener value

getPropChanges

public EventSupport getPropChanges()
Returns the EventSupport object which manages ATKEvents for this device.


refresh

public void refresh()
refresh sends out status and state events. This forces a synchronous device state and status reading.

Specified by:
refresh in interface IRefreshee

isAlive

public boolean isAlive()
isAlive checks to see if this device is reachable

Returns:
a boolean value which is true if the device is reachable, false otherwise
See Also:
Connection.ping()

getCommandList

public fr.esrf.TangoApi.CommandInfo[] getCommandList()
                                              throws fr.esrf.Tango.DevFailed
getCommandList returns the list of commands known to this device

Returns:
a DevCmdInfo[] value
Throws:
fr.esrf.Tango.DevFailed - if an error occurs

getCommand

public fr.esrf.TangoApi.CommandInfo getCommand(java.lang.String name)
                                        throws fr.esrf.Tango.DevFailed
getCommand returns a CommandInfo corresponding to the given name.

Parameters:
name - Command name
Returns:
CommandInfo
Throws:
fr.esrf.Tango.DevFailed - in case of failure.

getAttributeInfo

public fr.esrf.TangoApi.AttributeInfoEx[] getAttributeInfo(java.lang.String[] name)
                                                    throws fr.esrf.Tango.DevFailed
getAttributeInfo returns the attribute configs for the attributes named in the parameter.

Parameters:
name - a String[] value containing the names of the attributes we want the configs of.
Returns:
an AttributeConfig[] value
Throws:
fr.esrf.Tango.DevFailed - if an error occurs

getAttributeInfo

public fr.esrf.TangoApi.AttributeInfoEx getAttributeInfo(java.lang.String name)
                                                  throws fr.esrf.Tango.DevFailed
getAttributeInfo gets the attribute config of an attribute

Specified by:
getAttributeInfo in interface IDevice
Parameters:
name - a String value containing the name of the attribute we want the config of.
Returns:
an AttributeConfig value
Throws:
fr.esrf.Tango.DevFailed - if an error occurs
See Also:
getAttributeInfo(String[] name)

getName

public java.lang.String getName()
getName returns the name of this device.

Specified by:
getName in interface IDevice
Returns:
a String value containing the name of the device.

getAlias

public java.lang.String getAlias()
getAlias returns the alias of this device.

Specified by:
getAlias in interface IDevice
Returns:
a String value containing the alias of the device.

deviceError

protected void deviceError(java.lang.String s,
                           java.lang.Throwable t)
deviceError fires of an error event from this device

Parameters:
s - a String value containing an error message.
t - a Throwable value containing the exception which caused this error message to be called.

getState

public java.lang.String getState()
getState returns the state of the device as a string.

Specified by:
getState in interface IDevice
Returns:
a String value containing the states.
See Also:
for information on which states can bee returned.

toString

public static java.lang.String toString(fr.esrf.Tango.DevState st)

getStateFromString

public static fr.esrf.Tango.DevState getStateFromString(java.lang.String st)

getStatus

public java.lang.String getStatus()
getStatus returns the status of the device. returns UNKNOWN and sets an error if a DevFailed is thrown while obtaining the status.

Specified by:
getStatus in interface IDevice
Returns:
a String value containing the status.

readAttribute

public final fr.esrf.TangoApi.DeviceAttribute readAttribute(java.lang.String name)
                                                     throws fr.esrf.Tango.DevFailed
readAttribute reads the value of an attribute. It is made final to be a bit quicker.

Parameters:
name - a String value
Returns:
a DeviceAttribute value
Throws:
fr.esrf.Tango.DevFailed - if an error occurs

getRefreshCount

public long getRefreshCount()
Returns the number of call to refresh()


getIdlVersion

public int getIdlVersion()
Returns the IDL version number of this device.


readAttributeFromDevice

public final fr.esrf.TangoApi.DeviceAttribute readAttributeFromDevice(java.lang.String name)
                                                               throws fr.esrf.Tango.DevFailed
readAttributeFromDevice reads the value of an attribute. Force the reading from the tango device (ignore polling buffer).

Parameters:
name - a String value
Returns:
a DeviceAttribute value
Throws:
fr.esrf.Tango.DevFailed - if an error occurs

writeAttribute

public void writeAttribute(fr.esrf.TangoApi.DeviceAttribute a)
                    throws fr.esrf.Tango.DevFailed
writeAttribute writes an attribute.

Parameters:
a - a DeviceAttribute value to write.
Throws:
fr.esrf.Tango.DevFailed - if an error occurs

executeCommand

public fr.esrf.TangoApi.DeviceData executeCommand(java.lang.String command,
                                                  fr.esrf.TangoApi.DeviceData argin)
                                           throws fr.esrf.Tango.DevFailed
executeCommand

Specified by:
executeCommand in interface IDevice
Parameters:
command - a String value containing the name of the command, obtained by getCommandList();
argin - a DeviceData value holding the in argument
Returns:
a DeviceData value containing the result
Throws:
fr.esrf.Tango.DevFailed - if an error occurs

storeInfo

public void storeInfo(fr.esrf.TangoApi.AttributeInfoEx c)
               throws fr.esrf.Tango.DevFailed
storeInfo

Parameters:
c - an AttributeInfo value to store
Throws:
fr.esrf.Tango.DevFailed - if an error occurs

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

doesEvent

public boolean doesEvent()
Returns true if this device supports event.


getVersion

public java.lang.String getVersion()

getProperty

public DeviceProperty getProperty(java.lang.String propertyName)

getPropertyMap

public java.util.Map getPropertyMap()

storeProperty

public void storeProperty(java.lang.String propertyName)
Stores a property in database

Parameters:
propertyName - the name of the property to store

refreshPropertyMap

public void refreshPropertyMap()
You can use this method if you added or removed a property for this device by using jive. This forces the Device to refresh its Map of properties (DeviceProperty).


getDevTimeout

public int getDevTimeout()
                  throws ConnectionException
This method is provided to ATK applications so that they don't need to import fr.esrf.TangoApi.DeviceProxy to get the timeout for the connection to the device.

Throws:
ConnectionException

setDevTimeout

public void setDevTimeout(int tmout_ms)
                   throws ConnectionException
This method is provided to ATK applications so that they don't need to import fr.esrf.TangoApi.DeviceProxy to set the timeout for the connection to the device.

Throws:
ConnectionException

getListenerList

public AtkEventListenerList getListenerList()
Specified by:
getListenerList in interface IDevice

getInvertedOpenClose

public boolean getInvertedOpenClose()
Specified by:
getInvertedOpenClose in interface IDevice

getInvertedInsertExtract

public boolean getInvertedInsertExtract()
Specified by:
getInvertedInsertExtract in interface IDevice

areDevPropertiesLoaded

public boolean areDevPropertiesLoaded()

loadDevProperties

public void loadDevProperties()