Changeset 119 in tmcsimulator
- Timestamp:
- 10/14/2017 12:10:01 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/atmsdriver/ConsoleDriver.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/atmsdriver/ConsoleDriver.java
r114 r119 5 5 import atmsdriver.model.Highway; 6 6 import atmsdriver.model.Station; 7 import java.io.FileInputStream; 7 8 import java.util.ArrayList; 8 9 import java.util.Arrays; 9 10 import java.util.List; 11 import java.util.Properties; 10 12 import java.util.Scanner; 13 import java.util.logging.Level; 14 import java.util.logging.Logger; 11 15 12 16 /** … … 23 27 private final List<Integer> routeNumInputList; 24 28 private final List<String> dotColorInputList; 29 /** 30 * Properties for the ConsoleDriver 31 */ 32 private static Properties ConsoleDriverProperties; 25 33 26 34 /** Entry point for the application. … … 28 36 * @param args unused 29 37 */ 30 public static void main(String[] args) 38 public static void main(String[] args) { 39 try { 40 if (System.getProperty("ATMSDRIVER_PROPERTIES") != null) 41 { 42 // Load properties of runtime parameters 43 if (!loadProperties()) 44 { 45 System.exit(0); 46 } 47 // Create the Highway Model 48 Highways highways = new Highways( 49 "config/vds_data/lds.txt", 50 "config/vds_data/loop.txt", 51 "config/vds_data/highwaysMeta.txt", 52 ConsoleDriverProperties.getProperty( 53 "FEPWriterHost"), 54 Integer.parseInt(ConsoleDriverProperties.getProperty( 55 "FEPWriterPort"))); 56 57 // Construct the console driver using the highways model 58 ConsoleDriver driver = new ConsoleDriver(highways); 59 driver.runConsole(); 60 } else { 61 throw new Exception("ATMSDRIVER_PROPERTIES system property not defined."); 62 } 63 } catch (Exception e) { 64 Logger.getLogger("ConsoleDriver").logp(Level.SEVERE, "ConsoleDriver", "Main", 65 "Error occured initializing application", e); 66 System.exit(-1); 67 } 68 } 69 /** 70 * Load the properties file containing values for runtime parameters. 71 * 72 * @param propertiesFile 73 * @return 74 */ 75 private static boolean loadProperties() 31 76 { 32 Highways highways = new Highways( 33 "config/vds_data/lds.txt", 34 "config/vds_data/loop.txt", 35 "config/vds_data/highwaysMeta.txt", 36 "localhost", 8080); 37 ConsoleDriver app = new ConsoleDriver(highways); 38 app.runConsole(); 77 // Load the properties file. 78 try { 79 ConsoleDriverProperties = new Properties(); 80 ConsoleDriverProperties.load(new FileInputStream(System.getProperty("ATMSDRIVER_PROPERTIES"))); 81 } catch (Exception e) { 82 Logger.getLogger("CosoleDriver").logp(Level.SEVERE, "ConsoleDriver", 83 "Constructor", "Exception in reading properties file.", e); 84 } 85 86 return true; 39 87 } 40 88 /**
Note: See TracChangeset
for help on using the changeset viewer.
