Changeset 167 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures/ScriptIncident.java


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.

File:
1 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 
Note: See TracChangeset for help on using the changeset viewer.