Changeset 416 in tmcsimulator for trunk/src/tmcsim/client


Ignore:
Timestamp:
06/18/2019 10:56:55 AM (7 years ago)
Author:
jdalbey
Message:

Create new ExportAction?.java for Sim Mgr and a new client, CADlogDisplay that outputs to console the current CAD log every 10 seconds.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/client/CADlogDisplay.java

    r64 r416  
    88import java.rmi.server.UnicastRemoteObject; 
    99import java.util.Properties; 
     10import java.util.Vector; 
    1011import java.util.concurrent.TimeUnit; 
    1112import java.util.logging.Level; 
     
    1516import javax.swing.Timer; 
    1617import javax.swing.UIManager; 
     18import javax.swing.table.DefaultTableModel; 
     19import tmcsim.client.cadclientgui.data.Incident; 
     20import tmcsim.client.cadclientgui.enums.CADDataEnums.INC_TABLE; 
    1721import tmcsim.common.SimulationException; 
    1822import tmcsim.interfaces.CADClientInterface; 
     
    2024 
    2125/** 
    22  * ClockClient shows the simulation clock time. It operates as a client of the 
     26 * CADlogDisplays shows the current CAD log for all incidents. It operates as a client of the 
    2327 * CAD server, using RMI to poll the server every second for the current 
    24  * simulation clock time. 
     28 * list of incidents and associated comments/notes table.  
    2529 * 
    2630 * @author jdalbey 
    2731 */ 
    28 public class ClockClient extends UnicastRemoteObject implements 
     32public class CADlogDisplay extends UnicastRemoteObject implements 
    2933        CADClientInterface 
    3034{ 
     
    8286    private CADClientInterface client = this; 
    8387    private static final String CONFIG_FILE_NAME = "cad_client_config.properties"; 
    84     private final static int ONE_SECOND = 1000; 
     88    private final static int TEN_SECONDS = 10000; 
    8589 
    8690    /** 
     
    9195     * file containing configuration data. 
    9296     */ 
    93     public ClockClient(String propertiesFile) throws SimulationException, 
     97    public CADlogDisplay(String propertiesFile) throws SimulationException, 
    9498            RemoteException 
    9599    { 
     
    102106                cadClientProp.getProperty(PROPERTIES.CAD_RMI_PORT.name).trim()); 
    103107 
    104         theView = new ClockView(); 
    105         theView.setVisible(true); 
     108        //theView = new ClockView(); 
     109        //theView.setVisible(true); 
    106110 
    107111        // Create a timer that fetches the simulation time every second. 
    108         Timer timer = new Timer(ONE_SECOND, new ActionListener() 
     112        Timer timer = new Timer(TEN_SECONDS, new ActionListener() 
    109113        { 
    110114            public void actionPerformed(ActionEvent e) 
     
    112116                try 
    113117                { 
    114                     long simtime = theCoorInt.getCurrentSimulationTime(); 
    115                     theView.updateTime("" + formatInterval(simtime)); 
     118                    Vector<Incident> incList = theCoorInt.getIncidentList();  
     119                    StringBuffer sb = new StringBuffer(); 
     120 
     121                    for (Incident incident: incList) 
     122                    { 
     123                    // DefaultTableModel noteTable = (DefaultTableModel) theCoorInt.getCadDataIncidentTable(INC_TABLE.COMMENTS_NOTES, incident.getLogNum()); 
     124                     // Output noteTable 
     125                        sb.append("Incident # " + incident.logNum + "\n"); 
     126                        // Retrieve the table of comments/notes the users created 
     127                        DefaultTableModel notesTable = incident.getCommentsNotesTable(); 
     128                        // Retrieve the notes chronologically (Most recent is in first row) 
     129                        for (int row=notesTable.getRowCount()-1; row >=0; row--) 
     130                        { 
     131                            // Combine the fields into one export entry 
     132                            sb.append(notesTable.getValueAt(row,1) + " "); // time 
     133                            String initials = (String) notesTable.getValueAt(row,2); // initials 
     134                            // If there are no user intials, it's a scripted item 
     135                            if (initials.length() == 0) 
     136                            { 
     137                                initials = "Script"; 
     138                            } 
     139                            sb.append(initials + " "); 
     140                            sb.append(notesTable.getValueAt(row,4) + "\n"); // notes 
     141                        } 
     142                    } 
     143                    System.out.println(sb); 
     144                    //long simtime = theCoorInt.getCurrentSimulationTime(); 
     145                    //theView.updateTime("" + formatInterval(simtime)); 
    116146                } catch (RemoteException ex) 
    117147                { 
    118                     Logger.getLogger(ClockClient.class.getName()).log(Level.SEVERE, null, ex); 
     148                    Logger.getLogger(CADlogDisplay.class.getName()).log(Level.SEVERE, null, ex); 
    119149                } 
    120150            } 
     
    245275        { 
    246276            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
    247             new ClockClient(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME); 
     277            new CADlogDisplay(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME); 
    248278 
    249279        } catch (Exception e) 
Note: See TracChangeset for help on using the changeset viewer.