fr.esrf.tangoatk.core.command
Class ACommand

java.lang.Object
  extended by fr.esrf.tangoatk.core.command.ACommand
All Implemented Interfaces:
ICommand, IEntity, IRefreshee, fr.esrf.TangoDs.TangoConst, java.io.Serializable
Direct Known Subclasses:
ArrayArrayCommand, ArrayScalarCommand, ArrayTableCommand, ArrayVoidCommand, InvalidCommand, ScalarArrayCommand, ScalarScalarCommand, ScalarTableCommand, ScalarVoidCommand, TableArrayCommand, TableScalarCommand, TableTableCommand, TableVoidCommand, VoidArrayCommand, VoidScalarCommand, VoidTableCommand, VoidVoidCommand

public abstract class ACommand
extends java.lang.Object
implements ICommand

ACommand is like AAttribute is for Attributes, the mother of all commands. It holds all common behaviour of Commands, and delegates the handeling of input and output to its ACommandHelper instances, the inputHelper and the outputHelper.

See Also:
Serialized Form

Field Summary
protected  java.lang.String alias
           
protected  java.lang.String error
           
protected  int executionCount
           
protected  ACommandHelper inputHelper
           
protected  java.lang.String name
           
protected  java.lang.String nameSansDevice
           
protected  java.util.List oldResult
           
protected  java.lang.Throwable oldt
           
protected  ACommandHelper outputHelper
           
protected  EventSupport propChanges
           
protected  java.util.Map<java.lang.String,Property> propertyMap
           
 
Fields inherited from interface fr.esrf.TangoDs.TangoConst
ACCESS_READ, ACCESS_SERVICE, ACCESS_WRITE, ARCHIVE_EVENT, ATT_CONF_EVENT, Attr_AdmName, Attr_Description, Attr_Name, Attr_State, Attr_Status, Attr_Unknown, ATTRIBUTE, BY_CLASS, BY_DEVICE, BY_PROCESS, CHANGE_EVENT, COMMAND, CONTROL_SYSTEM, DATA_READY_EVENT, DEFAULT_LOCK_VALIDITY, eventNames, LOGGING_CONSOLE_TARGET, LOGGING_CONSOLE_TARGET_ID, LOGGING_DEBUG, LOGGING_DEF_RFT, LOGGING_DEVICE_TARGET, LOGGING_DEVICE_TARGET_ID, LOGGING_ERROR, LOGGING_FATAL, LOGGING_FILE_TARGET, LOGGING_FILE_TARGET_ID, LOGGING_INFO, LOGGING_LEVELS, LOGGING_MAX_RFT, LOGGING_MIN_RFT, LOGGING_OFF, LOGGING_SEPARATOR, LOGGING_UNKNOWN_TARGET_ID, LOGGING_WARN, NO_SYNC, NOT_STATELESS, NotANumber, Op_BlackBox, Op_Command, Op_Command_2, Op_Command_inout, Op_Command_inout_2, Op_Command_inout_history_2, Op_Command_list, Op_Command_list_2, Op_Get_Attr_Config, Op_Get_Attr_Config_2, Op_Info, Op_Ping, Op_Read_Attr, Op_Read_Attr_2, Op_Read_Attr_history_2, Op_Set_Attr_Config, Op_Unknown, Op_Write_Attr, PERIODIC_EVENT, QUALITY_EVENT, Req_Attribute, Req_Operation, Req_Unknown, SERVICE_PROP_NAME, STATELESS, Tango_AllAttr, Tango_AllAttr_3, Tango_AlrmValueNotSpec, Tango_AssocWritNotSpec, Tango_AttrDataFormatName, Tango_CLNT_TIMEOUT, Tango_CmdArgTypeName, Tango_CONST_DEV_STRING, Tango_DbObjName, Tango_DEFAULT_POLL_OLD_FACTOR, Tango_DEFAULT_TIMEOUT, Tango_DEFAULT_TIMEOUT_SEC, Tango_DefaultBlackBoxDepth, Tango_DefaultDocUrl, Tango_DefaultPollRingDepth, Tango_DefaultWritableProp, Tango_DELTA_T, Tango_DescNotSet, Tango_DescNotSpec, Tango_DEV_BOOLEAN, Tango_DEV_CHAR, Tango_DEV_DOUBLE, Tango_DEV_ENCODED, Tango_DEV_FLOAT, Tango_DEV_INT, Tango_DEV_LONG, Tango_DEV_LONG64, Tango_DEV_SHORT, Tango_DEV_STATE, Tango_DEV_STRING, Tango_DEV_UCHAR, Tango_DEV_ULONG, Tango_DEV_ULONG64, Tango_DEV_USHORT, Tango_DEV_VOID, Tango_DevStateName, Tango_DEVVAR_CHARARRAY, Tango_DEVVAR_DOUBLEARRAY, Tango_DEVVAR_DOUBLESTRINGARRAY, Tango_DEVVAR_FLOATARRAY, Tango_DEVVAR_LONG64ARRAY, Tango_DEVVAR_LONGARRAY, Tango_DEVVAR_LONGSTRINGARRAY, Tango_DEVVAR_SHORTARRAY, Tango_DEVVAR_STRINGARRAY, Tango_DEVVAR_ULONG64ARRAY, Tango_DEVVAR_ULONGARRAY, Tango_DEVVAR_USHORTARRAY, Tango_DevVersion, Tango_DISCARD_THRESHOLD, Tango_DispUnitNotSpec, Tango_DSDeviceDomain, Tango_EXPERT_ATTR, Tango_EXPERT_CMD, Tango_FormatNotSpec, Tango_InitialOutput, Tango_LabelNotSpec, TANGO_LOG_PATH, Tango_MAX_TRANSFER_SIZE, Tango_MaxServerNameLength, Tango_MIN_POLL_PERIOD, Tango_OPERATOR_ATTR, Tango_OPERATOR_CMD, Tango_POLL_ADD_OBJ, Tango_POLL_ATTR, Tango_POLL_CMD, Tango_POLL_REM_DEV, Tango_POLL_REM_OBJ, Tango_POLL_START, Tango_POLL_STOP, Tango_POLL_UPD_PERIOD, Tango_PollAttribute, Tango_PollCommand, Tango_QualityName, Tango_REL_1, Tango_REL_2, Tango_ResNotDefined, Tango_StdUnitNotSpec, Tango_SysProperty, Tango_TG_IMP_MINOR_DEVFAILED, Tango_TG_IMP_MINOR_NON_DEVFAILED, Tango_TG_IMP_MINOR_TO, Tango_TgLibVers, Tango_UnitNotSpec, USER_EVENT
 
Constructor Summary
ACommand()
           
 
Method Summary
 void addErrorListener(IErrorListener l)
          An IErrorListener is an object that listens to error property changes from this object.
 void addResultListener(IResultListener l)
          addResultListener adds a listener to the result of executing this command.
protected  boolean checkArgin(java.util.List l)
           
protected  void cmdError(java.lang.String message, java.lang.Throwable t)
          cmdError sends off an error event to all the errorlisteners of this command.
 boolean doesArrayOutput()
          doesArrayOutput returns true if this command does output in form of an array
 boolean doesOutput()
          doesOutput returns true if this command does ouput
 void execute()
          execute executes the command without input.
 void execute(java.util.List l)
          execute executes the command and uses the input in whatever way it feels appropriate.
 java.lang.String getAlias()
           
 Device getDevice()
          getDevice
 int getExecutionCount()
           
 java.lang.String getInTypeDescription()
          getInTypeDescription returns the description of the in type
 java.lang.String getInTypeElemName()
          getInTypeElemName returns the type name of an element of the array if this command has an "array" input argument.
 java.lang.String getLevel()
           
 AtkEventListenerList getListenerList()
           
 java.lang.String getName()
          Gets the name of this IEntity
 java.lang.String getNameSansDevice()
           
 java.lang.String getOutTypeDescription()
          getOutTypeDescription returns the description of the out type
 java.lang.String getOutTypeElemName()
           
 Property getProperty(java.lang.String name)
          getProperty returns the CommandProperty with the given name if such a beast exists.
 java.util.Map<java.lang.String,Property> getPropertyMap()
          getPropertyMap returns a Map containing this entitys properties.
 java.lang.String getTag()
           
protected  java.lang.String getTypeName(int type)
           
 java.lang.String getVersion()
           
protected  void init(Device d, java.lang.String cmdName, fr.esrf.TangoApi.CommandInfo info)
          init initializes the Command,
static boolean isArray(int type)
           
static boolean isBoolean(int type)
           
 boolean isExpert()
           
 boolean isOperator()
           
static boolean isScalar(int type)
           
static boolean isString(int type)
           
static boolean isTable(int type)
           
static boolean isVoid(int type)
           
protected  void publishResult(java.util.List result)
           
 void refresh()
          refreshes the listeners of this particular object.
 void removeErrorListener(IErrorListener l)
          Removes the given IErrorListener from this objects list of errorlisteners.
 void removeResultListener(IResultListener l)
          removeResultListener removes a listenener from this command
 void setAlias(java.lang.String alias)
           
protected  void setProperty(java.lang.String name, fr.esrf.Tango.DispLevel value)
           
 void storeConfig()
           
 boolean takesArrayInput()
          takesArrayInput returns true if this command takes array-input
 boolean takesInput()
          takesInput returns true if this command takes input
 boolean takesScalarInput()
          takesScalarInput return strue if this command takes scalar-input
 boolean takesTableInput()
          takesArrayInput returns true if this command takes array-input
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

inputHelper

protected ACommandHelper inputHelper

outputHelper

protected ACommandHelper outputHelper

propertyMap

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

name

protected java.lang.String name

nameSansDevice

protected java.lang.String nameSansDevice

error

protected java.lang.String error

oldResult

protected java.util.List oldResult

propChanges

protected EventSupport propChanges

oldt

protected java.lang.Throwable oldt

alias

protected java.lang.String alias

executionCount

protected int executionCount
Constructor Detail

ACommand

public ACommand()
Method Detail

getVersion

public java.lang.String getVersion()

init

protected void init(Device d,
                    java.lang.String cmdName,
                    fr.esrf.TangoApi.CommandInfo info)
init initializes the Command,

Parameters:
d - the Device this command is connected to
cmdName - a String value holding the name of this command.
info - a DevCmdInfo value holding the DevCmdInfo for this command

getDevice

public Device getDevice()
getDevice

Specified by:
getDevice in interface IEntity
Returns:
the Device of this command

cmdError

protected void cmdError(java.lang.String message,
                        java.lang.Throwable t)
cmdError sends off an error event to all the errorlisteners of this command.

Parameters:
message - a String value
t - a Throwable value

storeConfig

public void storeConfig()
Specified by:
storeConfig in interface IEntity

getProperty

public Property getProperty(java.lang.String name)
getProperty returns the CommandProperty with the given name if such a beast exists. Null otherwise

Specified by:
getProperty in interface IEntity
Parameters:
name - a String value
Returns:
a Property value

getTypeName

protected java.lang.String getTypeName(int type)

getInTypeElemName

public java.lang.String getInTypeElemName()
getInTypeElemName returns the type name of an element of the array if this command has an "array" input argument.

Specified by:
getInTypeElemName in interface ICommand
Returns:
an int value containing the in_type.
Throws:
java.util.NoSuchElementException - if no such property exists.
See Also:
TangoConst

getOutTypeElemName

public java.lang.String getOutTypeElemName()
Specified by:
getOutTypeElemName in interface ICommand

getTag

public java.lang.String getTag()
Specified by:
getTag in interface ICommand

getLevel

public java.lang.String getLevel()
Specified by:
getLevel in interface ICommand

getInTypeDescription

public java.lang.String getInTypeDescription()
getInTypeDescription returns the description of the in type

Specified by:
getInTypeDescription in interface ICommand
Returns:
a String value holding the description

getOutTypeDescription

public java.lang.String getOutTypeDescription()
getOutTypeDescription returns the description of the out type

Specified by:
getOutTypeDescription in interface ICommand
Returns:
a String value

getPropertyMap

public java.util.Map<java.lang.String,Property> getPropertyMap()
Description copied from interface: IEntity
getPropertyMap returns a Map containing this entitys properties.

Specified by:
getPropertyMap in interface IEntity
Returns:
a Map value

setProperty

protected void setProperty(java.lang.String name,
                           fr.esrf.Tango.DispLevel value)

refresh

public void refresh()
Description copied from interface: IRefreshee
refreshes the listeners of this particular object.

Specified by:
refresh in interface IRefreshee

getAlias

public java.lang.String getAlias()
Specified by:
getAlias in interface IEntity

setAlias

public void setAlias(java.lang.String alias)
Specified by:
setAlias in interface IEntity

getExecutionCount

public int getExecutionCount()

getName

public java.lang.String getName()
Description copied from interface: IEntity
Gets the name of this IEntity

Specified by:
getName in interface IEntity
Returns:
String the name of the IEntity

getNameSansDevice

public java.lang.String getNameSansDevice()
Specified by:
getNameSansDevice in interface IEntity

toString

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

addErrorListener

public void addErrorListener(IErrorListener l)
Description copied from interface: IEntity
An IErrorListener is an object that listens to error property changes from this object.

Specified by:
addErrorListener in interface IEntity
Parameters:
l - an IErrorListener value

removeErrorListener

public void removeErrorListener(IErrorListener l)
Description copied from interface: IEntity
Removes the given IErrorListener from this objects list of errorlisteners.

Specified by:
removeErrorListener in interface IEntity
Parameters:
l - an IErrorListener value

takesInput

public boolean takesInput()
Description copied from interface: ICommand
takesInput returns true if this command takes input

Specified by:
takesInput in interface ICommand
Returns:
a boolean value

takesTableInput

public boolean takesTableInput()
Description copied from interface: ICommand
takesArrayInput returns true if this command takes array-input

Specified by:
takesTableInput in interface ICommand
Returns:
a boolean value

takesArrayInput

public boolean takesArrayInput()
Description copied from interface: ICommand
takesArrayInput returns true if this command takes array-input

Specified by:
takesArrayInput in interface ICommand
Returns:
a boolean value

takesScalarInput

public boolean takesScalarInput()
Description copied from interface: ICommand
takesScalarInput return strue if this command takes scalar-input

Specified by:
takesScalarInput in interface ICommand
Returns:
a boolean value

doesOutput

public boolean doesOutput()
Description copied from interface: ICommand
doesOutput returns true if this command does ouput

Specified by:
doesOutput in interface ICommand
Returns:
a boolean value

doesArrayOutput

public boolean doesArrayOutput()
Description copied from interface: ICommand
doesArrayOutput returns true if this command does output in form of an array

Specified by:
doesArrayOutput in interface ICommand
Returns:
a boolean value

isVoid

public static boolean isVoid(int type)

isBoolean

public static boolean isBoolean(int type)

isString

public static boolean isString(int type)

isScalar

public static boolean isScalar(int type)

isArray

public static boolean isArray(int type)

isTable

public static boolean isTable(int type)

execute

public void execute()
Description copied from interface: ICommand
execute executes the command without input.

Specified by:
execute in interface ICommand
See Also:
ICommand.execute(java.util.List input)

addResultListener

public void addResultListener(IResultListener l)
Description copied from interface: ICommand
addResultListener adds a listener to the result of executing this command.

Specified by:
addResultListener in interface ICommand
Parameters:
l - an IResultListener value
See Also:
IResultListener

removeResultListener

public void removeResultListener(IResultListener l)
Description copied from interface: ICommand
removeResultListener removes a listenener from this command

Specified by:
removeResultListener in interface ICommand
Parameters:
l - an IResultListener value

publishResult

protected void publishResult(java.util.List result)

checkArgin

protected boolean checkArgin(java.util.List l)

execute

public void execute(java.util.List l)
Description copied from interface: ICommand
execute executes the command and uses the input in whatever way it feels appropriate. Results are published to all listeners which have registered by calling addResultListener

Specified by:
execute in interface ICommand
Parameters:
l - a java.util.List value

isOperator

public boolean isOperator()
Specified by:
isOperator in interface IEntity

isExpert

public boolean isExpert()
Specified by:
isExpert in interface IEntity

getListenerList

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