Changeset 210 in tmcsimulator


Ignore:
Timestamp:
11/02/2017 12:32:10 PM (9 years ago)
Author:
jdalbey
Message:

Integrate TrafficModelViewer? into the CAD Server GUI as an additional tab. Eliminates the separate window for traffic mgr view.

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/application.properties

    r209 r210  
    33Application.revision=208 
    44 
    5 Application.buildnumber=68 
     5Application.buildnumber=69 
  • trunk/src/tmcsim/cadsimulator/CADServer.java

    r206 r210  
    2121import tmcsim.cadsimulator.managers.SimulationClockManager; 
    2222import tmcsim.cadsimulator.managers.TrafficModelManager; 
    23 import tmcsim.cadsimulator.managers.TrafficModelViewer; 
    2423import tmcsim.cadsimulator.viewer.model.CADSimulatorState; 
    2524import tmcsim.common.SimulationException; 
     
    178177     */ 
    179178    protected static TrafficModelManager theTrafficMgr = null; 
    180     private TrafficModelViewer trafficView = null; 
    181179     
    182180    /** 
     
    259257                    CAD_PROPERTIES.TRAFFICMGR_PROP_FILE.name), 
    260258                    theCoordinator); 
    261             trafficView = new TrafficModelViewer(theTrafficMgr); 
    262              theTrafficMgr.addObserver(trafficView); 
     259            theTrafficMgr.addObserver(theViewer); 
     260            theTrafficMgr.run(); 
    263261 
    264262            theMediaMgr = new MediaManager( 
     
    315313 
    316314        theViewer.setVisible(true); 
    317         trafficView.setVisible(true); 
    318  
    319315 
    320316    } 
  • trunk/src/tmcsim/cadsimulator/managers/TrafficModelManager.java

    r206 r210  
    7676     */ 
    7777    private Properties props = null; 
     78     
     79    /**  
     80     * The Coordinator object from which we obtain the simulation clock. 
     81     */  
     82    private Coordinator theCoordinator; 
     83 
    7884    /** 
    7985     * Highways in traffic network 
     
    95101    private String currentClock = ""; 
    96102     
    97     /** 
    98      * GUI for this driver 
    99      */ 
    100     //private TrafficModelViewer theView; 
    101      
     103    
    102104    /** 
    103105     * Constructor. Loads the Properties file and initializes the 
    104      * ATMSCommunicator with the parsed data. 
     106     * highway network model.  
    105107     * 
    106108     * @param propertiesFile Target file path of properties file. 
     
    118120                props.getProperty(PROPERTIES.FEPSIM_IP_ADDR.name), 
    119121                8080);  
    120          
     122        this.theCoordinator = theCoordinator; 
     123    } 
     124    /** 
     125     * Load the traffic events and start processing the event queue. 
     126     * Usage: addObserver must be called before calling run. 
     127     */ 
     128    public void run() 
     129    { 
    121130        loadEvents(); 
    122131         
     
    378387    } 
    379388 
    380     /** 
    381      * Construct the CADClient with the properties file path, either from the 
    382      * command line arguments or default. 
    383      * 
    384      * @param args Command line arguments. 
    385      */ 
    386     public static void main(String[] args) throws RemoteException 
    387     { 
    388         final String CONFIG_FILE_NAME = "traffic_model_config.properties";         
    389         if (System.getProperty("CONFIG_DIR") == null) 
    390         { 
    391             System.setProperty("CONFIG_DIR", "config"); 
    392         } 
    393         CADSimulatorState theModel = new CADSimulatorState(); 
    394         Coordinator theCoordinator = new Coordinator(theModel); 
    395         try 
    396         { 
    397             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
    398             TrafficModelManager mgr = new TrafficModelManager(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME,                     
    399             theCoordinator); 
    400             TrafficModelViewer view = new TrafficModelViewer(mgr); 
    401             view.setVisible(true); 
    402             mgr.addObserver(view); 
    403         } 
    404         catch (Exception e) 
    405         { 
    406             logger.logp(Level.SEVERE, "SimulationManager", "Main", 
    407                     "Error initializing application."); 
    408  
    409             JOptionPane.showMessageDialog(new JWindow(), e.getMessage(), 
    410                     "Error - Program Exiting", JOptionPane.ERROR_MESSAGE); 
    411  
    412             System.exit(-1); 
    413         } 
    414  
    415     } 
    416389    class WriteToConsoleThread extends Thread 
    417390    { 
  • trunk/src/tmcsim/cadsimulator/viewer/CADServerViewer.java

    r124 r210  
    1818import javax.swing.JTabbedPane; 
    1919import javax.swing.KeyStroke; 
     20import tmcsim.cadsimulator.managers.TrafficModelManager; 
    2021import tmcsim.cadsimulator.viewer.actions.ExitAction; 
    2122import tmcsim.cadsimulator.viewer.model.CADMediaStatus; 
     
    3536public class CADServerViewer extends JFrame implements CADViewer 
    3637{ 
     38    private JTabbedPane cadSimTabbedPane; 
     39    private JMenuBar menubar; 
     40    private JMenu fileMenu; 
     41    private JMenuItem exitMenuItem; 
    3742 
    3843    /** 
     
    4853     */ 
    4954    private ConfigStatusPanel configPanel; 
    50  
     55    /* 
     56     * Panel to display Traffic Model Event Queue 
     57    */ 
     58    private TrafficModelViewPanel trafficPanel; 
     59     
    5160    /** 
    5261     * Constructor. 
     
    133142        mediaPanel = new MediaStatusPanel(); 
    134143        configPanel = new ConfigStatusPanel(); 
     144        trafficPanel = new TrafficModelViewPanel(); 
    135145 
    136146        cadSimTabbedPane = new JTabbedPane(); 
     
    138148        cadSimTabbedPane.addTab("Media", mediaPanel); 
    139149        cadSimTabbedPane.addTab("Config", configPanel); 
     150        cadSimTabbedPane.addTab("Traffic", trafficPanel); 
    140151 
    141152        add(cadSimTabbedPane); 
     
    153164 
    154165        javax.swing.JMenu helpMenu = new javax.swing.JMenu("Help"); 
    155         javax.swing.JMenuItem aboutItem = new javax.swing.JMenuItem("About"); 
    156166 
    157         aboutItem.addActionListener(new java.awt.event.ActionListener() 
    158         { 
    159             public void actionPerformed(java.awt.event.ActionEvent evt) 
    160             { 
    161                 String ver = "";//RevisionNumber.getString(); 
    162                 JOptionPane.showMessageDialog(rootPane, "Version: " + ver, "About", JOptionPane.INFORMATION_MESSAGE); 
    163             } 
    164         }); 
    165         helpMenu.add(aboutItem); 
    166167        menubar.add(helpMenu); 
    167168 
     
    173174        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    174175    } 
    175     private JTabbedPane cadSimTabbedPane; 
    176     private JMenuBar menubar; 
    177     private JMenu fileMenu; 
    178     private JMenuItem exitMenuItem; 
    179176 
    180177    @Override 
     
    189186            mediaPanel.refresh(obs); 
    190187        } 
     188        if (obs instanceof TrafficModelManager) 
     189        { 
     190            trafficPanel.update(obs, obj); 
     191        } 
    191192    } 
    192193} 
  • trunk/test/tmcsim/cadsimulator/SystemTest.java

    r123 r210  
    6262 
    6363        // Check CAD Simulator appears with no script and nothing connected 
    64         assertTrue("Title bar incorrect", cadwindow.getTitle().trim().startsWith("CAD Simulator")); 
     64        assertTrue("Title bar incorrect", cadwindow.getTitle().trim().startsWith("CAD Server")); 
    6565        Panel mainPanel = cadwindow.getPanel("contentPane"); 
    6666        TextBox txtStatus = mainPanel.getTextBox("simulationStatus"); 
Note: See TracChangeset for help on using the changeset viewer.