Changeset 105 in tmcsimulator for trunk/src/tmcsim
- Timestamp:
- 10/12/2017 09:57:54 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/tmcsim/client/ATMSDriverClient.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/client/ATMSDriverClient.java
r102 r105 4 4 import java.awt.event.ActionListener; 5 5 import java.io.FileInputStream; 6 import java.io.FileNotFoundException; 6 7 import java.rmi.Naming; 7 8 import java.rmi.RemoteException; 8 9 import java.rmi.server.UnicastRemoteObject; 10 import java.util.LinkedList; 9 11 import java.util.Properties; 12 import java.util.Queue; 13 import java.util.Scanner; 10 14 import java.util.concurrent.TimeUnit; 11 15 import java.util.logging.Level; … … 33 37 CADClientInterface 34 38 { 39 private static final String CONFIG_FILE_NAME = "cad_client_config.properties"; 40 private final static int ONE_SECOND = 1000; 35 41 /** 36 42 * Error logger. … … 82 88 */ 83 89 private CADClientInterface client = this; 84 private static final String CONFIG_FILE_NAME = "cad_client_config.properties"; 85 private final static int ONE_SECOND = 1000; 90 91 /** 92 * Queue of batch events 93 */ 94 private Queue<String> eventQueue; 95 86 96 87 97 /** … … 104 114 105 115 // READ THE BATCH FILE OF COMMANDS and put in a queue 116 readBatchFile(); 106 117 // Consider special cases: 1) time to fire first command 107 118 // has already past when application starts. … … 114 125 public void actionPerformed(ActionEvent e) 115 126 { 127 String currentClock = ""; 116 128 try 117 129 { 118 130 long simtime = theCoorInt.getCurrentSimulationTime(); 131 currentClock = formatInterval(simtime); 132 System.out.println("Current clock: " + currentClock); 133 } catch (RemoteException ex) 134 { 135 Logger.getLogger(ATMSDriverClient.class.getName()).log(Level.SEVERE, null, ex); 136 } 137 if (!eventQueue.isEmpty()) 138 { 119 139 // Check the queue of commands to see if the first 120 140 // item matches the current time. IF so, 121 141 // issue that command and remove it from queue. 122 142 String nextEvent = eventQueue.peek(); 143 String eventTime = nextEvent.substring(0,8); 144 System.out.println("Next event will be launched at: " + eventTime); 145 if (eventTime.equals(currentClock)) 146 { 147 System.out.println("LAUNCHING EVENT at " + nextEvent ); 148 eventQueue.remove(); 149 } 123 150 //theView.updateTime("" + formatInterval(simtime)); 124 } catch (RemoteException ex)125 {126 Logger.getLogger(ATMSDriverClient.class.getName()).log(Level.SEVERE, null, ex);127 151 } 128 152 } … … 133 157 } 134 158 159 private void readBatchFile() 160 { 161 FileInputStream fis; 162 try { 163 fis = new FileInputStream("config/vds_data/atmsBatchEvents.txt"); 164 Scanner scan = new Scanner(fis); 165 eventQueue = new LinkedList<String>(); 166 while (scan.hasNext()) 167 { 168 eventQueue.add(scan.nextLine()); 169 } 170 } catch (FileNotFoundException ex) { 171 Logger.getLogger(ATMSDriverClient.class.getName()).log(Level.SEVERE, null, ex); 172 } 173 } 174 135 175 /** 136 176 * Connect to the Coordinator's RMI object, and register this object for
Note: See TracChangeset
for help on using the changeset viewer.
