Index: trunk/code/projects/diagnostic_station/server/server.c
===================================================================
--- trunk/code/projects/diagnostic_station/server/server.c	(revision 1605)
+++ trunk/code/projects/diagnostic_station/server/server.c	(nonexistent)
@@ -1,118 +0,0 @@
-#include "comp-hub.h"
-
-// ALSO DON'T FORGET TO CHECK OUT
-// ATTRIBUTES ON LINES 39 ish TO 50 ish
-#define PORT_DEFAULT "/dev/ttyUSB0"
-#define BAUD_RATE 115200
-
-static char* com_port = PORT_DEFAULT;
-static int stream;
-
-int main(void)
-{
-	if(lib_init() < 0)
-		printf("Exiting...\n");
-	
-	//your code here
-	listen();
-	put_char('r');
-	listen();
-	put_char('b');
-	listen();
-	put_char('m');
-	listen();
-	
-	return 0;
-}
-
-int lib_init()
-{
-	stream = open(com_port, O_RDWR);
-	if (stream == -1)
-	{
-		printf("Failed to open connection on port ");
-		printf("%i\n", *com_port);
-		return -1;
-	} else {
-	  	printf("Successfully opened connection on port ");
-		printf("%i\n", (int)(*com_port));
-	}
-	// set baud rate, etc. correctly
-	struct termios options;
-	if(tcgetattr(stream, &options))
-		printf("Error getting attributes");
-	cfsetispeed(&options, BAUD_RATE);
-	cfsetospeed(&options, BAUD_RATE);
-	//options.c_iflag &= ~ICRNL;
-	//options.c_oflag &= ~OCRNL;
-	//options.c_cflag |= (CLOCAL | CREAD);
-	options.c_cflag &= ~PARENB; //no parity
-	options.c_cflag &= ~CSTOPB; //one stop bit
-	options.c_cflag &= ~CSIZE;
-	options.c_cflag |= CS8; //8 bits
-	//options.c_lflag &= ~ICANON;
-	//options.c_cc[VMIN] = 1;
-	//options.c_cc[VTIME] = 50;
-
-	if (tcsetattr(stream, TCSANOW, &options))
-	{
-		printf("Error setting attributes.\n");
-		return -1;
-	}
-	return 0;
-}
-
-/**
- * Listener function
- * At the moment, just prints out what it receives
- **/
-static void* listen()
-{
-	char c;
-	int count = 0;
-	char buf[100];
-	while (1)
-	{
-		if (read_char(&c) != 0) {
-			printf("Listen failed.\n");
-			return NULL;
-		}
-		
-		printf("%c", c); fflush(stdout);
-		
-		if(c == '\0')
-			break;
-	}
-
-	return NULL;
-}
-
-static int read_char(char* buf)
-{
-	if (read(stream, buf, 1) == -1) {
-		printf("Failed to read.\r\n");
-		return -1;
-	}
-	return 0;
-}
-
-/**
- * Put functions
- **/
-static int put_string(char *str)
-{
-	if (write(stream, str, strlen(str)) == -1) {
-		printf("Failed to write.\r\n");
-		return -1;
-	}
-	return 0;
-}
-
-static int put_char(char c)
-{
-	if (write(stream, &c, 1) == -1) {
-		printf("Failed to write.\r\n");
-		return -1;
-	}
-	return 0;
-}
Index: trunk/code/projects/diagnostic_station/server/server.h
===================================================================
--- trunk/code/projects/diagnostic_station/server/server.h	(revision 1605)
+++ trunk/code/projects/diagnostic_station/server/server.h	(nonexistent)
@@ -1,13 +0,0 @@
-#include <termios.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-int main(void);
-int lib_init();
-static void* listen();
-static int read_char(char* buf);
-static int put_string(char *str);
-static int put_char(char c);
Index: trunk/code/projects/diagnostic_station/server/Makefile
===================================================================
--- trunk/code/projects/diagnostic_station/server/Makefile	(revision 1605)
+++ trunk/code/projects/diagnostic_station/server/Makefile	(nonexistent)
@@ -1,5 +0,0 @@
-all:
-	gcc server.c -o server
-
-clean:
-	rm server
Index: trunk/code/projects/diagnostic_station/server/Main.java
===================================================================
--- trunk/code/projects/diagnostic_station/server/Main.java	(nonexistent)
+++ trunk/code/projects/diagnostic_station/server/Main.java	(revision 1606)
@@ -0,0 +1,6 @@
+
+public class Main {
+	public static void main(String[] args){
+		new DiagnosticsServer();
+	}
+}
Index: trunk/code/projects/diagnostic_station/server/jfreechart-1.0.13.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/code/projects/diagnostic_station/server/jfreechart-1.0.13.jar
===================================================================
--- trunk/code/projects/diagnostic_station/server/jfreechart-1.0.13.jar	(nonexistent)
+++ trunk/code/projects/diagnostic_station/server/jfreechart-1.0.13.jar	(revision 1606)

Property changes on: trunk/code/projects/diagnostic_station/server/jfreechart-1.0.13.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/code/projects/diagnostic_station/server/SerialComm.java
===================================================================
--- trunk/code/projects/diagnostic_station/server/SerialComm.java	(nonexistent)
+++ trunk/code/projects/diagnostic_station/server/SerialComm.java	(revision 1606)
@@ -0,0 +1,204 @@
+import gnu.io.CommPort;
+import gnu.io.CommPortIdentifier;
+import gnu.io.SerialPort;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class SerialComm
+{
+	/*
+	 * The following define the default settings for connections
+	 */
+	public static final String PORT_DEFAULT = "COM15";
+	public static final int BAUDRATE_DEFAULT = 115200;
+	public static final int PARITY_DEFAULT = SerialPort.PARITY_NONE;
+	public static final int DATABITS_DEFAULT = SerialPort.DATABITS_8;
+	// At this time, the station does use 2 stopbits
+	public static final int STOPBITS_DEFAULT = SerialPort.STOPBITS_2;
+	
+	/*
+	 * Possible parities
+	 */
+	public static final int PARITY_EVEN = SerialPort.PARITY_EVEN;
+	public static final int PARITY_MARK = SerialPort.PARITY_MARK;
+	public static final int PARITY_NONE = SerialPort.PARITY_NONE;
+	public static final int PARITY_ODD = SerialPort.PARITY_ODD;
+	public static final int PARITY_SPACE = SerialPort.PARITY_SPACE;
+	
+	/*
+	 * Possible numbers of databits
+	 */
+	public static final int DATABITS_5 = SerialPort.DATABITS_5;
+	public static final int DATABITS_6 = SerialPort.DATABITS_6;
+	public static final int DATABITS_7 = SerialPort.DATABITS_7;
+	public static final int DATABITS_8 = SerialPort.DATABITS_8;
+	
+	/*
+	 * Possible numbers of stopbits
+	 */
+	public static final int STOPBITS_1 = SerialPort.STOPBITS_1;
+	public static final int STOPBITS_2 = SerialPort.STOPBITS_2;
+	// 1.5 stopbits
+	public static final int STOPBITS_1_5 = SerialPort.STOPBITS_1_5;
+	
+	/*
+	 * The following global variables define the settings for connections
+	 * These may be changed using the different constructors
+	 */
+	private String port = PORT_DEFAULT;
+	private int baudRate = BAUDRATE_DEFAULT;
+	private int parity = PARITY_DEFAULT;
+	private int dataBits = DATABITS_DEFAULT;
+	private int stopBits = STOPBITS_DEFAULT;
+	private int timeout = 10000;
+	
+	/*
+	 * These input and output streams read from and write to serial
+	 * These are initialized by the connect method
+	 */
+	private InputStream in;
+	private OutputStream out;
+	
+	/*
+	 * We need to store the gui so that we can write to its console whenever
+	 * we read or write from serial
+	 */
+	private ServerGUI gui;
+	
+	/*
+	 * All settings at defaults (see above for default settings)
+	 */
+    public SerialComm(ServerGUI gui) throws IOException{
+        super();
+        this.gui = gui;
+        connect();
+    }
+    
+    /*
+     * For example, port could be "COM4"
+     * All other settings at defaults (see above for default settings)
+     */
+    public SerialComm(ServerGUI gui, String port) throws IOException{
+    	super();
+    	this.gui = gui;
+    	this.port = port;
+    	connect();
+    }
+    
+    /*
+     * All settings set as specified in the arguments
+     */
+    public SerialComm(ServerGUI gui, String port, int baudRate, int dataBits,
+    		int stopBits, int parity) throws IOException{
+    	super();
+    	this.gui = gui;
+    	this.port = port;
+    	this.baudRate = baudRate;
+    	this.parity = parity;
+    	this.dataBits = dataBits;
+    	this.stopBits = stopBits;
+    	connect();
+    }
+    
+    public void puts(String s) throws IOException{
+    	System.out.print("> " + s);
+    	gui.addTextToConsole("> " + s);
+    	out.write((s).getBytes());
+    }
+    
+    /*
+     * Reads until a newline is found
+     * This operation is blocking
+     */
+    public String gets() throws IOException{
+    	int c_read = 0;
+    	String read = "";
+    	do{
+    		c_read = in.read();
+    		if(c_read != -1)
+    			read += (char)c_read;
+    	}
+    	while(c_read != (int)'\n' && c_read != (int)'\r');
+    	System.out.print("< " + read);
+    	gui.addTextToConsole("< " + read);
+    	return read;
+    }
+    
+    /*
+     * If no data is available to be read, returns null
+     * If data is available, reads until a newline is found
+     * This operation is blocking until a newline is read
+     */
+    public String gets_nb() throws IOException{
+    	int c_read = 0;
+    	String read = "";
+    	if(in.available() < 0)
+    		return null;
+    	do{
+    		c_read = in.read();
+    		if(c_read != -1)
+    			read += (char)c_read;
+    	}
+    	while(c_read != (int)'\n' && c_read != (int)'\r');
+    	System.out.print("< " + read);
+    	gui.addTextToConsole("< " + read);
+    	return read;
+    }
+    
+    /*
+     * Returns the next character, or the character '\0' if there is no
+     * character to read
+     * This operation is non-blocking
+     */
+    public char getc_nb() throws IOException{
+    	int c_read = 0;
+    	char read = '\0';
+		if(in.available() <= 0)
+			return read;
+		c_read = in.read();
+    	if(c_read != -1)
+    		read = (char)c_read;
+    	System.out.print("< " + read);
+    	gui.addTextToConsole("< " + read);
+    	return read;
+    }
+    
+    /*
+     * Connects to a serial port using the settings specified in the
+     * global variables
+     * Must be called before using any of the get or put methods
+     * (called by the constructor)
+     * See global variables port, baudRate, parity, dataBits, stopBits, timeout
+     */
+    private void connect() throws IOException{
+    	try{
+	    	CommPortIdentifier portIdentifier =
+	    		CommPortIdentifier.getPortIdentifier(port);
+	        if ( portIdentifier.isCurrentlyOwned()){
+	            System.out.println("Error: Port is currently in use\n");
+	        }
+	        else{
+	            CommPort commPort = portIdentifier.open(this.getClass().getName(),
+	            		timeout);
+	            
+	            if ( commPort instanceof SerialPort ){
+	                SerialPort serialPort = (SerialPort) commPort;
+	                serialPort.setSerialPortParams(baudRate, dataBits, stopBits,
+	                		parity);
+	                
+	                in = serialPort.getInputStream();
+	                out = serialPort.getOutputStream();
+	            }
+	            else{
+	                System.out.println("Error: " + port +
+	                		" is not a serial port\n");
+	            }
+	        }
+    	}
+    	catch(Exception e){
+    		throw new IOException(e.getMessage());
+    	}
+    }
+}
Index: trunk/code/projects/diagnostic_station/server/ServerGUI.java
===================================================================
--- trunk/code/projects/diagnostic_station/server/ServerGUI.java	(nonexistent)
+++ trunk/code/projects/diagnostic_station/server/ServerGUI.java	(revision 1606)
@@ -0,0 +1,352 @@
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.LayoutManager;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+import javax.swing.AbstractButton;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+import javax.swing.border.Border;
+
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.ChartPanel;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.data.xy.XYSeries;
+import org.jfree.data.xy.XYSeriesCollection;
+
+public class ServerGUI implements ActionListener{
+	
+	private static final long serialVersionUID = 1L;
+
+	// whether or not to use the console
+	private static final boolean USE_CONSOLE = true;
+	
+	private int currentTest = -1;
+	private int testNum = -1;
+	
+	// the area that shows messages
+	private JTextArea console;
+	// the DiagnosticsServer that does all the processing
+	private DiagnosticsServer server;
+	
+	// a list of buttons
+	private JButton[] buttons = new JButton[DiagnosticsServer.NUM_TESTS];
+	// the stop button
+	JButton stop;
+	ButtonGroup numSelectGroup;
+	private JRadioButton[] radios;
+	private JFrame numSelectWindow, frame;
+	private JPanel graphPanel, top;
+	private LayoutManager layout;
+	
+	// Constructor - sets up the GUI
+	public ServerGUI(DiagnosticsServer server){
+		frame = new JFrame("Diagnostic Station Control Panel");
+		this.server = server;
+		
+		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+		
+		frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
+		
+		top = new JPanel();
+		layout = new BoxLayout(top, BoxLayout.X_AXIS);
+		top.setLayout(layout);
+		top.add(buttonPanel());
+		top.add(Box.createGlue());
+		graphPanel = graphPanel();
+		top.add(graphPanel);
+		
+		frame.add(top);
+		if(USE_CONSOLE)
+			frame.add(console());
+
+		frame.pack();
+		frame.setVisible(true);
+	}
+	
+	// returns the Panel containing the graph
+	private JPanel graphPanel(){
+		if(currentTest == -1 || currentTest == DiagnosticsServer.ALL_TESTS)
+			return blankPanel();
+	
+		String[] labels = server.getLabels(currentTest, testNum);
+		ArrayList[] data = server.getData(currentTest, testNum);
+		
+		int numSeries = labels.length - 3;
+		XYSeries series[] = new XYSeries[numSeries];
+		for(int i=0; i<numSeries; i++){
+			series[i] = new XYSeries(labels[i+3]);
+			ArrayList x = data[2*i];
+			ArrayList y = data[2*i+1];
+			for(int j=0; j<x.size(); j++){
+				series[i].add((Integer)x.get(j), (Integer)y.get(j));
+			}
+		}
+		XYSeriesCollection xyDataset = new XYSeriesCollection(series[0]);
+		for(int i=1; i<numSeries; i++)
+			xyDataset.addSeries(series[i]);
+		
+		JFreeChart chart = ChartFactory.createXYLineChart(labels[0],
+				labels[1], labels[2], xyDataset, PlotOrientation.VERTICAL, true,
+				false, false);
+		ChartPanel panel = new ChartPanel(chart);
+		
+		JPanel graphPanel = new JPanel();
+		graphPanel.add(panel);
+		return graphPanel;
+	}
+	
+	// returns a blank panel
+	private JPanel blankPanel(){
+		JPanel blank = new JPanel();
+		blank.setBorder(BorderFactory.createMatteBorder(20, 20, 20, 20, new Color(238, 238, 238)));
+		blank.setBackground(Color.WHITE);
+		blank.add(Box.createRigidArea(new Dimension(680, 420)));
+		return blank;
+	}
+	
+	// returns the console
+	private JScrollPane console(){
+		console = new JTextArea(10, 50);
+		JScrollPane pane = new JScrollPane(console); 
+		console.setEditable(false);
+		console.setLineWrap(false);
+		Border inner = BorderFactory.createLineBorder(Color.BLACK);
+		Border outer = BorderFactory.createEmptyBorder(5, 15, 5, 15);
+		Border border = BorderFactory.createCompoundBorder(outer, inner);
+		pane.setBorder(border);
+		return pane;
+	}
+	
+	// adds the given String to the console
+	public void addTextToConsole(final String s){
+		SwingUtilities.invokeLater(new Runnable (){
+			public void run() {
+				console.append(s);
+			}
+		});
+	}
+	
+	// the panel with the control buttons
+	private JPanel buttonPanel(){
+		int maxButtonWidth = 200;
+		int maxButtonHeight = 30;
+		
+		JPanel buttonPanel = new JPanel();
+		buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 15, 5, 15));
+		buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));
+		buttonPanel.setMinimumSize(new Dimension(maxButtonWidth, 25 + ((maxButtonHeight + 5) * DiagnosticsServer.NUM_TESTS)));
+		buttonPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
+		buttonPanel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
+		
+		buttons[DiagnosticsServer.ALL_TESTS] = new JButton("Run all tests");
+		buttons[DiagnosticsServer.RANGEFINDER] = new JButton("Run rangefinder test");
+		buttons[DiagnosticsServer.ENCODER] = new JButton("Run encoder test");
+		buttons[DiagnosticsServer.MOTOR] = new JButton("Run motor test");
+		buttons[DiagnosticsServer.BOM] = new JButton("Run bom test");
+		buttons[DiagnosticsServer.BOM_EMITTER] = new JButton("Run bom emitter test");
+		buttons[DiagnosticsServer.BOM_DETECTOR] = new JButton("Run bom detector test");
+		for(int i=0; i<DiagnosticsServer.NUM_TESTS; i++){
+			buttons[i].setVerticalTextPosition(AbstractButton.CENTER);
+			buttons[i].setActionCommand("frame " + i);
+			buttons[i].addActionListener(this);
+			buttons[i].setAlignmentX(Component.LEFT_ALIGNMENT);
+			buttons[i].setAlignmentY(Component.TOP_ALIGNMENT);
+			buttons[i].setMaximumSize(new Dimension(maxButtonWidth, maxButtonHeight));
+			if(i != 0)
+				buttonPanel.add(Box.createRigidArea(new Dimension(0, 5)));
+			buttonPanel.add(buttons[i]);			
+		}
+		stop = new JButton("Stop testing");
+		stop.setVerticalTextPosition(AbstractButton.CENTER);
+		stop.setActionCommand("stop");
+		stop.addActionListener(this);
+		stop.setAlignmentX(Component.LEFT_ALIGNMENT);
+		stop.setAlignmentY(Component.TOP_ALIGNMENT);
+		stop.setMaximumSize(new Dimension(maxButtonWidth, maxButtonHeight));
+		//stop.setBackground(Color.RED);
+		stop.setEnabled(false);
+		buttonPanel.add(Box.createRigidArea(new Dimension(0, 5)));
+		buttonPanel.add(stop);	
+		
+		buttonPanel.add(Box.createGlue());
+		
+		return buttonPanel;
+	}
+	
+	// shows the dialog asking the user which specific parts to test
+	private void getNumDialog(int testNum){
+		String instr = "Choose which test to run";
+		if(testNum == DiagnosticsServer.BOM){
+			instr = "Choose which bom to test";
+		}
+		else if(testNum == DiagnosticsServer.BOM_DETECTOR){
+			instr = "Choose which detector to test";
+		}
+		else if(testNum == DiagnosticsServer.BOM_EMITTER){
+			instr = "Choose which emitter to test";
+		}
+		else if(testNum == DiagnosticsServer.RANGEFINDER){
+			instr = "Choose which rangefinder to test";
+		}
+		else if(testNum == DiagnosticsServer.MOTOR){
+			instr = "Choose which motor to test";
+		}
+		else if(testNum == DiagnosticsServer.ENCODER){
+			instr = "Choose which encoder to test";
+		}
+		
+        JLabel label = new JLabel(instr);
+		radios = radios(testNum);
+
+        JPanel grid = new JPanel(new GridLayout(0, 1));
+        for (int i = 0; i < radios.length; i++) {
+            grid.add(radios[i]);
+        }
+
+        JPanel box = new JPanel();
+        box.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
+        box.setLayout(new BoxLayout(box, BoxLayout.PAGE_AXIS));
+        label.setAlignmentX(Component.LEFT_ALIGNMENT);
+        box.add(label);
+        box.add(grid);
+        grid.setAlignmentX(Component.LEFT_ALIGNMENT);
+
+        JPanel buttons = new JPanel();
+        buttons.setLayout(new BoxLayout(buttons, BoxLayout.Y_AXIS));
+        box.add(buttons);
+        JButton run = new JButton("Run test");
+        run.addActionListener(this);
+        run.setActionCommand("run");
+        run.setMaximumSize(new Dimension(200, 30));
+        buttons.add(run);
+        buttons.add(Box.createRigidArea(new Dimension(0, 5)));
+		JButton cancel = new JButton("Cancel");
+		cancel.addActionListener(this);
+		cancel.setActionCommand("cancel");
+		cancel.setMaximumSize(new Dimension(200, 30));
+		buttons.add(cancel);
+        
+        numSelectWindow = new JFrame("Select test");
+        numSelectWindow.setLayout(new BoxLayout(numSelectWindow.getContentPane(), BoxLayout.Y_AXIS));
+        numSelectWindow.add(box, BorderLayout.PAGE_START);
+		numSelectWindow.pack();
+		numSelectWindow.setVisible(true);
+	}
+	
+	// returns the radio buttons for the getNumDialog
+	private JRadioButton[] radios(int testNum){
+		int numTests = 0;
+		int startIndex = 0;
+		String allText = "All tests";
+		if(testNum == DiagnosticsServer.BOM || testNum == DiagnosticsServer.BOM_DETECTOR || testNum == DiagnosticsServer.BOM_EMITTER){
+			numTests = DiagnosticsServer.NUM_BOMS;
+			startIndex = DiagnosticsServer.BOM_OFFSET;
+			if(testNum == DiagnosticsServer.BOM)
+				allText = "All boms";
+			else if(testNum == DiagnosticsServer.BOM_DETECTOR)
+				allText = "All detectors";
+			else if(testNum == DiagnosticsServer.BOM_EMITTER)
+				allText = "All emitters";
+		}
+		else if(testNum == DiagnosticsServer.RANGEFINDER){
+			numTests = DiagnosticsServer.NUM_RANGEFINDERS;
+			startIndex = DiagnosticsServer.RANGEFINDER_OFFSET;
+			allText = "All rangefinders";
+		}
+		else if(testNum == DiagnosticsServer.MOTOR){
+			numTests = DiagnosticsServer.NUM_MOTORS;
+			startIndex = DiagnosticsServer.MOTOR_OFFSET;
+			allText = "Both motors";
+		}
+		else if(testNum == DiagnosticsServer.ENCODER){
+			numTests = DiagnosticsServer.NUM_ENCODERS;
+			startIndex = DiagnosticsServer.ENCODER_OFFSET;
+			allText = "Both encoders";
+		}
+			
+		JRadioButton radios[] = new JRadioButton[numTests+1];
+		numSelectGroup = new ButtonGroup();
+		for(int i=0; i<numTests+1; i++){
+			if(i==0){
+				radios[i] = new JRadioButton(allText);
+				radios[i].setSelected(true);
+			}
+			else{
+				radios[i] = new JRadioButton((i+startIndex-1) + "");
+				radios[i].setSelected(false);
+			}
+			radios[i].addActionListener(this);
+			radios[i].setActionCommand(testNum + " " + (i-1));
+			numSelectGroup.add(radios[i]);
+		}
+
+		return radios;
+	}
+
+	// the Action handler
+	public void actionPerformed(ActionEvent event) {
+		String actionCommand = event.getActionCommand();
+		try{
+			if(actionCommand.equals("stop")){
+				server.stopTest();
+				stop.setBackground(null);
+				stop.setEnabled(false);
+			}
+			else if(actionCommand.equals("cancel")){
+				numSelectWindow.dispose();
+				return;
+			}
+			else if(actionCommand.equals("run")){
+				Enumeration<AbstractButton> buttons = numSelectGroup.getElements();
+				while(buttons.hasMoreElements()){
+					AbstractButton button = buttons.nextElement();
+					if(button.isSelected()){
+						String command = button.getActionCommand();
+						int spaceIndex = command.indexOf(" ");
+						Integer testNum = Integer.parseInt(command.substring(0, spaceIndex));
+						Integer num = Integer.parseInt(command.substring(spaceIndex+1));
+						numSelectWindow.dispose();
+						currentTest = testNum;
+						this.testNum = num;
+						stop.setBackground(Color.RED);
+						stop.setEnabled(true);
+						frame.repaint();
+						server.startTest(testNum, num);
+						stop.setBackground(null);
+						stop.setEnabled(false);
+						top.remove(graphPanel);
+						graphPanel = graphPanel();
+						top.add(graphPanel);
+						top.validate();
+						break;
+					}
+				}
+			}
+			else if(actionCommand.startsWith("frame ")){
+				Integer num = Integer.parseInt(actionCommand.substring(6));
+				getNumDialog(num);
+			}
+		}
+		catch(Exception e){
+			System.out.println(e.getMessage());
+		}
+	}
+}
Index: trunk/code/projects/diagnostic_station/server/RXTXcomm.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/code/projects/diagnostic_station/server/RXTXcomm.jar
===================================================================
--- trunk/code/projects/diagnostic_station/server/RXTXcomm.jar	(nonexistent)
+++ trunk/code/projects/diagnostic_station/server/RXTXcomm.jar	(revision 1606)

Property changes on: trunk/code/projects/diagnostic_station/server/RXTXcomm.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/code/projects/diagnostic_station/server/README
===================================================================
--- trunk/code/projects/diagnostic_station/server/README	(revision 1605)
+++ trunk/code/projects/diagnostic_station/server/README	(revision 1606)
@@ -1,9 +1,24 @@
 #####################################################################
-# Server Code Folder
+# Server Code
 #
-# John Sexton
+# Emily Hart
 #####################################################################
 
 This folder contains code intended to be compiled and run on a
 computer acting as the server for the diagnostic station. All data
 analysis will occur at this level.
+
+This code has only been tested on Windows, but probably doesn't need a lot of
+modification to run in Linux.  Make sure PORT_DEFAULT, line 14 in
+SerialComm.java, is set correctly when you run this code.  The directions below
+are for running this code in Eclipse.  
+
+To use this code, the three .jar files need to be added to the build path  To do
+this in Eclipse, select the following in the Package Explorer:
+-jcommon-1.0.16.jar
+-jfreechart-1.0.13.jar
+-RXTXcomm.jar
+Right them and select Build Path >> Add to Build Path.  The four java
+classes should stop showing errors now.
+
+To run the code, right click Main.java and select Run As >> Java Application.
Index: trunk/code/projects/diagnostic_station/server/DiagnosticsServer.java
===================================================================
--- trunk/code/projects/diagnostic_station/server/DiagnosticsServer.java	(nonexistent)
+++ trunk/code/projects/diagnostic_station/server/DiagnosticsServer.java	(revision 1606)
@@ -0,0 +1,847 @@
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Scanner;
+
+public class DiagnosticsServer {
+	
+	/*
+	 * The following are used to differentiate between tests
+	 */
+	public static final int ALL_TESTS = 0;
+	public static final int RANGEFINDER = 1;
+	public static final int ENCODER = 2;
+	public static final int MOTOR = 3;
+	public static final int BOM = 4;
+	public static final int BOM_EMITTER = 5;
+	public static final int BOM_DETECTOR = 6;
+	/*
+     * The number of different tests
+     */
+	public static final int NUM_TESTS = 7;
+	/*
+	 * How many there are of each type
+	 * For example, there are 16 BOM components and 2 motors
+	 */
+	public static final int NUM_BOMS = 16;
+	public static final int NUM_RANGEFINDERS = 5;
+	public static final int NUM_MOTORS = 2;
+	public static final int NUM_ENCODERS = 2;
+	/*
+	 * Sometimes, we want to test all elements of a specific one
+	 * For example, all five rangefinders instead of just one of them
+	 */
+	public static final int ALL_ELEMENTS = -1;
+	/*
+	 * Specifies the lowest possible number for a type
+	 * For example, numbering starts at 0 for BOM components and 1 for motors
+	 */
+	public static final int RANGEFINDER_OFFSET = 1;
+	public static final int ENCODER_OFFSET = 1;
+	public static final int MOTOR_OFFSET = 1;
+	public static final int BOM_OFFSET = 0;
+	
+	/*
+	 * Station -> server message types
+	 */
+	private static final int PARSE_ERROR = 0;
+	private static final int DATA = 1;
+	private static final int COMMENT = 2;
+	private static final int READY = 3;
+	
+	/*
+	 * The following bitmasks are used to specify the status of a reading
+	 * from the station
+	 */
+	// Emitter status
+	private static final int EMITTER = 1;
+	private static final int DETECTOR = 2;
+	private static final int EMITTER_TOP = 4;
+	private static final int EMITTER_RIGHT = 8;
+	private static final int EMITTER_LEFT = 16;
+	private static final int DETECTOR_IN = 64;
+	private static final int DETECTOR_OUT = 128;
+	// Rangefinder status
+	private static final int RANGEFINDER_IN = 1;
+	private static final int RANGEFINDER_OUT = 2;
+	// Motor status
+	private static final int MOTOR_FORWARD = 1;
+	private static final int MOTOR_BACKWARD = 2;
+	private static final int MOTOR_ACCELERATING = 4;
+	private static final int MOTOR_DECELERATING = 8;
+	private static final int MOTOR_CONST_ACCEL = 16;
+	// Encoder status
+	private static final int ENCODER_FORWARD = 1;
+	private static final int ENCODER_BACKWARD = 2;
+	
+	/*
+	 * The following arrays of ArrayLists are used to store data received
+	 * from testing
+	 * For example, the 0th element of motorPWMData stores an ArrayList of
+	 * PWM information received from the first motor.
+	 * The 0th element of motorStatus stores an ArrayList of the same length
+	 * Each element is a bitmask with information such as the direction of
+	 * acceleration and whether the motor was running forwards or backwards
+	 */
+	private ArrayList[] bomData = new ArrayList[NUM_BOMS];
+	private ArrayList[] bomStatus = new ArrayList[NUM_BOMS];
+	private ArrayList[] rangefinderWallData = new ArrayList[NUM_RANGEFINDERS];
+	private ArrayList[] rangefinderRangeData = new ArrayList[NUM_RANGEFINDERS];
+	private ArrayList[] rangefinderStatus = new ArrayList[NUM_RANGEFINDERS];
+	private ArrayList[] motorPWMData = new ArrayList[NUM_MOTORS];
+	private ArrayList[] motorVelocityData = new ArrayList[NUM_MOTORS];
+	private ArrayList[] motorStatus = new ArrayList[NUM_MOTORS];
+	private ArrayList[] encoderDynamoData = new ArrayList[NUM_ENCODERS];
+	private ArrayList[] encoderValueData = new ArrayList[NUM_ENCODERS];
+	private ArrayList[] encoderStatus = new ArrayList[NUM_ENCODERS];	
+	
+	// The SerialComm object controls the connection to the station
+	private SerialComm serial;
+	// We send information to the gui
+	private ServerGUI gui;
+	
+	/*
+	 * Initializes gui, serial, and data arrays
+	 */
+	public DiagnosticsServer(){
+		gui = new ServerGUI(this);
+		try{
+			serial = new SerialComm(gui, "COM19", SerialComm.BAUDRATE_DEFAULT,
+					SerialComm.DATABITS_DEFAULT, SerialComm.STOPBITS_2,
+					SerialComm.PARITY_DEFAULT);
+		}
+		catch(IOException e){
+			System.out.println("Error connecting to serial");
+			System.out.println(e.getMessage());
+			System.out.println(e.getStackTrace());
+			return;
+		}
+		for(int i=0; i<NUM_BOMS; i++){
+			bomData[i] = new ArrayList<Integer>();
+			bomStatus[i] = new ArrayList<Integer>();
+		}
+		for(int i=0; i<NUM_RANGEFINDERS; i++){
+			rangefinderWallData[i] = new ArrayList<Integer>();
+			rangefinderRangeData[i] = new ArrayList<Integer>();
+			rangefinderStatus[i] = new ArrayList<Integer>();
+		}
+		for(int i=0; i<NUM_MOTORS; i++){
+			motorPWMData[i] = new ArrayList<Integer>();
+			motorVelocityData[i] = new ArrayList<Integer>();
+			motorStatus[i] = new ArrayList<Integer>();
+		}
+		for(int i=0; i<NUM_ENCODERS; i++){
+			encoderDynamoData[i] = new ArrayList<Integer>();
+			encoderValueData[i] = new ArrayList<Integer>();
+			encoderStatus[i] = new ArrayList<Integer>();
+		}
+	}
+	/*
+	 * The returned array has an even number of entries
+	 * The first of each pair is an ArrayList of X entries
+	 * The second of each pair is an ArrayList of the corresponding Y entries
+	 */
+	public ArrayList[] getData(int testType, int testNum){
+		ArrayList data[] = new ArrayList[2];
+		int arrSize = 2;
+		
+		switch(testType){
+		case ALL_TESTS:
+			data = null;
+			break;
+		case RANGEFINDER:
+			if(testNum == ALL_ELEMENTS){
+				arrSize = 2 * NUM_RANGEFINDERS;
+				data = new ArrayList[arrSize];
+				for(int i=0; i<arrSize/2; i++){
+					data[i*2] = rangefinderWallData[i];
+					data[i*2 + 1] = rangefinderRangeData[i];
+				}
+			}
+			else{
+				data = new ArrayList[arrSize];
+				data[0] = rangefinderWallData[testNum];
+				data[1] = rangefinderRangeData[testNum];
+			}
+			break;
+		case ENCODER:
+			if(testNum == ALL_ELEMENTS){
+				arrSize = 2 * NUM_ENCODERS;
+				data = new ArrayList[arrSize];
+				for(int i=0; i<arrSize/2; i++){
+					data[i*2] = encoderDynamoData[i];
+					data[i*2 + 1] = encoderValueData[i];
+				}
+			}
+			else{
+				data = new ArrayList[arrSize];
+				data[0] = encoderDynamoData[testNum];
+				data[1] = encoderValueData[testNum];
+			}
+			break;
+		case MOTOR:
+			if(testNum == ALL_ELEMENTS){
+				arrSize = 2 * NUM_MOTORS;
+				data = new ArrayList[arrSize];
+				for(int i=0; i<arrSize/2; i++){
+					data[i*2] = motorPWMData[i];
+					data[i*2 + 1] = motorVelocityData[i];
+				}
+			}
+			else{
+				data = new ArrayList[arrSize];
+				data[0] = motorPWMData[testNum];
+				data[1] = motorVelocityData[testNum];
+			}
+			break;
+		case BOM:
+			if(testNum == ALL_ELEMENTS){
+				arrSize = 2 * NUM_BOMS;
+				data = new ArrayList[arrSize];
+				for(int i=0; i<arrSize/2; i++){
+					ArrayList<Integer> trials = new ArrayList<Integer>();
+					for(int j=1; j<=bomData[i].size(); j++)
+						trials.add(j);
+					data[i*2] = trials;
+					data[i*2 + 1] = bomData[i];
+				}
+			}
+			else{
+				data = new ArrayList[arrSize];
+				ArrayList<Integer> trials = new ArrayList<Integer>();
+				for(int j=1; j<=bomData[testNum].size(); j++)
+					trials.add(j);
+				data[0] = trials;
+				data[1] = bomData[testNum];
+			}
+			break;
+		case BOM_EMITTER:
+			if(testNum == ALL_ELEMENTS){
+				arrSize = 2 * NUM_BOMS;
+				data = new ArrayList[arrSize];
+				for(int i=0; i<arrSize/2; i++){
+					ArrayList<Integer> bomEmitterData = getSubset(bomData[i],
+							bomStatus[i], BOM_EMITTER);
+					ArrayList<Integer> trials = new ArrayList<Integer>();
+					for(int j=1; j<=bomEmitterData.size(); j++)
+						trials.add(j);
+					data[i*2] = trials;
+					data[i*2 + 1] = bomEmitterData;
+				}
+			}
+			else{
+				data = new ArrayList[arrSize];
+				ArrayList<Integer> trials = new ArrayList<Integer>();
+				ArrayList<Integer> bomEmitterData = getSubset(bomData[testNum],
+						bomStatus[testNum], BOM_EMITTER);
+				for(int j=1; j<=bomEmitterData.size(); j++)
+					trials.add(j);
+				data[0] = trials;
+				data[1] = bomEmitterData;
+			}
+			break;
+		case BOM_DETECTOR:
+			if(testNum == ALL_ELEMENTS){
+				arrSize = 2 * NUM_BOMS;
+				data = new ArrayList[arrSize];
+				for(int i=0; i<arrSize/2; i++){
+					ArrayList<Integer> bomDetectorData = getSubset(bomData[i],
+							bomStatus[i], BOM_DETECTOR);
+					ArrayList<Integer> trials = new ArrayList<Integer>();
+					for(int j=1; j<=bomDetectorData.size(); j++)
+						trials.add(j);
+					data[i*2] = trials;
+					data[i*2 + 1] = bomDetectorData;
+				}
+			}
+			else{
+				data = new ArrayList[arrSize];
+				ArrayList<Integer> trials = new ArrayList<Integer>();
+				ArrayList<Integer> bomDetectorData = getSubset(bomData[testNum],
+						bomStatus[testNum], BOM_DETECTOR);
+				for(int j=1; j<=bomDetectorData.size(); j++)
+					trials.add(j);
+				data[0] = trials;
+				data[1] = bomDetectorData;
+			}
+			break;
+		}
+		return data;
+	}
+	
+	/*
+	 * The first entry is the chart title
+	 * The next two entries are the X and Y axis labels
+	 * The following entries are the labels for each series
+	 */
+	public String[] getLabels(int testType, int testNum){
+		String labels[];
+		int arrSize = 4;
+		
+		switch(testType){
+		case ALL_TESTS:
+			labels = new String[arrSize];
+			labels[0] = "";
+			labels[1] = "";
+			labels[2] = "";
+			labels[3] = "";
+			break;
+		case RANGEFINDER:
+			if(testNum == -1)
+				arrSize += NUM_RANGEFINDERS - 1;
+			labels = new String[arrSize];
+			labels[0] = "Rangefinder Data";
+			labels[1] = "Wall Data";
+			labels[2] = "Rangefinder Output";
+			if(testNum == -1){
+				for(int i=0; i<NUM_RANGEFINDERS; i++)
+					labels[i+3] = "" + (i + RANGEFINDER_OFFSET);
+			}
+			else
+				labels[3] = "" + (testNum + RANGEFINDER_OFFSET);
+			break;
+		case ENCODER:
+			if(testNum == -1)
+				arrSize += NUM_ENCODERS - 1;
+			labels = new String[arrSize];
+			labels[0] = "Encoder Data";
+			labels[1] = "Dynamo Data";
+			labels[2] = "Encoder Output";
+			if(testNum == -1){
+				for(int i=0; i<NUM_ENCODERS; i++)
+					labels[i+3] = "" + (i + ENCODER_OFFSET);
+			}
+			else
+				labels[3] = "" + (testNum + ENCODER_OFFSET);
+			break;
+		case MOTOR:
+			if(testNum == -1)
+				arrSize += NUM_MOTORS - 1;
+			labels = new String[arrSize];
+			labels[0] = "Motor Data";
+			labels[1] = "PWM Data";
+			labels[2] = "Motor Velocity Data";
+			if(testNum == -1){
+				for(int i=0; i<NUM_MOTORS; i++)
+					labels[i+3] = "" + (i + MOTOR_OFFSET);
+			}
+			else
+				labels[3] = "" + (testNum + MOTOR_OFFSET);
+			break;
+		case BOM:
+			if(testNum == -1)
+				arrSize += NUM_BOMS - 1;
+			labels = new String[arrSize];
+			labels[0] = "Bom Data";
+			labels[1] = "Test Number";
+			labels[2] = "BOM Reading";
+			if(testNum == -1){
+				for(int i=0; i<NUM_BOMS; i++)
+					labels[i+3] = "" + (i + BOM_OFFSET);
+			}
+			else
+				labels[3] = "" + (testNum + BOM_OFFSET);
+			break;
+		case BOM_EMITTER:
+			if(testNum == -1)
+				arrSize += NUM_BOMS - 1;
+			labels = new String[arrSize];
+			labels[0] = "Bom Emitter Data";
+			labels[1] = "Test Number";
+			labels[2] = "BOM Emitter Reading";
+			if(testNum == -1){
+				for(int i=0; i<NUM_BOMS; i++)
+					labels[i+3] = "" + (i + BOM_OFFSET);
+			}
+			else
+				labels[3] = "" + (testNum + BOM_OFFSET);
+			break;
+		case BOM_DETECTOR:
+			if(testNum == -1)
+				arrSize += NUM_BOMS - 1;
+			labels = new String[arrSize];
+			labels[0] = "Bom Detector Data";
+			labels[1] = "Test Number";
+			labels[2] = "BOM Detector Reading";
+			if(testNum == -1){
+				for(int i=0; i<NUM_BOMS; i++)
+					labels[i+3] = "" + (i + BOM_OFFSET);
+			}
+			else
+				labels[3] = "" + (testNum + BOM_OFFSET);
+			break;
+		default:
+			labels = new String[arrSize];
+			labels[0] = "";
+			labels[1] = "";
+			labels[2] = "";
+			labels[3] = "";
+		}
+		return labels;
+	}
+	
+	/*
+	 * Starts running the given test on all elements
+	 */
+	public void startTest(int testType) throws Exception{
+		startTest(testType, ALL_ELEMENTS);
+	}
+	
+	/*
+	 * Starts running the specified test on the specified element
+	 */
+	public void startTest(int testType, int num) throws Exception{
+		String command = getStartTestCommand(testType, num);
+		if(command == null){
+			System.out.println("Illegal test requested\n");
+			return;
+		}
+		gui.addTextToConsole(command);
+		serial.puts(command);
+		boolean ready = false;
+		while(!ready){
+			String input = getInput();
+			int parseStatus = parseInput(input);
+			if(parseStatus == READY)
+				ready = true;
+		}
+		printData(testType);
+	}
+	
+	/*
+	 * Stops the running test
+	 */
+	public void stopTest() throws Exception{
+		serial.puts("stop\r\n");
+	}
+	
+	/*
+	 * Prints out the received data - good for debugging if the grapher is malfunctioning
+	 */
+	public void printData(int test){
+		switch(test){
+		case ALL_TESTS:
+			printData(RANGEFINDER);
+			printData(ENCODER);
+			printData(MOTOR);
+			printData(BOM);
+			break;
+		case RANGEFINDER:
+			System.out.println("Rangefinder Wall Data:");
+			print(rangefinderWallData);
+			System.out.println("Rangefinder Range Data:");
+			print(rangefinderRangeData);
+			break;
+		case ENCODER:
+			System.out.println("Encoder Dynamo Data:");
+			print(encoderDynamoData);
+			System.out.println("Encoder Value Data:");
+			print(encoderValueData);
+			break;
+		case MOTOR:
+			System.out.println("Motor PWM Data:");
+			print(motorPWMData);
+			System.out.println("Motor Velocity Data:");
+			print(motorVelocityData);
+			break;
+		case BOM:
+			printData(BOM_EMITTER);
+			printData(BOM_DETECTOR);
+			break;
+		case BOM_EMITTER:
+			System.out.println("BOM emitter Data:");
+			printStatus(bomData, bomStatus, EMITTER);
+			break;
+		case BOM_DETECTOR:
+			System.out.println("BOM detector Data:");
+			printStatus(bomData, bomStatus, DETECTOR|DETECTOR_OUT);
+			break;
+		}
+	}
+	
+	/*
+	 * Picks out the given subset of the given data
+	 */
+	private ArrayList<Integer> getSubset(ArrayList data, ArrayList status, int bitmask){
+		ArrayList<Integer> arr = new ArrayList<Integer>();
+		for(int i=0; i< status.size(); i++){
+			if(((Integer)status.get(i) & bitmask) == bitmask){
+				arr.add((Integer)data.get(i));
+			}
+		}
+		return arr;
+	}
+	
+	/*
+	 * Prints out the current status
+	 */
+	private void printStatus(ArrayList data[], ArrayList status[], int bitmask){
+		for(int i=0; i<status.length; i++){
+			System.out.print(i + ": ");
+			printStatus(data[i], status[i], bitmask);
+			System.out.println();
+		}	
+	}
+	
+	/*
+	 * Prints the current status
+	 */
+	private void printStatus(ArrayList data, ArrayList status, int bitmask){
+		System.out.print("[");
+		boolean first = true;
+		for(int i=0; i< status.size(); i++){
+			if(((Integer)status.get(i) & bitmask) == bitmask){
+				if(!first)
+					System.out.print(", ");
+				System.out.print(data.get(i));
+				first = false;
+			}
+		}
+		System.out.print("]");
+	}
+	
+	/*
+	 * Prints an ArrayList of arrays
+	 */
+	private void print(ArrayList arr[]){
+		for(int i=0; i<arr.length; i++){
+			System.out.print(i + ": ");
+			print(arr[i]);
+			System.out.println();
+		}			
+	}
+	
+	/*
+	 * Prints an array
+	 */
+	private void print(ArrayList arr){
+		System.out.print("[");
+		for(int i=0; i< arr.size(); i++){
+			System.out.print(arr.get(i));
+			if(i < arr.size() - 1)
+				System.out.print(", ");
+		}
+		System.out.print("]");
+	}
+	
+	/*
+	 * Returns the command to pass to the server, or null if the
+	 * request is malformed
+	 */
+	public String getStartTestCommand(int testType, int num){
+		String command = "start_test";
+		switch(testType){
+		case ALL_TESTS:
+			command += " all\n";
+			return command;
+		case RANGEFINDER:
+			command += " rangefinder";
+			break;
+		case ENCODER:
+			command += " encoder";
+			break;
+		case MOTOR:
+			command += " motor";
+			break;
+		case BOM:
+			command += " bom";
+			break;
+		case BOM_EMITTER:
+			command += " bom emitter";
+			break;
+		case BOM_DETECTOR:
+			command += " bom detector";
+			break;
+		default:
+			return null;
+		}
+		if(num == -1)
+			command += " all";
+		else
+			command += " " + num;
+		return command + "\n";
+	}
+	
+	/*
+	 * Sends the given message to the station
+	 */
+	public void send_message(String s) throws Exception{
+		serial.puts(s);
+	}
+	
+	/*
+	 * Prints out all data received (this method hangs permanently)
+	 */
+	public String getInput() throws Exception{
+		while(true){
+			String rec = serial.gets();
+			if(rec != null)
+				return rec;
+		}
+	}
+	
+	/*
+	 * Prints any received data (hangs for ms milliseconds)
+	 */
+	public String getInput(int ms) throws Exception{
+		long time = System.currentTimeMillis();
+		while(true){
+			if(System.currentTimeMillis() - time > ms){
+				System.out.println("Operation timed out\n");
+				return null;
+			}
+			String rec = serial.gets();
+			if(rec != null)
+				return rec;
+		}
+	}
+	
+	/*
+	 * Parses the input to determine which kind of request is being received
+	 */
+	private int parseInput(String s){
+		if(s.charAt(0) == '#' || s.charAt(0) == '\n' || s.charAt(0) == '\r'){
+			System.out.print(s);
+			return COMMENT;
+		}
+		else if(s.startsWith("data")){
+			if(parseData(s.substring(4)))
+				return DATA;
+			else{
+				System.out.println("Error parsing data >" + s + "<");
+				return PARSE_ERROR;
+			}
+		}
+		else if(s.startsWith("ready"))
+			return READY;
+		else{
+			System.out.println("Unable to parse message >" + s + "<");
+			return PARSE_ERROR;
+		}
+	}
+	
+	/*
+	 * Parses data messages
+	 */
+	private boolean parseData(String s){
+		try{
+			Scanner scan = new Scanner(s);
+			String testType = scan.next();
+			if(testType.equals("bom")){
+				ArrayList<Integer> dataArr = new ArrayList<Integer>();
+				ArrayList<Integer> statusArr = new ArrayList<Integer>();
+				
+				String emDet = scan.next();
+				int num = scan.nextInt();
+				if(num >= NUM_BOMS){
+					System.out.println("Invalid bom index: " + num);
+					return false;
+				}
+				
+				if(emDet.equals("emitter")){
+					while(scan.hasNext()){
+						int mask = EMITTER;
+						String data = scan.next();
+						if(data.startsWith("top"))
+							mask |= EMITTER_TOP;
+						else if(data.startsWith("left"))
+							mask |= EMITTER_LEFT;
+						else if(data.startsWith("right"))
+							mask |= EMITTER_RIGHT;
+						else
+							return false;
+						
+						int slashIdx = data.indexOf("/");
+						int value = Integer.valueOf(data.substring(
+								slashIdx+1));
+						dataArr.add(value);
+						statusArr.add(mask);
+					}
+					bomData[num].addAll(dataArr);
+					bomStatus[num].addAll(statusArr);
+					return true;
+				}
+				else if(emDet.equals("detector")){
+					while(scan.hasNext()){
+						int mask = DETECTOR;
+						String data = scan.next();
+						int dataStart;
+						if(data.startsWith("in")){
+							mask |= DETECTOR_IN;
+							dataStart = 3;
+						}
+						else if(data.startsWith("out")){
+							mask |= DETECTOR_OUT;
+							dataStart = 4;
+						}
+						else
+							return false;
+						if(data.charAt(dataStart-1) != '/')
+							return false;
+						int value = Integer.valueOf(data.substring(dataStart));
+						dataArr.add(value);
+						statusArr.add(mask);
+					}
+					bomData[num].addAll(dataArr);
+					bomStatus[num].addAll(statusArr);
+					return true;
+				}
+				else
+					return false;
+			}
+			else if(testType.equals("rangefinder")){
+				ArrayList<Integer> dataWallArr = new ArrayList<Integer>();
+				ArrayList<Integer> dataRangeArr = new ArrayList<Integer>();
+				ArrayList<Integer> statusArr = new ArrayList<Integer>();
+
+				int num = scan.nextInt();
+				if(num >= NUM_RANGEFINDERS){
+					System.out.println("Invalid rangefinder index: " + num);
+					return false;
+				}
+				
+				String dir = scan.next();
+				int mask;
+				if(dir.equals("in"))
+					mask = RANGEFINDER_IN;
+				else if(dir.equals("out"))
+					mask = RANGEFINDER_OUT;
+				else
+					return false;
+
+				while(scan.hasNext()){
+					String data = scan.next();
+
+					int slashIdx = data.indexOf("/");
+					int wallDist = Integer.valueOf(data.substring(0,
+							slashIdx));
+					int rangefinderReading = Integer.valueOf(data.substring(
+							slashIdx+1));
+					
+					dataWallArr.add(wallDist);
+					dataRangeArr.add(rangefinderReading);
+					statusArr.add(mask);
+				}
+				rangefinderWallData[num].addAll(dataWallArr);
+				rangefinderRangeData[num].addAll(dataRangeArr);
+				rangefinderStatus[num].addAll(statusArr);
+				return true;
+			}
+			else if(testType.equals("motor")){
+				ArrayList<Integer> dataPWMArr = new ArrayList<Integer>();
+				ArrayList<Integer> dataVelocityArr = new ArrayList<Integer>();
+				ArrayList<Integer> statusArr = new ArrayList<Integer>();
+
+				int num = scan.nextInt();
+				if(num >= NUM_MOTORS){
+					System.out.println("Invalid motor index: " + num);
+					return false;
+				}
+				
+				String dir = scan.next();
+				int mask;
+				boolean forward = true;
+				if(dir.equals("forward"))
+					mask = MOTOR_FORWARD;
+				else if(dir.equals("backward")){
+					mask = MOTOR_BACKWARD;
+					forward = false;
+				}
+				else
+					return false;
+				
+				String accel = scan.next();
+				if(accel.equals("increasing"))
+					mask |= MOTOR_ACCELERATING;
+				else if(accel.equals("decreasing"))
+					mask |= MOTOR_DECELERATING;
+				else if(accel.equals("constant"))
+					mask |= MOTOR_CONST_ACCEL;
+				else
+					return false;
+
+				while(scan.hasNext()){
+					String data = scan.next();
+
+					int slashIdx = data.indexOf("/");
+					int pwm = Integer.valueOf(data.substring(0,
+							slashIdx));
+					int velocity = Integer.valueOf(data.substring(
+							slashIdx+1));
+					if(forward)
+						dataPWMArr.add(pwm);
+					else
+						dataPWMArr.add(-1 * pwm);
+					dataVelocityArr.add(velocity);
+					statusArr.add(mask);
+				}
+				motorPWMData[num].addAll(dataPWMArr);
+				motorVelocityData[num].addAll(dataVelocityArr);
+				motorStatus[num].addAll(statusArr);
+				return true;
+			}
+			else if(testType.equals("encoder")){
+				ArrayList<Integer> dataDynamoArr = new ArrayList<Integer>();
+				ArrayList<Integer> dataEncoderArr = new ArrayList<Integer>();
+				ArrayList<Integer> statusArr = new ArrayList<Integer>();
+
+				int num = scan.nextInt();
+				if(num >= NUM_ENCODERS){
+					System.out.println("Invalid encoder index: " + num);
+					return false;
+				}
+				
+				String dir = scan.next();
+				int mask;
+				if(dir.equals("forward"))
+					mask = ENCODER_FORWARD;
+				else if(dir.equals("backward"))
+					mask = ENCODER_BACKWARD;
+				else
+					return false;
+
+				while(scan.hasNext()){
+					String data = scan.next();
+
+					int slashIdx = data.indexOf("/");
+					int dynamo = Integer.valueOf(data.substring(0,
+							slashIdx));
+					int encoder = Integer.valueOf(data.substring(
+							slashIdx+1));
+					
+					dataDynamoArr.add(dynamo);
+					dataEncoderArr.add(encoder);
+					statusArr.add(mask);
+				}
+				encoderDynamoData[num].addAll(dataDynamoArr);
+				encoderValueData[num].addAll(dataEncoderArr);
+				encoderStatus[num].addAll(statusArr);
+				return true;
+			}
+			else
+				return false;
+			}
+		catch(Exception e){
+			return false;
+		}
+	}
+	
+	/*
+	 * Pings the station
+	 */
+	public void ping() throws Exception{
+		serial.puts("ping\n");
+		System.out.println(serial.gets());
+	}
+	
+	/*
+	 * Receives pings and returns a pong
+	 */
+	public void receive_ping() throws Exception{
+		String in = serial.gets();
+		if(in == "#ping\n")
+			serial.puts("#pong\n");
+		else
+			System.out.println("Message received was not a ping.  " +
+					"Message was:\n" + in);
+	}
+}
Index: trunk/code/projects/diagnostic_station/server/jcommon-1.0.16.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/code/projects/diagnostic_station/server/jcommon-1.0.16.jar
===================================================================
--- trunk/code/projects/diagnostic_station/server/jcommon-1.0.16.jar	(nonexistent)
+++ trunk/code/projects/diagnostic_station/server/jcommon-1.0.16.jar	(revision 1606)

Property changes on: trunk/code/projects/diagnostic_station/server/jcommon-1.0.16.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
