Changeset 184 in tmcsimulator for trunk/src/atmsdriver/model/FEPLine.java
- Timestamp:
- 10/28/2017 05:24:02 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/atmsdriver/model/FEPLine.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/atmsdriver/model/FEPLine.java
r103 r184 1 1 package atmsdriver.model; 2 2 3 import java.util.ArrayList; 3 4 import java.util.List; 4 5 import org.w3c.dom.Document; 5 6 import org.w3c.dom.Element; 6 7 7 /** An FEPLine is a simulated line of communication from the FEP to 8 * LoopDetectorStations in the traffic network. 9 * 10 * An FEPLine contains static meta data and a list of LoopDetectorStations. 11 * A single FEPLine contains multiple LoopDetectorStations. 8 /** 9 * An FEPLine is a simulated line of communication from the FEP to 10 * Stations in the highways network. 11 * 12 * An FEPLine contains static line meta data and a list of Stations. A 13 * single FEPLine contains multiple Stations. 12 14 * 13 15 * @author John A. Torres 14 16 * @version 09/10/2017 15 */ 16 public class FEPLine { 17 */ 18 final public class FEPLine 19 { 17 20 /* Static FEPLine meta data */ 18 21 final public int lineNum; 19 22 final public List<Station> stations; 20 23 final private int count; 21 22 final private int schedule; 23 final private int lineInfo; 24 final private long systemKey; 25 26 // THESE WILL NEED TO BE UPDATED MAYBE, NOT SURE, NOT A PRIORITY. SEE METHOD 27 // UPDATESEQUENCES() 28 private long globalSeq; 29 private long scheduleSeq; 30 31 public FEPLine(int lineNum, List<Station> stations, int count, 32 int schedule, int lineInfo, long systemKey, long globalSeq, 33 long scheduleSeq) 24 25 /** 26 * Constructs an FEPLine from given line number, list of stations, and count. 27 * 28 * @param lineNum 29 * @param stations 30 * @param count 31 */ 32 FEPLine(int lineNum, ArrayList<Station> stations, int count) 34 33 { 35 34 this.lineNum = lineNum; 36 35 this.stations = stations; 37 36 this.count = count; 38 this.schedule = schedule;39 this.lineInfo = lineInfo;40 this.systemKey = systemKey;41 this.globalSeq = globalSeq;42 this.scheduleSeq = scheduleSeq;43 37 } 44 38 45 // NEED TO CHECK NUMBERS? DO WE EVEN NEED THIS? 46 public void updateSequences() 47 { 48 this.scheduleSeq += 1; 49 this.globalSeq += 51; 50 } 51 39 /** 40 * Returns the FEPLine meta data in string format 41 * @return FEPLine metadata 42 */ 52 43 public String getLineMeta() 53 44 { … … 59 50 build.append(Integer.toString(this.stations.size())); 60 51 build.append("\n"); 61 for (Station station : stations)52 for (Station station : stations) 62 53 { 63 54 build.append(station.getStationMeta()); … … 66 57 } 67 58 59 /** 60 * Returns the FEPLine data in XMLFormat 61 * 62 * @param currElem The current XML <Line> element 63 */ 68 64 public void toXML(Element currElem) 69 65 { 70 66 Document theDoc = currElem.getOwnerDocument(); 71 67 72 68 Element lineElement = theDoc.createElement(XML_TAGS.LINE.tag); 73 69 currElem.appendChild(lineElement); 74 70 75 71 Element lineNumElement = theDoc.createElement(XML_TAGS.LINE_NUM.tag); 76 72 lineNumElement.appendChild(theDoc.createTextNode(String.valueOf(this.lineNum))); 77 73 lineElement.appendChild(lineNumElement); 78 74 79 75 Element countElement = theDoc.createElement(XML_TAGS.COUNT.tag); 80 76 countElement.appendChild(theDoc.createTextNode(String.valueOf(this.count))); 81 77 lineElement.appendChild(countElement); 82 83 Element scheduleElement = theDoc.createElement(XML_TAGS.SCHEDULE.tag); 84 scheduleElement.appendChild(theDoc.createTextNode(String.valueOf(this.schedule))); 85 lineElement.appendChild(scheduleElement); 86 87 Element lineInfoElement = theDoc.createElement(XML_TAGS.LINE_INFO.tag); 88 lineInfoElement.appendChild(theDoc.createTextNode(String.valueOf(this.lineInfo))); 89 lineElement.appendChild(lineInfoElement); 90 91 Element systemKeyElement = theDoc.createElement(XML_TAGS.SYSTEM_KEY.tag); 92 systemKeyElement.appendChild(theDoc.createTextNode(String.valueOf(this.systemKey))); 93 lineElement.appendChild(systemKeyElement); 94 95 Element globalSeqElement = theDoc.createElement(XML_TAGS.GLOBAL_SEQ.tag); 96 globalSeqElement.appendChild(theDoc.createTextNode(String.valueOf(this.globalSeq))); 97 lineElement.appendChild(globalSeqElement); 98 99 Element scheduleSeqElement = theDoc.createElement(XML_TAGS.SCHEDULE_SEQ.tag); 100 scheduleSeqElement.appendChild(theDoc.createTextNode(String.valueOf(this.scheduleSeq))); 101 lineElement.appendChild(scheduleSeqElement); 102 78 103 79 Element stationsElement = theDoc.createElement(XML_TAGS.STATIONS.tag); 104 80 lineElement.appendChild(stationsElement); 105 for (Station station : stations)81 for (Station station : stations) 106 82 { 107 83 station.toXML(stationsElement); … … 109 85 } 110 86 87 /** 88 * XML Tags used in toXML() 89 */ 111 90 private static enum XML_TAGS 112 91 { 92 113 93 LINE("Line"), 114 94 LINE_NUM("Line_Num"), 115 95 STATIONS("Stations"), 116 COUNT("Count"), 117 SCHEDULE("Schedule"), 118 LINE_INFO("Line_Info"), 119 SYSTEM_KEY("System_Key"), 120 GLOBAL_SEQ("Global_Seq"), 121 SCHEDULE_SEQ("Schedule_Seq"); 122 96 COUNT("Count"); 97 123 98 String tag; 124 99 125 100 private XML_TAGS(String n) 126 101 {
Note: See TracChangeset
for help on using the changeset viewer.
