Changeset 145 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures
- Timestamp:
- 11/04/2019 08:14:32 AM (7 years ago)
- Location:
- trunk/src/scriptbuilder/structures
- Files:
-
- 1 added
- 9 edited
-
.directory (added)
-
CadData.java (modified) (2 diffs)
-
ELEMENT.java (modified) (1 diff)
-
MyScriptHandler.java (modified) (3 diffs)
-
ScriptEvent.java (modified) (1 diff)
-
ScriptIncident.java (modified) (5 diffs)
-
SimulationScript.java (modified) (7 diffs)
-
TimeSlice.java (modified) (3 diffs)
-
events/UnitEvent.java (modified) (1 diff)
-
units/Unit.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/structures/CadData.java
r143 r145 15 15 locInfo = new ArrayList<Location_Info>(); 16 16 } 17 18 /** 19 * Constructor to add type and location, where TruncLoc is the first 5 letters of the fullloc. 20 * @param Header_Type 21 * @param Header_FullLoc 22 */ 23 public CadData(String Header_Type, String Header_FullLoc) 24 { 25 this.Header_Type = Header_Type; 26 this.Header_FullLoc = Header_FullLoc; 27 // if(Header_FullLoc.length()>10) 28 // { 29 // this.Header_TruncLoc = Header_FullLoc.substring(0,9); 30 // } 31 this.Header_TruncLoc = Header_FullLoc; 32 locInfo = new ArrayList<Location_Info>(); 33 } 17 34 18 35 public TimeSlice tSlice; 19 36 20 public String Header_Type = " DEFAULT";37 public String Header_Type = ""; 21 38 22 39 public String Header_Beat = ""; 23 40 24 public String Header_TruncLoc = " Default Location (short)";25 26 public String Header_FullLoc = " Default Location (long)";41 public String Header_TruncLoc = ""; 42 43 public String Header_FullLoc = ""; 27 44 28 45 public String Master_Inc_Num = ""; … … 134 151 } 135 152 136 if (hasHeaderInfo() || true) //checking to see if header info is always necessary 137 { 153 if (hasHeaderInfo()) //checking to see if header info is always necessary 154 { 155 //todo: make this logic trigger only once per incident 138 156 output += XMLWriter.openTag(ELEMENT.HEADER_INFO.tag); 139 157 -
trunk/src/scriptbuilder/structures/ELEMENT.java
r138 r145 35 35 LOCATION_INFO, 36 36 NEW_UNIT, 37 //todo: change this paramics to traffic modeler 37 38 PARAMICS,//EVENT 38 39 RADIO_EVALUATION, -
trunk/src/scriptbuilder/structures/MyScriptHandler.java
r138 r145 304 304 305 305 docPosition.push(ELEMENT.byName(qName)); 306 306 307 307 try 308 308 { … … 612 612 * SAX Handler method. Executes at the close of each XML element. 613 613 */ 614 //todo: interpret this function better so that what is loaded from the XML file is easier to know. 614 615 @Override 615 616 public void endElement(String uri, String localName, String qName) … … 670 671 { 671 672 cad.Header_Type = pcData.remove(currentElement); 673 // //change where the data is loaded in here 674 // currInc.insertCadData((int) currentEventTime, cad); 672 675 } 673 676 else if (currentElement == ELEMENT.Beat && docPosition.peek() == ELEMENT.HEADER_INFO) -
trunk/src/scriptbuilder/structures/ScriptEvent.java
r107 r145 83 83 public int length; 84 84 85 p rivateTimeSlice slice;85 public TimeSlice slice; 86 86 87 87 /** -
trunk/src/scriptbuilder/structures/ScriptIncident.java
r131 r145 46 46 */ 47 47 public String description; 48 48 49 49 /** 50 50 * Length, in seconds, of the incident. … … 72 72 public int eventCount = 0; 73 73 74 SimulationScript script;74 public SimulationScript script; 75 75 76 76 /** … … 135 135 this.setOffset(offset); 136 136 } 137 138 // /** 139 // * Constructor with type and location parameters. 140 // * @param color 141 // * @param number 142 // * @param name 143 // * @param description 144 // * @param script 145 // * @param offset 146 // * @param type 147 // * @param location 148 // */ 149 // public ScriptIncident(Color color, int number, String name, 150 // String description, SimulationScript script, 151 // int offset, String type, String location) 152 // { 153 // this.color = color; 154 // this.number = number; 155 // this.name = name; 156 // this.description = description; 157 // this.script = script; 158 // slices = new TreeMap<Integer, TimeSlice>(); 159 // this.setOffset(offset); 160 // this.location = location; 161 // this.type = type; 162 // insertCadData(offset, new CadData(type,location)); 163 // } 137 164 138 165 /** … … 293 320 } 294 321 295 void insertCadData(long currentEventTime, CadData cad)322 public void insertCadData(long currentEventTime, CadData cad) 296 323 { 297 324 int time = (int) currentEventTime; … … 305 332 slice = slices.get(time); 306 333 slice.cadData = cad; 334 } 335 336 public CadData getCadData(long currentEventTime) 337 { 338 int time = (int) currentEventTime; 339 TimeSlice slice; 340 341 slice = slices.get(time); 342 return slice.cadData; 307 343 } 308 344 -
trunk/src/scriptbuilder/structures/SimulationScript.java
r131 r145 21 21 * 22 22 * @author Bryan McGuffin <bmcguffi@calpoly.edu> 23 * @author Sebastien Danthinne <sdanthin@calpoly.edu> 23 24 * @version 2017/06/22 24 25 */ … … 61 62 * The units which participate in Unit events. 62 63 */ 63 public List<Unit> units; 64 public List<Unit> units; 64 65 65 66 //Somewhere in the code, something assumes that the list of incidents 66 67 //contains exactly 10 items. Until I can find and un-break that, this will do. 68 //todo: this incident fill count error 67 69 private final int INCIDENT_FILL_COUNT = 10; 68 70 … … 76 78 */ 77 79 private MyScriptHandler sh; 80 81 public boolean saved; 78 82 79 83 //TODO: Pretty much everything in this constructor is dummy data. … … 89 93 units = new ArrayList<Unit>(); 90 94 numberOfIncidents = 0; 95 saved = true; 91 96 92 97 //Backfill with null incidents … … 96 101 } 97 102 } 98 103 104 /** 105 * checks and sees if this object has the unit passed. 106 * @param unitID 107 * @return does this SimulationScript have unitnum? 108 */ 109 public boolean hasUnit(String unitID){ 110 boolean indicator = false; 111 if(units.size()!=0){ 112 for(Unit u : units){ 113 if(unitID.equals(u.UnitNum)){ 114 indicator = true; 115 } 116 } 117 } 118 119 return indicator; 120 } 121 /** 122 * creates a dummy unit that only has unit number 123 * @param unitNum 124 */ 125 public void addDummyUnit(String unitNum){ 126 Unit dummy = new Unit(); 127 dummy.UnitNum = unitNum; 128 units.add(dummy); 129 } 99 130 /** 100 131 * Update the script's observers. 101 * 132 * 102 133 */ 103 134 public void update() 104 135 { 105 136 // The script has changed, notify observers 137 //use to rewrite the save indicator 138 //System.out.println("Script changed"); 106 139 setChanged(); 107 140 notifyObservers(this); 108 } 141 saved = false; 142 143 144 } 145 109 146 110 147 /** … … 154 191 { 155 192 System.out.println("ERROR LOADING SCRIPT"); 193 ex.printStackTrace(); 194 } 195 System.out.println("H"); 196 for(Unit testUnit : units){ 197 System.out.println(testUnit.toXML()); 198 } 199 this.update(); 200 } 201 202 /** 203 * Load in an existing list of units from an XML file. 204 * @param f the file containing the units 205 */ 206 public void loadUnitsFromFile(File f){ 207 try 208 { 209 SAXParserFactory.newInstance().newSAXParser().parse(f, sh); 210 units.addAll(sh.getUnits()); 211 } 212 catch (Exception ex) 213 { 214 System.out.println("ERROR LOADING UNITS"); 156 215 ex.printStackTrace(); 157 216 } … … 197 256 ex.printStackTrace(); 198 257 } 258 saved = true; 199 259 } 200 260 -
trunk/src/scriptbuilder/structures/TimeSlice.java
r142 r145 56 56 } 57 57 58 59 public ScriptIncident getIncident(){ 60 return thisIncident; 61 } 58 62 /** 59 63 * Add a new script event to this time slice. Sort events by event type. … … 77 81 public int getX() 78 82 { 83 // System.out.println("position: " + seconds / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION 84 // * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK); 79 85 return seconds / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION 80 86 * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK; … … 210 216 public String toXML() 211 217 { 218 //eventsCopy2 is used to clear out eventsCopy with one element contained 212 219 ArrayList<I_ScriptEvent> eventsCopy = new ArrayList<I_ScriptEvent>(); 213 220 ArrayList<I_ScriptEvent> eventsCopy2 = new ArrayList<I_ScriptEvent>(); -
trunk/src/scriptbuilder/structures/events/UnitEvent.java
r76 r145 22 22 /** 23 23 * Constructor. 24 * //TODO: when created, add a unit to the main units list that is contained within SimulationScript 24 25 */ 25 26 public UnitEvent() 26 27 { 28 27 29 super(ScriptEventType.UNIT_EVENT); 30 28 31 } 29 32 -
trunk/src/scriptbuilder/structures/units/Unit.java
r46 r145 102 102 Unit_Status = ""; 103 103 } 104 105 public boolean equals(Unit u){ 106 return UnitNum.equals(u.UnitNum); 107 } 108 public boolean equals(String num){ 109 return UnitNum.equals(num); 110 } 104 111 105 112 @Override
Note: See TracChangeset
for help on using the changeset viewer.
