Changeset 167 in tmcsimulator-scriptbuilder for trunk


Ignore:
Timestamp:
12/16/2019 03:55:46 PM (6 years ago)
Author:
sdanthin
Message:

TimeSlice?.java modified remove/getcorrespondingAudioEvent to work with ID system. CHPRadioEvent.java modified to implement setID and ids in the I_AudioEvent.java. ScriptIncident? "adding event" modified to account for ID system. AudioEvent? has ids added. Preliminary tests show working.

Location:
trunk/src/scriptbuilder/structures
Files:
5 edited

Legend:

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

    r164 r167  
    296296        { 
    297297            t = new TimeSlice(start, this); 
    298             //t.addEvent(ev); 
    299298            slices.put(start, t); 
    300299        } 
    301         else 
    302         { 
    303             //t.addEvent(ev); 
     300         
     301        //checks if event to add is an I_AudioEvent and if the I_AudioEvent already has an AudioEvent to connect with it 
     302        if(ev instanceof I_AudioEvent && t.getCorrespondingAudioEvent((I_AudioEvent)ev)==null){ 
     303             
     304            AudioEvent audio = (AudioEvent) ScriptEvent.factoryByType(ScriptEventType.AUDIO_EVENT); 
     305             
     306            //checks to see if there is already a filename in the I_AudioEvent, if so, set the AudioEvent ID. This is because the ID is not stored within the Script itself. 
     307            if(!((I_AudioEvent) ev).getFileName().equals("")) 
     308            { 
     309                ((I_AudioEvent) ev).setID(((I_AudioEvent) ev).getFileName()); 
     310            } 
     311            // checks to see if the I_AudioEvent already has an ID or not, if not, set one based on the audioEventCount.  
     312            if(((I_AudioEvent) ev).getID().equals("")) 
     313            { 
     314                ((I_AudioEvent) ev).setID(number+Integer.toString(audioEventCount)); 
     315                audioEventCount++; 
     316            } 
     317            //sets AudioEvent id to id of I_AudioEvent 
     318            audio.id = ((I_AudioEvent) ev).getID(); 
     319            //sets I_AudioEvent filename to the AudioEvent id 
     320            ((I_AudioEvent) ev).setFileName(audio.id); 
     321            //sets the file path of the AudioEvent based on its internal id 
     322            audio.setAudioFilePathRelative(); 
     323            //adds AudioEvent to the timeslice 
     324            t.addEvent(audio); 
     325             
    304326        } 
    305327        t.addEvent(ev); 
    306         if(ev instanceof I_AudioEvent){ 
    307             //should make a path and a different filename fields for the file itself. Either that or deal with the string separation each time 
    308             //needs a check for when we move I_AudioEvents in the incident, as to not make duplicate events. 
    309             String fileName = number+"/"+number + "" + audioEventCount; 
    310             AudioEvent audio = (AudioEvent) ScriptEvent.factoryByType(ScriptEventType.AUDIO_EVENT); 
    311             ((I_AudioEvent) ev).setFileName(fileName); 
    312             audio.setAudioFilePathRelative(fileName); 
    313              
    314             t.addEvent(audio); 
    315             audioEventCount++; 
    316         } 
    317328        eventCount++; 
    318329 
  • trunk/src/scriptbuilder/structures/TimeSlice.java

    r162 r167  
    320320        } 
    321321    } 
     322    //these two following functions should not be necessary. 
    322323    /** 
    323324     * this method removes an audioevent that corresponds to the input I_AudioEvent. NEEDS VERIFICATION 
    324325     */ 
    325326    public void removeCorrespondingAudioEvent(I_AudioEvent comparisonEvent){ 
    326         String id = comparisonEvent.getFileName().split("/")[1]; 
     327        String id = comparisonEvent.getID(); 
    327328        for(I_ScriptEvent event : events) 
    328329        { 
    329330            if(event instanceof AudioEvent) 
    330331            { 
    331                 System.out.println("removed an audioevent \n" + ((AudioEvent)event).audioPath.split("/")[2].substring(0,((AudioEvent)event).audioPath.split("/")[2].length() - 4)); 
    332                 System.out.println(id); 
    333                 System.out.println(id.equals(((AudioEvent)event).audioPath.split("/")[2].substring(0,((AudioEvent)event).audioPath.split("/")[2].length() - 4))); 
    334  
    335                 if(id.equals(((AudioEvent)event).audioPath.split("/")[2].substring(0,((AudioEvent)event).audioPath.split("/")[2].length() - 4))) 
     332                if(id.equals(((AudioEvent) event).id)) 
    336333                { 
    337334                    System.out.println("the event was deleted"); 
     
    342339        } 
    343340    } 
    344     public AudioEvent getCorrespondingAudioEvent(I_AudioEvent compariosonEvent) 
    345     { 
    346         String id = compariosonEvent.getFileName(); 
     341    public AudioEvent getCorrespondingAudioEvent(I_AudioEvent comparisonEvent) 
     342    { 
     343        String id = comparisonEvent.getID(); 
    347344        AudioEvent retVal = null; 
    348345        for(I_ScriptEvent event: events) 
    349346        { 
    350             if(event instanceof AudioEvent && ((AudioEvent)event).audioPath.split("/")[2].equals(id)) 
     347            if(event instanceof AudioEvent && id.equals(((AudioEvent) event).id)) 
    351348            { 
    352349                retVal = (AudioEvent) event; 
  • trunk/src/scriptbuilder/structures/events/AudioEvent.java

    r161 r167  
    4444 
    4545    /** 
    46      * File path for the audio file. 
     46     * File path for the audio file. Perhaps should only be generated on save? 
    4747     */ 
    4848    public String audioPath = ""; 
     
    6464        audioPath = "audio/" + f + ".mp3"; 
    6565    } 
    66      
     66    /** 
     67     * sets audio path relative to the working directory using the id value. 
     68     */ 
    6769    public void setAudioFilePathRelative() 
    6870    { 
  • trunk/src/scriptbuilder/structures/events/CHPRadioEvent.java

    r161 r167  
    7878     
    7979    @Override 
     80    public void setID(String id) 
     81    { 
     82        this.id = id; 
     83    } 
     84     
     85    @Override 
    8086    public void setFileName(String s) 
    8187    { 
  • trunk/src/scriptbuilder/structures/events/I_AudioEvent.java

    r159 r167  
    1111 */ 
    1212public interface I_AudioEvent { 
    13     /** 
    14      * allows for the AudioEvent type to return if it is an audio event. Could be replaced by just using instanceOf I think 
    15      * @return  
    16      */ 
    1713     
    1814     
     
    2117    String getID(); 
    2218     
     19    void setID(String id); 
     20     
    2321    void setFileName(String s); 
    2422     
Note: See TracChangeset for help on using the changeset viewer.