| 1 | /* |
|---|
| 2 | * To change this license header, choose License Headers in Project Properties. |
|---|
| 3 | * To change this template file, choose Tools | Templates |
|---|
| 4 | * and open the template in the editor. |
|---|
| 5 | */ |
|---|
| 6 | package scriptbuilder.structures.events; |
|---|
| 7 | |
|---|
| 8 | import java.util.ArrayList; |
|---|
| 9 | import scriptbuilder.structures.ELEMENT; |
|---|
| 10 | import scriptbuilder.structures.I_XML_Writable; |
|---|
| 11 | import scriptbuilder.structures.ScriptEvent; |
|---|
| 12 | import scriptbuilder.structures.XMLBuilder; |
|---|
| 13 | |
|---|
| 14 | /** |
|---|
| 15 | * Data model for a Paramics event. Paramics data has a status, an event type, a |
|---|
| 16 | * location ID, and some number of affected lanes. |
|---|
| 17 | * |
|---|
| 18 | * @author Bryan McGuffin |
|---|
| 19 | */ |
|---|
| 20 | public class ParamicsEvent extends ScriptEvent implements I_XML_Writable |
|---|
| 21 | { |
|---|
| 22 | |
|---|
| 23 | /** |
|---|
| 24 | * Constructor. |
|---|
| 25 | */ |
|---|
| 26 | public ParamicsEvent() |
|---|
| 27 | { |
|---|
| 28 | super(ScriptEventType.PARAMICS_EVENT); |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | public String status = ""; |
|---|
| 32 | |
|---|
| 33 | public String type = ""; |
|---|
| 34 | |
|---|
| 35 | public ArrayList<Integer> laneNums = new ArrayList<Integer>(); |
|---|
| 36 | |
|---|
| 37 | public String locationID = ""; |
|---|
| 38 | |
|---|
| 39 | @Override |
|---|
| 40 | public String toXML() |
|---|
| 41 | { |
|---|
| 42 | String output = XMLBuilder.openTag(ELEMENT.PARAMICS.tag + " LocationID=\"" + locationID + "\""); |
|---|
| 43 | |
|---|
| 44 | output += XMLBuilder.simpleTag(status, ELEMENT.Status); |
|---|
| 45 | |
|---|
| 46 | if (!type.equals("")) |
|---|
| 47 | { |
|---|
| 48 | output += XMLBuilder.simpleTag(type, ELEMENT.Incident_type); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | for (Integer lane : laneNums) |
|---|
| 52 | { |
|---|
| 53 | output += XMLBuilder.simpleTag("" + lane, ELEMENT.Lane_number); |
|---|
| 54 | } |
|---|
| 55 | output += XMLBuilder.closeTag(ELEMENT.PARAMICS.tag); |
|---|
| 56 | |
|---|
| 57 | return output; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | } |
|---|