Index: trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleTest.java	(revision 47)
@@ -0,0 +1,601 @@
+package tmcsim.cadsimulator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import junit.framework.TestCase;
+import static org.mockito.Mockito.mock;
+import tmcsim.cadsimulator.viewer.CADConsoleViewer;
+import tmcsim.common.CADEnums;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+import tmcsim.interfaces.CADClientInterface;
+import tmcsim.interfaces.SimulationManagerInterface;
+
+/**
+ * Test of CADSimulator Console
+ *
+ * @author jdalbey
+ */
+public class CADSimulatorConsoleTest extends TestCase
+{
+
+    private static CADSimulator app = null;
+    private CADConsoleViewer console;
+    private StringWriter sw;
+
+    public CADSimulatorConsoleTest(String testName)
+    {
+        super(testName);
+    }
+
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        writeConfigData();
+        // Since CADSimulator has registry, we musn't instantiate it more than once
+        if (app == null)
+        {
+            try
+            {
+                app = new CADSimulator("config.txt");
+            } catch (Exception ex)
+            {
+                fail("Couldn't launch CADSimulator");
+            }
+        }
+        console = (CADConsoleViewer) app.theViewer;
+        sw = new StringWriter();
+        console.setWriter(sw);
+    }
+
+    @Override
+    public void tearDown() throws java.io.IOException
+    {
+        File removeMe = new File("config.txt");
+        removeMe.delete();
+        removeMe = new File("pconfig.txt");
+        removeMe.delete();
+        removeMe = new File("empty.txt");
+        removeMe.delete();
+    }
+
+    /**
+     * compare StringWriter contents against expected
+     */
+    private void verify(String msg, String expect)
+    {
+        String result = sw.toString().trim();
+        result = result.replaceAll("\n", ",");
+        String fullExpect = expect.trim();
+        fullExpect = fullExpect.replaceAll("\n", ",");
+//        System.out.println(fullExpect);
+//        System.out.println(result.substring(result.length() - fullExpect.length(), result.length()));
+//        String diff = StringUtils.difference(fullExpect, result);
+        boolean match = result.endsWith(fullExpect);
+        assertTrue(msg + ": " + result, match);
+    }
+
+    public static void pause(int millis)
+    {
+        try
+        {
+            Thread.sleep(millis);
+        } catch (InterruptedException ex)
+        {
+        }
+    }
+
+    /**
+     * The tests must be all run in one method, because the order matters. As
+     * separate methods, we couldn't control which is executed first.
+     *
+     * @throws java.io.IOException
+     * @throws SimulationException
+     * @throws ScriptException
+     */
+    public void testAll() throws java.io.IOException, SimulationException, ScriptException
+    {
+        CADConsoleViewer console = (CADConsoleViewer) app.theViewer;
+        String expected1 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --";
+        System.out.println("setVisible");
+        console.setVisible(true);
+        verify("Initial output incorrect: ", expected1);
+        String expected2 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 1\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+
+        System.out.println("connect one");
+        CADClientInterface ci = mock(CADClientInterface.class);
+        app.theCoordinator.registerForCallback(ci);
+        verify("connected 1 terminal output incorrect: ", expected2);
+        String expected3 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 2\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        System.out.println("connect two");
+        app.theCoordinator.registerForCallback(ci);
+        verify("connected 2 terminals output incorrect: ", expected3);
+        System.out.println("disconnect");
+        app.theCoordinator.unregisterForCallback(ci);
+        verify("disconnect terminal output incorrect: ", expected2);
+        app.theCoordinator.unregisterForCallback(ci);
+        String expected4 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        System.out.println("sim mgr connect");
+        SimulationManagerInterface si = mock(SimulationManagerInterface.class);
+        app.theCoordinator.registerForCallback(si);
+        verify("sim mgr connected output incorrect: ", expected4);
+        String expected5 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n"
+                + ". = Console Info Message.\n"
+                + "-- Error Messages --\n\n";
+        System.out.println("Info msg");
+        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.INFO, "", "", "Console Info Message.");
+        verify("Info message output incorrect: ", expected5);
+        String expected7 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n"
+                + ". = Console Info Message.\n"
+                + "-- Error Messages --\n"
+                + "Someclass.Somemethod = Something bad happened.\n";
+        System.out.println("Error msg");
+        cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.SEVERE, "Someclass", "Somemethod", "Something bad happened.");
+        verify("Error message output incorrect: ", expected7);
+        String expected6 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : Yes\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n"
+                + ". = Console Info Message.\n"
+                + "-- Error Messages --\n"
+                + "Someclass.Somemethod = Something bad happened.\n";
+        System.out.println("Paramics connect");
+        app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED);
+        pause(500);
+        pause(500);
+        verify("paramics connected should be yes", expected6);
+        String expected8 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : Ready\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : Yes\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n"
+                + ". = Console Info Message.\n"
+                + "-- Error Messages --\n"
+                + "Someclass.Somemethod = Something bad happened.\n";
+        String expected9 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:01\n"
+                + "Status                      : Running\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : Yes\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n"
+                + ". = Console Info Message.\n"
+                + "-- Error Messages --\n"
+                + "Someclass.Somemethod = Something bad happened.\n";
+        System.out.println("Sim status");
+        // Load a script file - to put status at Ready
+        String autoloadScriptname = "scripts/one-incident.xml";
+        app.theCoordinator.loadScriptFile(new File(autoloadScriptname));
+        pause(500);
+        verify("Status should be 'ready'", expected8);
+        // startSimulation to put status at Running
+        app.theCoordinator.startSimulation();
+        pause(500);
+        verify("Status should be 'running', time should be 0:01", expected9);
+    }
+//    public void testNetworkID()
+//    {
+//        String expected10 =
+//                "--- CAD Simulator ---\n"
+//                + "Elapsed Simulation Time     : 0:00:00\n"
+//                + "Status                      : No Script\n"
+//                + "Connected CAD Terminals     : 0\n"
+//                + "Simulation Manager Connected: No\n"
+//                + "Connected to Paramics       : No\n"
+//                + "Network Loaded              : 17\n"
+//                + "-- Info Messages --\n\n"
+//                + "-- Error Messages --\n\n";
+//        // this will tell the model it has a new network ID
+//        cadmodel.setParamicsNetworkLoaded("17");
+//        cadmodel.setParamicsStatus(CADEnums.PARAMICS_STATUS.LOADED);
+//        pause(500);
+//        verify("network id should be 17", expected10);
+//    }
+//    ByteArrayOutputStream bos;
+//    PrintStream ps;
+    static final String configData =
+            "CADClientPort          = 4444 \n"
+            + "CoordinatorRMIPort     = 4445 \n"
+            + "CADRmiPort             = 4446 \n"
+            + "UserInterface          = tmcsim.cadsimulator.viewer.CADConsoleViewer\n"
+            + "ParamicsProperties     = pconfig.txt\n"
+            + "ATMSProperties         = empty.txt\n"
+            + "MediaProperties        = empty.txt\n";
+    static final String paramicsData = "ParamicsCommHost = 127.0.0.1\n"
+            + "ParamicsCommPort       = 4450\n"
+            + "IncidentUpdateInterval = 30\n"
+            + "IncidentUpdateFile     = exchange.xml\n"
+            + "ParamicsStatusInterval = 15\n"
+            + "ParamicsStatusFile     = paramics_status.xml\n"
+            + "CameraStatusInterval   = 30\n"
+            + "CameraStatusFile       = camera_status.xml\n";
+    static final String cardfileURL = "http://pastebin.com/raw/Yr26nfp7";
+    static final String smallXMLURL = "http://pastebin.com/raw/Eqj2N5qD";
+    /*
+     * Creating instance of app must be done only once or you get registry
+     * bind problems, and code Written in Constructor is Executed
+     * before each Test Method
+     */
+
+    private void writeConfigData()
+    {
+        // Declare a stream to the output
+//        bos = new ByteArrayOutputStream();
+//        ps = new PrintStream(bos);
+        // Redirect the standard output
+//        System.setOut(ps);
+        writedata("config.txt", configData);
+        writedata("pconfig.txt", paramicsData);
+        writedata("empty.txt", "");
+        writeScriptfiles();
+    }
+
+    private void writeScriptfiles()
+    {
+        new File("scripts").mkdir();
+        writedata("scripts/Cardfile.xml", cardfileData);
+        writedata("scripts/one-incident.xml", oneincidentXML);
+    }
+
+    // Write the test data to a file
+    private void writedata(String filename, String data)
+    {
+        File cardFile = new File(filename);
+        // If a cardfile exists, leave it
+        if (!cardFile.exists())
+        {
+            PrintWriter writer = null;
+            try
+            {
+                writer = new PrintWriter(new FileWriter(filename));
+                writer.println(data);
+                writer.close();
+            } catch (Exception ex)
+            {
+                ex.printStackTrace();
+            }
+        }
+    }
+    private static final String cardfileData =
+            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+            + "<!--Please do not modify titles. Note that these titles are not"
+            + "sent into the actual screen. If titles are to be modified,"
+            + "they need to be changed in CardfileHandler.java  -->"
+            + ""
+            + ""
+            + ""
+            + "<CARDFILE> "
+            + "	<TAB title = \"Coastal Division Units\">"
+            + "		<CARDFILE_OBJ name = \"Name\" >"
+            + "			<ADDRESS>Address</ADDRESS>"
+            + "			<CITY>City</CITY>"
+            + "			<STATE>State</STATE>"
+            + "			<ZIP>Zip</ZIP>"
+            + "			<PHONE1>Phone1</PHONE1>"
+            + "			<PHONE2>Phone2</PHONE2>"
+            + "			<FAX>Fax</FAX>"
+            + "		</CARDFILE_OBJ>"
+            + "		"
+            + "		<CARDFILE_OBJ  name = \"Name2\" >"
+            + "			<ADDRESS>Address2</ADDRESS>"
+            + "			<CITY>City2</CITY>"
+            + "			<STATE>State2</STATE>"
+            + "			<ZIP>Zip2</ZIP>"
+            + "			<PHONE1>Phone12</PHONE1>"
+            + "			<PHONE2>Phone22</PHONE2>"
+            + "			<FAX>Fax2</FAX>"
+            + "		</CARDFILE_OBJ>"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Police/Sheriff/Coroner\">"
+            + "	"
+            + "		<CARDFILE_OBJ  name = \"Name\" >"
+            + "			<ADDRESS>Address</ADDRESS>"
+            + "			<CITY>City</CITY>"
+            + "			<STATE>State</STATE>"
+            + "			<ZIP>Zip</ZIP>"
+            + "			<PHONE1>Phone1</PHONE1>"
+            + "			<PHONE2>Phone2</PHONE2>"
+            + "			<FAX>Fax</FAX>"
+            + "		</CARDFILE_OBJ>"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Courts\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Public Transportation\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"GG Other\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"MY Misc\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"SL Misc\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"VT Misc\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"CHP Offices\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"State Agencies/Facilities\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Government Officials\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Federal Agencies\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Fire/EMS\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Jails\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Hospitals/Med Centers\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Tow Companies\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"CalTrans\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"County Roads\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Utilities\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Animal Control\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Airports\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Credit Cards\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"GG Crisis Shelters\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Ranges\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Hotlines\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Hwy Patrols OOS\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Parks/Recreation\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Shelters\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"SL County Services\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"SL Resources\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Truck/Tire Repair\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"MCC Employees\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Gate Access Codes\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"VT Call Signs\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"SLCC Employees\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + ""
+            + "</CARDFILE>";
+    private static final String oneincidentXML =
+            "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
+            + ""
+            + "<TMC_SCRIPT title=\"One Incident Simulation\">"
+            + ""
+            + "	<SCRIPT_EVENT>"
+            + "		<TIME_INDEX>00:00:00</TIME_INDEX>"
+            + "		<INCIDENT LogNum=\"100\">Media Log</INCIDENT>		"
+            + "		"
+            + "		<CAD_DATA>"
+            + "			<HEADER_INFO>"
+            + "				<Type>Media</Type>"
+            + "				<Beat>"
+            + "				</Beat>"
+            + "				<TruncLoc>"
+            + "				</TruncLoc>"
+            + "				<FullLoc>"
+            + "				</FullLoc>"
+            + "			</HEADER_INFO>			"
+            + "			"
+            + "			<CAD_INCIDENT_EVENT>	"
+            + "			</CAD_INCIDENT_EVENT>		"
+            + "			"
+            + "		</CAD_DATA>				"
+            + "		"
+            + "	</SCRIPT_EVENT>	"
+            + "</TMC_SCRIPT>";
+}
Index: trunk/test/tmcsim/cadsimulator/CADSimulatorGUITest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/CADSimulatorGUITest.java	(revision 34)
+++ trunk/test/tmcsim/cadsimulator/CADSimulatorGUITest.java	(revision 47)
@@ -5,5 +5,4 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
-
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.fail;
@@ -50,26 +49,4 @@
         removeMe.delete();
     }
-
-    /**
-     * Test of getCADTime method, of class CADSimulator.
-     */
-    public void testGetCADTime()
-    {
-        System.out.println("getCADTime");
-        String result = CADSimulator.getCADTime();
-        // Just test length for now
-        assertEquals(4, result.length());
-    }
-
-    /**
-     * Test of getCADDate method, of class CADSimulator.
-     */
-    public void testGetCADDate()
-    {
-        System.out.println("getCADDate");
-        String result = CADSimulator.getCADDate();
-        // Just test length for now
-        assertEquals(6, result.length());
-    }
     /**
      * Test of main method, of class CADSimulator.
@@ -79,9 +56,17 @@
     public void testConstructor() throws SimulationException, RemoteException, ScriptException
     {
+        System.out.println("CADSimulator constructor");
         CADSimulatorFixture.writeConfigData();
         CADSimulatorFixture.writedata("config.txt", configData);
-        System.out.println("CADSimulator constructor");
+        Window cadwindow = null;
+//        try
+//        {
+//            app = new CADSimulator("config.txt");
+//        } catch (Exception e)
+//        {
+//            fail("Couldn't launch CADSimulator" + e.getMessage());
+//        }
+
         System.setProperty("CONFIG_DIR", "config/testConfig");
-        Window cadwindow = null;
         if (System.getProperty("CONFIG_DIR") != null)
         {
@@ -100,33 +85,41 @@
                 }
             });
-        } else
+        }
+        else
         {
             fail("CONFIG_DIR system property not defined.");
         }
-        assertEquals("CAD Simulator", cadwindow.getTitle());
+
+        System.out.println("Tests for text fields.");
+        // Create a UISpec window from the CADSimulator's Viewer (gui)
+//        cadwindow = new Window((CADSimulatorViewer) app.theViewer);
+        assertTrue("Title bar incorrect", cadwindow.getTitle().startsWith("CAD Simulator revision:"));
         Panel mainPanel = cadwindow.getPanel("contentPane");
         TextBox txtStatus = mainPanel.getTextBox("simulationStatus");
-        assertEquals("No Script", txtStatus.getText());
+        assertEquals("simulation status should say No Script", "No Script", txtStatus.getText().trim());
         TextBox terminals = mainPanel.getTextBox("termConnectedTF");
-        assertEquals("0", terminals.getText().trim());
-        assertEquals("No", mainPanel.getTextBox("managerConnectedTF").getText().trim());
-        assertEquals("0:00:00", mainPanel.getTextBox("simulationClockLabel").getText());
+        assertEquals("should be 0 terminals", "0", terminals.getText().trim());
+        assertEquals("mgr connected should be no", "No", mainPanel.getTextBox("managerConnectedTF").getText().trim());
+        assertEquals("paramics connected should be no", "No", mainPanel.getTextBox("paramicsConnectedTF").getText().trim());
+        assertEquals("initial time should be 0:00:00", "0:00:00", mainPanel.getTextBox("simulationClockLabel").getText().trim());
 
-        CADClientInterface ci = new FakeClient();
+        CADClientInterface ci = mock(CADClientInterface.class);
         app.theCoordinator.registerForCallback(ci);
-        assertEquals("1", terminals.getText().trim());
+        assertEquals("should be 1 terminal", "1", terminals.getText().trim());
         app.theCoordinator.registerForCallback(ci);
-        assertEquals("2", terminals.getText().trim());
+        assertEquals("should be 2 terminals", "2", terminals.getText().trim());
 
         SimulationManagerInterface si = mock(SimulationManagerInterface.class);
+
         app.theCoordinator.registerForCallback(si);
-        assertEquals("Yes", mainPanel.getTextBox("managerConnectedTF").getText().trim());
+        assertEquals("mgr connected should be yes", "Yes", mainPanel.getTextBox("managerConnectedTF").getText().trim());
 
         Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
         cadSimLogger.logp(Level.INFO, "", "", "Sample Info Message.");
 
+        System.out.println("Tests for message panes.");
         Panel infoPane = mainPanel.getPanel("infoMessagesPane");
         TextBox infoText = infoPane.getTextBox("infoMessagesTA");
-        assertEquals(". = Sample Info Message.", infoText.getText().trim());
+        assertEquals("wrong info msg text", ". = Sample Info Message.", infoText.getText().trim());
 
         cadSimLogger.logp(Level.SEVERE, "", "", "Sample Error Message.");
@@ -134,10 +127,11 @@
         Panel errPane = mainPanel.getPanel("errorMessagesPane");
         TextBox errText = errPane.getTextBox("errorMessagesTA");
-        assertEquals(". = Sample Error Message.", errText.getText().trim());
+        assertEquals("wrong error msg text", ". = Sample Error Message.", errText.getText().trim());
 
+        System.out.println("Tests for status changes.");
         app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED);
         CADSimulatorFixture.pause(500);
-        assertEquals("Yes", mainPanel.getTextBox("paramicsConnectedTF").getText().trim());
-        assertEquals("None", mainPanel.getTextBox("networkLoadedTF").getText().trim());
+        assertEquals("paramics connected should be yes", "Yes", mainPanel.getTextBox("paramicsConnectedTF").getText().trim());
+        assertEquals("network id should be None", "None", mainPanel.getTextBox("networkLoadedTF").getText().trim());
 
 //        app.theCoordinator.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING);
@@ -148,35 +142,21 @@
         app.theCoordinator.loadScriptFile(new File(autoloadScriptname));
         // The status should now say Ready
-        assertEquals("Ready", mainPanel.getTextBox("simulationStatus").getText().trim());
+        assertEquals("sim status should be ready", "Ready", mainPanel.getTextBox("simulationStatus").getText().trim());
 
         app.theCoordinator.startSimulation();
-        CADSimulatorFixture.pause(500);
-        assertEquals("Running", mainPanel.getTextBox("simulationStatus").getText().trim());
-        assertEquals("0:00:01", mainPanel.getTextBox("simulationClockLabel").getText());
+        CADSimulatorFixture.pause(900);
+        assertEquals("sim status should be running", "Running", mainPanel.getTextBox("simulationStatus").getText().trim());
+        assertEquals("sim time should be 0:00:01", "0:00:01", mainPanel.getTextBox("simulationClockLabel").getText().trim());
 
         ParamicsSimulationManager psm = mock(ParamicsSimulationManager.class);
         when(psm.isConnected()).thenReturn(Boolean.TRUE);
+        when(psm.getParamicsNetworkLoaded()).thenReturn(1); // provide the network ID to return
         app.theParamicsSimMgr = psm;
-        app.theCoordinator.loadParamicsNetwork(1);
-
-//        app.theViewer.dispose();
-//        Window confirmPopup = null;
-//        confirmPopup = WindowInterceptor.run(new Trigger()
-//        {
-//            public void run()
-//            {
-//                app.theViewer.closeViewer();
-//            }
-//        });
-//        confirmPopup.getButton("OK").click();
-    }
-
-    class FakeClient implements CADClientInterface
-    {
-
-        @Override
-        public void refresh() throws RemoteException
-        {
-        }
+        // this will tell the model it has a new network ID
+        app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.LOADED);
+        CADSimulatorFixture.pause(500);
+        assertEquals("network id should be 1", "1", mainPanel.getTextBox("networkLoadedTF").getText().trim());
+        //mainPanel.getMenu().getItem("Exit").click();
+        boolean breakpoint = true;
     }
 }
Index: trunk/test/tmcsim/cadsimulator/CADSimulatorFixture.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/CADSimulatorFixture.java	(revision 26)
+++ trunk/test/tmcsim/cadsimulator/CADSimulatorFixture.java	(revision 47)
@@ -34,5 +34,5 @@
             + "ATMSProperties         = empty.txt\n"
             + "MediaProperties        = empty.txt\n";
-    static final String configpData = "ParamicsCommHost = 192.168.251.45\n"
+    static final String paramicsData = "ParamicsCommHost       = 192.168.251.45\n"
             + "ParamicsCommPort       = 4450\n"
             + "IncidentUpdateInterval = 30\n"
@@ -60,6 +60,5 @@
         System.setOut(ps);
         writedata("config.txt", configData);
-        writedata("pconfig.txt", configpData);
-        writedata("pmcprops.txt", paramConfig);
+        writedata("pconfig.txt", paramicsData);
         writedata("empty.txt", "");
         writeScriptfiles();
Index: trunk/test/tmcsim/cadsimulator/viewer/CADConsoleViewerTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/viewer/CADConsoleViewerTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/viewer/CADConsoleViewerTest.java	(revision 47)
@@ -0,0 +1,253 @@
+package tmcsim.cadsimulator.viewer;
+
+import java.io.StringWriter;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import junit.framework.TestCase;
+import tmcsim.cadsimulator.viewer.model.CADSimulatorModel;
+import tmcsim.common.CADEnums;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class CADConsoleViewerTest extends TestCase
+{
+
+    CADConsoleViewer console;
+    CADSimulatorModel cadmodel;
+    StringWriter sw;
+
+    public CADConsoleViewerTest(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        console = new CADConsoleViewer();
+        cadmodel = new CADSimulatorModel();
+        cadmodel.addObserver(console);
+        sw = new StringWriter();
+        console.setWriter(sw);
+    }
+    /**
+     * compare StringWriter contents against expected
+     */
+    private void verify(String msg, String expect)
+    {
+        String result = sw.toString().trim();
+        result = result.replaceAll("\n", ",");
+        String fullExpect = expect.trim();
+        fullExpect = fullExpect.replaceAll("\n", ",");
+        assertTrue(msg + ": " + result, result.endsWith(fullExpect));
+    }
+
+    public static void pause(int millis)
+    {
+        try
+        {
+            Thread.sleep(millis);
+        } catch (InterruptedException ex)
+        {
+        }
+    }
+
+    /**
+     * Test of setVisible method, of class CADConsoleViewer.
+     */
+    public void testSetVisible()
+    {
+        String expected1 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --";
+        System.out.println("setVisible");
+        console.setVisible(true);
+        String out = sw.toString().trim();
+        assertEquals(expected1, out);
+    }
+
+    public void testConnect()
+    {
+        String expected2 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 1\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.connectClient();
+        verify("connected 1 terminal output incorrect: ", expected2);
+    }
+
+    public void testConnect2()
+    {
+        String expected3 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 2\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.connectClient();
+        cadmodel.connectClient();
+        verify("connected 2 terminals output incorrect: ", expected3);
+    }
+
+    public void testDisconnect()
+    {
+        String expected3 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 2\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.connectClient();
+        cadmodel.connectClient();
+        cadmodel.connectClient();
+        cadmodel.disconnectClient();
+        verify("disconnect terminal output incorrect: ", expected3);
+    }
+
+    public void testSimMgrConnect()
+    {
+        String expected4 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.setSimManagerStatus(true);
+        verify("sim mgr connected output incorrect: ", expected4);
+    }
+
+    public void testInfoPane()
+    {
+        String expected5 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n"
+                + ". = Console Info Message.\n"
+                + "-- Error Messages --\n\n";
+        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.INFO, "", "", "Console Info Message.");
+        verify("Info message output incorrect: ", expected5);
+    }
+
+    public void testErrorPane()
+    {
+        String expected7 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n"
+                + "Someclass.Somemethod = Something bad happened.\n";
+        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.SEVERE, "Someclass", "Somemethod", "Something bad happened.");
+        verify("Error message output incorrect: ", expected7);
+    }
+
+    public void testParamicsChg()
+    {
+        String expected6 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : Yes\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED);
+        pause(500);
+        verify("paramics connected should be yes", expected6);
+    }
+
+    public void testSimStatus()
+    {
+        String expected8 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : Ready\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_STOPPED_NOT_STARTED);
+        verify("sim status should be ready", expected8);
+        cadmodel.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING);
+        String result = sw.toString();
+        assertTrue("sim status should be running: " + result, result.contains("Running"));
+    }
+
+    public void testSimTime()
+    {
+        String expected9 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:01:01\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.setTime(61L);
+        verify("sim time should be 0:01:01", expected9);
+    }
+
+    public void testNetworkID()
+    {
+        String expected10 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : 17\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        // this will tell the model it has a new network ID
+        cadmodel.setParamicsNetworkLoaded("17");
+        cadmodel.setParamicsStatus(CADEnums.PARAMICS_STATUS.LOADED);
+        pause(500);
+        verify("network id should be 17", expected10);
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/viewer/model/CADSimulatorStatusTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/viewer/model/CADSimulatorStatusTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/viewer/model/CADSimulatorStatusTest.java	(revision 47)
@@ -0,0 +1,108 @@
+package tmcsim.cadsimulator.viewer.model;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import static junit.framework.Assert.assertEquals;
+import junit.framework.TestCase;
+import tmcsim.common.CADEnums;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class CADSimulatorStatusTest extends TestCase
+{
+
+    CADSimulatorStatus stat;
+
+    public CADSimulatorStatusTest(String testName)
+    {
+        super(testName);
+    }
+
+    public void setUp()
+    {
+        stat = new CADSimulatorStatus();
+    }
+
+    /**
+     * Test of connectClient method, of class CADSimulatorStatus.
+     */
+    public void testConnectClient()
+    {
+        System.out.println("connectClient");
+        stat.connectClient();
+        assertEquals(1, stat.getNumClients());
+    }
+
+    /**
+     * Test of disconnectClient method, of class CADSimulatorStatus.
+     */
+    public void testDisconnectClient()
+    {
+        System.out.println("disconnectClient");
+        stat.connectClient();
+        stat.connectClient();
+        stat.disconnectClient();
+        assertEquals(1, stat.getNumClients());
+    }
+
+    /**
+     * Test of getNumClients method, of class CADSimulatorStatus.
+     */
+    public void testGetNumClients()
+    {
+        System.out.println("getNumClients");
+        int expResult = 0;
+        int result = stat.getNumClients();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of setSimManagerStatus method, of class CADSimulatorStatus.
+     */
+    public void testSetSimManagerStatus()
+    {
+        System.out.println("setSimManagerStatus");
+        stat.setSimManagerStatus(false);
+        assertFalse(stat.isSimManagerConnected());
+    }
+
+    /**
+     * Test of setTime method, of class CADSimulatorStatus.
+     */
+    public void testSetTime()
+    {
+        System.out.println("setTime");
+        long seconds = 1L;
+        stat.setTime(seconds);
+        String result = stat.getCurrentTime();
+        assertEquals("0:00:01", result);
+    }
+
+    /**
+     * Test of setScriptStatus method, of class CADSimulatorStatus.
+     */
+    public void testSetScriptStatus()
+    {
+        System.out.println("setScriptStatus");
+        CADEnums.SCRIPT_STATUS newStatus = CADEnums.SCRIPT_STATUS.NO_SCRIPT;
+        stat.setScriptStatus(newStatus);
+        CADEnums.SCRIPT_STATUS expResult = CADEnums.SCRIPT_STATUS.NO_SCRIPT;
+        CADEnums.SCRIPT_STATUS result = stat.getScriptStatus();
+        assertEquals(expResult, result);
+        newStatus = CADEnums.SCRIPT_STATUS.ATMS_SYNCHRONIZATION;
+        stat.setScriptStatus(newStatus);
+        assertEquals(CADEnums.SCRIPT_STATUS.ATMS_SYNCHRONIZATION, stat.getScriptStatus());
+        newStatus = CADEnums.SCRIPT_STATUS.SCRIPT_PAUSED_STARTED;
+        stat.setScriptStatus(newStatus);
+        assertEquals(CADEnums.SCRIPT_STATUS.SCRIPT_PAUSED_STARTED, stat.getScriptStatus());
+    }
+
+    public void testInfoMsg()
+    {
+        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.INFO, "", "", "Sample Info Message.");
+        assertEquals(". = Sample Info Message.", stat.getInfoMessages());
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/viewer/model/CADSimulatorModelTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/viewer/model/CADSimulatorModelTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/viewer/model/CADSimulatorModelTest.java	(revision 47)
@@ -0,0 +1,151 @@
+package tmcsim.cadsimulator.viewer.model;
+
+import java.util.Observable;
+import java.util.Observer;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import junit.framework.TestCase;
+import tmcsim.cadsimulator.viewer.DVDInfoPanel;
+import java.util.Iterator;
+import tmcsim.cadsimulator.videocontrol.DVDStatusUpdate;
+import tmcsim.common.CADEnums;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class CADSimulatorModelTest extends TestCase implements Observer
+{
+
+    private CADSimulatorModel model;
+    private String currentTest;
+
+    public CADSimulatorModelTest(String testName)
+    {
+        super(testName);
+    }
+
+    public void setUp()
+    {
+        model = new CADSimulatorModel();
+        model.addObserver(this);
+    }
+
+    /**
+     * Test of connectClient method, of class CADSimulatorStatus.
+     */
+    public void testConnectClient()
+    {
+        currentTest = "connectClient";
+        model.connectClient();
+    }
+
+    /**
+     * Test of disconnectClient method, of class CADSimulatorStatus.
+     */
+    public void testDisconnectClient()
+    {
+        currentTest = "doNothing";
+        model.connectClient();
+        model.connectClient();
+        currentTest = "disconnectClient";
+        model.disconnectClient();
+    }
+
+    /**
+     * Test of setSimManagerStatus method, of class CADSimulatorStatus.
+     */
+    public void testSetSimManagerStatus()
+    {
+        currentTest = "setSimManagerStatus";
+        model.setSimManagerStatus(false);
+    }
+
+    /**
+     * Test of setTime method, of class CADSimulatorStatus.
+     */
+    public void testSetTime()
+    {
+        currentTest = "setTime";
+        long seconds = 0L;
+        model.setTime(seconds);
+    }
+
+    /**
+     * Test of setScriptStatus method, of class CADSimulatorStatus.
+     */
+    public void testSetScriptStatus()
+    {
+        currentTest = "setScriptStatus";
+        CADEnums.SCRIPT_STATUS newStatus = CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING;
+        model.setScriptStatus(newStatus);
+    }
+
+    public void testSetParamicsStatus()
+    {
+        currentTest = "setParamicsStatus";
+        CADEnums.PARAMICS_STATUS newStatus = CADEnums.PARAMICS_STATUS.CONNECTED;
+        model.setParamicsStatus(newStatus);
+    }
+
+    public void testLoadNetwork()
+    {
+        currentTest = "loadNetwork";
+        model.setParamicsNetworkLoaded("ABC");
+    }
+    
+    public void testDVDupdate()
+    {
+        currentTest = "dvdUpdate";
+        model.updateDVDStatus(new DVDStatusUpdate("1", false, new Throwable()));
+    }
+
+    @Override
+    public void update(Observable obs, Object obj)
+    {
+        CADSimulatorStatus stat = null;
+        CADMediaStatus ms = null;
+        if (obs instanceof CADSimulatorStatus)
+        {
+            stat = (CADSimulatorStatus) obs;
+        }
+        if (obs instanceof CADMediaStatus)
+        {
+            ms = (CADMediaStatus) obs;
+        }
+        System.out.println(currentTest);
+        switch (currentTest)
+        {
+            case "connectClient":
+                assertEquals(1, stat.getNumClients());
+                break;
+            case "disconnectClient":
+                assertEquals(1, stat.getNumClients());
+                break;
+            case "setSimManagerStatus":
+                assertFalse(stat.isSimManagerConnected());
+                break;
+            case "setTime":
+                assertEquals("0:00:00", stat.getCurrentTime());
+                break;
+            case "setScriptStatus":
+                CADEnums.SCRIPT_STATUS expResult = CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING;
+                CADEnums.SCRIPT_STATUS result = stat.getScriptStatus();
+                assertEquals(expResult, result);
+                break;
+            case "setParamicsStatus":
+                CADEnums.PARAMICS_STATUS expect = CADEnums.PARAMICS_STATUS.CONNECTED;
+                assertEquals(expect, stat.getParamicsStatus());
+                break;
+            case "loadNetwork":
+                String id = stat.getParmicsNetworkID();
+                assertEquals("ABC", id);
+                break;
+            case "dvdUpdate":
+                Iterator<DVDInfoPanel> iter = ms.getDVDlist();
+                assertTrue(iter.hasNext());
+            case "doNothing":
+                break;
+        }
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/viewer/CADSimulatorViewModelTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/viewer/CADSimulatorViewModelTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/viewer/CADSimulatorViewModelTest.java	(revision 47)
@@ -0,0 +1,146 @@
+package tmcsim.cadsimulator.viewer;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.uispec4j.*;
+import tmcsim.cadsimulator.viewer.model.CADSimulatorModel;
+import tmcsim.common.CADEnums;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class CADSimulatorViewModelTest extends junit.framework.TestCase //extends UISpecTestCase
+{
+
+    CADSimulatorViewer viewer;
+    Window cadwindow;
+    CADSimulatorModel model;
+    Panel mainPanel;
+
+    public CADSimulatorViewModelTest(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        viewer = new CADSimulatorViewer();
+        cadwindow = new Window(viewer);
+        model = new CADSimulatorModel();
+        model.addObserver(viewer);
+        mainPanel = cadwindow.getPanel("contentPane");
+    }
+
+    public void testInitialView()
+    {
+        String actual;
+        assertTrue("Title bar incorrect", cadwindow.getTitle().trim().startsWith("CAD Simulator"));
+        TextBox txtStatus = mainPanel.getTextBox("simulationStatus");
+        actual = txtStatus.getText().trim();
+        assertEquals("simulation status should say No Script", "No Script", actual);
+        TextBox terminals = mainPanel.getTextBox("termConnectedTF");
+        actual = terminals.getText().trim();
+        assertEquals("should be 0 terminals", "0", actual);
+        actual = mainPanel.getTextBox("managerConnectedTF").getText().trim();
+        assertEquals("mgr connected should be no", "No", actual);
+        actual = mainPanel.getTextBox("paramicsConnectedTF").getText().trim();
+        assertEquals("paramics connected should be no", "No", actual);
+        actual = mainPanel.getTextBox("simulationClockLabel").getText().trim();
+        assertEquals("initial time should be 0:00:00", "0:00:00", actual);
+        actual = mainPanel.getTextBox("networkLoadedTF").getText().trim();
+        assertEquals("network id should be None", "None", actual);
+    }
+
+    public void testClients()
+    {
+        String actual;
+        model.connectClient();
+        TextBox terminals = mainPanel.getTextBox("termConnectedTF");
+        assertEquals(1, model.getNumClients());
+        assertEquals("should be 1 terminal", "1", terminals.getText().trim());
+        model.connectClient();
+        assertEquals("should be 2 terminals", "2", terminals.getText().trim());
+        model.disconnectClient();
+        assertEquals("should be 1 terminal after disconnect", "1", terminals.getText().trim());
+    }
+
+    public void testSimMgr()
+    {
+        String actual;
+        model.setSimManagerStatus(true);
+        actual = mainPanel.getTextBox("managerConnectedTF").getText().trim();
+        assertEquals("mgr connected should be yes", "Yes", actual);
+        assertTrue(model.isSimManagerConnected());
+    }
+
+    public void testMessagePanes()
+    {
+        String actual;
+        System.out.println("Tests for message panes.");
+        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.INFO, "", "", "Sample Info Message.");
+        Panel infoPane = mainPanel.getPanel("infoMessagesPane");
+        TextBox infoText = infoPane.getTextBox("infoMessagesTA");
+        actual = infoText.getText().trim();
+        assertEquals("wrong info msg text", ". = Sample Info Message.", actual);
+
+        cadSimLogger.logp(Level.SEVERE, "", "", "Sample Error Message.");
+
+        Panel errPane = mainPanel.getPanel("errorMessagesPane");
+        TextBox errText = errPane.getTextBox("errorMessagesTA");
+        actual = errText.getText().trim();
+        assertEquals("wrong error msg text", ". = Sample Error Message.", actual);
+    }
+
+    public void testStatusChg()
+    {
+        String actual;
+        System.out.println("Tests for status changes.");
+        model.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED);
+        pause(500);
+        actual = mainPanel.getTextBox("paramicsConnectedTF").getText().trim();
+        assertEquals("paramics connected should be yes", "Yes", actual);
+        actual = mainPanel.getTextBox("networkLoadedTF").getText().trim();
+        assertEquals("network id should be None", "None", actual);
+
+        model.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_STOPPED_NOT_STARTED);
+
+        // The status should now say Ready
+        actual = mainPanel.getTextBox("simulationStatus").getText().trim();
+        assertEquals("sim status should be ready", "Ready", actual);
+
+        model.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING);
+        model.setTime(61L);
+        actual = mainPanel.getTextBox("simulationStatus").getText().trim();
+        assertEquals("sim status should be running", "Running", actual);
+        actual = mainPanel.getTextBox("simulationClockLabel").getText().trim();
+        assertEquals("sim time should be 0:01:01", "0:01:01", actual);
+    }
+
+    public void testNetworkID()
+    {
+        String actual;
+        // this will tell the model it has a new network ID
+        model.setParamicsNetworkLoaded("1");
+        model.setParamicsStatus(CADEnums.PARAMICS_STATUS.LOADED);
+        pause(500);
+        actual = mainPanel.getTextBox("networkLoadedTF").getText().trim();
+        assertEquals("network id should be 1", "1", actual);
+
+        //  model.updateDVDStatus(new DVDStatusUpdate("1", false, new Throwable()));
+
+    }
+
+    public static void pause(int millis)
+    {
+        try
+        {
+            Thread.sleep(millis);
+        } catch (InterruptedException ex)
+        {
+        }
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/BOStest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/BOStest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/BOStest.java	(revision 47)
@@ -0,0 +1,60 @@
+package tmcsim.cadsimulator;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.rmi.RemoteException;
+import static junit.framework.Assert.assertEquals;
+import org.uispec4j.*;
+import tmcsim.common.SimulationException;
+
+/**
+ * Test of Byte Output Stream and redirection
+ *
+ * @author jdalbey
+ */
+public class BOStest extends UISpecTestCase
+{
+
+    public BOStest(String testName)
+    {
+        super(testName);
+    }
+    /**
+     * Test of main method, of class CADSimulator.
+     */
+    ByteArrayOutputStream bos;
+
+    public void setUp() throws SimulationException, RemoteException
+    {
+        // Declare a stream to the output
+        bos = new ByteArrayOutputStream();
+        PrintStream ps = new PrintStream(bos);
+        // Redirect the standard output
+        System.setOut(ps);
+    }
+
+    @Override
+    public void tearDown() throws java.io.IOException
+    {
+    }
+
+    public void testConstructor()
+    {
+        System.out.println("Mary had a little lamb.");
+        // Convert the output stream into a string we can test.
+        String result = bos.toString();
+        assertEquals(expected1, result);
+
+    }
+
+    public void testLoad() throws RemoteException
+    {
+        System.out.print(expected2);
+        // Convert the output stream into a string we can test.
+        String result = bos.toString();
+        assertEquals(expected2, result);
+
+    }
+    String expected1 = "Mary had a little lamb.\n";
+    String expected2 = "Fleece white as snow.\n";
+}
Index: trunk/test/tmcsim/cadsimulator/VisibleSystemDemoDriver.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/VisibleSystemDemoDriver.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/VisibleSystemDemoDriver.java	(revision 47)
@@ -0,0 +1,202 @@
+package tmcsim.cadsimulator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.rmi.RemoteException;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.fail;
+import org.uispec4j.*;
+import org.uispec4j.interception.WindowInterceptor;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+import tmcsim.paramicscommunicator.PComm;
+import tmcsim.paramicscommunicator.gui.ParamicsCommunicatorGUI;
+import tmcsim.simulationmanager.SimulationManager;
+
+/**
+ * Requires manual starting CADSimulator before running this test. System test
+ * with emulated Paramics Modeler NO ATMS server.
+ *
+ * @author jdalbey
+ */
+public class VisibleSystemDemoDriver extends UISpecTestCase
+{
+
+    SimulationManager simMgrApp;
+
+    public VisibleSystemDemoDriver(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /**
+     * Test of run method, of class ParamicsCommunicator.
+     */
+    public void testRun() throws ScriptException, SimulationException, RemoteException
+    {
+        System.out.println("Visible System Test starting.");
+        // NOTE: CADSimulator must be started prior to running this test,
+        // because it displays a GUI, and if we try to do it inside this test,
+        // UISpec will complain about an uncaught window appearing.
+
+        PComm pc = null;
+        pc = new PComm("config/testConfig/paramics_communicator_config.properties");
+        ParamicsCommunicatorGUI theGUI = new ParamicsCommunicatorGUI();
+        pc.setGUI(theGUI);
+        // Note: Don't set visible ANY windows during UISpec test
+
+        // expect pcomm to say "sleeping"
+
+        Window simMgrWindow = null;
+        simMgrWindow = WindowInterceptor.run(new Trigger()
+        {
+            public void run()
+            {
+                try
+                {
+                    simMgrApp = new SimulationManager("config/sim_manager_systest_config.properties");
+                } catch (Exception ex)
+                {
+                    fail("Couldn't launch Simulation Manager, perhaps CADSimulator isn't running.");
+                }
+            }
+        });
+
+        // Check that the Sim Mgr GUI appears without a script loaded yet
+        Panel contentPanel = simMgrWindow.getPanel("contentPane");
+        TextBox txtSimStatus = contentPanel.getTextBox("simulationStatusText");
+        assertEquals("No Script", txtSimStatus.getText());
+        TextBox txtParamStatus = contentPanel.getTextBox("paramicsStatusInfoLabel");
+        assertEquals("Unknown", txtParamStatus.getText());
+        Button loadNetworkBtn = simMgrWindow.getButton("Load Network");
+        assertFalse(loadNetworkBtn.isEnabled());
+        // Begin actions
+        Button paramicsBtn = simMgrWindow.getButton("Connect to Paramics");
+        paramicsBtn.click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Disconnect from Paramics", paramicsBtn.getLabel());
+
+        assertEquals("Connected", txtParamStatus.getText());
+        pc.startReading();
+
+        loadNetworkBtn.click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Sending Network ID", txtParamStatus.getText());
+        System.out.println("Sending Network ID");
+        assertFalse(loadNetworkBtn.isEnabled());
+        String warmingXML = "<Paramics>\n"
+                + "<Network_Status>WARMING</Network_Status>\n"
+                + "<Network_ID>1</Network_ID>\n"
+                + "</Paramics>";
+        writedata("paramics_status.xml", warmingXML);
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Warming Up", txtParamStatus.getText());
+        System.out.println("Warming Up Passed");
+
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        String loadedXML = "<Paramics>\n"
+                + "<Network_Status>LOADED</Network_Status>"
+                + "<Network_ID>1</Network_ID>"
+                + "</Paramics>";
+        writedata("paramics_status.xml", loadedXML);
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Network 1 Loaded", txtParamStatus.getText());
+        System.out.println("Network Loaded Passed");
+
+        // Load a script file
+        String autoloadScriptname = "scripts/audio_systest.xml";
+        simMgrApp.loadScript(new File(autoloadScriptname));
+        try
+        {
+            Thread.sleep(500);
+        } catch (Exception ex)
+        {
+        }
+
+        // The status should now say Ready
+        assertEquals("Ready", txtSimStatus.getText());
+
+        // Click "Start"
+        simMgrWindow.getButton("Start").click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+            ex.printStackTrace();
+        }
+        assertEquals("Running", txtSimStatus.getText());
+        System.out.println("Running Passed");
+        try
+        {
+            Thread.sleep(9000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Pause").click();
+        try
+        {
+            Thread.sleep(3000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Start").click();
+        try
+        {
+            Thread.sleep(3000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Pause").click();
+        simMgrWindow.getMenuBar().getMenu("File").getSubMenu("Exit").click();
+        System.out.println("Exiting.");
+    }
+
+    // Write the test data to a file
+    public static void writedata(String filename, String data)
+    {
+//        System.out.println("writedata called for " + filename);
+        PrintWriter writer = null;
+        try
+        {
+            writer = new PrintWriter(new FileWriter(filename));
+            writer.println(data);
+            writer.close();
+        } catch (Exception ex)
+        {
+            ex.printStackTrace();
+        }
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/SystemTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/SystemTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/SystemTest.java	(revision 47)
@@ -0,0 +1,228 @@
+package tmcsim.cadsimulator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.rmi.RemoteException;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+import org.uispec4j.*;
+import org.uispec4j.interception.WindowInterceptor;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+import tmcsim.paramicscommunicator.PComm;
+import tmcsim.paramicscommunicator.ParamicsCommunicator;
+import tmcsim.paramicscommunicator.gui.ParamicsCommunicatorGUI;
+import tmcsim.simulationmanager.SimulationManager;
+
+/**
+ * System test (include CADSimulator) with emulated Paramics Modeler NO ATMS
+ * server captures GUI display using UISpec4J.
+ *
+ * @author jdalbey
+ */
+public class SystemTest extends UISpecTestCase
+{
+
+    SimulationManager simMgrApp;
+    CADSimulator engine;
+    ParamicsCommunicator paramicscomm;
+
+    public SystemTest(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /**
+     * Test of run method, of class ParamicsCommunicator.
+     */
+    public void testRun() throws ScriptException, SimulationException, RemoteException
+    {
+        System.out.println("Invisible System Test");
+        Window cadwindow = null;
+        cadwindow = WindowInterceptor.run(new Trigger()
+        {
+            public void run()
+            {
+                try
+                {
+                    engine = new CADSimulator("config/testConfig/cad_simulator_config.properties");
+                } catch (Exception e)
+                {
+                    fail("Couldn't launch CADSimulator");
+                }
+            }
+        });
+
+        // Check CAD Simulator appears with no script and nothing connected
+        assertTrue("Title bar incorrect", cadwindow.getTitle().trim().startsWith("CAD Simulator"));
+        Panel mainPanel = cadwindow.getPanel("contentPane");
+        TextBox txtStatus = mainPanel.getTextBox("simulationStatus");
+        assertEquals("No Script", txtStatus.getText());
+        TextBox terms = mainPanel.getTextBox("termConnectedTF");
+        assertEquals("0", terms.getText().trim());
+        assertEquals("No", mainPanel.getTextBox("managerConnectedTF").getText().trim());
+        assertEquals("network id should be None", "None", mainPanel.getTextBox("networkLoadedTF").getText().trim());
+
+        PComm pc = null;
+        pc = new PComm("config/testConfig/paramics_communicator_config.properties");
+        ParamicsCommunicatorGUI theGUI = new ParamicsCommunicatorGUI();
+        pc.setGUI(theGUI);
+        // Note: Can't set visible ANY windows during UISpec test
+
+        // expect pcomm to say "sleeping"
+
+        Window simMgrWindow = null;
+        simMgrWindow = WindowInterceptor.run(new Trigger()
+        {
+            public void run()
+            {
+                try
+                {
+                    simMgrApp = new SimulationManager("config/sim_manager_systest_config.properties");
+                } catch (Exception ex)
+                {
+                    fail("Couldn't launch Simulation Manager");
+                }
+            }
+        });
+
+        // TODO: Check that the Sim Mgr GUI appears without a script loaded yet
+
+        Panel contentPanel = simMgrWindow.getPanel("contentPane");
+        TextBox txtSimStatus = contentPanel.getTextBox("simulationStatusText");
+        assertEquals("No Script", txtSimStatus.getText());
+        TextBox txtParamStatus = contentPanel.getTextBox("paramicsStatusInfoLabel");
+        assertEquals("Unknown", txtParamStatus.getText());
+        Button loadNetworkBtn = simMgrWindow.getButton("Load Network");
+        assertFalse(loadNetworkBtn.isEnabled());
+
+        Button paramicsBtn = simMgrWindow.getButton("Connect to Paramics");
+        paramicsBtn.click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Disconnect from Paramics", paramicsBtn.getLabel());
+
+        assertEquals("Connected", txtParamStatus.getText());
+        pc.startReading();
+
+        loadNetworkBtn.click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Sending Network ID", txtParamStatus.getText());
+        System.out.println("Sending Network ID");
+        assertFalse(loadNetworkBtn.isEnabled());
+        String warmingXML = "<Paramics>\n"
+                + "<Network_Status>WARMING</Network_Status>\n"
+                + "<Network_ID>1</Network_ID>\n"
+                + "</Paramics>";
+        writedata("paramics_status.xml", warmingXML);
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Warming Up", txtParamStatus.getText());
+        System.out.println("Warming Up Passed");
+
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        String loadedXML = "<Paramics>\n"
+                + "<Network_Status>LOADED</Network_Status>"
+                + "<Network_ID>1</Network_ID>"
+                + "</Paramics>";
+        writedata("paramics_status.xml", loadedXML);
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Network 1 Loaded", txtParamStatus.getText());
+        assertEquals("network id should be 1", "1", mainPanel.getTextBox("networkLoadedTF").getText().trim());
+
+
+        // Load a script file
+        String autoloadScriptname = "scripts/system_test_script.xml";
+        simMgrApp.loadScript(new File(autoloadScriptname));
+        try
+        {
+            Thread.sleep(500);
+        } catch (Exception ex)
+        {
+        }
+
+        // The status should now say Ready
+        assertEquals("Ready", txtSimStatus.getText());
+
+        // Click "Start"
+        simMgrWindow.getButton("Start").click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+            ex.printStackTrace();
+        }
+        assertEquals("Running", txtSimStatus.getText());
+        System.out.println("Running Passed");
+        try
+        {
+            Thread.sleep(9000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Pause").click();
+        try
+        {
+            Thread.sleep(3000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Start").click();
+        try
+        {
+            Thread.sleep(3000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Pause").click();
+        simMgrWindow.getMenuBar().getMenu("File").getSubMenu("Exit").click();
+        System.out.println("Exiting.");
+    }
+
+    // Write the test data to a file
+    public static void writedata(String filename, String data)
+    {
+        PrintWriter writer = null;
+        try
+        {
+            writer = new PrintWriter(new FileWriter(filename));
+            writer.println(data);
+            writer.close();
+        } catch (Exception ex)
+        {
+            ex.printStackTrace();
+        }
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleDriver.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleDriver.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleDriver.java	(revision 47)
@@ -0,0 +1,191 @@
+package tmcsim.cadsimulator;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import junit.framework.TestCase;
+import static org.mockito.Mockito.mock;
+import static tmcsim.cadsimulator.CADSimulatorFixture.writedata;
+import tmcsim.common.CADEnums;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+import tmcsim.interfaces.CADClientInterface;
+import tmcsim.interfaces.SimulationManagerInterface;
+
+/**
+ * Driver for CADSimulator Console - output to stdout.
+ *
+ * @author jdalbey
+ */
+public class CADSimulatorConsoleDriver extends TestCase
+{
+
+    static CADSimulator app;
+    static final String configData =
+            "CADClientPort          = 4444 \n"
+            + "CoordinatorRMIPort     = 4445 \n"
+            + "CADRmiPort             = 4446 \n"
+            + "UserInterface          = tmcsim.cadsimulator.viewer.CADConsoleViewer\n"
+            + "ParamicsProperties     = pconfig.txt\n"
+            + "ATMSProperties         = empty.txt\n"
+            + "MediaProperties        = empty.txt\n";
+    static final String paramicsData = "ParamicsCommHost       = 192.168.251.45\n"
+            + "ParamicsCommPort       = 4450\n"
+            + "IncidentUpdateInterval = 30\n"
+            + "IncidentUpdateFile     = exchange.xml\n"
+            + "ParamicsStatusInterval = 15\n"
+            + "ParamicsStatusFile     = paramics_status.xml\n"
+            + "CameraStatusInterval   = 30\n"
+            + "CameraStatusFile       = camera_status.xml\n";
+    /*
+     * Creating instance of app must be done only once or you get registry
+     * bind problems, and code Written in Constructor is Executed
+     * before each Test Method
+     */
+
+    public static void main(String[] args) throws IOException, SimulationException, ScriptException
+    {
+        writedata("config.txt", configData);
+        writedata("pconfig.txt", paramicsData);
+        writedata("empty.txt", "");
+        CADSimulatorFixture.writeScriptfiles();
+        CADSimulatorFixture.startCADSim();
+        (new CADSimulatorConsoleDriver()).testAll();
+        System.exit(0);
+    }
+    // Write the test data to a file
+
+    private void testAll() throws java.io.IOException, SimulationException, ScriptException
+    {
+
+        CADClientInterface ci = mock(CADClientInterface.class); //new tmcsim.cadsimulator.CADSimulatorDriver.FakeClient();
+        app.theCoordinator.registerForCallback(ci);
+        // Convert the output stream into a string we can test.
+
+        app.theCoordinator.registerForCallback(ci);
+
+        SimulationManagerInterface si = mock(SimulationManagerInterface.class);
+
+        app.theCoordinator.registerForCallback(si);
+
+        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.INFO, "", "", "Sample Info Message.");
+
+        app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED);
+        CADSimulatorFixture.pause(500);
+
+        // Show loaded, and ALSO update the current network id
+        app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.LOADED);
+        CADSimulatorFixture.pause(500);
+
+        app.theCoordinator.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING);
+        CADSimulatorFixture.pause(500);
+
+        cadSimLogger.logp(Level.SEVERE, "Someclass", "Somemethod", "Something bad happened.");
+
+        // Load a script file
+        String autoloadScriptname = "scripts/one-incident.xml";
+        app.theCoordinator.loadScriptFile(new File(autoloadScriptname));
+        // The status should now say Ready
+
+
+//        ParamicsSimulationManager psm = mock(ParamicsSimulationManager.class);
+//        when(psm.isConnected()).thenReturn(Boolean.TRUE, Boolean.FALSE);
+//        app.theParamicsSimMgr = psm;
+//        app.theCoordinator.connectToParamics();
+//        app.theCoordinator.loadParamicsNetwork(1);
+//        CADSimulatorFixture.pause(500);
+//        app.theCoordinator.disconnectFromParamics();
+//        CADSimulatorFixture.pause(500);
+
+        app.theCoordinator.startSimulation();
+        CADSimulatorFixture.pause(1500);
+        app.theCoordinator.pauseSimulation();
+        app = null;
+        cleanup();
+    }
+
+    private void cleanup()
+    {
+        File removeMe = new File("config.txt");
+        removeMe.delete();
+        removeMe = new File("pconfig.txt");
+        removeMe.delete();
+        removeMe = new File("empty.txt");
+        removeMe.delete();
+    }
+    String expected1 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 0\n"
+            + "Simulation Manager Connected: No\n"
+            + "Connected to Paramics       : No\n"
+            + "Network Loaded              : \n"
+            + "-- Info Messages --\n\n"
+            + "-- Error Messages --\n\n";
+    String expected2 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 1\n"
+            + "Simulation Manager Connected: No\n"
+            + "Connected to Paramics       : No\n"
+            + "Network Loaded              : \n"
+            + "-- Info Messages --\n\n"
+            + "-- Error Messages --\n\n";
+    String expected3 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 2\n"
+            + "Simulation Manager Connected: No\n"
+            + "Connected to Paramics       : No\n"
+            + "Network Loaded              : \n"
+            + "-- Info Messages --\n\n"
+            + "-- Error Messages --\n\n";
+    String expected4 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 2\n"
+            + "Simulation Manager Connected: Yes\n"
+            + "Connected to Paramics       : No\n"
+            + "Network Loaded              : \n"
+            + "-- Info Messages --\n\n"
+            + "-- Error Messages --\n\n";
+    String expected5 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 2\n"
+            + "Simulation Manager Connected: Yes\n"
+            + "Connected to Paramics       : No\n"
+            + "Network Loaded              : \n"
+            + "-- Info Messages --\n"
+            + ". = Sample Info Message.\n"
+            + "-- Error Messages --\n\n";
+    String expected6 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 2\n"
+            + "Simulation Manager Connected: Yes\n"
+            + "Connected to Paramics       : Yes\n"
+            + "Network Loaded              : \n"
+            + "-- Info Messages --\n"
+            + ". = Sample Info Message.\n"
+            + "-- Error Messages --\n\n";
+    String expected7 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 2\n"
+            + "Simulation Manager Connected: Yes\n"
+            + "Connected to Paramics       : Yes\n"
+            + "Network Loaded              : 3\n"
+            + "-- Info Messages --\n"
+            + ". = Sample Info Message.\n"
+            + "-- Error Messages --\n\n";
+}
Index: trunk/test/tmcsim/cadsimulator/SystemConsoleTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/SystemConsoleTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/SystemConsoleTest.java	(revision 47)
@@ -0,0 +1,226 @@
+package tmcsim.cadsimulator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.rmi.RemoteException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import org.uispec4j.*;
+import org.uispec4j.interception.WindowInterceptor;
+import tmcsim.cadsimulator.managers.ATMSManager;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+import tmcsim.paramicscommunicator.PComm;
+import tmcsim.paramicscommunicator.gui.ParamicsCommunicatorGUI;
+import tmcsim.simulationmanager.SimulationManager;
+
+/**
+ * Note, this is just like VisibleSystemTest except it starts it's own
+ * CADSimulator running on the console.
+ *
+ * @author jdalbey
+ */
+public class SystemConsoleTest extends UISpecTestCase
+{
+
+    SimulationManager simMgrApp;
+    CADSimulator engine;
+
+    public SystemConsoleTest(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /**
+     * Test of run method, of class ParamicsCommunicator.
+     */
+    public void testRun() throws ScriptException, SimulationException, RemoteException
+    {
+        System.out.println("System Console Test");
+
+        try
+        {
+            engine = new CADSimulator("config/testConfig/cad_simulator_console_config.properties");
+        } catch (Exception e)
+        {
+            fail("Couldn't launch CADSimulator");
+        }
+
+        PComm pc = null;
+        pc = new PComm("config/testConfig/paramics_communicator_config.properties");
+        ParamicsCommunicatorGUI theGUI = new ParamicsCommunicatorGUI();
+        pc.setGUI(theGUI);
+        // Note: Can't set visible ANY windows during UISpec test
+
+        // expect pcomm to say "sleeping"
+
+        Window simMgrWindow = null;
+        simMgrWindow = WindowInterceptor.run(new Trigger()
+        {
+            public void run()
+            {
+                try
+                {
+                    simMgrApp = new SimulationManager("config/sim_manager_systest_config.properties");
+                } catch (Exception ex)
+                {
+                    fail("Couldn't launch Simulation Manager");
+                }
+            }
+        });
+
+        // TODO: Check that the Sim Mgr GUI appears without a script loaded yet
+
+        Panel contentPanel = simMgrWindow.getPanel("contentPane");
+        TextBox txtSimStatus = contentPanel.getTextBox("simulationStatusText");
+        assertEquals("No Script", txtSimStatus.getText());
+        TextBox txtParamStatus = contentPanel.getTextBox("paramicsStatusInfoLabel");
+        assertEquals("Unknown", txtParamStatus.getText());
+        Button loadNetworkBtn = simMgrWindow.getButton("Load Network");
+        assertFalse(loadNetworkBtn.isEnabled());
+
+        Button paramicsBtn = simMgrWindow.getButton("Connect to Paramics");
+        paramicsBtn.click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Disconnect from Paramics", paramicsBtn.getLabel());
+
+        assertEquals("Connected", txtParamStatus.getText());
+        pc.startReading();
+
+        loadNetworkBtn.click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Sending Network ID", txtParamStatus.getText());
+        System.out.println("Sending Network ID");
+        assertFalse(loadNetworkBtn.isEnabled());
+        String warmingXML = "<Paramics>\n"
+                + "<Network_Status>WARMING</Network_Status>\n"
+                + "<Network_ID>1</Network_ID>\n"
+                + "</Paramics>";
+        writedata("paramics_status.xml", warmingXML);
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Warming Up", txtParamStatus.getText());
+        System.out.println("Warming Up Passed");
+
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        String loadedXML = "<Paramics>\n"
+                + "<Network_Status>LOADED</Network_Status>"
+                + "<Network_ID>1</Network_ID>"
+                + "</Paramics>";
+        writedata("paramics_status.xml", loadedXML);
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Network 1 Loaded", txtParamStatus.getText());
+        System.out.println("Network Loaded Passed");
+
+        // Load a script file
+        String autoloadScriptname = "scripts/audio_systest.xml";
+        simMgrApp.loadScript(new File(autoloadScriptname));
+        try
+        {
+            Thread.sleep(500);
+        } catch (Exception ex)
+        {
+        }
+
+        // The status should now say Ready
+        assertEquals("Ready", txtSimStatus.getText());
+
+        // Mock out the ATMS manager in CADSimulator
+        ATMSManager atm = mock(ATMSManager.class);
+        try
+        {
+            when(atm.getCurrentTime()).thenReturn(29000L);
+        } catch (Exception ex)
+        {
+            Logger.getLogger(SystemConsoleTest.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        engine.theATMSMgr = atm;
+
+        // Click "Start"
+        simMgrWindow.getButton("Start").click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+            ex.printStackTrace();
+        }
+        assertEquals("Running", txtSimStatus.getText());
+        System.out.println("Running Passed");
+        try
+        {
+            Thread.sleep(9000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Pause").click();
+        try
+        {
+            Thread.sleep(3000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Start").click();
+        try
+        {
+            Thread.sleep(3000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Pause").click();
+        simMgrWindow.getMenuBar().getMenu("File").getSubMenu("Exit").click();
+        System.out.println("Exiting.");
+
+
+    }
+
+    // Write the test data to a file
+    public static void writedata(String filename, String data)
+    {
+        PrintWriter writer = null;
+        try
+        {
+            writer = new PrintWriter(new FileWriter(filename));
+            writer.println(data);
+            writer.close();
+        } catch (Exception ex)
+        {
+            ex.printStackTrace();
+        }
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/CADSimulatorNetworkTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/CADSimulatorNetworkTest.java	(revision 28)
+++ 	(revision )
@@ -1,174 +1,0 @@
-package tmcsim.cadsimulator;
-
-import java.io.File;
-import java.rmi.RemoteException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.fail;
-import static org.mockito.Mockito.*;
-import org.uispec4j.*;
-import org.uispec4j.interception.WindowInterceptor;
-import tmcsim.cadsimulator.managers.ParamicsSimulationManager;
-import tmcsim.common.CADEnums;
-import tmcsim.common.ScriptException;
-import tmcsim.common.SimulationException;
-import tmcsim.interfaces.CADClientInterface;
-import tmcsim.interfaces.SimulationManagerInterface;
-import tmcsim.paramicscommunicator.ParamicsCommunicator;
-
-/**
- * Test of CADSimulator GUI
- *
- * @author jdalbey
- */
-public class CADSimulatorNetworkTest extends UISpecTestCase
-{
-
-    static final String configData =
-            "CADClientPort          = 4444 \n"
-            + "CoordinatorRMIPort     = 4445 \n"
-            + "CADRmiPort             = 4446 \n"
-            + "UserInterface          = tmcsim.cadsimulator.viewer.CADSimulatorViewer\n"
-            + "ParamicsProperties     = pconfig.txt\n"
-            + "ATMSProperties         = empty.txt\n"
-            + "MediaProperties        = empty.txt\n";
-
-    public CADSimulatorNetworkTest(String testName)
-    {
-        super(testName);
-    }
-
-    @Override
-    public void tearDown() throws java.io.IOException
-    {
-        File removeMe = new File("config.txt");
-        removeMe.delete();
-        removeMe = new File("pconfig.txt");
-        removeMe.delete();
-        removeMe = new File("empty.txt");
-        removeMe.delete();
-        removeMe = new File("pmcprops.txt");
-        removeMe.delete();
-    }
-
-    /**
-     * Test of getCADTime method, of class CADSimulator.
-     */
-    public void testGetCADTime()
-    {
-        System.out.println("getCADTime");
-        String result = CADSimulator.getCADTime();
-        // Just test length for now
-        assertEquals(4, result.length());
-    }
-
-    /**
-     * Test of getCADDate method, of class CADSimulator.
-     */
-    public void testGetCADDate()
-    {
-        System.out.println("getCADDate");
-        String result = CADSimulator.getCADDate();
-        // Just test length for now
-        assertEquals(6, result.length());
-    }
-    /**
-     * Test of main method, of class CADSimulator.
-     */
-    CADSimulator app;
-
-    public void testConstructor() throws SimulationException, RemoteException, ScriptException
-    {
-        CADSimulatorFixture.writeConfigData();
-        CADSimulatorFixture.writedata("config.txt", configData);
-        System.out.println("CADSimulator constructor");
-        System.setProperty("CAD_SIM_PROPERTIES", "config.txt");
-        Window cadwindow = null;
-        if (System.getProperty("CAD_SIM_PROPERTIES") != null)
-        {
-            cadwindow = WindowInterceptor.run(new Trigger()
-            {
-                public void run()
-                {
-                    try
-                    {
-                        app = new CADSimulator(System.getProperty("CAD_SIM_PROPERTIES"));
-                    } catch (Exception e)
-                    {
-                        fail("Couldn't launch CADSimulator" + e.getMessage());
-                    }
-                }
-            });
-        } else
-        {
-            fail("CAD_SIM_PROPERTIES system property not defined.");
-        }
-        assertEquals("CAD Simulator", cadwindow.getTitle());
-        Panel mainPanel = cadwindow.getPanel("contentPane");
-        TextBox txtStatus = mainPanel.getTextBox("simulationStatus");
-        assertEquals("No Script", txtStatus.getText());
-        TextBox terminals = mainPanel.getTextBox("termConnectedTF");
-        assertEquals("0", terminals.getText().trim());
-        assertEquals("No", mainPanel.getTextBox("managerConnectedTF").getText().trim());
-        assertEquals("0:00:00", mainPanel.getTextBox("simulationClockLabel").getText());
-
-        CADClientInterface ci = mock (CADClientInterface.class);
-        app.theCoordinator.registerForCallback(ci);
-        assertEquals("1", terminals.getText().trim());
-        app.theCoordinator.registerForCallback(ci);
-        assertEquals("2", terminals.getText().trim());
-
-        SimulationManagerInterface si = mock(SimulationManagerInterface.class);
-        app.theCoordinator.registerForCallback(si);
-        assertEquals("Yes", mainPanel.getTextBox("managerConnectedTF").getText().trim());
-
-
-        app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED);
-        CADSimulatorFixture.pause(500);
-        assertEquals("Yes", mainPanel.getTextBox("paramicsConnectedTF").getText().trim());
-        assertEquals("None", mainPanel.getTextBox("networkLoadedTF").getText().trim());
-
-String loadedXML = "<Paramics>\n"
-    + "<Network_Status>LOADED</Network_Status>"
-    + "<Network_ID>1</Network_ID>"
-    + "</Paramics>";
-
-//         Thread pmc = new Thread(new ParamicsCommunicator("pmcprops.txt"));
-//        pmc.start();
-//        pmc.stop();
-        /*
-         * Start Paramics Controller.
-         * app.theCoordinator.connectToParamics();
-        CADSimulatorFixture.pause(500);
-        assertEquals("Yes", mainPanel.getTextBox("paramicsConnectedTF").getText().trim());
-           theCoorInt.loadParamicsNetwork(networkID);
-         * Optional: assert Status is "Sending Network ID" in Sim Mgr
-         * When "
-         * paramics_status.xml becomes 
-<Paramics>
-<Network_Status>WARMING</Network_Status>
-<Network_ID>1</Network_ID>
-</Paramics>
-*          then Sim Mgr status becomes "Warming up"
- When paramics_status.xml becomes loadedXML
-CADSimulatorFixture.writedata(loadedXML, "paramics_status.xml");
-pause()
-       then Sim MGr status becomes Network Loaded and
- CADSimulator Netowrk Loaded field says "1".
- * 
- * When "Load Script" happens, Camera Status is sent to Paramics Comm.
-* 
-         */
-        ParamicsSimulationManager psm = mock(ParamicsSimulationManager.class);
-        when(psm.isConnected()).thenReturn(Boolean.TRUE);
-        app.theParamicsSimMgr = psm;
-        app.theCoordinator.loadParamicsNetwork(1);
-        // Load a script file
-        String autoloadScriptname = "scripts/one-incident.xml";
-        app.theCoordinator.loadScriptFile(new File(autoloadScriptname));
-        // The status should now say Ready
-        assertEquals("Ready", mainPanel.getTextBox("simulationStatus").getText().trim());
-    }
-
-}
Index: trunk/test/tmcsim/cadsimulator/CADSimulatorTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/CADSimulatorTest.java	(revision 34)
+++ 	(revision )
@@ -1,167 +1,0 @@
-package tmcsim.cadsimulator;
-
-import java.rmi.RemoteException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.JScrollPane;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.fail;
-import org.uispec4j.*;
-import org.uispec4j.interception.WindowInterceptor;
-import tmcsim.client.CADClient;
-import tmcsim.client.cadclientgui.data.Incident;
-import tmcsim.client.cadclientgui.data.IncidentEvent;
-import tmcsim.common.CADEnums;
-import tmcsim.common.SimulationException;
-import tmcsim.interfaces.CADClientInterface;
-import tmcsim.interfaces.SimulationManagerInterface;
-
-/**
- * Test of CADSimulator GUI
- *
- * @author jdalbey
- */
-public class CADSimulatorTest extends UISpecTestCase
-{
-
-    public CADSimulatorTest(String testName)
-    {
-        super(testName);
-    }
-
-    /**
-     * Test of getCADTime method, of class CADSimulator.
-     */
-    public void testGetCADTime()
-    {
-        System.out.println("getCADTime");
-        String result = CADSimulator.getCADTime();
-        // Just test length for now
-        assertEquals(4, result.length());
-    }
-
-    /**
-     * Test of getCADDate method, of class CADSimulator.
-     */
-    public void testGetCADDate()
-    {
-        System.out.println("getCADDate");
-        String result = CADSimulator.getCADDate();
-        // Just test length for now
-        assertEquals(6, result.length());
-    }
-    /**
-     * Test of main method, of class CADSimulator.
-     */
-    CADSimulator app;
-
-    public void testConstructor() throws SimulationException, RemoteException
-    {
-        System.out.println("CADSimulator constructor");
-        System.setProperty("CONFIG_DIR", "config/testConfig");
-        Window cadwindow = null;
-        if (System.getProperty("CONFIG_DIR") != null)
-        {
-            cadwindow = WindowInterceptor.run(new Trigger()
-            {
-                public void run()
-                {
-                    try
-                    {
-                        app = new CADSimulator(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + "cad_simulator_config.properties");
-                    }
-                    catch (Exception e)
-                    {
-                        fail("Couldn't launch CADSimulator");
-                    }
-                }
-            });
-        }
-        else
-        {
-            fail("CONFIG_DIR system property not defined.");
-        }
-        assertEquals("CAD Simulator", cadwindow.getTitle());
-        Panel mainPanel = cadwindow.getPanel("contentPane");
-        TextBox txtStatus = mainPanel.getTextBox("simulationStatus");
-        assertEquals("No Script", txtStatus.getText());
-        TextBox terminals = mainPanel.getTextBox("termConnectedTF");
-        assertEquals("0", terminals.getText().trim());
-        assertEquals("No", mainPanel.getTextBox("managerConnectedTF").getText().trim());
-
-        CADClientInterface ci = new CADSimulatorTest.FakeClient();
-        app.theCoordinator.registerForCallback(ci);
-        assertEquals("1", terminals.getText().trim());
-        app.theCoordinator.registerForCallback(ci);
-        assertEquals("2", terminals.getText().trim());
-
-        SimulationManagerInterface si = new CADSimulatorTest.FakeSimMgr();
-        app.theCoordinator.registerForCallback(si);
-        assertEquals("Yes", mainPanel.getTextBox("managerConnectedTF").getText().trim());
-
-        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
-        cadSimLogger.logp(Level.INFO, "", "", "Sample Info Message.");
-
-        Panel infoPane = mainPanel.getPanel("InfoMessagesPane");
-        TextBox infoText = infoPane.getTextBox("infoMessagesTA");
-        assertEquals(". = Sample Info Message.\n", infoText.getText());
-
-        app = null;
-    }
-
-    class FakeClient implements CADClientInterface
-    {
-
-        @Override
-        public void refresh() throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-    }
-
-    class FakeSimMgr implements SimulationManagerInterface
-    {
-
-        @Override
-        public void tick(long theTime) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public void eventOccured(Integer logNumber, IncidentEvent theEvent) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public void incidentAdded(Incident newIncident) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public void incidentStarted(Integer logNumber) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public void incidentRemoved(Integer logNumber) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public void setScriptStatus(CADEnums.SCRIPT_STATUS newStatus) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public void setParamicsStatus(CADEnums.PARAMICS_STATUS newStatus) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-    }
-}
Index: trunk/test/tmcsim/simulationmanager/IncidentHistoryPanelDriver.java
===================================================================
--- trunk/test/tmcsim/simulationmanager/IncidentHistoryPanelDriver.java	(revision 47)
+++ trunk/test/tmcsim/simulationmanager/IncidentHistoryPanelDriver.java	(revision 47)
@@ -0,0 +1,47 @@
+package tmcsim.simulationmanager;
+
+import java.awt.BorderLayout;
+import java.util.Vector;
+import javax.swing.JFrame;
+import tmcsim.cadmodels.*;
+import tmcsim.client.cadclientgui.data.IncidentEvent;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class IncidentHistoryPanelDriver
+{
+
+    public static void main(String[] args)
+    {
+        // Create an IncidentEvent
+        Vector dummy = new Vector();
+        IncidentInquiryHeader hdr = new IncidentInquiryHeader();
+        // The incident type is a 4-digit string (Use MMYY for month and year of your birth)
+        hdr.type = "1179";
+        // The incident location is the name of your home town
+        hdr.fullLocation = "San Luis Obispo";
+        IncidentInquiryModel_obj mo = new IncidentInquiryModel_obj();
+        mo.setHeader(hdr);
+        // The incident details is a parade on the main street (provide street name for your home town)
+        IncidentInquiryDetails det = new IncidentInquiryDetails("1", "Parade on Higuera", false);
+        mo.addDetail(det);
+        IncidentEvent event = new IncidentEvent(10, mo, "", 4, dummy, dummy);
+        // Create an IncidentHistoryPanel
+        IncidentHistoryPanel ihPanel = new IncidentHistoryPanel();
+        // Add the event to the panel
+        ihPanel.updateIncidentHistory(event);
+
+        // Create the frame.
+        JFrame frame = new JFrame("Incident Panel Demo");
+        // Specify closing behavior
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        // Add component to the frame.
+        frame.getContentPane().add(ihPanel, BorderLayout.CENTER);
+        // Size the frame.
+        frame.pack();
+        // Show it.
+        frame.setVisible(true);
+    }
+}
Index: trunk/test/tmcsim/simulationmanager/model/AppliedDiversionTableItemTest.java
===================================================================
--- trunk/test/tmcsim/simulationmanager/model/AppliedDiversionTableItemTest.java	(revision 47)
+++ trunk/test/tmcsim/simulationmanager/model/AppliedDiversionTableItemTest.java	(revision 47)
@@ -0,0 +1,26 @@
+package tmcsim.simulationmanager.model;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class AppliedDiversionTableItemTest extends TestCase
+{
+
+    public AppliedDiversionTableItemTest(String testName)
+    {
+        super(testName);
+    }
+
+    public void testCompareTo()
+    {
+        System.out.println("compareTo");
+        AppliedDiversionTableItem arg = new AppliedDiversionTableItem("1", "o", "n", 1, 1L);
+        AppliedDiversionTableItem instance = new AppliedDiversionTableItem("1", "o", "n", 1, 1L);
+        int expResult = 0;
+        int result = instance.compareTo(arg);
+        assertEquals(expResult, result);
+    }
+}
Index: trunk/test/tmcsim/paramicslog/ParamicsLogRMITestSkeleton.java
===================================================================
--- trunk/test/tmcsim/paramicslog/ParamicsLogRMITestSkeleton.java	(revision 47)
+++ trunk/test/tmcsim/paramicslog/ParamicsLogRMITestSkeleton.java	(revision 47)
@@ -0,0 +1,94 @@
+package tmcsim.paramicslog;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.fail;
+import junit.framework.TestCase;
+import tmcsim.cadsimulator.CADSimulator;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class ParamicsLogRMITestSkeleton extends TestCase
+{
+
+    public ParamicsLogRMITestSkeleton(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+    String propsfile = "config/paramics_communicator_logging.properties";
+
+    /**
+     * Test of getInstance method, of class ParamicsLog.
+     */
+    public void testGetInstance() throws ScriptException, SimulationException, RemoteException, FileNotFoundException, IOException
+    {
+        System.out.println("getInstance");
+        try
+        {
+            CADSimulator engine = new CADSimulator("config/testConfig/cad_simulator_console_config.properties");
+        } catch (Exception e)
+        {
+            fail("Couldn't launch CADSimulator");
+        }
+        try
+        {
+            Thread.sleep(2000);
+        } catch (InterruptedException ex)
+        {
+        }
+        // This seems to fail because the ParamicsLog static initializer gets
+        // run before the CADSimulator is created, so no RMI connection can be made.
+        ParamicsLog plog = ParamicsLog.getInstance();
+        Properties paramicsLogProp = new Properties();
+        paramicsLogProp.load(new FileInputStream(propsfile));
+        String logFilename = paramicsLogProp.getProperty("LogFile");
+        File logFile = new File(logFilename);
+        assertTrue("log file doesn't exist", logFile.exists());
+
+        plog.writeToLog("Hello friendly log.");
+        String expected = "\n<!-- Time written to file: ? -->\nHello friendly log.\n";
+        String actual = plog.getLog();
+        assertEquals("log written incorrectly", expected, actual);
+    }
+
+    public void testFormatEasyTime()
+    {
+        ParamicsLog plog = ParamicsLog.getInstance();
+        String expected = "00:01:02";
+        String actual = plog.formatTime(62l);
+        assertEquals("time format wrong", expected, actual);
+
+        expected = "1:00:01";
+        actual = plog.formatTime(3601l);
+        assertEquals("time format wrong", expected, actual);
+    }
+
+    public void testFormatDate() throws ParseException
+    {
+        ParamicsLog plog = ParamicsLog.getInstance();
+        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
+        String expected = "01:01:01";
+        Date one = formatter.parse(expected);
+        long millis = one.getTime();
+        String actual = plog.formatTime(millis);
+        assertEquals("time format wrong", expected, actual);
+    }
+}
Index: trunk/test/tmcsim/paramicslog/ParamicsLogFileHandlerTest.java
===================================================================
--- trunk/test/tmcsim/paramicslog/ParamicsLogFileHandlerTest.java	(revision 47)
+++ trunk/test/tmcsim/paramicslog/ParamicsLogFileHandlerTest.java	(revision 47)
@@ -0,0 +1,56 @@
+package tmcsim.paramicslog;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.util.Properties;
+import java.util.logging.Logger;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import junit.framework.TestCase;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class ParamicsLogFileHandlerTest extends TestCase
+{
+
+    public ParamicsLogFileHandlerTest(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+    String propsfile = "config/paramics_communicator_logging.properties";
+
+    /**
+     * Test of getInstance method, of class ParamicsLog.
+     */
+    public void testGetInstance() throws ScriptException, SimulationException, RemoteException, FileNotFoundException, IOException
+    {
+        System.out.println("getInstance");
+        //ParamicsLog plog = ParamicsLog.getInstance();
+        Properties paramicsLogProp = new Properties();
+        paramicsLogProp.load(new FileInputStream(propsfile));
+        String logFilename = paramicsLogProp.getProperty("LogFile");
+        // This test assumes there is NO CADSimulator running.
+        Logger logger = Logger.getLogger("tmcsim.parmicsLog");
+        ParamicsLogFileHandler fh = ParamicsLogFileHandler.getInstance();
+        logger.addHandler(fh);
+        logger.info("Hello friendly log.");
+        File logFile = new File(logFilename);
+        assertTrue("log file doesn't exist", logFile.exists());
+        String expected = "\n<!-- Time written to file: ? -->\nHello friendly log.\n";
+        String actual = fh.getLog();
+        assertEquals("log written incorrectly", expected, actual);
+    }
+}
Index: trunk/IDE_metadata/NetBeans/TMCSim/build.xml
===================================================================
--- trunk/IDE_metadata/NetBeans/TMCSim/build.xml	(revision 44)
+++ trunk/IDE_metadata/NetBeans/TMCSim/build.xml	(revision 47)
@@ -71,5 +71,5 @@
     <!--         *** Build a jar with everything ***            -->
     <property name="deploy.jar.name" value="TMCSimAll"/>
-    <property name="deploy.dir" value="deploy"/>
+    <property name="deploy.dir" value="${workdir}/deploy"/>
     <property name="deploy.jar" value="${deploy.dir}/${deploy.jar.name}.jar"/>
 
Index: trunk/src/tmcsim/application.properties
===================================================================
--- trunk/src/tmcsim/application.properties	(revision 44)
+++ trunk/src/tmcsim/application.properties	(revision 47)
@@ -1,5 +1,5 @@
-#Thu, 23 Jun 2016 19:19:14 -0700
+#Tue, 28 Jun 2016 14:56:40 -0700
 
-Application.revision=43
+Application.revision=44
 
-Application.buildnumber=1
+Application.buildnumber=10
Index: trunk/src/tmcsim/simulationmanager/SimulationManager.java
===================================================================
--- trunk/src/tmcsim/simulationmanager/SimulationManager.java	(revision 33)
+++ trunk/src/tmcsim/simulationmanager/SimulationManager.java	(revision 47)
@@ -9,9 +9,8 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
-
 import javax.swing.JOptionPane;
 import javax.swing.UIManager;
-
 import tmcsim.common.CADEnums.PARAMICS_STATUS;
+import tmcsim.common.ScriptException;
 import tmcsim.common.SimulationException;
 
@@ -48,5 +47,5 @@
 
     private static final String CONFIG_FILE_NAME = "sim_manager_config.properties";
-	/**
+    /**
      * Error logger.
      */
@@ -192,18 +191,35 @@
 
     /**
+     * Load a simulation script from the specified file.
+     *
+     * @param scriptFile the XML file containing the simulation control script
+     * to be run.
+     * @throws ScriptException if the script throws an exception
+     * @throws SimulationException if the simulation throws an exception
+     */
+    public void loadScript(File scriptFile) throws ScriptException, SimulationException
+    {
+        theSimManagerModel.loadScript(scriptFile);
+    }
+
+    /**
      * Main class.
      *
      * @param args Command line arguments.
      */
-    static public void main(String[] args) {
+    static public void main(String[] args)
+    {
         //System.setProperty("swing.defaultlaf", "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
-    	if(System.getProperty("CONFIG_DIR") == null){
-        	System.setProperty("CONFIG_DIR", "config");
-        }
-    	
-        try {           
-        	UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+        if (System.getProperty("CONFIG_DIR") == null)
+        {
+            System.setProperty("CONFIG_DIR", "config");
+        }
+
+        try
+        {
+            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
             new SimulationManager(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME);
-        } catch (Exception e) {
+        } catch (Exception e)
+        {
             simManLogger.logp(Level.SEVERE, "SimulationManager", "Main",
                     "Error occured initializing application", e);
Index: trunk/src/tmcsim/simulationmanager/SimulationManagerView.java
===================================================================
--- trunk/src/tmcsim/simulationmanager/SimulationManagerView.java	(revision 9)
+++ trunk/src/tmcsim/simulationmanager/SimulationManagerView.java	(revision 47)
@@ -866,4 +866,5 @@
         paramicsStatusLabel     = new JLabel("Status:");
         paramicsStatusInfoLabel = new JLabel("Unknown");
+        paramicsStatusInfoLabel.setName("paramicsStatusInfoLabel");
         paramicsStatusBox.add(paramicsStatusLabel);
         paramicsStatusBox.add(Box.createHorizontalStrut(10));
Index: trunk/src/tmcsim/paramicscommunicator/ParamicsCommunicator.java
===================================================================
--- trunk/src/tmcsim/paramicscommunicator/ParamicsCommunicator.java	(revision 33)
+++ trunk/src/tmcsim/paramicscommunicator/ParamicsCommunicator.java	(revision 47)
@@ -19,5 +19,5 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
-
+import javax.swing.JFrame;
 import javax.swing.JOptionPane;
 import javax.swing.UIManager;
@@ -140,8 +140,13 @@
     public ParamicsCommunicator(String propertiesFile)
     {
+        paramLogger.logp(Level.INFO, "ParamicsCommunicator", "Constructor",
+                "Entering ");
 
         writers = new TreeMap<String, ParamicsFileWriter>();
         readers = new TreeMap<String, ParamicsFileReader>();
 
+        theGUI = new ParamicsCommunicatorGUI();
+        addObserver(theGUI);
+        theGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         try
         {
@@ -301,4 +306,14 @@
                         "Dropped Connection", JOptionPane.ERROR_MESSAGE);
                 break;
+            }
+            try
+            {
+                Thread.sleep(2000);
+                paramLogger.logp(Level.INFO, "ParamicsCommunicator",
+                        "run", "sleeping.");
+            } catch (InterruptedException ex)
+            {
+                paramLogger.logp(Level.INFO, "ParamicsCommunicator",
+                        "run", "Exception in reading data from the socket.", ex);
             }
         }
@@ -456,5 +471,15 @@
             } catch (SocketTimeoutException ste)
             {
-                System.out.println("...waiting for socket connection from the CAD Simulator...");
+                System.out.println("...waiting...");
+                try
+                {
+                    Thread.sleep(2000);
+                    paramLogger.logp(Level.INFO, "ParamicsCommunicator",
+                            "initializeSockets", "sleeping.");
+                } catch (InterruptedException ex)
+                {
+                    paramLogger.logp(Level.INFO, "ParamicsCommunicator",
+                            "initializeSockets", "Exception exiting for socket.", ex);
+                }
             } catch (IOException ioe)
             {
@@ -462,4 +487,5 @@
                         + "the receiving socket on port " + socketPort);
             }
+
         }
 
Index: trunk/src/tmcsim/paramicscommunicator/ParamicsFileReader.java
===================================================================
--- trunk/src/tmcsim/paramicscommunicator/ParamicsFileReader.java	(revision 40)
+++ trunk/src/tmcsim/paramicscommunicator/ParamicsFileReader.java	(revision 47)
@@ -5,4 +5,5 @@
 import java.io.FileWriter;
 import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.util.Observable;
 import java.util.Timer;
@@ -67,4 +68,8 @@
      */
     private long readerInterval;
+    /**
+     * Time formatter for diagnostic messages
+     */
+    private SimpleDateFormat formatter;
 
     /**
@@ -80,12 +85,10 @@
         public void run()
         {
-//            paramLogger.logp(Level.INFO,
-//                    "ParamicsFileReader.ReaderTimerTask", "run()",
-//                    "Waiting for " + inputFile + " to be modified.");
+//            System.out.println(
+//                    "Checking last modified time on " + inputFile.getName()
+//                    + formatter.format(lastModified) + ":" + formatter.format(inputFile.lastModified()));
+
             if (lastModified < inputFile.lastModified())
             {
-//                paramLogger.logp(Level.INFO,
-//                        "ParamicsFileReader.ReaderTimerTask", "run()",
-//                        "Cool, " + inputFile + " has been modified, let's read it.");
 
                 try
@@ -101,9 +104,4 @@
                     Element messageElem = readerDoc.createElement(PARAMICS_COMM_TAGS.MESSAGE.tag);
                     String fileContents = readFromFile();
- //                   int stringlen = Math.min(160, fileContents.length()-1);
-                    // Log two lines that were read
-//                    paramLogger.logp(Level.INFO,
-//                            "ParamicsFileReader.ReaderTimerTask", "run()",
-//                            "Nice, we read " + fileContents.length() + " bytes.");
                     messageElem.appendChild(readerDoc.createTextNode(fileContents));
                     readerElem.appendChild(messageElem);
@@ -142,4 +140,5 @@
         try
         {
+            formatter = new SimpleDateFormat("HH:mm:ss");
             readerID = id;
             readerInterval = interval;
@@ -159,5 +158,5 @@
         {
             paramLogger.logp(Level.SEVERE, "ParamicsFileReader",
-                    "Constructor()", "Exception in initializing file reading.", ioe);
+                    "Constructor()", "Exception in initializing file reading of "+workingDir + targetFile, ioe);
         }
     }
@@ -194,4 +193,6 @@
 
         lastModified = inputFile.lastModified();
+//        System.out.println(
+//                "Read from a file last modified at " + formatter.format(lastModified));
 
         setChanged();
Index: trunk/src/tmcsim/paramicscommunicator/gui/ParamicsCommunicatorGUI.java
===================================================================
--- trunk/src/tmcsim/paramicscommunicator/gui/ParamicsCommunicatorGUI.java	(revision 29)
+++ trunk/src/tmcsim/paramicscommunicator/gui/ParamicsCommunicatorGUI.java	(revision 47)
@@ -11,5 +11,4 @@
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
-
 import javax.swing.BorderFactory;
 import javax.swing.Box;
@@ -21,5 +20,4 @@
 import javax.swing.JTabbedPane;
 import javax.swing.JTextArea;
-
 import tmcsim.common.RevisionNumber;
 import tmcsim.paramicscommunicator.FileIOUpdate;
@@ -126,5 +124,6 @@
                         "Exception in receiving FileIOUpdate object.", e);
             }
-        } else if (arg instanceof FileRegUpdate)
+        }
+        else if (arg instanceof FileRegUpdate)
         {
             try
@@ -218,5 +217,5 @@
                 BorderFactory.createRaisedBevelBorder(), "Registered Readers "),
                 BorderFactory.createEmptyBorder(5, 5, 5, 5)));
-        
+
         fileWriterTabs = new JTabbedPane();
         fileWriterTabs.setAlignmentX(Box.CENTER_ALIGNMENT);
@@ -243,5 +242,5 @@
         tabbedBox.add(fileReaderTabs);
         tabbedBox.add(fileWriterTabs);
-        
+
         Box guiBox = new Box(BoxLayout.Y_AXIS);
         guiBox.add(tabbedBox);
@@ -255,5 +254,5 @@
         setResizable(false);
         pack();
-        setVisible(true);
+        //setVisible(true);
     }
 
@@ -284,5 +283,4 @@
 
     }
-    
     private JTabbedPane fileReaderTabs;
     private JTabbedPane fileWriterTabs;
Index: trunk/src/tmcsim/paramicscommunicator/PComm.java
===================================================================
--- trunk/src/tmcsim/paramicscommunicator/PComm.java	(revision 47)
+++ trunk/src/tmcsim/paramicscommunicator/PComm.java	(revision 47)
@@ -0,0 +1,586 @@
+package tmcsim.paramicscommunicator;
+
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketTimeoutException;
+import java.util.Observable;
+import java.util.Observer;
+import java.util.Properties;
+import java.util.TreeMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import tmcsim.common.CADProtocol.PARAMICS_ACTIONS;
+import tmcsim.common.CADProtocol.PARAMICS_COMM_TAGS;
+import tmcsim.paramicscommunicator.FileIOUpdate.IO_TYPE;
+import tmcsim.paramicscommunicator.FileRegUpdate.REG_TYPE;
+import tmcsim.paramicscommunicator.gui.ParamicsCommunicatorGUI;
+
+/**
+ * ParamicsCommunicator is the main class for this module. The Paramics
+ * Communicator is used to provide communication between the CAD Simulator and
+ * the Paramics traffic modeler. While the application is running, data is
+ * received on a socket from the CAD Simulator. Transmitted data are XML
+ * documents containing information and action commands. The CAD Simulator
+ * registers readers and writers with the ParamicsCommunicator. Any data read by
+ * a ParamicsReader is sent back to the CAD Simulator. All data to be written by
+ * a ParamicsWriter is received through the socket.<br><br>
+ * The properties file for the ParamicsCommunicator class contains the following
+ * data.<br>
+ * <code>
+ * -----------------------------------------------------------------------------<br>
+ * Socket Port The port number to use for socket communication.<br>
+ * Working Directory The working directory use for Paramics file
+ * communication.<br>
+ * Error File The target file to use for error logging.<br>
+ * -----------------------------------------------------------------------------<br>
+ * Example File: <br>
+ * SocketPort = 4450 <br>
+ * WorkingDirectory = c:\\tmc_simulator\\ <br>
+ * ErrorFile = sim_mgr_error.xml <br>
+ * -----------------------------------------------------------------------------<br>
+ * </code>
+ *
+ * @author Matthew Cechini (mcechini@calpoly.edu)
+ * @version $Date: 2009/04/17 16:27:46 $ $Revision: 1.7
+ */
+public class PComm extends Observable implements Observer
+{
+
+    /**
+     * Error logger.
+     */
+    private static Logger paramLogger = Logger.getLogger("tmcsim.paramicscommunicator");
+
+    /**
+     * Enumeration containing property names.
+     *
+     * @author Matthew Cechini
+     */
+    private static enum PROPERTIES
+    {
+
+        SOCKET_PORT("SocketPort"),
+        WORKING_DIR("WorkingDirectory");
+        public String name;
+
+        private PROPERTIES(String n)
+        {
+            name = n;
+        }
+    }
+    /**
+     * Properties object.
+     */
+    private Properties paramicsCommProp = null;
+    /**
+     * Current working directory where files will be read and written
+     */
+    private String workingDirectory = null;
+    /**
+     * Socket used to create socket communication with the CAD Simulator.
+     */
+    private ServerSocket serverSocket = null;
+    /**
+     * Soccket used to communicate with CAD Simulator.
+     */
+    private Socket paramicsSocket = null;
+    /**
+     * Input Stream for reading data from the CAD Simulator.
+     */
+    private ObjectInputStream in = null;
+    /**
+     * Output Stream for writing data to the CAD Simulator.
+     */
+    private ObjectOutputStream out = null;
+    /**
+     * Map of all current ParamicsFileWriters referenced by I/O ID.
+     */
+    private TreeMap<String, ParamicsFileWriter> writers = null;
+    /**
+     * Map of all current ParamicsFileReaders referenced by I/O ID.
+     */
+    private TreeMap<String, ParamicsFileReader> readers = null;
+    /**
+     * The view class for the ParamicsCommunicator.
+     */
+    private static ParamicsCommunicatorGUI theGUI;
+    /**
+     * The thread used to initialize the socket connection with the CADSimulator
+     */
+    Thread initThread;
+
+    /**
+     * Constructor. Read in the property values. If the properties file does not
+     * contain a value for the working directory, open a dialog to prompt the
+     * user for the path of the Paramics working directory. An empty string is
+     * not accepted. A null signifies that the user pressed cancel. Prompt the
+     * user to accept the cancel and exit the application if confirmed. Continue
+     * until a valid directory has been entered, that exists, and append a '\'
+     * to the end of the directory if necessary.
+     *
+     * Initialize the Sockets and begin communication.
+     *
+     * @param propertiesFilePath File Path of ParamicsCommunicator properties
+     * file.
+     */
+    public PComm(String propertiesFile)
+    {
+        writers = new TreeMap<String, ParamicsFileWriter>();
+        readers = new TreeMap<String, ParamicsFileReader>();
+
+        try
+        {
+            paramicsCommProp = new Properties();
+            paramicsCommProp.load(new FileInputStream(propertiesFile));
+
+            if (paramicsCommProp.getProperty(PROPERTIES.SOCKET_PORT.name) == null)
+            {
+                JOptionPane.showMessageDialog(theGUI,
+                        "Properties file missing CAD Simulator Port information.",
+                        "Invalid Configuration", JOptionPane.ERROR_MESSAGE);
+                System.exit(0);
+            }
+            else if (paramicsCommProp.getProperty(PROPERTIES.WORKING_DIR.name) == null
+                    || paramicsCommProp.getProperty(PROPERTIES.WORKING_DIR.name).length() == 0)
+            {
+
+                try
+                {
+                    String workingDir = null;
+
+                    while (workingDir == null || workingDir.length() == 0)
+                    {
+                        workingDir = JOptionPane.showInputDialog(null,
+                                "Please set the output directory for Paramics communication.",
+                                "Paramics Working Directory", JOptionPane.QUESTION_MESSAGE);
+
+                        if (workingDir == null)
+                        {
+                        }
+                        else if (!new File(workingDir).exists())
+                        {
+                            JOptionPane.showMessageDialog(null,
+                                    "Directory does not exist.",
+                                    "Invalid Working Directory", JOptionPane.WARNING_MESSAGE);
+
+                            workingDir = null;
+                        }
+                        else if (!new File(workingDir).isDirectory())
+                        {
+                            JOptionPane.showMessageDialog(null,
+                                    workingDir + " is not a directory.",
+                                    "Invalid Working Directory", JOptionPane.WARNING_MESSAGE);
+
+                            workingDir = null;
+                        }
+                    }
+
+                    if (workingDir.lastIndexOf("\\") != workingDir.length() - 1)
+                    {
+                        workingDir = workingDir + "\\";
+                    }
+
+                    paramicsCommProp.setProperty(PROPERTIES.WORKING_DIR.name, workingDir);
+                    paramicsCommProp.store(new FileOutputStream(propertiesFile), "");
+                } catch (IOException ioe)
+                {
+                    paramLogger.logp(Level.SEVERE, "ParamicsCommunicator", "Constructor",
+                            "Exception in writing properties file.", ioe);
+                }
+
+            }
+
+            workingDirectory = paramicsCommProp.getProperty(
+                    PROPERTIES.WORKING_DIR.name).trim();
+
+        } catch (Exception e)
+        {
+            paramLogger.logp(Level.SEVERE, "ParamicsCommunicator", "Constructor",
+                    "Exception in reading properties file.", e);
+        }
+
+        Integer desiredPort = Integer.parseInt(paramicsCommProp.getProperty(
+                PROPERTIES.SOCKET_PORT.name).trim());
+        /* Start a thread to initialize the sockets that talk to CADsimulator */
+        initThread = new Thread(new SocketStarter(desiredPort));
+        initThread.start();
+    }
+
+    /**
+     * For testing, we want to be able to provide a non-visible instance of the
+     * GUI to be used. (As main won't be called).
+     *
+     * @param viewer
+     */
+    public void setGUI(ParamicsCommunicatorGUI viewer)
+    {
+        theGUI = viewer;
+        addObserver(theGUI);
+    }
+
+    /**
+     * Start the thread that does the main work of the communicator. This method
+     * waits until the initial thread has opened the needed sockets to connect
+     * to the CADSimulator, then it starts the socket reader thread, which runs
+     * until the application is terminated. Usage: Normally this method is
+     * called immediately after constructing this object, but for testing
+     * purposes it is available to be invoked by the test harness after the
+     * Simulation Manager initiates a connection.
+     */
+    public void startReading()
+    {
+        while (initThread.isAlive())
+        {
+            try
+            {
+                Thread.sleep(1000);
+            } catch (InterruptedException ex)
+            {
+                paramLogger.logp(Level.SEVERE, "ParamicsCommunicator", "runstarter",
+                        "Sleep interrupted.");
+            }
+        }
+        Runnable sr = new SocketReader();
+        new Thread(sr).start();
+    }
+
+    /**
+     * Transmits a message XML document object to the CAD Simulator.
+     *
+     * @param mess The ParamicsCommMessage to be transmitted.
+     */
+    private void write(Document mess)
+    {
+
+        synchronized (paramicsSocket)
+        {
+            try
+            {
+                out.writeObject(mess);
+                out.flush();
+            } catch (Exception e)
+            {
+                paramLogger.logp(Level.SEVERE, "ParamicsCommunicator", "write",
+                        "Exception in writing to the socket.", e);
+            }
+        }
+    }
+
+    /**
+     * Observer/Observable update method. The Paramics Communicator observers
+     * registered ParamicsReaders. When messages are to be sent, they are sent
+     * through this method. All messages are ParamicsCommMessage objects. Send
+     * these messages to the write() method for transmission on the socket.
+     */
+    public void update(Observable o, Object arg)
+    {
+
+        if (arg instanceof Document)
+        {
+            write((Document) arg);
+        }
+    }
+
+    private class SocketReader implements Runnable
+    {
+
+        /**
+         * Runnable method. While this thread is not interrupted, read in an
+         * object from the socket input stream. If an object exists, call
+         * doMessage() to parse and perform the received action in the message.
+         */
+        public void run()
+        {
+
+            while (true)
+            {
+                try
+                {
+                    doMessage((Document) in.readObject());
+                } catch (SocketTimeoutException ste)
+                {
+                    //just try again
+                } catch (EOFException eofe)
+                {
+                    paramLogger.logp(Level.SEVERE, "ParamicsCommunicator",
+                            "run", "EOF Exception in reading data from the socket.", eofe);
+                } catch (Exception e)
+                {
+                    paramLogger.logp(Level.SEVERE, "ParamicsCommunicator",
+                            "run", "Exception in reading data from the socket.", e);
+
+                    JOptionPane.showMessageDialog(theGUI,
+                            "Connection has been lost to the CAD Simulator.  "
+                            + "Paramics Communicator will now shutdown.",
+                            "Dropped Connection", JOptionPane.ERROR_MESSAGE);
+                    break;
+                }
+                try
+                {
+                    // Sleep for a second while waiting in this infinite loop
+                    // to yield to other threads run by test harness.
+                    Thread.sleep(1000);
+                } catch (InterruptedException ex)
+                {
+                    paramLogger.logp(Level.INFO, "ParamicsCommunicator",
+                            "run", "Exception in reading data from the socket.", ex);
+                }
+            }
+
+
+            try
+            {
+                in.close();
+            } catch (Exception e)
+            {
+            }
+            try
+            {
+                out.close();
+            } catch (Exception e)
+            {
+            }
+            try
+            {
+                serverSocket.close();
+            } catch (Exception e)
+            {
+            }
+            try
+            {
+                paramicsSocket.close();
+            } catch (Exception e)
+            {
+            }
+
+        }
+    }
+
+    /**
+     * Perform the action represented in the received XML document message.
+     * First determine if the action is from a READER, WRITER, and RESET. If the
+     * paramics action is REGISTER, add a new ParamicsFileReader/Writer to the
+     * local list of readers/writers and update the GUI with a FileRegUpdate
+     * object. If the paramics action is UNREGISTER, remove the
+     * ParamicsFileReader/Writer from the local list of readers/writers and
+     * update the GUI with a FileRegUpdate object. If RESET is received, clear
+     * all readers and writers.
+     *
+     * @param mess Received XML document message.
+     */
+    private void doMessage(Document mess)
+    {
+
+        Element rootElement = mess.getDocumentElement();
+
+        String id = null;
+        String action = null;
+
+        switch (PARAMICS_COMM_TAGS.fromString(rootElement.getNodeName()))
+        {
+            case READER:
+                id = rootElement.getAttribute(PARAMICS_COMM_TAGS.ID.tag);
+                action = rootElement.getAttribute(PARAMICS_COMM_TAGS.ACTION.tag);
+
+                switch (PARAMICS_ACTIONS.fromString(action))
+                {
+                    case REGISTER:
+                        Integer interval = Integer.parseInt(rootElement.getChildNodes().item(0).getTextContent());
+                        String targetFile = rootElement.getChildNodes().item(1).getTextContent();
+
+                        readers.put(id, new ParamicsFileReader(workingDirectory, id,
+                                interval, targetFile));
+                        readers.get(id).addObserver(this);
+                        readers.get(id).addObserver(theGUI);
+
+                        setChanged();
+                        notifyObservers(new FileRegUpdate(IO_TYPE.READ,
+                                REG_TYPE.REGISTER, id, targetFile, interval));
+                        break;
+                    case UNREGISTER:
+                        readers.get(id).deleteObserver(this);
+                        readers.get(id).deleteObserver(theGUI);
+                        readers.remove(id);
+
+                        setChanged();
+                        notifyObservers(new FileRegUpdate(IO_TYPE.READ,
+                                REG_TYPE.UNREGISTER, id, null, null));
+                        break;
+                }
+                break;
+            case WRITER:
+                id = rootElement.getAttribute(PARAMICS_COMM_TAGS.ID.tag);
+                action = rootElement.getAttribute(PARAMICS_COMM_TAGS.ACTION.tag);
+
+                switch (PARAMICS_ACTIONS.fromString(action))
+                {
+                    case REGISTER:
+                        String targetFile = rootElement.getChildNodes().item(0).getTextContent();
+
+                        writers.put(id, new ParamicsFileWriter(id,
+                                workingDirectory, targetFile));
+                        writers.get(id).addObserver(theGUI);
+
+                        setChanged();
+                        notifyObservers(new FileRegUpdate(IO_TYPE.WRITE,
+                                REG_TYPE.REGISTER, id, targetFile, null));
+                        break;
+                    case UNREGISTER:
+                        writers.remove(id);
+
+                        writers.get(id).deleteObserver(theGUI);
+
+                        setChanged();
+                        notifyObservers(new FileRegUpdate(IO_TYPE.WRITE,
+                                REG_TYPE.UNREGISTER, id, null, null));
+                        break;
+                    case WRITE_FILE:
+                        writers.get(id).writeMessage((Element) rootElement.getChildNodes().item(0));
+                        break;
+                }
+                break;
+            case RESET:
+                readers.clear();
+                writers.clear();
+                break;
+        }
+    }
+
+    private class SocketStarter implements Runnable
+    {
+
+        Integer socketPort;
+
+        /**
+         * Method waits to accept a socket connection from the CAD Simulator.
+         * When a connection has been established the method exits. The input
+         * and output streams are created on the new socket.
+         *
+         * @param socketPort Socket port to use for establishing Socket
+         * communication.
+         * @throws IOException if there is an exception in establishing Socket
+         * communication.
+         */
+        //private void initializeSockets(Integer socketPort) throws IOException
+        public SocketStarter(Integer socketPort)
+        {
+            this.socketPort = socketPort;
+        }
+
+        public void run()
+        {
+
+            boolean waiting = true;
+
+            try
+            {
+                serverSocket = new ServerSocket(socketPort);
+                //delay for accept timeout(milliseconds)
+                serverSocket.setSoTimeout(10 * 1000);
+            } catch (IOException ioe)
+            {
+                paramLogger.logp(Level.SEVERE, "ParamicsCommunicator",
+                        "initializeSockets", "Exception in creating "
+                        + "the server socket on port " + socketPort + ", terminating.");
+                System.exit(1);
+            }
+
+            while (waiting)
+            {
+                try
+                {
+                    paramicsSocket = serverSocket.accept();
+                    waiting = false;
+                } catch (SocketTimeoutException ste)
+                {
+                    System.out.println("...waiting...");
+                    try
+                    {
+                        Thread.sleep(2000);
+                        paramLogger.logp(Level.INFO, "ParamicsCommunicator",
+                                "initializeSockets", "sleeping.");
+                    } catch (InterruptedException ex)
+                    {
+                        paramLogger.logp(Level.INFO, "ParamicsCommunicator",
+                                "initializeSockets", "Exception exiting for socket.", ex);
+                    }
+                } catch (IOException ioe)
+                {
+                    paramLogger.logp(Level.SEVERE, "ParamicsCommunicator",
+                            "initializeSockets", "Exception in creating "
+                            + "the receiving socket on port " + socketPort + ", terminating.");
+                    System.exit(1);
+                }
+
+            }
+
+
+            //** out must be performed before in to unlock for connecting socket **//
+            try
+            {
+                out = new ObjectOutputStream(paramicsSocket.getOutputStream());
+                in = new ObjectInputStream(paramicsSocket.getInputStream());
+            } catch (IOException ioe)
+            {
+                paramLogger.logp(Level.SEVERE, "ParamicsCommunicator",
+                        "initializeSockets", "Exception in creating "
+                        + "input and output streams on socket, terminating.");
+                System.exit(1);
+            }
+
+        }
+    }
+
+    /**
+     * Construct the ParamicsCommunicator with the properties file path, either
+     * from the command line arguments or default.
+     *
+     * @param args Command line arguments.
+     */
+    public static void main(String[] args)
+    {
+        System.setProperty("PARAMICS_COMM_PROPERTIES", "config/paramics_communicator_config.properties");
+
+        try
+        {
+            if (System.getProperty("PARAMICS_COMM_PROPERTIES") != null)
+            {
+                PComm pc = new PComm(System.getProperty("PARAMICS_COMM_PROPERTIES"));
+                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+                theGUI = new ParamicsCommunicatorGUI();
+                pc.addObserver(theGUI);
+                theGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+                theGUI.setVisible(true);
+                pc.startReading();
+
+            }
+            else
+            {
+                throw new Exception("PARAMICS_COMM_PROPERTIES system property not defined.");
+            }
+        } catch (Exception e)
+        {
+            paramLogger.logp(Level.SEVERE, "ParamicsCommunicator", "Main",
+                    "Error occured initializing application", e);
+
+            JOptionPane.showMessageDialog(null, e.getMessage(),
+                    "Error - Program Exiting", JOptionPane.ERROR_MESSAGE);
+
+            System.exit(-1);
+        }
+
+
+    }
+}
Index: trunk/src/tmcsim/paramicslog/ParamicsLog.java
===================================================================
--- trunk/src/tmcsim/paramicslog/ParamicsLog.java	(revision 33)
+++ trunk/src/tmcsim/paramicslog/ParamicsLog.java	(revision 47)
@@ -10,9 +10,5 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
-
 import javax.swing.JOptionPane;
-
-import org.w3c.dom.Element;
-
 import tmcsim.common.SimulationException;
 import tmcsim.interfaces.CoordinatorInterface;
@@ -21,40 +17,38 @@
 /**
  * Logs communication from ParamicsCommunicator to ParamicsSimulator.
- * 
- * The system property "PARAMICS_LOG_CONFIG" should be set to the path
- * where the properties file for this class is located. <br><br>
+ *
+ * The system property "PARAMICS_LOG_CONFIG" should be set to the path where the
+ * properties file for this class is located. <br><br>
  * The data for the properties file follows. <br>
  * <code>
  * -----------------------------------------------------------------<br>
- * Log File                The file to write the communication to.
- * CAD Simulator Host      The host that runs the CAD Simulator.
- * CAD Simulator RMI Port  The port on the host that runs the CAD 
- *                         Simulator where the RMI Coordinator
- *                         object is registered to. 
+ * Log File The file to write the communication to. CAD Simulator Host The host
+ * that runs the CAD Simulator. CAD Simulator RMI Port The port on the host that
+ * runs the CAD Simulator where the RMI Coordinator object is registered to.
  * -----------------------------------------------------------------<br>
  * Example File: <br>
- * LogFile=c:\\log.txt
- * CADSimulatorHost=localhost
- * CADSimulatorRMIPort=4445
+ * LogFile=c:\\log.txt CADSimulatorHost=localhost CADSimulatorRMIPort=4445
  * -----------------------------------------------------------------<br>
  * </code>
- * 
+ *
  * @author Nathaniel Lehrer
- * @version 
+ * @version
  */
-public class ParamicsLog extends Observable 
-{   
+public class ParamicsLog extends Observable
+{
+
     /**
      * Enmeration containing property names.
+     *
      * @author Nathaniel Lehrer
      */
-    private enum PROPERTIES 
-    {
-        LOG_FILE      ("LogFile"),
-        CAD_SIM_HOST  ("CADSimulatorHost"),
-        CAD_SIM_PORT  ("CADSimulatorRMIPort");
-        
+    private enum PROPERTIES
+    {
+
+        LOG_FILE("LogFile"),
+        CAD_SIM_HOST("CADSimulatorHost"),
+        CAD_SIM_PORT("CADSimulatorRMIPort");
         public String name;
-        
+
         private PROPERTIES(String n)
         {
@@ -62,79 +56,92 @@
         }
     }
-
-	private static final String CONFIG_FILE_NAME = "paramics_communicator_logging.properties";
-    
-    /** Error logger. */
+    private static final String CONFIG_FILE_NAME = "paramics_communicator_logging.properties";
+    /**
+     * Error logger.
+     */
     private static Logger paramLogger = Logger.getLogger("tmcsim.paramicslog");
-    
-    /** Static instance. */
+    /**
+     * Static instance.
+     */
     private static ParamicsLog instance;
-    
-    /** Properties object. */
+    /**
+     * Properties object.
+     */
     private Properties paramicsLogProp;
-    
-    /** File log entries are written to */
+    /**
+     * File log entries are written to
+     */
     private File logFile;
-    
-    /** Stores the log entries. This contains the same information logFile. */
+    /**
+     * Stores the log entries. This contains the same information logFile.
+     */
     private StringBuilder log;
-
-    /** Remote reference to the simulation */
+    /**
+     * Remote reference to the simulation
+     */
     private CoordinatorInterface theCoorInt;
-    
-    /** Object for synchronizing IO */
+    /**
+     * Object for synchronizing IO
+     */
     Object lock;
-    
+
     /**
      * Creates the singleton instance of this class.
      */
-    static {
-        try {
-        	if(System.getProperty("CONFIG_DIR") == null){
-            	System.setProperty("CONFIG_DIR", "config");
-            }
-        	
-        	instance = new ParamicsLog(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME);
-        } 
-        catch (Exception e) 
+    static
+    {
+        try
+        {
+            if (System.getProperty("CONFIG_DIR") == null)
+            {
+                System.setProperty("CONFIG_DIR", "config");
+            }
+
+            instance = new ParamicsLog(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME);
+        } catch (Exception e)
         {
             instance = new ParamicsLog();
-            
-            paramLogger.logp(Level.WARNING, "ParamicsLog", "static initializer", 
+
+            paramLogger.logp(Level.WARNING, "ParamicsLog", "static initializer",
                     "Error occured initializing application", e);
 
-            JOptionPane.showMessageDialog(null, e.getMessage(), 
-                    "Error - ParamicsLog will not save log to file.", 
-                    JOptionPane.ERROR_MESSAGE); 
-        }
-        
+            JOptionPane.showMessageDialog(null, e.getMessage(),
+                    "Error - ParamicsLog will not save log to file.",
+                    JOptionPane.ERROR_MESSAGE);
+        }
+
         instance.addObserver(ParamicsLogGUI.getInstance());
     }
-    
-    /**
-     * Creates an instance of ParamicsLog that does not write to a file when 
+
+    /**
+     * Creates an instance of ParamicsLog that does not write to a file when
      * writeToLog is called.
      */
-    private ParamicsLog() {
-        
+    private ParamicsLog()
+    {
+
         lock = new Object();
         log = new StringBuilder("");
     }
-    
-    /**
-     * Creates an instance of ParamicsLog that writes to a file when writeToLog is called.
+
+    /**
+     * Creates an instance of ParamicsLog that writes to a file when writeToLog
+     * is called.
+     *
      * @param propertiesFile
      */
-    private ParamicsLog(String propertiesFile) {
+    private ParamicsLog(String propertiesFile)
+    {
         this();
-        
+
         String logFile = null;
         String CADSIMHost = null;
         String CADSIMPort = null;
-        
-        try {
+
+        try
+        {
             paramicsLogProp = new Properties();
             paramicsLogProp.load(new FileInputStream(propertiesFile));
-            
+
             if ((logFile = paramicsLogProp.getProperty(PROPERTIES.LOG_FILE.name)) == null)
             {
@@ -142,5 +149,5 @@
             }
             else if ((CADSIMHost = paramicsLogProp.getProperty(PROPERTIES.CAD_SIM_HOST.name)) == null)
-            {   
+            {
                 throw new Exception("Properties file missing CAD Simulator host.");
             }
@@ -149,40 +156,40 @@
                 throw new Exception("Properties file missing CAD Simulator RMI port.");
             }
-            
+
             try
             {
                 connect(CADSIMHost, CADSIMPort);
-            }
-            catch (Exception e)
-            {
-                JOptionPane.showMessageDialog(null, 
-                        "ParamicsLog: Could not connect to remote Coordinator object.", 
-                        "Network Error", JOptionPane.ERROR_MESSAGE);                
-            }
-            
-            try 
+            } catch (Exception e)
+            {
+                JOptionPane.showMessageDialog(null,
+                        "ParamicsLog: Could not connect to remote Coordinator object.",
+                        "Network Error", JOptionPane.ERROR_MESSAGE);
+            }
+
+            try
             {
                 createLogFile(logFile);
-            }
-            catch (Exception e)
-            {
-                JOptionPane.showMessageDialog(null, 
-                        "ParamicsLog: Could not create new log file.", 
+            } catch (Exception e)
+            {
+                JOptionPane.showMessageDialog(null,
+                        "ParamicsLog: Could not create new log file.",
                         "File Error", JOptionPane.ERROR_MESSAGE);
             }
-            
-        } catch (Exception e) {
-            
-            paramLogger.logp(Level.WARNING, "ParamicsLog", "ParamicsLog constructor", 
+
+        } catch (Exception e)
+        {
+
+            paramLogger.logp(Level.WARNING, "ParamicsLog", "ParamicsLog constructor",
                     "Properties file incorrect or missing.", e);
-            
-            JOptionPane.showMessageDialog(null, 
-                    "ParamicsLog: Properties file invalid.", 
+
+            JOptionPane.showMessageDialog(null,
+                    "ParamicsLog: Properties file invalid.",
                     "Invalid Configuration", JOptionPane.ERROR_MESSAGE);
         }
     }
-    
+
     /**
      * Creates the log file.
+     *
      * @param filePath The path to the file including the file name.
      * @throws IOException If the log file could not be created.
@@ -190,69 +197,78 @@
     private void createLogFile(String filePath) throws IOException
     {
-        try {
+        try
+        {
             logFile = new File(filePath);
-            
-            if (logFile.exists()) {
+
+            if (logFile.exists())
+            {
                 logFile.delete();
             }
-            
+
             logFile.createNewFile();
-            
-        } catch (Exception e) {
-            
+
+        } catch (Exception e)
+        {
+
             logFile = null;
-            
-            paramLogger.logp(Level.WARNING, "ParamicsLog", "ParamicsLog constructor", 
+
+            paramLogger.logp(Level.WARNING, "ParamicsLog", "ParamicsLog constructor",
                     "Could not create new log file.", e);
-            
+
             throw new IOException("Could not create log file.");
-        }               
-    }
-    
+        }
+    }
+
     /**
      * Connect to the Coordinator's RMI object.
-     * @param hostname Host name of the CAD Simulator.    
-     * @param portNumber Port number of the CAD Simulator RMI communication. 
-     * @throws SimulationException if there is an error creating the RMI connection.
-     */ 
-    private void connect(String hostname, String portNumber) 
-        throws SimulationException {
-        
+     *
+     * @param hostname Host name of the CAD Simulator.
+     * @param portNumber Port number of the CAD Simulator RMI communication.
+     * @throws SimulationException if there is an error creating the RMI
+     * connection.
+     */
+    private void connect(String hostname, String portNumber)
+            throws SimulationException
+    {
+
         String coorIntURL = "";
-        
-        try {  
-            coorIntURL = "rmi://" + hostname + ":" + portNumber + "/coordinator"; 
-            
-            theCoorInt = (CoordinatorInterface)Naming.lookup(coorIntURL);           
-        }
-        catch (Exception e) 
-        {
-            paramLogger.logp(Level.WARNING, "ParamicsLog", 
-                    "establishRMIConnection", "Unable to establish RMI " +
-                    "communication with the CAD Simulator.  URL <" + coorIntURL + ">", e);
-        }   
-    }
-    
+
+        try
+        {
+            coorIntURL = "rmi://" + hostname + ":" + portNumber + "/coordinator";
+
+            theCoorInt = (CoordinatorInterface) Naming.lookup(coorIntURL);
+        } catch (Exception e)
+        {
+            paramLogger.logp(Level.WARNING, "ParamicsLog",
+                    "establishRMIConnection", "Unable to establish RMI "
+                    + "communication with the CAD Simulator.  URL <" + coorIntURL + ">", e);
+        }
+    }
+
     /**
      * Accessor to the entries in the log. No file IO is used.
+     *
      * @return The entries in the log.
      */
-    public String getLog() {
-        
+    public String getLog()
+    {
+
         return log.toString();
     }
-    
-    /**
-     * Writes an entry to the log. 
-     * The simulator time when the message was sent is prepended to the entry.
-     * Entries are padded by a blank line before and after them.
-     * TODO: Ensure output is written in order of request.
+
+    /**
+     * Writes an entry to the log. The simulator time when the message was sent
+     * is prepended to the entry. Entries are padded by a blank line before and
+     * after them. TODO: Ensure output is written in order of request.
+     *
      * @param entry
      */
-    public void writeToLog(String entry) {
-        
+    public void writeToLog(String entry)
+    {
+
         String time = "?";
         String formattedEntry;
-        
+
         if (theCoorInt != null)
         {
@@ -260,20 +276,19 @@
             {
                 time = formatTime(theCoorInt.getCurrentSimulationTime());
-            }
-            catch (Exception e)
-            {
-                paramLogger.logp(Level.WARNING, "ParamicsLog", 
+            } catch (Exception e)
+            {
+                paramLogger.logp(Level.WARNING, "ParamicsLog",
                         "RMICommunication", "Unable to communicate with RMI object", e);
             }
         }
-        
+
         formattedEntry = "\n" + "<!-- Time written to file: " + time + " -->\n" + entry + "\n";
         log.append(formattedEntry);
-        
+
         if (logFile != null)
         {
-            try 
-            {
-                synchronized(lock)
+            try
+            {
+                synchronized (lock)
                 {
                     FileWriter writer = new FileWriter(logFile, true);
@@ -282,21 +297,21 @@
                     writer.close();
                 }
-            } 
-            catch (IOException e) 
-            {
-                paramLogger.logp(Level.WARNING, "ParamicsLog", "writeToLog", 
+            } catch (IOException e)
+            {
+                paramLogger.logp(Level.WARNING, "ParamicsLog", "writeToLog",
                         "Could not write to log file.", e);
             }
         }
-        
+
         setChanged();
         notifyObservers(entry);
     }
-    
+
     /**
      * Formats the time given in seconds to hh:mm:ss format.
+     *
      * @param time The time in seconds.
      */
-    private String formatTime(long time)
+    public String formatTime(long time)
     {
         long seconds = time % 60;
@@ -306,5 +321,5 @@
         return padr(hours) + ":" + padr(minutes) + ":" + padr(seconds);
     }
-    
+
     private String padr(long n)
     {
@@ -317,11 +332,13 @@
         }
     }
-    
+
     /**
      * Accessor for static instance of this class.
+     *
      * @return The instance of this class.
      */
-    public static ParamicsLog getInstance() {
-        
+    public static ParamicsLog getInstance()
+    {
+
         return instance;
     }
Index: trunk/src/tmcsim/paramicslog/gui/ParamicsLogGUI.java
===================================================================
--- trunk/src/tmcsim/paramicslog/gui/ParamicsLogGUI.java	(revision 2)
+++ trunk/src/tmcsim/paramicslog/gui/ParamicsLogGUI.java	(revision 47)
@@ -1,39 +1,52 @@
 package tmcsim.paramicslog.gui;
 
-import javax.swing.*;
 import java.awt.event.WindowEvent;
 import java.util.*;
+import javax.swing.*;
 
 /**
- * The UI for ParamicsLog. 
+ * The UI for ParamicsLog.
+ *
  * @author Nathaniel Lehrer
  * @version
  */
-public class ParamicsLogGUI extends JFrame implements Observer {
+public class ParamicsLogGUI extends JFrame implements Observer
+{
 
-    /** The static instance */
+    /**
+     * The static instance
+     */
     private static ParamicsLogGUI instance = new ParamicsLogGUI();
+    /**
+     * The text area to display the log in
+     */
+    private JTextArea textArea;
 
-    /** The text area to display the log in */
-    private JTextArea textArea;
-    
-    /** Creates an instance of this class */
-    public ParamicsLogGUI() {
-        
+    /**
+     * Creates an instance of this class
+     */
+    public ParamicsLogGUI()
+    {
+
         setupGUI();
     }
-    
-    /** Creates the UI */
+
+    /**
+     * Creates the UI
+     */
     private void setupGUI()
     {
-        try {
+        try
+        {
             UIManager.setLookAndFeel(
-                UIManager.getSystemLookAndFeelClassName());
-        } catch (Exception e) {
+                    UIManager.getSystemLookAndFeelClassName());
+        } catch (Exception ex)
+        {
+            System.out.println(ex.getMessage());
             System.err.println("Couldn't use system look and feel.");
         }
-        
-        this.addWindowListener(new java.awt.event.WindowAdapter() {
-            
+
+        this.addWindowListener(new java.awt.event.WindowAdapter()
+        {
             public void windowClosing(WindowEvent e)
             {
@@ -41,18 +54,20 @@
             }
         });
-        
-        
+
+
         setTitle("Paramics Log");
-        
+
         textArea = new JTextArea();
         textArea.setColumns(60);
         textArea.setRows(30);
         JScrollPane scrollPane = new JScrollPane(textArea);
-        
+
         getContentPane().add(scrollPane);
-        
+
     }
-    
-    /** Shows the UI window */
+
+    /**
+     * Shows the UI window
+     */
     public void display()
     {
@@ -62,6 +77,7 @@
 
     /**
-     * Updates the text area. If the observable class given is of type ParamicsLog then
-     * the log entries are displayed.
+     * Updates the text area. If the observable class given is of type
+     * ParamicsLog then the log entries are displayed.
+     *
      * @param o The model for this viewer.
      * @param arg An argument that is not used.
@@ -72,16 +88,17 @@
         {
             textArea.setText(((tmcsim.paramicslog.ParamicsLog) o).getLog());
-        } 
+        }
 
         repaint();
     }
-    
+
     /**
      * Accessor for the instance of ParamicsLogGUI.
+     *
      * @return The instance of ParamicsLogGUI.
      */
-    public static ParamicsLogGUI getInstance() {
+    public static ParamicsLogGUI getInstance()
+    {
         return instance;
     }
-    
 }
Index: trunk/src/tmcsim/paramicslog/ParamicsLogFileHandler.java
===================================================================
--- trunk/src/tmcsim/paramicslog/ParamicsLogFileHandler.java	(revision 47)
+++ trunk/src/tmcsim/paramicslog/ParamicsLogFileHandler.java	(revision 47)
@@ -0,0 +1,307 @@
+package tmcsim.paramicslog;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.rmi.Naming;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+import javax.swing.JOptionPane;
+import tmcsim.common.SimulationException;
+import tmcsim.interfaces.CoordinatorInterface;
+
+/**
+ * Logs communication from ParamicsCommunicator to ParamicsSimulator.
+ *
+ * The system property "PARAMICS_LOG_CONFIG" should be set to the path where the
+ * properties file for this class is located. <br><br>
+ * The data for the properties file follows. <br>
+ * <code>
+ * -----------------------------------------------------------------<br>
+ * Log File The file to write the communication to. CAD Simulator Host The host
+ * that runs the CAD Simulator. CAD Simulator RMI Port The port on the host that
+ * runs the CAD Simulator where the RMI Coordinator object is registered to.
+ * -----------------------------------------------------------------<br>
+ * Example File: <br>
+ * LogFile=c:\\log.txt CADSimulatorHost=localhost CADSimulatorRMIPort=4445
+ * -----------------------------------------------------------------<br>
+ * </code>
+ *
+ * @author Nathaniel Lehrer
+ * @version
+ */
+public class ParamicsLogFileHandler extends java.util.logging.FileHandler
+{
+
+    /**
+     * Enmeration containing property names.
+     *
+     * @author Nathaniel Lehrer
+     */
+    private enum PROPERTIES
+    {
+
+        LOG_FILE("LogFile"),
+        CAD_SIM_HOST("CADSimulatorHost"),
+        CAD_SIM_PORT("CADSimulatorRMIPort");
+        public String name;
+
+        private PROPERTIES(String n)
+        {
+            name = n;
+        }
+    }
+    /**
+     * Error logger.
+     */
+    private static Logger paramLogger = Logger.getLogger("tmcsim.paramicslog");
+    /**
+     * Static instance.
+     */
+    private static ParamicsLogFileHandler instance;
+    private static String propertiesFile;
+    /**
+     * Properties object.
+     */
+    private static Properties paramicsLogProp;
+    /**
+     * File log entries are written to
+     */
+//    private static String logFile;
+    /**
+     * Stores the log entries. This contains the same information logFile.
+     */
+    private StringBuilder log;
+    /**
+     * Remote reference to the simulation
+     */
+    private CoordinatorInterface theCoorInt;
+    /**
+     * Object for synchronizing IO
+     */
+    Object lock;
+
+    /**
+     * Creates the singleton instance of this class.
+     */
+    public static ParamicsLogFileHandler getInstance() throws IOException
+    {
+        System.setProperty("PARAMICS_LOG_PROPERTIES", "config/paramics_communicator_logging.properties");
+        // Has an instance been created yet?
+        if (instance == null)
+        {
+            try
+            {
+                if (System.getProperty("PARAMICS_LOG_PROPERTIES") != null)
+                {
+                    propertiesFile = System.getProperty("PARAMICS_LOG_PROPERTIES");
+
+                    paramicsLogProp = new Properties();
+                    paramicsLogProp.load(new FileInputStream(propertiesFile));
+
+                    if ((paramicsLogProp.getProperty(PROPERTIES.LOG_FILE.name)) == null)
+                    {
+                        throw new Exception("Properties file missing log file location.");
+                    }
+                    String logFile = paramicsLogProp.getProperty(PROPERTIES.LOG_FILE.name);
+                    instance = new ParamicsLogFileHandler(logFile);
+                }
+                else
+                {
+                    throw new Exception("PARAMICS_LOG_PROPERTIES system property not defined.");
+                }
+            } catch (Exception e)
+            {
+                instance = new ParamicsLogFileHandler();
+
+                paramLogger.logp(Level.WARNING, "ParamicsLog", "static initializer",
+                        "Error occured initializing application", e);
+
+                JOptionPane.showMessageDialog(null, e.getMessage(),
+                        "Error - ParamicsLog will not save log to file.",
+                        JOptionPane.ERROR_MESSAGE);
+            }
+        }
+        return instance;
+    }
+
+    /**
+     * Creates an instance of ParamicsLog that does not write to a file when
+     * writeToLog is called.
+     */
+    private ParamicsLogFileHandler() throws IOException
+    {
+        lock = new Object();
+        log = new StringBuilder("");
+    }
+
+    /**
+     * Creates an instance of ParamicsLog that writes to a file when writeToLog
+     * is called.
+     *
+     * @param propertiesFile
+     */
+    private ParamicsLogFileHandler(String logFile) throws IOException
+    {
+        super(logFile);
+        lock = new Object();
+        log = new StringBuilder("");
+
+        //String logFile = null;
+        String CADSIMHost = null;
+        String CADSIMPort = null;
+
+        try
+        {
+            paramicsLogProp = new Properties();
+            paramicsLogProp.load(new FileInputStream(propertiesFile));
+
+            if ((CADSIMHost = paramicsLogProp.getProperty(PROPERTIES.CAD_SIM_HOST.name)) == null)
+            {
+                throw new Exception("Properties file missing CAD Simulator host.");
+            }
+            else if ((CADSIMPort = paramicsLogProp.getProperty(PROPERTIES.CAD_SIM_PORT.name)) == null)
+            {
+                throw new Exception("Properties file missing CAD Simulator RMI port.");
+            }
+
+            try
+            {
+                connect(CADSIMHost, CADSIMPort);
+            } catch (Exception e)
+            {
+                JOptionPane.showMessageDialog(null,
+                        "ParamicsLog: Could not connect to remote Coordinator object.",
+                        "Network Error", JOptionPane.ERROR_MESSAGE);
+            }
+
+//            try
+//            {
+//                createLogFile(logFile);
+//            } catch (Exception e)
+//            {
+//                JOptionPane.showMessageDialog(null,
+//                        "ParamicsLog: Could not create new log file.",
+//                        "File Error", JOptionPane.ERROR_MESSAGE);
+//            }
+
+        } catch (Exception e)
+        {
+
+            paramLogger.logp(Level.WARNING, "ParamicsLog", "ParamicsLog constructor",
+                    "Properties file incorrect or missing.", e);
+
+            JOptionPane.showMessageDialog(null,
+                    "ParamicsLog: Properties file invalid.",
+                    "Invalid Configuration", JOptionPane.ERROR_MESSAGE);
+        }
+    }
+
+    /**
+     * Connect to the Coordinator's RMI object.
+     *
+     * @param hostname Host name of the CAD Simulator.
+     * @param portNumber Port number of the CAD Simulator RMI communication.
+     * @throws SimulationException if there is an error creating the RMI
+     * connection.
+     */
+    private void connect(String hostname, String portNumber)
+            throws SimulationException
+    {
+
+        String coorIntURL = "";
+
+        try
+        {
+            coorIntURL = "rmi://" + hostname + ":" + portNumber + "/coordinator";
+
+            theCoorInt = (CoordinatorInterface) Naming.lookup(coorIntURL);
+        } catch (Exception e)
+        {
+            paramLogger.logp(Level.WARNING, "ParamicsLog",
+                    "establishRMIConnection", "Unable to establish RMI "
+                    + "communication with the CAD Simulator.  URL <" + coorIntURL + ">", e);
+        }
+    }
+
+    /**
+     * Accessor to the entries in the log. No file IO is used.
+     *
+     * @return The entries in the log.
+     */
+    public String getLog()
+    {
+
+        return log.toString();
+    }
+
+    /**
+     * Writes an entry to the log. The simulator time when the message was sent
+     * is prepended to the entry. Entries are padded by a blank line before and
+     * after them. TODO: Ensure output is written in order of request.
+     *
+     * @param entry
+     */
+    public void publish(LogRecord rec)
+    {
+
+        String time = "?";
+        String formattedEntry;
+        String entry = rec.getMessage();
+
+        if (theCoorInt != null)
+        {
+            try
+            {
+                time = formatTime(theCoorInt.getCurrentSimulationTime());
+            } catch (Exception e)
+            {
+                paramLogger.logp(Level.WARNING, "ParamicsLog",
+                        "RMICommunication", "Unable to communicate with RMI object", e);
+            }
+        }
+
+        formattedEntry = "\n" + "<!-- Time written to file: " + time + " -->\n" + entry + "\n";
+        log.append(formattedEntry);
+        rec.setMessage(formattedEntry);
+        super.publish(rec);
+
+        //ParamicsLogGUI.getInstance().update(this, entry);
+    }
+
+    /**
+     * Formats the time given in seconds to hh:mm:ss format.
+     *
+     * @param time The time in seconds.
+     */
+    public String formatTime(long time)
+    {
+        long seconds = time % 60;
+        long minutes = (time - seconds) / 60;
+        long hours = (time - seconds - minutes * 60) / 60;
+
+        return padr(hours) + ":" + padr(minutes) + ":" + padr(seconds);
+    }
+
+    private String padr(long n)
+    {
+        if (n < 10)
+        {
+            return "0" + n;
+        }
+        {
+            return "" + n;
+        }
+    }
+    /**
+     * Accessor for static instance of this class.
+     *
+     * @return The instance of this class.
+     */
+//    public static ParamicsLogFileHandler getInstance()
+//    {
+//
+//        return instance;
+//    }
+}
