cse466
Class Tester

java.lang.Object
  |
  +--cse466.Tester

public class Tester
extends java.lang.Object

This is the main class for the tester. It controls the parsing and running of the tests. At this point, it just logs what happens to System.out, but it would probably be nice to add some other type of checking later. This tester is designed to be used with the net.tinyos.sf.SerialForwarder to do the serial communication with the mote.


Nested Class Summary
protected  class Tester.SocketReader
          Reads from the socket and logs when packets come in.
 
Field Summary
protected static cse466.Tester _self
          My singleton instance
protected  java.net.Socket _sock
          The socket to the SerialForwarder
protected  java.io.InputStream _sockIs
          The input stream from the SerialForwarder
protected  java.io.OutputStream _sockOs
          The output stream to the SerialForwarder
protected  long _startTime
          The time that this test was started.
protected  java.lang.Object _stdOutLock
          A lock to prevent interleaved writes to System.out There is the potential since the receiving from the SerialForwarder and sending to the SerialForwarder are on separate threads
 
Constructor Summary
protected Tester()
          This class is a singleton, so this is protected
 
Method Summary
static cse466.Tester getInstance()
          Get the singleton instance of the tester
 void logReceivedPacket(cse466.packets.CSE466Packet pkt)
          Log to System.out that a packet was received
 void logSentPacket(cse466.packets.CSE466Packet pkt)
          Log to System.out that a packet was sent
static void main(java.lang.String[] args)
           
 java.util.List parseFile(java.lang.String filename, boolean ignoreBadAMValues)
          Parses the input file that should contain a list of actions.
static void printUsage()
           
 void run(java.util.List actionsList)
          Run through the list and do the actions
 void setupSocket(java.lang.String host, int port)
          Sets up the connection to the SerialForwarder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_sock

protected java.net.Socket _sock
The socket to the SerialForwarder


_sockOs

protected java.io.OutputStream _sockOs
The output stream to the SerialForwarder


_sockIs

protected java.io.InputStream _sockIs
The input stream from the SerialForwarder


_stdOutLock

protected java.lang.Object _stdOutLock
A lock to prevent interleaved writes to System.out There is the potential since the receiving from the SerialForwarder and sending to the SerialForwarder are on separate threads


_startTime

protected long _startTime
The time that this test was started. This is used to record the time after the start that events came in


_self

protected static cse466.Tester _self
My singleton instance

Constructor Detail

Tester

protected Tester()
This class is a singleton, so this is protected

Method Detail

getInstance

public static cse466.Tester getInstance()
Get the singleton instance of the tester


parseFile

public java.util.List parseFile(java.lang.String filename,
                                boolean ignoreBadAMValues)
                         throws ParserException,
                                java.io.IOException
Parses the input file that should contain a list of actions. The actions can be either a delay or a packet. The delay will just delay the sending thread by the specified number of milliseconds. The packet action will send the specified packet. The packet specification looks like this:

  packet <packetType>
  <fieldName> <value>
  <fieldName> <value>
  end
  
And it must have as many fieldNames as are in the packet. The delay is simple:

  delay <delayInMilliseconds>
  

Parameters:
filename - The name of the file that contains the actions.
ignoreBadAMValues - if false, it will validate the am values of the packets
Returns:
The list of actions that are defined in the file
Throws:
ParserException - if the input is malformed.
java.io.IOException - if there was a problem reading from the file.

setupSocket

public void setupSocket(java.lang.String host,
                        int port)
                 throws java.io.IOException
Sets up the connection to the SerialForwarder.

Parameters:
host - the name of the host where the SerialForwarder is running
port - the port on which the SerialForwarder is listening
Throws:
java.io.IOException - if there was a problem connecting to the SerialForwarder

run

public void run(java.util.List actionsList)
         throws java.io.IOException
Run through the list and do the actions

Parameters:
actionsList - The list of actions to perform. The run method will be called on each one in order
Throws:
java.io.IOException - if there was a problem writing to the SerialForwarder.

printUsage

public static void printUsage()

logReceivedPacket

public void logReceivedPacket(cse466.packets.CSE466Packet pkt)
Log to System.out that a packet was received


logSentPacket

public void logSentPacket(cse466.packets.CSE466Packet pkt)
Log to System.out that a packet was sent


main

public static void main(java.lang.String[] args)