com.adventnet.tl1
Class TL1API

java.lang.Object
  extended by java.lang.Thread
      extended by com.adventnet.tl1.TL1API
All Implemented Interfaces:
java.lang.Runnable

public final class TL1API
extends java.lang.Thread

The TL1API class is a utility class that monitors TL1 sessions and tracks timeouts and retransmits of TL1 requests. The TL1API class needs to be instantiated to use the TL1 Package. This class is a separate thread that monitors TL1 Sessions, and contains TL1 Parameters.
TL1API is the foundation for creating any low-level applications.
To use the low-level API instantiate an TL1API and run the start() method. From there, you can create TL1 sessions, and perform TL1 operations. A single instance of TL1API can manage several sessions. While forming the TL1Session,the TL1API instance given as the argument monitors that particular session.

 TL1API api = new TL1API();
 api.start();
 TL1Session session = new TL1Session(api);
 

Note that a single application may contain several TL1API objects, each managing a set of several TL1Session objects depending upon the number of TL1 Devices that the application has to manage.

See Also:
TL1Session

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static byte ACK_MESSAGE
          Constant for TL1AckMessage type
static byte AUTONOMOUS_MESSAGE
          Constant for TL1AutoMessage type
static byte INPUT_MESSAGE
          Constants for TL1InputMessage type
static byte INVALID_TL1_MESSAGE
          Constant for Invalid TL1 Message type
(package private)  int MONITOR_SLEEP
           
static byte RESPONSE_MESSAGE
          Constant for TL1ResponseMessage type
(package private)  boolean threadStop
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TL1API()
          Default constructor that creates an instance of the TL1API object
 
Method Summary
 void addTL1Session(TL1Session sess)
          This method is used to add TL1Session to the list of sessions which are managed under this TL1API instance.
 java.util.Vector checkResponses()
          Checks each session to see if there are any outstanding responses.
 void close()
          This method stops the API thread which monitors the session for timeouts and retries and also closes all the TL1Sessions registered in this TL1API.
 int genCTag()
          To generate a unique C-Tag field which serves as a request id.
 java.util.Vector getSessionList()
          This method is used to get the List of TL1Sessions managed under this TL1API instance.
 void removeTL1Session(TL1Session sess)
          This method is used to remove TL1Session from the list of sessions maintained by the TL1API instance.
 void run()
          This method starts the API thread which monitors the sessions to look for the requests which have timedout and retransmits the request if required.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INPUT_MESSAGE

public static byte INPUT_MESSAGE
Constants for TL1InputMessage type


ACK_MESSAGE

public static byte ACK_MESSAGE
Constant for TL1AckMessage type


RESPONSE_MESSAGE

public static byte RESPONSE_MESSAGE
Constant for TL1ResponseMessage type


AUTONOMOUS_MESSAGE

public static byte AUTONOMOUS_MESSAGE
Constant for TL1AutoMessage type


INVALID_TL1_MESSAGE

public static byte INVALID_TL1_MESSAGE
Constant for Invalid TL1 Message type


threadStop

boolean threadStop

MONITOR_SLEEP

int MONITOR_SLEEP
Constructor Detail

TL1API

public TL1API()
Default constructor that creates an instance of the TL1API object

Method Detail

addTL1Session

public void addTL1Session(TL1Session sess)
This method is used to add TL1Session to the list of sessions which are managed under this TL1API instance. Users can remove the instance of TL1Session registered in this TL1API using the method removeTL1Session(TL1Session) provided in this class.

Parameters:
sess - The TL1Session instance to be managed.
See Also:
removeTL1Session(com.adventnet.tl1.TL1Session), TL1Session

removeTL1Session

public void removeTL1Session(TL1Session sess)
This method is used to remove TL1Session from the list of sessions maintained by the TL1API instance.

Parameters:
sess - The TL1Session instance to be removed.
See Also:
TL1Session

getSessionList

public java.util.Vector getSessionList()
This method is used to get the List of TL1Sessions managed under this TL1API instance.

Returns:
vector of sessions.

genCTag

public int genCTag()
To generate a unique C-Tag field which serves as a request id.

Returns:
Unique-Id as an integer.

checkResponses

public java.util.Vector checkResponses()
Checks each session to see if there are any outstanding responses.

Returns:
list of sessions with outstanding responses
See Also:
TL1Session

run

public void run()
This method starts the API thread which monitors the sessions to look for the requests which have timedout and retransmits the request if required. This thread can be stopped by the close method provided in this class. The outstanding requests are monitored for timedouts. If the request(TL1InputMessage) has timedout, then the request is retransmitted. If there are no more retries, then request is removed from the request list and returns null in case of syncSend(). This method overrides run() method of the Thread class.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

close

public void close()
This method stops the API thread which monitors the session for timeouts and retries and also closes all the TL1Sessions registered in this TL1API.