| 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 | |
|---|
| 13 | /** |
|---|
| 14 | * Data model for a Paramics event. Paramics data has a status, an event type, a |
|---|
| 15 | * location ID, and some number of affected lanes. |
|---|
| 16 | * |
|---|
| 17 | * @author Bryan McGuffin |
|---|
| 18 | */ |
|---|
| 19 | public class ParamicsEvent extends ScriptEvent implements I_XML_Writable |
|---|
| 20 | { |
|---|
| 21 | |
|---|
| 22 | public ParamicsEvent() |
|---|
| 23 | { |
|---|
| 24 | super(ScriptEventType.PARAMICS_EVENT); |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | public String status = ""; |
|---|
| 28 | |
|---|
| 29 | public String type = ""; |
|---|
| 30 | |
|---|
| 31 | public ArrayList<Integer> laneNums = new ArrayList<Integer>(); |
|---|
| 32 | |
|---|
| 33 | public String locationID = ""; |
|---|
| 34 | |
|---|
| 35 | @Override |
|---|
| 36 | public String openTag(String s) |
|---|
| 37 | { |
|---|
| 38 | return "<" + s + ">\n"; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | @Override |
|---|
| 42 | public String closeTag(String s) |
|---|
| 43 | { |
|---|
| 44 | return "</" + s + ">\n"; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | @Override |
|---|
| 48 | public String emptyTag(String s) |
|---|
| 49 | { |
|---|
| 50 | return "<" + s + "/>\n"; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | @Override |
|---|
| 54 | public String toXML() |
|---|
| 55 | { |
|---|
| 56 | String output = openTag(ELEMENT.PARAMICS.tag + " LocationID=\"" + locationID + "\""); |
|---|
| 57 | |
|---|
| 58 | output += openTag(ELEMENT.Status.tag); |
|---|
| 59 | output += status; |
|---|
| 60 | output += closeTag(ELEMENT.Status.tag); |
|---|
| 61 | |
|---|
| 62 | output += openTag(ELEMENT.Incident_type.tag); |
|---|
| 63 | output += type; |
|---|
| 64 | output += closeTag(ELEMENT.Incident_type.tag); |
|---|
| 65 | |
|---|
| 66 | for (Integer lane : laneNums) |
|---|
| 67 | { |
|---|
| 68 | output += openTag(ELEMENT.Lane_number.tag); |
|---|
| 69 | output += lane; |
|---|
| 70 | output += closeTag(ELEMENT.Lane_number.tag); |
|---|
| 71 | } |
|---|
| 72 | output += closeTag(ELEMENT.PARAMICS.tag); |
|---|
| 73 | |
|---|
| 74 | return output; |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | } |
|---|