Changeset 38 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures/SimulationScript.java


Ignore:
Timestamp:
08/03/2017 04:30:19 PM (9 years ago)
Author:
bmcguffin
Message:

Removed the newLine at the end of each openTag method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/structures/SimulationScript.java

    r30 r38  
    1919import scriptbuilder.structures.ScriptIncident.IncidentFocusedEvent; 
    2020import scriptbuilder.structures.ScriptIncident.SliceChangedEvent; 
     21import scriptbuilder.structures.units.Unit; 
    2122 
    2223/** 
     
    5657    public List<ScriptIncident> incidents; 
    5758 
     59    /** 
     60     * The units which participate in Unit events. 
     61     */ 
     62    public List<Unit> units; 
     63 
    5864    //Somewhere in the code, something assumes that the list of incidents 
    5965    //contains exactly 10 items. Until I can find and un-break that, this will do. 
     
    8086        sh = new MyScriptHandler(this); 
    8187        incidents = new ArrayList<ScriptIncident>(); 
     88        units = new ArrayList<Unit>(); 
    8289        numberOfIncidents = 0; 
    8390 
    84         // Create the media event 
    85         /*incidents.add(new ScriptIncident(incidentColors[0], 100, "Media", 
    86          "An incident for the media in CAD.", 10800, this)); 
    87          numberOfIncidents++; 
    88          // Create the "other" event 
    89          incidents.add(new ScriptIncident(incidentColors[9], 999, "Other", 
    90          "An incident for small-scale events, false events, " 
    91          + "and noise.  All events added to this incident will " 
    92          + "receive a randomly generated incident number.", 
    93          10800, this)); 
    94          numberOfIncidents++;*/ 
    9591        //Backfill with null incidents 
    9692        for (int i = numberOfIncidents; i < INCIDENT_FILL_COUNT; i++) 
     
    9894            incidents.add(null); 
    9995        } 
    100         /* 
    101          Add some demo events 
    102          incidents.add(new ScriptIncident(incidentColors[1], 174, "Blueberry Truck", 
    103          "Blueberry truck crashed on the freeway.", 8800, this)); 
    104          numberOfIncidents++; 
    105          incidents.add(new ScriptIncident(incidentColors[2], 175, "Construction Crash", 
    106          "Crash at construction site on Red Road.", 6800, this)); 
    107          numberOfIncidents++; 
    108          incidents.add(new ScriptIncident(incidentColors[3], 176, "Car Freeway Flip", 
    109          "Car flipped across the lane divider on the freeway.", 7200, this)); 
    110          numberOfIncidents++; 
    111          incidents.add(new ScriptIncident(incidentColors[4], 177, "Two Lane Crash", 
    112          "Crash taking two lanes on Tree Road.", 4200, this)); 
    113          numberOfIncidents++; 
    114          incidents.add(new ScriptIncident(incidentColors[5], 178, "Stalled Truck", 
    115          "Truck stalled on the freeway.", 2800, this)); 
    116          numberOfIncidents++; 
    117          incidents.add(new ScriptIncident(incidentColors[6], 179, "Tomato Truck Spill", 
    118          "Tomato trucked spilt tomatos all over the freeway.", 3200, this)); 
    119          incidents.add(new ScriptIncident(incidentColors[7], 180, "Crash at Intersection", 
    120          "Crash at the intersection of Tree Road and Red Road.", 4300, this)); 
    121          incidents.add(new ScriptIncident(incidentColors[8], 181, "Bomb Threat", 
    122          "Bomb threat and Road X.", 6000, this)); 
    123          incidents.add(null); 
    124          incidents.add(null); 
    125          incidents.add(null); 
    126          Random rng = new Random(); 
    127          ScriptEventType[] eventTypes = ScriptEventType.values(); 
    128          if (numberOfIncidents > 0) 
    129          { 
    130          for (int i = 0; i < 300; i++) 
    131          { 
    132          int n = rng.nextInt(); 
    133          int s = rng.nextInt(); 
    134          int e = rng.nextInt(); 
    135          if (n < 0) 
    136          { 
    137          n *= -1; 
    138          } 
    139          if (s < 0) 
    140          { 
    141          s *= -1; 
    142          } 
    143          if (e < 0) 
    144          { 
    145          e *= -1; 
    146          } 
    147          incidents.get(n % numberOfIncidents).slices.get(s % (incidents.get(n % numberOfIncidents).slices.size())).addEvent(new ScriptEvent(eventTypes[e % eventTypes.length])); 
    148          }   
    149          incidents.get(1).setOffset(200); 
    150          incidents.get(2).setOffset(3400); 
    151          incidents.get(3).setOffset(1400); 
    152          incidents.get(4).setOffset(4400); 
    153          incidents.get(5).setOffset(1400); 
    154          incidents.get(6).setOffset(7600); 
    155          incidents.get(7).setOffset(2400); 
    156          incidents.get(8).setOffset(4800);  
    157          } 
    158          */ 
    15996    } 
    16097 
     
    207144 
    208145            Vector<ScriptIncident> inc = sh.getIncidents(); 
    209  
     146            units = sh.getUnits(); 
    210147            for (ScriptIncident sci : inc) 
    211148            { 
     
    246183    public String toXML() 
    247184    { 
     185        ArrayList<TimeSlice> slices = allSlices(); 
    248186        String output = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; 
    249         output += "<!DOCTYPE TMC_SCRIPT SYSTEM \"script.dtd\">"; 
    250         ArrayList<TimeSlice> slices = allSlices(); 
     187        output += "<!DOCTYPE TMC_SCRIPT SYSTEM \"script.dtd\">\n"; 
    251188        output += openTag(ELEMENT.TMC_SCRIPT.tag + " title=\"" + this.title + "\""); 
     189 
     190        if (units.size() > 0) 
     191        { 
     192            output += openTag(ELEMENT.SCRIPT_DATA.tag); 
     193            for (Unit unit : units) 
     194            { 
     195                output += unit.toXML(); 
     196            } 
     197            output += closeTag(ELEMENT.SCRIPT_DATA.tag); 
     198        } 
    252199        for (TimeSlice slice : slices) 
    253200        { 
     
    261208    public String openTag(String s) 
    262209    { 
    263         return "<" + s + ">\n"; 
     210        return "<" + s + ">"; 
    264211    } 
    265212 
     
    291238            for (ScriptIncident inc : incidents) 
    292239            { 
    293                  
     240 
    294241                if (inc != null && inc.slices.get(i) != null) 
    295242                { 
Note: See TracChangeset for help on using the changeset viewer.