Changeset 194 in tmcsimulator
- Timestamp:
- 10/30/2017 02:50:59 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/atmsdriver/model/Highways.java (modified) (1 diff)
-
test/atmsdriver/TrafficModelEventDriver.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/atmsdriver/model/Highways.java
r191 r194 480 480 for (Highway hwy: highways) 481 481 { 482 result.append(""+String.format("%3s ",hwy.routeNumber)); 483 for (Station stat: hwy.stations) 484 { 485 result.append(stat.getColorByDirection(stat.direction)); 486 } 487 result.append("\n"); 488 } 482 for (DIRECTION dir: DIRECTION.values()) 483 { 484 StringBuilder lineout = new StringBuilder(); 485 lineout.append(""+String.format("%3s ",hwy.routeNumber)+dir.getLetter()+' '); 486 for (Station stat: hwy.stations) 487 { 488 if (stat.direction == dir) 489 { 490 //lineout.append("" + dir.getLetter() + stat.postmile); 491 lineout.append(stat.getColorByDirection(stat.direction)); 492 //lineout.append(" "); 493 } 494 } 495 if (lineout.length() > 6) 496 { 497 result.append(lineout + "\n"); 498 } 499 } 500 } 501 result.append("\n"); 489 502 return result.toString(); 490 503 } -
trunk/test/atmsdriver/TrafficModelEventDriver.java
r192 r194 1 1 package atmsdriver; 2 2 3 import tmcsim.client.*;4 3 import atmsdriver.model.Highways; 5 4 import atmsdriver.model.TrafficEvent; 6 import atmsdriver.model.LoopDetector.DOTCOLOR;7 import java.awt.event.ActionEvent;8 import java.awt.event.ActionListener;9 5 import java.io.FileInputStream; 10 6 import java.io.FileNotFoundException; 11 7 import java.rmi.RemoteException; 12 import java.rmi.server.UnicastRemoteObject;13 8 import java.text.ParseException; 14 9 import java.text.SimpleDateFormat; 15 10 import java.util.ArrayList; 16 11 import java.util.Collections; 17 import java.util.Date;18 12 import java.util.HashMap; 19 13 import java.util.LinkedList; 20 14 import java.util.List; 21 15 import java.util.Map; 22 import java.util.Properties;23 16 import java.util.Scanner; 24 import java.util.concurrent.TimeUnit;25 17 import java.util.logging.Level; 26 18 import java.util.logging.Logger; 27 19 import javax.swing.JOptionPane; 28 20 import javax.swing.JWindow; 29 import javax.swing.Timer;30 import javax.swing.UIManager;31 import tmcsim.common.SimulationException;32 import tmcsim.interfaces.CADClientInterface;33 import tmcsim.interfaces.CoordinatorInterface;34 21 35 22 /** … … 39 26 * @author jdalbey 40 27 */ 41 public class TrafficModelEventDriver extends UnicastRemoteObject implements 42 CADClientInterface 28 public class TrafficModelEventDriver 43 29 { 44 private final static SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");45 30 /** 46 31 * Error logger. 47 32 */ 48 private static Logger cadClientLogger = Logger.getLogger("tmcsim.client"); 49 50 @Override 51 public void refresh() throws RemoteException 52 { 53 System.out.println("ATMSBatchDriver.refresh() was invoked."); 54 } 33 private static Logger logger = Logger.getLogger("trafficmodeleventdriver"); 55 34 56 35 /** … … 69 48 70 49 /** 71 * Constructor. Initialize data from parsed properties file. Create a socket 72 * connection to the CADSimulator. 50 * Constructor. Load highways and events. 73 51 * 74 * @param propertiesFile File path (absolute or relative) to the properties75 * file containing configuration data.76 52 */ 77 53 public TrafficModelEventDriver() throws RemoteException … … 86 62 // READ THE BATCH FILE OF COMMANDS and put in a queue 87 63 readBatchFile(); 88 64 } 65 public void run() 66 { 89 67 // If we have any events left to process 90 68 while (!eventQueue.isEmpty()) 91 69 { 92 // Get the time to launch thenext event70 // Get next event 93 71 TrafficEvent nextEvent = eventQueue.peek(); 94 72 System.out.println("LAUNCHING EVENT: " + nextEvent.toString()); … … 99 77 // Remove this event from the queue, we're done with it. 100 78 eventQueue.remove(); 101 102 79 } 103 104 80 } 105 81 … … 158 134 159 135 /** 160 * Format a time in seconds as HH:MM:SS 161 * 162 * @param l 163 * @return 164 */ 165 private String formatInterval(final long l) 166 { 167 final long hr = TimeUnit.SECONDS.toHours(l); 168 final long min = TimeUnit.SECONDS.toMinutes(l - TimeUnit.HOURS.toSeconds(hr)); 169 final long sec = TimeUnit.SECONDS.toSeconds(l - TimeUnit.HOURS.toSeconds(hr) - TimeUnit.MINUTES.toSeconds(min)); 170 return String.format("%02d:%02d:%02d", hr, min, sec); 171 } 172 /** 173 * Construct the CADClient with the properties file path, either from the 174 * command line arguments or default. 136 * local main to launch the app. 175 137 * 176 138 * @param args Command line arguments. … … 178 140 public static void main(String[] args) 179 141 { 180 if (System.getProperty("CONFIG_DIR") == null)181 {182 System.setProperty("CONFIG_DIR", "config");183 }184 185 142 try 186 143 { 187 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 188 new TrafficModelEventDriver(); 189 144 TrafficModelEventDriver driver = new TrafficModelEventDriver(); 145 driver.run(); 190 146 } 191 147 catch (Exception e) 192 148 { 193 cadClientLogger.logp(Level.SEVERE, "SimulationManager", "Main",149 logger.logp(Level.SEVERE, "Traffic Model Event Driver", "Main", 194 150 "Error initializing application."); 195 151
Note: See TracChangeset
for help on using the changeset viewer.
