Changeset 111 in tmcsimulator-scriptbuilder


Ignore:
Timestamp:
09/05/2017 05:48:12 PM (9 years ago)
Author:
bmcguffin
Message:

Annotated these files. Fixed a bug that caused newly created incidents to have the wrong offset when new events were added.

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/gui/application.properties

    r103 r111  
    1 #Fri, 01 Sep 2017 13:13:39 -0700 
     1#Tue, 05 Sep 2017 18:53:17 -0700 
    22 
    33Application.revision=0 
  • trunk/src/scriptbuilder/structures/ScriptIncident.java

    r107 r111  
    158158        this.offset = offset; 
    159159        TreeMap<Integer, TimeSlice> newSlices = new TreeMap<Integer, TimeSlice>(); 
    160          
     160 
    161161        int latest = 0; 
    162          
    163         for(Integer k : slices.keySet()) 
     162 
     163        for (Integer k : slices.keySet()) 
    164164        { 
    165165            newSlices.put(k + (offset - old), slices.get(k)); 
    166166            latest = k + (offset - old); 
    167167        } 
    168          
     168 
    169169        latestStart = latest; 
    170170 
     
    173173            ts.shift(offset - old); 
    174174        } 
    175          
     175 
    176176        slices = newSlices; 
    177177        updateLength(); 
     
    188188    public void addNewEvent(I_ScriptEvent ev, int start) 
    189189    { 
     190        //Check to see if there's already a timeslice here 
    190191        TimeSlice t = slices.get(start); 
     192        //If not, make one; then, add the event to it 
    191193        if (t == null) 
    192194        { 
    193             //System.out.println("Generating new slice at time " + start); 
    194195            t = new TimeSlice(start, this); 
    195196            t.addEvent(ev); 
     
    202203        eventCount++; 
    203204 
     205        //If this is the latest start time in the incident, update that number 
    204206        if (start > latestStart) 
    205207        { 
    206208            latestStart = start; 
    207             //System.out.println("Latest Start: " + latestStart); 
    208         } 
    209         if (start < offset) 
     209        } 
     210        //If this event is earlier than all previous events, or if there are  
     211        //no other events, the offset is equal to this event's start time 
     212        if (start < offset || eventCount == 1) 
    210213        { 
    211214            offset = start; 
     
    375378        return this.number + " - " + this.name; 
    376379    } 
    377      
     380 
    378381    /** 
    379382     * Remove the timeslice at the given position. 
    380      *  
     383     * 
    381384     * @param seconds absolute start time of the timeslice to remove. 
    382385     */ 
     
    385388        //remove the timeslice 
    386389        this.slices.remove(seconds); 
    387          
     390 
    388391        //offset is equivalent to start time of earliest slice 
    389         if(seconds == offset) 
     392        if (seconds == offset) 
    390393        { 
    391394            offset = slices.firstKey(); 
  • trunk/src/scriptbuilder/structures/TimeSlice.java

    r107 r111  
    213213        } 
    214214 
    215         System.out.println("Seconds:: " + seconds); 
    216215        String output = XMLWriter.openTag(ELEMENT.SCRIPT_EVENT.tag); 
    217216        SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss"); 
     
    275274        } 
    276275        output += XMLWriter.closeTag(ELEMENT.SCRIPT_EVENT.tag); 
    277         System.out.println(output); 
    278276        return output; 
    279277    } 
     
    297295                || ev instanceof WitnessEvent || ev instanceof CADEvent; 
    298296    } 
    299      
     297 
    300298    public void checkEmpty() 
    301299    { 
  • trunk/test/scriptbuilder/structures/SimulationScriptTest.java

    r80 r111  
    235235        assertEquals(11, result); 
    236236 
    237         ((ScriptEvent) instance.incidents.get(0).slices.get(0).events.get(0)).length = 45; 
     237        ((ScriptEvent) instance.incidents.get(0).slices.get(10).events.get(0)).length = 45; 
    238238        instance.incidents.get(0).updateLength(); 
    239239        assertEquals(10, instance.incidents.get(0).offset); 
Note: See TracChangeset for help on using the changeset viewer.