Changeset 145 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures


Ignore:
Timestamp:
11/04/2019 08:14:32 AM (7 years ago)
Author:
sdanthin
Message:

Move from Git to Svn (LARGE COMMIT)

Location:
trunk/src/scriptbuilder/structures
Files:
1 added
9 edited

Legend:

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

    r143 r145  
    1515        locInfo = new ArrayList<Location_Info>(); 
    1616    } 
     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    } 
    1734 
    1835    public TimeSlice tSlice; 
    1936 
    20     public String Header_Type = "DEFAULT"; 
     37    public String Header_Type = ""; 
    2138 
    2239    public String Header_Beat = ""; 
    2340 
    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 = ""; 
    2744 
    2845    public String Master_Inc_Num = ""; 
     
    134151        } 
    135152 
    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 
    138156            output += XMLWriter.openTag(ELEMENT.HEADER_INFO.tag); 
    139157 
  • trunk/src/scriptbuilder/structures/ELEMENT.java

    r138 r145  
    3535    LOCATION_INFO, 
    3636    NEW_UNIT, 
     37    //todo: change this paramics to traffic modeler 
    3738    PARAMICS,//EVENT 
    3839    RADIO_EVALUATION, 
  • trunk/src/scriptbuilder/structures/MyScriptHandler.java

    r138 r145  
    304304 
    305305        docPosition.push(ELEMENT.byName(qName)); 
    306  
     306         
    307307        try 
    308308        { 
     
    612612     * SAX Handler method. Executes at the close of each XML element. 
    613613     */ 
     614    //todo: interpret this function better so that what is loaded from the XML file is easier to know. 
    614615    @Override 
    615616    public void endElement(String uri, String localName, String qName) 
     
    670671            { 
    671672                cad.Header_Type = pcData.remove(currentElement); 
     673//                //change where the data is loaded in here 
     674//                currInc.insertCadData((int) currentEventTime, cad); 
    672675            } 
    673676            else if (currentElement == ELEMENT.Beat && docPosition.peek() == ELEMENT.HEADER_INFO) 
  • trunk/src/scriptbuilder/structures/ScriptEvent.java

    r107 r145  
    8383    public int length; 
    8484     
    85     private TimeSlice slice; 
     85    public TimeSlice slice; 
    8686 
    8787    /** 
  • trunk/src/scriptbuilder/structures/ScriptIncident.java

    r131 r145  
    4646     */ 
    4747    public String description; 
    48  
     48     
    4949    /** 
    5050     * Length, in seconds, of the incident. 
     
    7272    public int eventCount = 0; 
    7373 
    74     SimulationScript script; 
     74    public SimulationScript script; 
    7575 
    7676    /** 
     
    135135        this.setOffset(offset); 
    136136    } 
     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//    } 
    137164 
    138165    /** 
     
    293320    } 
    294321 
    295     void insertCadData(long currentEventTime, CadData cad) 
     322    public void insertCadData(long currentEventTime, CadData cad) 
    296323    { 
    297324        int time = (int) currentEventTime; 
     
    305332        slice = slices.get(time); 
    306333        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; 
    307343    } 
    308344 
  • trunk/src/scriptbuilder/structures/SimulationScript.java

    r131 r145  
    2121 * 
    2222 * @author Bryan McGuffin <bmcguffi@calpoly.edu> 
     23 * @author Sebastien Danthinne <sdanthin@calpoly.edu> 
    2324 * @version 2017/06/22 
    2425 */ 
     
    6162     * The units which participate in Unit events. 
    6263     */ 
    63     public List<Unit> units; 
     64    public List<Unit> units;  
    6465 
    6566    //Somewhere in the code, something assumes that the list of incidents 
    6667    //contains exactly 10 items. Until I can find and un-break that, this will do. 
     68    //todo: this incident fill count error 
    6769    private final int INCIDENT_FILL_COUNT = 10; 
    6870 
     
    7678     */ 
    7779    private MyScriptHandler sh; 
     80     
     81    public boolean saved; 
    7882 
    7983    //TODO: Pretty much everything in this constructor is dummy data. 
     
    8993        units = new ArrayList<Unit>(); 
    9094        numberOfIncidents = 0; 
     95        saved = true; 
    9196 
    9297        //Backfill with null incidents 
     
    96101        } 
    97102    } 
    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    } 
    99130    /** 
    100131     * Update the script's observers. 
    101      * 
     132     *  
    102133     */ 
    103134    public void update() 
    104135    { 
    105136        // The script has changed, notify observers 
     137        //use to rewrite the save indicator 
     138        //System.out.println("Script changed"); 
    106139        setChanged(); 
    107140        notifyObservers(this); 
    108     } 
     141        saved = false; 
     142         
     143         
     144    } 
     145     
    109146 
    110147    /** 
     
    154191        { 
    155192            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"); 
    156215            ex.printStackTrace(); 
    157216        } 
     
    197256            ex.printStackTrace(); 
    198257        } 
     258        saved = true; 
    199259    } 
    200260 
  • trunk/src/scriptbuilder/structures/TimeSlice.java

    r142 r145  
    5656    } 
    5757 
     58     
     59    public ScriptIncident getIncident(){ 
     60        return thisIncident; 
     61    } 
    5862    /** 
    5963     * Add a new script event to this time slice. Sort events by event type. 
     
    7781    public int getX() 
    7882    { 
     83//        System.out.println("position: " + seconds / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION 
     84//                * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK); 
    7985        return seconds / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION 
    8086                * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK; 
     
    210216    public String toXML() 
    211217    { 
     218        //eventsCopy2 is used to clear out eventsCopy with one element contained 
    212219        ArrayList<I_ScriptEvent> eventsCopy = new ArrayList<I_ScriptEvent>(); 
    213220        ArrayList<I_ScriptEvent> eventsCopy2 = new ArrayList<I_ScriptEvent>(); 
  • trunk/src/scriptbuilder/structures/events/UnitEvent.java

    r76 r145  
    2222    /** 
    2323     * Constructor. 
     24     * //TODO: when created, add a unit to the main units list that is contained within SimulationScript 
    2425     */ 
    2526    public UnitEvent() 
    2627    { 
     28         
    2729        super(ScriptEventType.UNIT_EVENT); 
     30         
    2831    } 
    2932 
  • trunk/src/scriptbuilder/structures/units/Unit.java

    r46 r145  
    102102        Unit_Status = ""; 
    103103    } 
     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    } 
    104111 
    105112    @Override 
Note: See TracChangeset for help on using the changeset viewer.