edu.nps.moves.logger
Class LogWriter

java.lang.Object
  extended by edu.nps.moves.logger.LogWriter
All Implemented Interfaces:
java.lang.Runnable

public class LogWriter
extends java.lang.Object
implements java.lang.Runnable

Writes the contents of the PDU buffer to the file in a separate thread. This accepts Lists of PDUs from the reader thread and writes them out in XML format. Since the reader thread may be faster at times than the writer, we can queue up PDU lists and write them out as we get the chance.

Version:
$Id:$
Author:
mcgredo

Constructor Summary
LogWriter(java.lang.String pExerciseName)
          Creates a new instance of LogWriter.
 
Method Summary
 void addListToWriteQueue(java.util.List<Pdu> pduList)
          Add a list of PDUs to our write queue
 boolean finishedWriting()
          Test to see whether we're done writing and it's OK to quit the thread
 void run()
          Start writing PDUs.
 void setUnqueuedPdus(boolean state)
          Irritating interaction with the reder thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogWriter

public LogWriter(java.lang.String pExerciseName)
Creates a new instance of LogWriter. Exercise name is used to create a directory we write log files to

Parameters:
pExerciseName -
Method Detail

setUnqueuedPdus

public void setUnqueuedPdus(boolean state)
Irritating interaction with the reder thread. They may have read a few PDUs, but don't have enough for a "full" list to send to us. this keeps the writer thread alive until it sends the data to us.

Parameters:
state -

addListToWriteQueue

public void addListToWriteQueue(java.util.List<Pdu> pduList)
Add a list of PDUs to our write queue

Parameters:
pduList -

run

public void run()
Start writing PDUs. This blocks if it has no PDU lists to write.

Specified by:
run in interface java.lang.Runnable

finishedWriting

public boolean finishedWriting()
Test to see whether we're done writing and it's OK to quit the thread