Index: trunk/src/tmcsim/cadsimulator/managers/TrafficModelManager.java
===================================================================
--- trunk/src/tmcsim/cadsimulator/managers/TrafficModelManager.java	(revision 197)
+++ trunk/src/tmcsim/cadsimulator/managers/TrafficModelManager.java	(revision 204)
@@ -47,5 +47,5 @@
      * Error Logger.
      */
-    private static Logger atmsLogger = Logger.getLogger("tmcsim.cadsimulator.managers");
+    private static Logger logger = Logger.getLogger("tmcsim.cadsimulator.managers");
 
     /**
@@ -56,15 +56,6 @@
     private static enum PROPERTIES
     {
-        /**
-         *
-         */
         HIGHWAYS_MAP_FILE("Highways_Map_File"),
-        /**
-         *
-         */
         FEPSIM_IP_ADDR("FEPSim_IP_addr"),
-        /**
-         *
-         */
         EVENTS_FILE("Events_File"),
         OUTPUT_DEST("Output_Destination");
@@ -82,5 +73,5 @@
      * Properties Object.
      */
-    private Properties atmsProperties = null;
+    private Properties props = null;
     /**
      * Highways in traffic network
@@ -113,21 +104,29 @@
             throws SimulationException 
     {
-        if (!loadProperties(propertiesFile))
-        {
-            System.exit(0);
-        }
-//        final Coordinator theCoordinator = theCoordinator;
+        props = loadProperties(propertiesFile);
         // Initialize the highway model
         incidents = new HashMap<String, List<TrafficEvent>>();
         highways = new Highways(
-                atmsProperties.getProperty(PROPERTIES.HIGHWAYS_MAP_FILE.name),
-                //"config/vds_data/highways_fullmap.txt",
-                //        "192.168.251.46", 8080);  //IP address of FEP Sim Linux VM
-                atmsProperties.getProperty(PROPERTIES.FEPSIM_IP_ADDR.name),
+                props.getProperty(PROPERTIES.HIGHWAYS_MAP_FILE.name),
+                props.getProperty(PROPERTIES.FEPSIM_IP_ADDR.name),
                 8080); 
 
-        // READ THE BATCH FILE OF COMMANDS and put in a queue
-        eventQueue = readBatchFile();
-        // Launch the display
+        // Read the text file of events and put in a queue
+        FileInputStream fis = null;
+        try
+        {
+            fis = new FileInputStream(props.getProperty(PROPERTIES.EVENTS_FILE.name));
+        } catch (FileNotFoundException ex)
+        {
+            Logger.getLogger(TrafficModelManager.class.getName()).log(Level.SEVERE, null, 
+                    "Missing Traffic Events file " + props.getProperty(PROPERTIES.EVENTS_FILE.name));
+            System.exit(-1);
+        }
+        // Read all lines from the file of events
+        Scanner fileScanner = new Scanner(fis);        
+        eventQueue = readBatchFile(fileScanner);
+        // Extract the incidents and create a map
+        incidents = createIncidentMap(eventQueue);
+        // Launch the GUI display
         theView = new TrafficModelViewer(this, new ArrayList<String>(incidents.keySet()));
         theView.setVisible(true);
@@ -147,5 +146,5 @@
                 {
                     long simtime = theCoordinator.getCurrentSimulationTime();
-                    currentClock = formatInterval(simtime);
+                    currentClock = formatTimeInSeconds(simtime);
                     // For Debugging, show the ATMS time
 //                    long ATMStime = theCoorInt.getATMStime();       
@@ -159,8 +158,7 @@
                     {
                         Logger.getLogger(TrafficModelManager.class.getName()).log(Level.SEVERE, null, ex);
-                        System.out.println("Invalid simulation clock time found in ATMSDriverClient");
+                        System.out.println("Invalid simulation clock time found");
                         System.exit(-1);
                     }
-                    //System.out.println("Current clock: " + currentClock);
                 }
                 catch (RemoteException ex)
@@ -175,5 +173,4 @@
                     TrafficEvent nextEvent = eventQueue.peek();
                     Date eventTime = nextEvent.eventDate;
-                    //System.out.println("Next event will be launched at: " + formatter.format(eventTime));
                     // Check the queue of events to see if the first
                     // item should be launched.  IF so, 
@@ -195,5 +192,5 @@
         timer.start();
 
-        if (atmsProperties.getProperty(PROPERTIES.OUTPUT_DEST.name).equals("FEP"))
+        if (props.getProperty(PROPERTIES.OUTPUT_DEST.name).equals("FEP"))
         {
             // Start the FEP thread (to update ATMS every 30 sec). (See class def below)
@@ -210,64 +207,49 @@
 
     /**
-     * This method verifies that the CAD Simulator Host and Port values are not
-     * null. Also, if a CAD Position or User ID do not exist in the properties
-     * file, the user is prompted to enter values. These values are written to
-     * the properties file. If the user cancels the process of entering these
-     * values, the verification fails.
+     * This method verifies that the needed configuration properties are not
+     * null. 
      *
      * @param propertiesFile File path (absolute or relative) to the properties
      * file containing configuration data.
-     * @return True if the properties file is valid, false if not.
+     * @return The Properties loaded
      * @throws SimulationException if there is an exception in verifying the
-     * properties file, or if the user cancels input.
-     */
-    private boolean loadProperties(String propertiesFile)
+     * properties file
+     */
+    public static Properties loadProperties(String propertiesFile)
             throws SimulationException
     {
+        Properties props;
         // Load the properties file.
         try
         {
-            atmsProperties = new Properties();
-            atmsProperties.load(new FileInputStream(propertiesFile));
+            props = new Properties();
+            props.load(new FileInputStream(propertiesFile));
 
         } catch (Exception e)
         {
-            atmsLogger.logp(Level.SEVERE, "TrafficModelManager", "Constructor",
-                    "Exception in parsing properties file.", e);
-            throw new SimulationException(SimulationException.INITIALIZE_ERROR,
-                    e);            
-        }
-
+            throw new SimulationException(SimulationException.INITIALIZE_ERROR);
+        }
 
         // Ensure that the properties file does not have null values for the
         // required information.
-        if (atmsProperties.getProperty(PROPERTIES.HIGHWAYS_MAP_FILE.name) == null
-                || atmsProperties.getProperty(PROPERTIES.FEPSIM_IP_ADDR.name) == null
-                || atmsProperties.getProperty(PROPERTIES.EVENTS_FILE.name) == null
-                || atmsProperties.getProperty(PROPERTIES.OUTPUT_DEST.name) == null)
-        {
-            atmsLogger.logp(Level.SEVERE, "TrafficModelManager",
-                    "Constructor", "Null value in properties file.");
+        if (props.getProperty(PROPERTIES.HIGHWAYS_MAP_FILE.name) == null
+                || props.getProperty(PROPERTIES.FEPSIM_IP_ADDR.name) == null
+                || props.getProperty(PROPERTIES.EVENTS_FILE.name) == null
+                || props.getProperty(PROPERTIES.OUTPUT_DEST.name) == null)
+        {
+            System.out.println("Missing property value in "+propertiesFile);
             throw new SimulationException(SimulationException.INITIALIZE_ERROR);
         }
 
-        return true;
+        return props;
     }
     /**
      * Read a file of traffic events.  
+     * @param filename the name of the events file
      * @return the chronologically ordered list of events
      */
-    // Method is package private to facilitate unit testing.
-    LinkedList<TrafficEvent> readBatchFile()
-    {
-        FileInputStream fis;
+    public static LinkedList<TrafficEvent> readBatchFile(Scanner scan)
+    {
         LinkedList<TrafficEvent> eventList = new LinkedList<TrafficEvent>();
-        try
-        {
-            fis = new FileInputStream(
-                    //"config/vds_data/atmsBatchEvents.txt");
-            atmsProperties.getProperty(PROPERTIES.EVENTS_FILE.name));
-            // Read all lines from the file of events
-            Scanner scan = new Scanner(fis);
             while (scan.hasNext())
             {
@@ -281,18 +263,4 @@
                         evt = new TrafficEvent(line);
                         eventList.add(evt);
-                        String incident = evt.incident;
-                        // Add the line to the list for the corresponding incident
-                        List evtList;
-                        if (incidents.containsKey(evt.incident))
-                        {
-                            evtList = incidents.get(evt.incident);
-                        }
-                        else
-                        {
-                            evtList = new ArrayList<String>();
-                        }
-                        evtList.add(evt);
-                        // and put it back in the map
-                        incidents.put(incident, evtList);
                     }
                     catch (ParseException ex)
@@ -304,9 +272,4 @@
                 }
             }
-        }
-        catch (FileNotFoundException ex)
-        {
-            Logger.getLogger(TrafficModelManager.class.getName()).log(Level.SEVERE, null, ex);
-        }
         System.out.println("Events file read, " + eventList.size() + " events queued.");
         // Put the events in chronological order
@@ -315,4 +278,26 @@
     }
 
+    static Map<String, List<TrafficEvent>> createIncidentMap(LinkedList<TrafficEvent> eventList)
+    {
+        Map<String, List<TrafficEvent>> incidents = new HashMap<String, List<TrafficEvent>>();
+        for (TrafficEvent evt: eventList)
+        {
+            // Add the line to the list for the corresponding incident
+            List evtList;
+            if (incidents.containsKey(evt.incident))
+            {
+                evtList = incidents.get(evt.incident);
+            }
+            else
+            {
+                evtList = new ArrayList<String>();
+            }
+            evtList.add(evt);
+            // and put it back in the map
+            incidents.put(evt.incident, evtList);
+        }        
+        return incidents;
+    }
+    
     /**
      * Clear an incident. For each event associated with an incident, turn the
@@ -349,12 +334,12 @@
      * Format a time in seconds as HH:MM:SS
      *
-     * @param l
-     * @return
-     */
-    private String formatInterval(final long l)
-    {
-        final long hr = TimeUnit.SECONDS.toHours(l);
-        final long min = TimeUnit.SECONDS.toMinutes(l - TimeUnit.HOURS.toSeconds(hr));
-        final long sec = TimeUnit.SECONDS.toSeconds(l - TimeUnit.HOURS.toSeconds(hr) - TimeUnit.MINUTES.toSeconds(min));
+     * @param seconds
+     * @return HH:MM:SS formatted string
+     */
+    public static String formatTimeInSeconds(final long seconds)
+    {
+        final long hr = TimeUnit.SECONDS.toHours(seconds);
+        final long min = TimeUnit.SECONDS.toMinutes(seconds - TimeUnit.HOURS.toSeconds(hr));
+        final long sec = TimeUnit.SECONDS.toSeconds(seconds - TimeUnit.HOURS.toSeconds(hr) - TimeUnit.MINUTES.toSeconds(min));
         return String.format("%02d:%02d:%02d", hr, min, sec);
     }
@@ -384,5 +369,5 @@
         catch (Exception e)
         {
-            atmsLogger.logp(Level.SEVERE, "SimulationManager", "Main",
+            logger.logp(Level.SEVERE, "SimulationManager", "Main",
                     "Error initializing application.");
 
@@ -409,5 +394,5 @@
                 try
                 {
-                    Thread.sleep(1000);
+                    Thread.sleep(5000);
                 }
                 catch (InterruptedException ie)
