org.fosstrak.hal.impl.sim
Class SimulatorController

java.lang.Object
  extended by org.fosstrak.hal.impl.sim.SimulatorController
All Implemented Interfaces:
HardwareAbstraction

public class SimulatorController
extends java.lang.Object
implements HardwareAbstraction

The SimulatorController is a HAL controller that enables the implementation of different kinds of RFID reader simulators/emulators. From the HAL point of view the SimulatorController supports the same functionality as hardware controllers. Additionally it provides methods that allow a Simulator (i.e. SimulatorEngine) to (virtually) add and remove RFID tags.

Author:
Roland Schneider

Field Summary
 java.util.Vector<java.lang.String> continuousIdentifyErrors
          Contains the names of all read points whose identify-operations will always fail.
 java.util.Vector<java.lang.String> continuousKillErrors
          Contains the names of all read points whose kill-operations will always fail.
 java.util.Vector<java.lang.String> continuousReadErrors
          Contains the names of all read points whose read-operations will always fail.
 java.util.Vector<java.lang.String> continuousWriteErrors
          Contains the names of all read points whose write-operations will always fail.
 java.util.Vector<java.lang.String> identifyError
          Contains the names of all read points whose next identify-operation will fail.
 java.util.Vector<java.lang.String> killError
          Contains the names of all read points whose next kill-operation will fail.
 java.util.Vector<java.lang.String> readError
          Contains the names of all read points whose next read-operation will fail.
 java.util.Vector<java.lang.String> writeError
          Contains the names of all read points whose next write-operation will fail.
 
Constructor Summary
SimulatorController(java.lang.String halName, java.lang.String propFile)
           
 
Method Summary
 boolean add(java.lang.String readPointName, java.lang.String tagId)
          To move a certain tag to a certain antenna.
 boolean add(java.lang.String readPointName, Tag tag)
          To move a certain tag to a certain antenna.
 void addAsynchronousIdentifyListener(AsynchronousIdentifyListener listener)
          Adds an asynchronous identify listener.
 boolean contains(java.lang.String readPointName, java.lang.String tagId)
          To find out whether a certain tag is situated on a certain antenna.
 boolean contains(java.lang.String readPointName, Tag tag)
          To find out whether a certain tag is situated on a certain antenna.
 java.lang.String[] getAllParameterNames()
          Gets the names of the supported parameters.
 java.lang.String getHALName()
          Returns the HAL name.
 java.lang.String getParameter(java.lang.String param)
          Gets the value of a given parameter.
 java.lang.String[] getReadPointNames()
          Gets the names of all available read points.
 int getReadPointNoiseLevel(java.lang.String readPointName, boolean normalize)
          Returns the current noise level observed at a certain read point.
 int getReadPointPowerLevel(java.lang.String readPointName, boolean normalize)
          Returns the current transmit power level of a certain read point.
 java.util.Set getTagsFromReadPoint(java.lang.String readPointName)
          To get a set of all tags situated on a certain antenna.
 Observation[] identify(java.lang.String[] readPointNames)
          Identifies the tags in a reader's field.
 void initialize()
          Initialize a reader.
 boolean isAsynchronousIdentifyRunning()
          Checks whether asynchronous identify is running.
 boolean isReadPointReady(java.lang.String readPointName)
          Checks whether a read point is ready (i.e. it has been started up).
 void kill(java.lang.String readPointName, java.lang.String id, java.lang.String[] passwords)
          Kills the specified tag, if in range.
static void main(java.lang.String[] args)
          For debugging.
 void programId(java.lang.String id, java.lang.String[] passwords)
           
 UnsignedByteArray readBytes(java.lang.String readPointName, java.lang.String id, int memoryBank, int offset, int length, java.lang.String[] passwords)
          Reads data from a specified tag, if in range.
 boolean remove(java.lang.String readPointName, java.lang.String tagId)
          To remove a certain tag from a certain antenna.
 boolean remove(java.lang.String readPointName, Tag tag)
          To remove a certain tag from a certain antenna.
 void removeAsynchronousIdentifyListener(AsynchronousIdentifyListener listener)
          removes an asynchronous identify listener.
 void reset()
          Resets the reader.
 void setParameter(java.lang.String param, java.lang.String value)
          Sets a given parameter.
 void shutDownReadPoint(java.lang.String readPointName)
          Shuts down a read point.
 void startAsynchronousIdentify(java.lang.String[] readPointNames, Trigger trigger)
          Identifies the tags in a reader's field in a continuous way that operates asynchronously.
 void startUpReadPoint(java.lang.String readPointName)
          Starts up a read point.
 void stopAsynchronousIdentify()
          Stops the asynchronous identification for a specific listener.
 boolean supportsAsynchronousIdentify()
          Checks whether this HAL controller implementation supports the startAsynchronousIdentify(), stopAsynchronousIdentify(), isAsynchronousIdentifyRunning(), addAsynchronousIdentifyListener() and removeAsynchronousIdentifyListener() methods.
 boolean supportsGetReadPointNoiseLevel()
          Checks whether this HAL controller implementation supports the getReadPointNoiseLevel() method.
 boolean supportsGetReadPointPowerLevel()
          Checks whether this HAL controller implementation supports the getReadPointPowerLevel() method.
 boolean supportsIsReadPointReady()
          Checks whether this HAL controller implementation supports the isReadPointReady() method.
 boolean supportsKill()
          Checks whether this HAL controller implementation supports the kill() method.
 boolean supportsParameters()
          Checks whether the HAL controller implementation supports the getAllParameterNames(), getParameter() and setParameter() methods.
 boolean supportsProgramId()
           
 boolean supportsReadBytes()
          Checks whether this HAL controller implementation supports the readBytes() method.
 boolean supportsReset()
          Checks whether this HAL controller implementation supports the reset() method.
 boolean supportsShutDownReadPoint()
          Checks whether this HAL controller implementation supports the shutDownReadPoint() method.
 boolean supportsStartUpReadPoint()
          Checks whether this HAL controller implementation supports the startUpReadPoint() method.
 boolean supportsWriteBytes()
          Checks whether this HAL controller implementation supports the writeBytes() method.
 boolean supportsWriteId()
          Checks whether this HAL controller implementation supports the writeId() method.
 void writeBytes(java.lang.String readPointName, java.lang.String id, int memoryBank, int offset, UnsignedByteArray data, java.lang.String[] passwords)
          Writes data to a specific tag, if in range.
 void writeId(java.lang.String readPointName, java.lang.String id, java.lang.String[] passwords)
          Writes the given ID onto a tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

identifyError

public java.util.Vector<java.lang.String> identifyError
Contains the names of all read points whose next identify-operation will fail.


readError

public java.util.Vector<java.lang.String> readError
Contains the names of all read points whose next read-operation will fail.


writeError

public java.util.Vector<java.lang.String> writeError
Contains the names of all read points whose next write-operation will fail.


killError

public java.util.Vector<java.lang.String> killError
Contains the names of all read points whose next kill-operation will fail.


continuousIdentifyErrors

public java.util.Vector<java.lang.String> continuousIdentifyErrors
Contains the names of all read points whose identify-operations will always fail.


continuousReadErrors

public java.util.Vector<java.lang.String> continuousReadErrors
Contains the names of all read points whose read-operations will always fail.


continuousWriteErrors

public java.util.Vector<java.lang.String> continuousWriteErrors
Contains the names of all read points whose write-operations will always fail.


continuousKillErrors

public java.util.Vector<java.lang.String> continuousKillErrors
Contains the names of all read points whose kill-operations will always fail.

Constructor Detail

SimulatorController

public SimulatorController(java.lang.String halName,
                           java.lang.String propFile)
Method Detail

initialize

public void initialize()
Initialize a reader.


add

public boolean add(java.lang.String readPointName,
                   Tag tag)
To move a certain tag to a certain antenna.

Parameters:
readPointName - The name of the read point to which the tag should be added.
tag - The tag object to be added to the antenna / read point.
Returns:
Returns true if tag has been added. False if tag with same TagID already is in this antenna.

add

public boolean add(java.lang.String readPointName,
                   java.lang.String tagId)
To move a certain tag to a certain antenna.

Parameters:
readPointName - The name of the read point to which the tag should be added.
tagId - The ID of a tag to be added to the antenna / read point. A new (empty) tag object with ID tagId will be generated.
Returns:
Returns true if tag has been added. False if tag with same TagID already is in this antenna.

remove

public boolean remove(java.lang.String readPointName,
                      Tag tag)
To remove a certain tag from a certain antenna.

Parameters:
readPointName - The name of the read point from which the tag should be removed.
tag - The tag object to be removed from the antenna / read point.
Returns:
Returns true if tag has been removed. False if no such tag existed in this antenna.

remove

public boolean remove(java.lang.String readPointName,
                      java.lang.String tagId)
To remove a certain tag from a certain antenna.

Parameters:
readPointName - The name of the read point from which the tag should be removed.
tagId - The ID of a tag to be removed from the antenna / read point.
Returns:
Returns true if tag has been removed. False if no such tag existed in this antenna.

contains

public boolean contains(java.lang.String readPointName,
                        Tag tag)
To find out whether a certain tag is situated on a certain antenna.

Parameters:
readPointName - The name of the read point
tag - The tag.
Returns:
Returns true if such a tag is on this antenna. False if no such tag existed in this antenna.

contains

public boolean contains(java.lang.String readPointName,
                        java.lang.String tagId)
To find out whether a certain tag is situated on a certain antenna.

Parameters:
readPointName - The name of the read point
tagId - The ID of a tag.
Returns:
Returns true if a tag with ID tagId is on this antenna. False if no such tag existed in this antenna.

getTagsFromReadPoint

public java.util.Set getTagsFromReadPoint(java.lang.String readPointName)
To get a set of all tags situated on a certain antenna.

Parameters:
readPointName - The name of the read point
Returns:
Returns a Set containing a copy of all tags currently on this read point.

getHALName

public java.lang.String getHALName()
Description copied from interface: HardwareAbstraction
Returns the HAL name. The HAL name identifies the HAL controller instance and should be specified in a properties file.

Specified by:
getHALName in interface HardwareAbstraction
Returns:
The HAL name

identify

public Observation[] identify(java.lang.String[] readPointNames)
                       throws HardwareException
Description copied from interface: HardwareAbstraction
Identifies the tags in a reader's field. The concrete behaviour of this method depends on the concrete implementation of the underlaying hardware. If the controller is a single-read-point-reader the array readPointNames should contain only one read point. Tags that have been locked during the identification can be reactivated by calling the reset() method.

Specified by:
identify in interface HardwareAbstraction
Parameters:
readPointNames - Array that contains the names of all read points to be scanned
Returns:
An array that contains for each read point an Observation object
Throws:
HardwareException

startAsynchronousIdentify

public void startAsynchronousIdentify(java.lang.String[] readPointNames,
                                      Trigger trigger)
                               throws HardwareException,
                                      UnsupportedOperationException
Description copied from interface: HardwareAbstraction
Identifies the tags in a reader's field in a continuous way that operates asynchronously. If the controller is a single-read-point-reader the array readPointNames should contain only one read point.

Specified by:
startAsynchronousIdentify in interface HardwareAbstraction
Parameters:
readPointNames - Assay that contains the names of all read points to be scanned
trigger - The trigger that indicates the type of asynchronous identify
Throws:
HardwareException
UnsupportedOperationException

stopAsynchronousIdentify

public void stopAsynchronousIdentify()
                              throws HardwareException,
                                     UnsupportedOperationException
Description copied from interface: HardwareAbstraction
Stops the asynchronous identification for a specific listener.

Specified by:
stopAsynchronousIdentify in interface HardwareAbstraction
Throws:
HardwareException
UnsupportedOperationException

isAsynchronousIdentifyRunning

public boolean isAsynchronousIdentifyRunning()
                                      throws HardwareException,
                                             UnsupportedOperationException
Description copied from interface: HardwareAbstraction
Checks whether asynchronous identify is running.

Specified by:
isAsynchronousIdentifyRunning in interface HardwareAbstraction
Returns:
true, if asynchronous identify is running, false otherwise
Throws:
HardwareException
UnsupportedOperationException

addAsynchronousIdentifyListener

public void addAsynchronousIdentifyListener(AsynchronousIdentifyListener listener)
                                     throws HardwareException,
                                            UnsupportedOperationException
Description copied from interface: HardwareAbstraction
Adds an asynchronous identify listener.

Specified by:
addAsynchronousIdentifyListener in interface HardwareAbstraction
Throws:
HardwareException
UnsupportedOperationException

removeAsynchronousIdentifyListener

public void removeAsynchronousIdentifyListener(AsynchronousIdentifyListener listener)
                                        throws HardwareException,
                                               UnsupportedOperationException
Description copied from interface: HardwareAbstraction
removes an asynchronous identify listener.

Specified by:
removeAsynchronousIdentifyListener in interface HardwareAbstraction
Throws:
HardwareException
UnsupportedOperationException

supportsAsynchronousIdentify

public boolean supportsAsynchronousIdentify()
Description copied from interface: HardwareAbstraction
Checks whether this HAL controller implementation supports the startAsynchronousIdentify(), stopAsynchronousIdentify(), isAsynchronousIdentifyRunning(), addAsynchronousIdentifyListener() and removeAsynchronousIdentifyListener() methods.

Specified by:
supportsAsynchronousIdentify in interface HardwareAbstraction
Returns:
true, if methods are supported, false otherwise

readBytes

public UnsignedByteArray readBytes(java.lang.String readPointName,
                                   java.lang.String id,
                                   int memoryBank,
                                   int offset,
                                   int length,
                                   java.lang.String[] passwords)
                            throws HardwareException,
                                   UnsupportedOperationException
Description copied from interface: HardwareAbstraction
Reads data from a specified tag, if in range. The transponder id should be a result of a previous identify. The data on a tag's memory can be read in block units. Therefore the length parameter, that indicates the number of bytes that have to be read, has to contain a multiple of the blocksize.

Specified by:
readBytes in interface HardwareAbstraction
Parameters:
readPointName - The name of the read point on which the read attempt will be done
id - ID of the tag from which the data will be read
memoryBank - The number of the memory bank of the data
offset - The offset of the data in bytes
length - The number of bytes to be read
passwords - An optional list of one or more passwords (or lock code)
Returns:
The data that has been read from the tag
Throws:
HardwareException
UnsupportedOperationException

writeBytes

public void writeBytes(java.lang.String readPointName,
                       java.lang.String id,
                       int memoryBank,
                       int offset,
                       UnsignedByteArray data,
                       java.lang.String[] passwords)
                throws HardwareException,
                       UnsupportedOperationException
Description copied from interface: HardwareAbstraction
Writes data to a specific tag, if in range. The transponder id should be a result of a previous identify.

Specified by:
writeBytes in interface HardwareAbstraction
Parameters:
readPointName - The name of the read point on which the write attempt will be done
id - ID of the tag to which the data will be written
memoryBank - The number of the memory bank of the data
offset - The offset of the data in bytes
data - The byte data to be written to the tag
passwords - An optional list of one or more passwords (or lock code)
Throws:
HardwareException
UnsupportedOperationException

writeId

public void writeId(java.lang.String readPointName,
                    java.lang.String id,
                    java.lang.String[] passwords)
             throws ReadPointNotFoundException,
                    HardwareException,
                    UnsupportedOperationException
Description copied from interface: HardwareAbstraction
Writes the given ID onto a tag. If the physical environment supports the setting of a new tag ID this method can be used to access the appropriate blocks within the memory.

Specified by:
writeId in interface HardwareAbstraction
Parameters:
readPointName - The name of the read point on which the write attempt will be done
id - the new ID for the tag
passwords - an optional list of one or more passwords (or lock code)
Throws:
ReadPointNotFoundException
HardwareException
UnsupportedOperationException

supportsWriteId

public boolean supportsWriteId()
Description copied from interface: HardwareAbstraction
Checks whether this HAL controller implementation supports the writeId() method.

Specified by:
supportsWriteId in interface HardwareAbstraction
Returns:
true, if method is supported, false otherwise

getReadPointNames

public java.lang.String[] getReadPointNames()
Description copied from interface: HardwareAbstraction
Gets the names of all available read points.

Specified by:
getReadPointNames in interface HardwareAbstraction
Returns:
An array containing the names of all available read points

setParameter

public void setParameter(java.lang.String param,
                         java.lang.String value)
                  throws HardwareException,
                         UnsupportedOperationException
Description copied from interface: HardwareAbstraction
Sets a given parameter. A call of the getAllParameterNames() should precede this method in order not to set undefined parameters.

Specified by:
setParameter in interface HardwareAbstraction
Parameters:
param - The parameter name
value - The parameter value
Throws:
HardwareException
UnsupportedOperationException

getAllParameterNames

public java.lang.String[] getAllParameterNames()
                                        throws HardwareException,
                                               UnsupportedOperationException
Description copied from interface: HardwareAbstraction
Gets the names of the supported parameters. The parameters which are configurable should be listed in the associated properties file.

Specified by:
getAllParameterNames in interface HardwareAbstraction
Returns:
The parameter names of all supported paramters
Throws:
HardwareException
UnsupportedOperationException

getParameter

public java.lang.String getParameter(java.lang.String param)
                              throws HardwareException,
                                     UnsupportedOperationException
Description copied from interface: HardwareAbstraction
Gets the value of a given parameter. A call of the getAllParameterNames() should precede this method in order not to request undefined parameters.

Specified by:
getParameter in interface HardwareAbstraction
Parameters:
param - The parameter name to be read
Returns:
The parameter value
Throws:
HardwareException
UnsupportedOperationException

supportsParameters

public boolean supportsParameters()
Description copied from interface: HardwareAbstraction
Checks whether the HAL controller implementation supports the getAllParameterNames(), getParameter() and setParameter() methods.

Specified by:
supportsParameters in interface HardwareAbstraction
Returns:
true, if methods are supported, false otherwise

programId

public void programId(java.lang.String id,
                      java.lang.String[] passwords)
               throws HardwareException,
                      UnsupportedOperationException
Throws:
HardwareException
UnsupportedOperationException

reset

public void reset()
           throws HardwareException
Description copied from interface: HardwareAbstraction
Resets the reader. This includes the unlocking of all previously locked (muted) tags. Furthermore, if anything should not work as desired due to any failures, this method reinitializes the hardware abstraction.

Specified by:
reset in interface HardwareAbstraction
Throws:
HardwareException

kill

public void kill(java.lang.String readPointName,
                 java.lang.String id,
                 java.lang.String[] passwords)
          throws HardwareException,
                 UnsupportedOperationException
Description copied from interface: HardwareAbstraction
Kills the specified tag, if in range. A killed tag doesn't respond to requests any longer.

Specified by:
kill in interface HardwareAbstraction
Parameters:
readPointName - the name of the read point on which the kill attempt will be done
id - id of the tag that will be killed
passwords - an optional list of one or more passwords (or lock code)
Throws:
HardwareException
UnsupportedOperationException

supportsReadBytes

public boolean supportsReadBytes()
Description copied from interface: HardwareAbstraction
Checks whether this HAL controller implementation supports the readBytes() method.

Specified by:
supportsReadBytes in interface HardwareAbstraction
Returns:
true, if method is supported, false otherwise

supportsWriteBytes

public boolean supportsWriteBytes()
Description copied from interface: HardwareAbstraction
Checks whether this HAL controller implementation supports the writeBytes() method.

Specified by:
supportsWriteBytes in interface HardwareAbstraction
Returns:
true, if method is supported, false otherwise

supportsProgramId

public boolean supportsProgramId()

supportsKill

public boolean supportsKill()
Description copied from interface: HardwareAbstraction
Checks whether this HAL controller implementation supports the kill() method.

Specified by:
supportsKill in interface HardwareAbstraction
Returns:
true, if method is supported, false otherwise

supportsReset

public boolean supportsReset()
Description copied from interface: HardwareAbstraction
Checks whether this HAL controller implementation supports the reset() method.

Specified by:
supportsReset in interface HardwareAbstraction
Returns:
true, if method is supported, false otherwise

getReadPointPowerLevel

public int getReadPointPowerLevel(java.lang.String readPointName,
                                  boolean normalize)
Description copied from interface: HardwareAbstraction
Returns the current transmit power level of a certain read point.

Specified by:
getReadPointPowerLevel in interface HardwareAbstraction
Parameters:
readPointName - The name of the read point
normalize - Specifies whether the power level should be returned in a normalized form (i.e. in a range from 0 to 255)
Returns:
The current transmit power level of the read point

supportsGetReadPointPowerLevel

public boolean supportsGetReadPointPowerLevel()
Description copied from interface: HardwareAbstraction
Checks whether this HAL controller implementation supports the getReadPointPowerLevel() method.

Specified by:
supportsGetReadPointPowerLevel in interface HardwareAbstraction
Returns:
true, if method is supported, false otherwise

getReadPointNoiseLevel

public int getReadPointNoiseLevel(java.lang.String readPointName,
                                  boolean normalize)
Description copied from interface: HardwareAbstraction
Returns the current noise level observed at a certain read point.

Specified by:
getReadPointNoiseLevel in interface HardwareAbstraction
Parameters:
readPointName - The name of the read point
normalize - Specifies whether the noise level should be returned in a normalized form (i.e. in a range from 0 to 255)
Returns:
The current noise level observed at the read point

supportsGetReadPointNoiseLevel

public boolean supportsGetReadPointNoiseLevel()
Description copied from interface: HardwareAbstraction
Checks whether this HAL controller implementation supports the getReadPointNoiseLevel() method.

Specified by:
supportsGetReadPointNoiseLevel in interface HardwareAbstraction
Returns:
true, if method is supported, false otherwise

startUpReadPoint

public void startUpReadPoint(java.lang.String readPointName)
Description copied from interface: HardwareAbstraction
Starts up a read point.

Specified by:
startUpReadPoint in interface HardwareAbstraction
Parameters:
readPointName - The name of the read point

supportsStartUpReadPoint

public boolean supportsStartUpReadPoint()
Description copied from interface: HardwareAbstraction
Checks whether this HAL controller implementation supports the startUpReadPoint() method.

Specified by:
supportsStartUpReadPoint in interface HardwareAbstraction
Returns:
true, if method is supported, false otherwise

shutDownReadPoint

public void shutDownReadPoint(java.lang.String readPointName)
Description copied from interface: HardwareAbstraction
Shuts down a read point.

Specified by:
shutDownReadPoint in interface HardwareAbstraction
Parameters:
readPointName - The name of the read point

supportsShutDownReadPoint

public boolean supportsShutDownReadPoint()
Description copied from interface: HardwareAbstraction
Checks whether this HAL controller implementation supports the shutDownReadPoint() method.

Specified by:
supportsShutDownReadPoint in interface HardwareAbstraction
Returns:
true, if method is supported, false otherwise

isReadPointReady

public boolean isReadPointReady(java.lang.String readPointName)
Description copied from interface: HardwareAbstraction
Checks whether a read point is ready (i.e. it has been started up).

Specified by:
isReadPointReady in interface HardwareAbstraction
Parameters:
readPointName - The name of the read point
Returns:
true it the antenna is ready, false otherwise

supportsIsReadPointReady

public boolean supportsIsReadPointReady()
Description copied from interface: HardwareAbstraction
Checks whether this HAL controller implementation supports the isReadPointReady() method.

Specified by:
supportsIsReadPointReady in interface HardwareAbstraction
Returns:
true, if method is supported, false otherwise

main

public static void main(java.lang.String[] args)
For debugging.

Parameters:
args - No arguments


Copyright © 2008. All Rights Reserved.