NMEA
Class AcquireNmeaData

java.lang.Object
  extended by PamguardMVC.PamProcess
      extended by NMEA.AcquireNmeaData
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, Annotator, PamObserver

public class AcquireNmeaData
extends PamProcess
implements java.awt.event.ActionListener

Author:
Doug Gillespie, Dave McLaren, Paul Redmond

PamProcess for NMEA data acquisition.


Nested Class Summary
private  class AcquireNmeaData.RestartNMEASource
          Restart the NMEA thread from the AWT thread in a call from invokeLater
(package private)  class AcquireNmeaData.SerialPortInterface
           
(package private)  class AcquireNmeaData.SimThread
           
(package private)  class AcquireNmeaData.UdpThread
           
 
Field Summary
private  java.lang.Thread activeNMEAsource
          Thread references for NMEA capture.
(package private)  java.util.List<java.lang.StringBuffer> newStrings
          ArrayList to temorarily hold data read in by the captr thread before it is read out by the main thread
(package private)  NMEAControl nmeaControl
           
(package private)  NMEADataBlock outputDatablock
          Ouput data block for NMEA data strings
(package private)  AcquireNmeaData.SerialPortInterface serialPortInterface
           
private  boolean stopActiveNMEAsource
           
(package private)  boolean temp
           
private  javax.swing.Timer timer
          Timer for reading data out of newStrings
 
Fields inherited from class PamguardMVC.PamProcess
outputDataBlocks, processName, sampleRate
 
Constructor Summary
AcquireNmeaData(NMEAControl nmeaControl, NMEAParameters nmeaParameters)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
           
(package private) static boolean checkStringCheckSum(java.lang.StringBuffer nmeaString)
          Checks the checksum of an NMEA data string.
(package private)  void closeSerialThread()
           
static byte createStringChecksum(java.lang.StringBuffer nmeaString)
          Calculate the correct string buffer for an NMEA sentence.
 long firstRequiredTime(PamObservable o, java.lang.Object arg)
           
 NMEADataBlock getOutputDatablock()
           
static byte getStringChecksum(java.lang.StringBuffer nmeaString)
          Gets the checksum from the end of a string.
 void makeSerialThread()
           
 void makeSimThread()
           
 void makeUdpThread()
           
 void noteNewSettings()
           
 void pamStart()
          Called for each process to tell it to start (may not be necessary for processes which are listening for data anyway.
 void pamStop()
          Stops the process.
private  void processNmeaString(java.lang.StringBuffer stringBuffer)
          Convert a string buffer into an NMEA data unit and output to the datablock.
private  void restartNMEA()
          Restart the NMEA thread using the Swing utilitiy invokeLater(...)
 void setSampleRate(float sampleRate, boolean notify)
          New sample rate
 void startNmeaSource(NMEAParameters.NmeaSources sourceType)
           
 
Methods inherited from class PamguardMVC.PamProcess
absMillisecondsToSamples, absSamplesToMilliseconds, addOutputDataBlock, changedThreading, clearOldData, createAnnotations, destroyProcess, fillXMLElement, fillXMLParameters, getAncestorDataBlock, getAnnotation, getBackendProcess, getChainPosition, getCpuPercent, getNumAnnotations, getNumOutputDataBlocks, getObserverName, getObserverObject, getOfflineData, getOutputDataBlock, getPamControlledUnit, getParentDataBlock, getParentProcess, getProcessName, getRawSourceDataBlock, getRequiredDataHistory, getSampleRate, getSourceDataBlock, getSourceProcess, isCanMultiThread, makePamProcess, masterClockUpdate, newData, notifyModelChanged, prepareProcess, relMillisecondsToSamples, relSamplesToMilliseconds, removeObservable, removeOutputDatablock, saveViewerData, setBackendProcess, setCanMultiThread, setParentDataBlock, setParentDataBlock, setProcessName, setupProcess, toString, update, updateData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nmeaControl

NMEAControl nmeaControl

temp

boolean temp

serialPortInterface

AcquireNmeaData.SerialPortInterface serialPortInterface

outputDatablock

NMEADataBlock outputDatablock
Ouput data block for NMEA data strings


newStrings

java.util.List<java.lang.StringBuffer> newStrings
ArrayList to temorarily hold data read in by the captr thread before it is read out by the main thread


timer

private javax.swing.Timer timer
Timer for reading data out of newStrings


activeNMEAsource

private java.lang.Thread activeNMEAsource
Thread references for NMEA capture.


stopActiveNMEAsource

private volatile boolean stopActiveNMEAsource
Constructor Detail

AcquireNmeaData

AcquireNmeaData(NMEAControl nmeaControl,
                NMEAParameters nmeaParameters)
Method Detail

makeSimThread

public void makeSimThread()

closeSerialThread

void closeSerialThread()

makeUdpThread

public void makeUdpThread()

makeSerialThread

public void makeSerialThread()

restartNMEA

private void restartNMEA()
Restart the NMEA thread using the Swing utilitiy invokeLater(...)


startNmeaSource

public void startNmeaSource(NMEAParameters.NmeaSources sourceType)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

processNmeaString

private void processNmeaString(java.lang.StringBuffer stringBuffer)
Convert a string buffer into an NMEA data unit and output to the datablock.

Parameters:
stringBuffer -

checkStringCheckSum

static boolean checkStringCheckSum(java.lang.StringBuffer nmeaString)
Checks the checksum of an NMEA data string.

the checksum is an exclusive OR of all characters between the $ or ! that starts the string and the * that preceeds the checksum.

Parameters:
nmeaString -
Returns:

createStringChecksum

public static byte createStringChecksum(java.lang.StringBuffer nmeaString)
Calculate the correct string buffer for an NMEA sentence.

The checksum is an exclusive OR of all characters between, but not including the first ($ or !) and the * preceding the checksum

Parameters:
nmeaString - NMEA sentence
Returns:
checksum value.

getStringChecksum

public static byte getStringChecksum(java.lang.StringBuffer nmeaString)
Gets the checksum from the end of a string. The is the two characters that follow the *

Parameters:
nmeaString - NMEA string
Returns:
Checksum value

noteNewSettings

public void noteNewSettings()
Specified by:
noteNewSettings in interface PamObserver
Overrides:
noteNewSettings in class PamProcess

firstRequiredTime

public long firstRequiredTime(PamObservable o,
                              java.lang.Object arg)

setSampleRate

public void setSampleRate(float sampleRate,
                          boolean notify)
Description copied from interface: PamObserver
New sample rate

Specified by:
setSampleRate in interface PamObserver
Overrides:
setSampleRate in class PamProcess
notify - Notify other PamObservers and PamObservables in the chain.

pamStart

public void pamStart()
Description copied from class: PamProcess
Called for each process to tell it to start (may not be necessary for processes which are listening for data anyway.

Specified by:
pamStart in class PamProcess

pamStop

public void pamStop()
Description copied from class: PamProcess
Stops the process.

Specified by:
pamStop in class PamProcess

getOutputDatablock

public NMEADataBlock getOutputDatablock()
Returns:
Returns the outputDatablock.