public abstract class SensorSession
extends java.lang.Object
Constructor and Description |
---|
SensorSession(java.lang.String ID,
AbstractSensor<?> sensor)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
connect()
Open the connection to the Sensor.
|
abstract void |
disconnect()
Close the connection and stop processing of commands.
|
java.util.List<CommandDTO> |
getCommands()
Get a list of all commands in their execution order
|
SessionDTO |
getDTO()
Get the Data Transfer Object used to serialize a Reader Session
|
java.lang.String |
getID()
Returns the ID for this session.
|
AbstractSensor<?> |
getSensor() |
abstract SessionStatus |
getStatus()
Get the status of the sensorSession.
|
int |
getTimeout()
Get the amount of time to wait on a response before timing out by reading
the system property org.rifidi.edge.sessions.timeout.
|
void |
handleTimeout()
This method is used to notify the session that a timeout has occurred.
|
void |
killAllCommands()
Kill all the commands that have been submitted to this session.
|
abstract void |
killComand(java.lang.Integer id)
This method deletes a command from the session, including the DTO.
|
void |
restoreCommands(SessionDTO dto)
This method should be called by subclasses to restore the commands that
need to be submitted to a session from a SessionDTO.
|
abstract void |
submit(Command command)
Submit a command for a one-time execution.
|
abstract void |
submit(Command command,
long interval,
java.util.concurrent.TimeUnit unit)
Schedule a command for a repeated execution.
|
abstract java.lang.Integer |
submit(java.lang.String commandID,
long interval,
java.util.concurrent.TimeUnit unit)
Submit a command to a reader session for execution.
|
abstract boolean |
submitAndBlock(Command command,
long timeout,
java.util.concurrent.TimeUnit unit)
Submit a command for a one-time execution.
|
public SensorSession(java.lang.String ID, AbstractSensor<?> sensor)
ID
- The ID of the sessionsensor
- The Sensor this session belongs topublic void connect() throws java.io.IOException
java.io.IOException
- if the connection failspublic abstract void disconnect()
public void handleTimeout()
public int getTimeout()
public java.util.List<CommandDTO> getCommands()
public abstract java.lang.Integer submit(java.lang.String commandID, long interval, java.util.concurrent.TimeUnit unit)
commandID
- The command to executeinterval
- The interval between executionsunit
- The Unit of time to measure the intervalpublic abstract void submit(Command command)
command
- The command to executepublic abstract void submit(Command command, long interval, java.util.concurrent.TimeUnit unit)
command
- The command to executepublic abstract boolean submitAndBlock(Command command, long timeout, java.util.concurrent.TimeUnit unit)
command
- The command to executetimeout
- The amount of time to wait. If -1, wait forever before
throwing a TimoutExceptionTimeUnit
- The unit of time used with timeoutpublic abstract void killComand(java.lang.Integer id)
id
- The ID of the command to killpublic void killAllCommands()
public void restoreCommands(SessionDTO dto)
dto
- The DTO of the session which contains the DTOs of the commandspublic abstract SessionStatus getStatus()
public SessionDTO getDTO()
public java.lang.String getID()
public AbstractSensor<?> getSensor()