com.ionetrics.lib.annotatorcomm
Class AnnotatorComm

java.lang.Object
  extended by com.ionetrics.lib.annotatorcomm.AnnotatorComm
All Implemented Interfaces:
java.io.Closeable
Direct Known Subclasses:
AnnotatorI, AnnotatorJr

public class AnnotatorComm
extends java.lang.Object
implements java.io.Closeable

AnnotatorComm is the base class for communications with the Annotator. It is capable of communicating across any pair of I/O streams and is thread-safe.


Field Summary
static int ETX
          End of Transmission Marker
static int MAX_NAME_LEN
          Maximum length of an Annotator name
static int STX
          Start of Transmission Marker
 
Constructor Summary
AnnotatorComm(java.io.InputStream in, java.io.OutputStream out)
          Construct an AnnotatorComm from I/O streams attached to an Annotator.
 
Method Summary
 void addTextMessageListener(TextMessageListener listener)
          Add a text message listener to be notified when a text message is received.
 void addTimestampListener(TimestampListener listener)
          Add a timestamp listener to be notified when a timestamp is received.
 void close()
          Close I/O streams attached to the Annotator.
 MicrosecondTimestamp getCurrentTime()
          Get the Annotator's current time.
 DeviceId getDeviceId()
          Get the device's ID.
 java.lang.String getDeviceName()
          Get the device's name.
 java.lang.String getFirmwareTimestamp()
          Get the firmware build time and date stamp.
 FirmwareVersion getFirmwareVersion()
          Get the device's version number.
static java.lang.String getLibAnnotatorCommVersion()
          Get the version of libAnnotatorComm.
 int getSerialNumber()
          Get the device's serial number.
 TimeSource[] getSupportedTimeSources()
          Get the supported time sources.
 TextMessageListener[] getTextMessageListeners()
          Get current text message listeners.
 TimeSource getTimeSource()
          Get the time source currently being decoded.
 TimeSourceLockStatus getTimeSourceLockStatus()
          Get the time source lock status.
 TimestampListener[] getTimestampListeners()
          Get current timestamp listeners.
 boolean isTimeSourceTimestampMode()
          Get the time source timestamp mode.
 void noop()
          Perform a NOOP command.
 void removeTextMessageListener(TextMessageListener listener)
          Remove a text message listener.
 void removeTimestampListener(TimestampListener listener)
          Remove a timestamp listener.
 void saveOptions()
          Save current options as the default to flash memory.
protected  ResponseMessage sendRecv(CommandMessage msg)
          Send a command and return its response.
 void setCurrentTime(MicrosecondTimestamp timestamp)
          Set the Annotator's current time.
 void setDeviceName(java.lang.String name)
          Set the device's name.
 void setSerialNumber(int serialno, int key)
          Set the device's serial number.
 void setTimeSource(TimeSource timeSource)
          Set the time source to be decoded.
 void setTimeSourceTimestampMode(boolean isEnabled)
          Set the time source timestamp mode.
protected  void signal(ResponseMessage rspmsg)
          Signal that a response message has been read and needs tending.
protected  void signalSynchronousResponse(ResponseMessage rspmsg)
          Signal that a response message has been received.
protected  void signalTimestampListeners(Timestamp timestamp)
          Signal timestamp listeners that a timestamp has been received.
static void sleep(int iMilliseconds)
          Put the calling thread to sleep for the requested number of milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_NAME_LEN

public static final int MAX_NAME_LEN
Maximum length of an Annotator name

See Also:
Constant Field Values

STX

public static final int STX
Start of Transmission Marker

See Also:
Constant Field Values

ETX

public static final int ETX
End of Transmission Marker

See Also:
Constant Field Values
Constructor Detail

AnnotatorComm

public AnnotatorComm(java.io.InputStream in,
                     java.io.OutputStream out)
Construct an AnnotatorComm from I/O streams attached to an Annotator.

Parameters:
in - input stream from the controller
out - output stream to the controller
Method Detail

close

public void close()
           throws java.io.IOException
Close I/O streams attached to the Annotator.

Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException - failure to close streams

addTimestampListener

public void addTimestampListener(TimestampListener listener)
Add a timestamp listener to be notified when a timestamp is received.

Parameters:
listener - timestamp listener to notify

removeTimestampListener

public void removeTimestampListener(TimestampListener listener)
Remove a timestamp listener.

Parameters:
listener - timestamp listener to remove

getTimestampListeners

public TimestampListener[] getTimestampListeners()
Get current timestamp listeners.

Returns:
timestamp listeners

addTextMessageListener

public void addTextMessageListener(TextMessageListener listener)
Add a text message listener to be notified when a text message is received.

Parameters:
listener - text message listener to notify

removeTextMessageListener

public void removeTextMessageListener(TextMessageListener listener)
Remove a text message listener.

Parameters:
listener - text message listener to remove

getTextMessageListeners

public TextMessageListener[] getTextMessageListeners()
Get current text message listeners.

Returns:
text message listeners

noop

public void noop()
          throws java.io.IOException
Perform a NOOP command.

Throws:
java.io.IOException - failure to complete NOOP command

getDeviceId

public DeviceId getDeviceId()
                     throws java.io.IOException
Get the device's ID. Determine which type of Annotator is present.

Returns:
device id
Throws:
java.io.IOException - failure to get the device's ID

getFirmwareVersion

public FirmwareVersion getFirmwareVersion()
                                   throws java.io.IOException
Get the device's version number.

Returns:
device firmware version
Throws:
java.io.IOException - failure to get device firmware version

getFirmwareTimestamp

public java.lang.String getFirmwareTimestamp()
                                      throws java.io.IOException
Get the firmware build time and date stamp.

Returns:
firmware build time
Throws:
java.io.IOException - failure to get firmware build time

getSerialNumber

public int getSerialNumber()
                    throws java.io.IOException
Get the device's serial number.

Returns:
serial number
Throws:
java.io.IOException - failure to get serial number

setSerialNumber

public void setSerialNumber(int serialno,
                            int key)
                     throws java.io.IOException
Set the device's serial number. This method is for factory use only and requires a security key to function.

Parameters:
serialno - serial number
key - security key
Throws:
java.io.IOException

getDeviceName

public java.lang.String getDeviceName()
                               throws java.io.IOException
Get the device's name.

Returns:
device name
Throws:
java.io.IOException - failure to get device name

setDeviceName

public void setDeviceName(java.lang.String name)
                   throws java.io.IOException
Set the device's name.

Parameters:
name - device name
Throws:
java.io.IOException - failure to set device name
See Also:
MAX_NAME_LEN

getSupportedTimeSources

public TimeSource[] getSupportedTimeSources()
                                     throws java.io.IOException
Get the supported time sources. The device can be set to decode any of the returned time sources.

Returns:
supported time sources
Throws:
java.io.IOException - failure to get supported time sources

getTimeSource

public TimeSource getTimeSource()
                         throws java.io.IOException
Get the time source currently being decoded.

Returns:
current time source
Throws:
java.io.IOException - failiure to get current time source

setTimeSource

public void setTimeSource(TimeSource timeSource)
                   throws java.io.IOException
Set the time source to be decoded.

Parameters:
timeSource - time source to decode
Throws:
java.io.IOException - failure to set time source

getCurrentTime

public MicrosecondTimestamp getCurrentTime()
                                    throws java.io.IOException
Get the Annotator's current time.

Returns:
curren time
Throws:
java.io.IOException - failure to get current time

setCurrentTime

public void setCurrentTime(MicrosecondTimestamp timestamp)
                    throws java.io.IOException
Set the Annotator's current time.

Parameters:
timestamp - current time
Throws:
java.io.IOException - failure to set current time

getTimeSourceLockStatus

public TimeSourceLockStatus getTimeSourceLockStatus()
                                             throws java.io.IOException
Get the time source lock status.

Returns:
lock status
Throws:
java.io.IOException - failure to get lock status

setTimeSourceTimestampMode

public void setTimeSourceTimestampMode(boolean isEnabled)
                                throws java.io.IOException
Set the time source timestamp mode. When enabled, the Annotator will stream time source timestamps back across the AnnotatorComm link.

Parameters:
isEnabled - enabled status
Throws:
java.io.IOException - failure to set mode

isTimeSourceTimestampMode

public boolean isTimeSourceTimestampMode()
                                  throws java.io.IOException
Get the time source timestamp mode.

Returns:
enabled status
Throws:
java.io.IOException - failure to get mode

saveOptions

public void saveOptions()
                 throws java.io.IOException
Save current options as the default to flash memory. When the device is reset, the options will be restored from flash. Device name and other options specially marked are not affected by this command.

Throws:
java.io.IOException - failure to save options

sendRecv

protected ResponseMessage sendRecv(CommandMessage msg)
                            throws java.io.IOException
Send a command and return its response.

Parameters:
msg - command message to send
Returns:
response received
Throws:
java.io.IOException - failure to send and receive

signal

protected void signal(ResponseMessage rspmsg)
Signal that a response message has been read and needs tending. This is called by ResponseReader. Override this method to provide device specific response message functionality.

Parameters:
rspmsg - new response message

signalTimestampListeners

protected void signalTimestampListeners(Timestamp timestamp)
Signal timestamp listeners that a timestamp has been received.

Parameters:
timestamp - timestamp received

signalSynchronousResponse

protected void signalSynchronousResponse(ResponseMessage rspmsg)
Signal that a response message has been received.

Parameters:
rspmsg - reponse message received

sleep

public static void sleep(int iMilliseconds)
Put the calling thread to sleep for the requested number of milliseconds.

Parameters:
iMilliseconds - number of milliseconds to sleep

getLibAnnotatorCommVersion

public static java.lang.String getLibAnnotatorCommVersion()
Get the version of libAnnotatorComm.

Returns:
libAnnotatorComm version


Copyright © 2006 Ionetrics Corp. All Rights Reserved.