Changeset 128 in tmcsimulator


Ignore:
Timestamp:
10/17/2017 09:11:22 AM (9 years ago)
Author:
jdalbey
Message:

ATMSBatchDriver.java Added a GUI to display event queue. Highways.java modified to throw an exception when writeToFEP can't connect to FEP_Sim.

Location:
trunk/src
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/atmsdriver/ATMSDriver.java

    r103 r128  
    66import java.util.logging.Level; 
    77import java.util.logging.Logger; 
     8import tmcsim.common.SimulationException; 
    89 
    910/** 
     
    7374                    .getProperty(PROPERTIES.EXCHANGE_FILE_NAME.name)); 
    7475 
    75             highways.writeToFEP(); 
     76            try { 
     77                highways.writeToFEP(); 
     78            } catch (SimulationException ex) { 
     79                            System.out.println("Skipping writeToFEP..."); 
     80            } 
    7681            // Update if exchangeInfo is recieved 
    7782            if (exInfo != null) { 
  • trunk/src/atmsdriver/ConsoleDriver.java

    r127 r128  
    1313import java.util.logging.Level; 
    1414import java.util.logging.Logger; 
     15import tmcsim.common.SimulationException; 
    1516 
    1617/** 
     
    198199        } 
    199200        System.out.println(""); 
    200         highways.writeToFEP(); 
     201        try { 
     202            highways.writeToFEP(); 
     203        } catch (SimulationException ex) { 
     204            System.out.println("Skipping writeToFEP..."); 
     205        } 
    201206    } 
    202207     
  • trunk/src/atmsdriver/model/Highways.java

    r127 r128  
    2727import org.w3c.dom.Document; 
    2828import org.w3c.dom.Element; 
     29import tmcsim.common.SimulationException; 
    2930 
    3031/** The Highways class aggregates all Highway instances within a geographic 
     
    209210     */ 
    210211 
    211     public void writeToFEP() { 
     212    public void writeToFEP() throws SimulationException { 
    212213        try { 
    213214            Socket sock = new Socket(FEPHostName /*"192.168.251.130"*/, 8080); 
     
    218219            Logger.getLogger(Highways.class.getName()).log(Level.SEVERE, null, ex); 
    219220            System.out.println("Highway Model failed writing to FEPSim."); 
     221            throw new SimulationException(SimulationException.BINDING); 
    220222        } 
    221223    } 
  • trunk/src/tmcsim/client/ATMSBatchDriver.java

    r127 r128  
    114114    /** Instance of ConsoleDriver that contains the highway model */ 
    115115    private ConsoleDriver console; 
    116  
     116     
     117    /** GUI for this driver */ 
     118    private ATMSBatchViewer theView; 
     119     
    117120    /** 
    118121     * Constructor. Initialize data from parsed properties file. Create a socket 
     
    142145        // READ THE BATCH FILE OF COMMANDS and put in a queue 
    143146        readBatchFile(); 
     147        // Launch the display 
     148        theView = new ATMSBatchViewer(); 
     149        theView.setVisible(true); 
     150        theView.update("0:00", eventQueue);         
    144151        // Create a timer that fetches the simulation time every second. 
    145152        Timer timer = new Timer(ONE_SECOND, new ActionListener() 
     
    162169                        System.exit(-1); 
    163170                    }                     
    164                     System.out.println("Current clock: " + currentClock); 
     171                    //System.out.println("Current clock: " + currentClock); 
    165172                } catch (RemoteException ex) 
    166173                { 
     
    181188                        eventQueue.remove(); 
    182189                    } 
    183                     System.out.println("Next event will be launched at: " + formatter.format(eventTime)); 
     190                    //System.out.println("Next event will be launched at: " + formatter.format(eventTime)); 
     191                    theView.update(currentClock, eventQueue); 
    184192                    // Check the queue of events to see if the first 
    185193                    // item should be launched.  IF so,  
     
    381389            while (true) 
    382390            { 
    383                 // Write the highway network status to the FEP Simulator 
    384                 highways.writeToFEP(); 
     391                try { 
     392                    // Write the highway network status to the FEP Simulator 
     393                    highways.writeToFEP(); 
     394                } catch (SimulationException ex)  
     395                { 
     396                    System.out.println("Skipping writeToFEP..."); 
     397                } 
    385398 
    386399                // Wait for FEP Sim to process the data we just sent 
Note: See TracChangeset for help on using the changeset viewer.