Changeset 87 in tmcsimulator for trunk/src/atmsdriver/ATMSDriver.java
- Timestamp:
- 10/10/2017 01:09:50 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/atmsdriver/ATMSDriver.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/atmsdriver/ATMSDriver.java
r79 r87 1 1 package atmsdriver; 2 2 3 import atmsdriver.model. Network;3 import atmsdriver.model.Highways; 4 4 import java.io.File; 5 5 import java.io.FileInputStream; 6 import java.io.FileNotFoundException; 7 import java.io.PrintWriter; 6 8 import java.util.Properties; 7 9 import java.util.logging.Level; … … 9 11 10 12 /** 13 * ATMS Driver reads the current simulation traffic conditions from the 14 * EXCHANGE.XML file and constructs the Highway Network status info in the 15 * format required by the FEP. It then sends this XML data over a socket to the 16 * FEP Simulator. 11 17 * 12 18 * @author John A. Torres … … 15 21 public class ATMSDriver implements Runnable { 16 22 17 /** ATMSDriver Error logger. */ 23 /** 24 * ATMSDriver Error logger. 25 */ 18 26 private static Logger ATMSDriverLogger = Logger.getLogger("atmsdriver"); 19 27 20 28 private static final String CONFIG_FILE_NAME = "atms_driver_config.properties"; 21 29 22 /** Properties object for the CADClient class. */ 30 /** 31 * Properties object for the CADClient class. 32 */ 23 33 private Properties ATMSDriverProperties; 24 34 … … 31 41 */ 32 42 private static enum PROPERTIES { 33 34 43 LDS_FILE_NAME("LDSFileName"), 35 LOOP_FILE_NAME("LoopFileName"), 36 NETWORK_FILE_NAME("NetworkFileName"), 37 EXCHANGE_FILE_NAME("ExchangeFileName"); 44 LOOPS_FILE_NAME("LoopsFileName"), 45 HIGHWAY_META_FILE("HighwayMetaFileName"), 46 EXCHANGE_FILE_NAME("ExchangeFileName"), 47 FEP_WRITER_HOST("FEPWriterHost"), 48 FEP_WRITER_PORT("FEPWriterPort"); 38 49 39 50 public String name; … … 44 55 } 45 56 46 /** Network model. */ 47 final private Network network; 48 49 /** Sleep Time (10 seconds). **/ 50 private static final int SLEEP_TIME = 10000; 51 52 /** Exchange Reader */ 57 /** 58 * Highways in traffic network 59 */ 60 final private Highways highways; 61 62 /** 63 * Sleep Time (30 seconds). * 64 */ 65 private static final int SLEEP_TIME = 30000; 66 67 /** 68 * Exchange Reader 69 */ 53 70 private ExchangeReader exchangeReader; 54 71 55 72 @Override 56 73 public void run() { 57 74 // Check for packets and update the simulator 58 for (;;) {75 while (true) { 59 76 // Flush the input file 60 77 ExchangeInfo exInfo = exchangeReader.parse(ATMSDriverProperties 61 78 .getProperty(PROPERTIES.EXCHANGE_FILE_NAME.name)); 62 network.toXML(); 63 // Update if packet is recieved 79 80 System.out.println(highways.toXML()); 81 highways.writeToFEP(); 82 // Update if exchangeInfo is recieved 64 83 if (exInfo != null) { 65 System.out.println("Grabbed"); 84 // TODO: handle this condition 85 Logger.getLogger("ATMSDriver").log(Level.INFO, "exInfo is not null"); 66 86 } 67 87 68 // Sleep88 // Wait for FEP Sim to process the data we just sent 69 89 try { 70 90 Thread.sleep(SLEEP_TIME); 71 91 } catch (InterruptedException ie) { 72 92 ie.printStackTrace(); 73 93 } 74 94 } … … 81 101 } 82 102 83 network = new Network( 84 new File(ATMSDriverProperties.getProperty( 85 PROPERTIES.LDS_FILE_NAME.name)), 86 new File(ATMSDriverProperties.getProperty( 87 PROPERTIES.LOOP_FILE_NAME.name)), 88 new File(ATMSDriverProperties.getProperty( 89 PROPERTIES.NETWORK_FILE_NAME.name))); 90 network.toXML(); 103 highways = new Highways( 104 ATMSDriverProperties.getProperty( 105 PROPERTIES.LDS_FILE_NAME.name), 106 ATMSDriverProperties.getProperty( 107 PROPERTIES.LOOPS_FILE_NAME.name), 108 ATMSDriverProperties.getProperty( 109 PROPERTIES.HIGHWAY_META_FILE.name), 110 ATMSDriverProperties.getProperty(PROPERTIES.FEP_WRITER_HOST.name), 111 Integer.parseInt(ATMSDriverProperties.getProperty( 112 PROPERTIES.FEP_WRITER_PORT.name))); 113 91 114 exchangeReader = new ExchangeReader(); 92 115 } … … 106 129 107 130 /** 108 * Runs the Paramics simulator.131 * Runs the ATMS Driver. 109 132 */ 110 133 public static void main(String[] args) {
Note: See TracChangeset
for help on using the changeset viewer.
