source: tmcsimulator/trunk/src/tmcsim/common/CADProtocol.java @ 2

Revision 2, 10.0 KB checked in by jdalbey, 10 years ago (diff)

Initial Import of project files

Line 
1package tmcsim.common;
2
3import java.io.Serializable;
4
5
6/**
7 * CADProtocol contains enumerations used to create the communications protocol
8 * between the CAD Client, CAD Simulator, and ParamicsCommunicator.
9 *
10 * @author Matthew Cechini (mcechini@calpoly.edu)
11 * @version $Date: 2006/06/06 20:46:41 $ $Revision: 1.4 $
12 */
13public class CADProtocol {
14
15    /**
16     * Enumeration of commands that are performed by the CAD client and
17     * transmitted to the CAD Simulator.
18     * @author Matthew Cechini
19     */
20    public static enum CAD_CLIENT_CMD implements Serializable {
21        TERMINAL_REGISTER ("TERMINAL_REGISTER"),
22        TERMINAL_FUNCTION ("TERMINAL_FUNCTION"),
23        TERMINAL_CMD_LINE ("TERMINAL_CMD_LINE"),
24        SAVE_COMMAND_LINE ("SAVE_COMMAND_LINE"),
25        UNKNOWN           ("");
26       
27        public String type;
28       
29        private CAD_CLIENT_CMD(String t) {
30            type = t;           
31        }
32         
33        /**
34         * Returns the CAD_CLIENT_CMD enumeration value which has a command
35         * value that matches the parameter value.
36         * @param t Command type
37         * @throws ScriptException if the parameter value is invalid.
38         * @return CAD_CLIENT_CMD for the parameter value.
39         */     
40        public static CAD_CLIENT_CMD fromString(String t) {
41            for(CAD_CLIENT_CMD cmdType : values()) {
42                if(cmdType.type.equals(t))
43                    return cmdType;
44            }
45           
46            return UNKNOWN;
47        }
48    };
49   
50    /**
51     * Enumeration of commands that are performed by the CAD simulator
52     * and transmitted to the CAD Client.
53     * @author Matthew Cechini
54     */   
55    public static enum CAD_SIMULATOR_CMD implements Serializable {
56        UPDATE_SCREEN     ("UPDATE_SCREEN"),
57        UPDATE_STATUS     ("UPDATE_STATUS"),
58        UPDATE_TIME       ("UPDATE_TIME"),
59        UPDATE_MSG_COUNT  ("UPDATE_MSG_COUNT"),
60        UPDATE_MSG_UNREAD ("UPDATE_MSG_UNREAD"),
61        CAD_INFO          ("CAD_INFO"),
62        APP_CLOSE         ("APP_CLOSE"),
63        UNKNOWN           ("");
64       
65        public String type;
66       
67        private CAD_SIMULATOR_CMD(String t) {
68            type = t;           
69        }
70               
71        /**
72         * Returns the CAD_SIMULATOR_CMD enumeration value which has a command
73         * value that matches the parameter value.
74         * @param t Command type
75         * @throws ScriptException if the parameter value is invalid.
76         * @return CAD_SIMULATOR_CMD for the parameter value.
77         */         
78        public static CAD_SIMULATOR_CMD fromString(String t) {
79            for(CAD_SIMULATOR_CMD cmdType : values()) {
80                if(cmdType.type.equals(t))
81                    return cmdType;
82            }
83           
84            return UNKNOWN;
85        }
86    };   
87       
88    /**
89     * Enumeration of commands that are parsed from the CAD command line.
90     * @author Matthew Cechini
91     */       
92    public static enum CAD_COMMANDS implements Serializable {
93       
94        BLANK_SCREEN     ("",   "BLANK_SCREEN"),
95        INCIDENT_BOARD   ("IB", "INCIDENT_BOARD"),
96        INCIDENT_UPDATE  ("UI", "INCIDENT_UPDATE"),
97        INCIDENT_INQUIRY ("II", "INCIDENT_INQUIRY"),
98        INCIDENT_SUMMARY ("SA", "INCIDENT_SUMMARY"),
99        ROUTED_MESSAGE   ("TO", "ROUTED_MESSAGE"),
100        ENTER_INCIDENT   ("EI", "ENTER_INCIDENT"),
101        TERMINAL_OFF     ("OF", "TERMINAL_OFF"),
102        APP_CLOSE        ("KILL", "APP_CLOSE"),
103        UNKNOWN          ("", "");
104       
105        /** Mnemonic used on command line. */
106        public String mnemonic = "";
107        /** Full text name of command used for XML document creation. */
108        public String fullName = "";
109       
110        private CAD_COMMANDS(String new_mnemonic, String new_name) {
111            mnemonic = new_mnemonic;
112            fullName = new_name;
113        }
114       
115        /**
116         * Returns the CAD_COMMANDS enumeration value which has a full name
117         * value that matches the parameter value.
118         * @param fName Full name
119         * @throws ScriptException if the parameter value is invalid.
120         * @return CAD_COMMANDS for the parameter value.
121         */         
122        public static CAD_COMMANDS fromFullName(String fName) {
123            for(CAD_COMMANDS cmd : values()) {
124                if(cmd.fullName.equals(fName))
125                    return cmd;
126            }
127           
128            return UNKNOWN;
129        }
130    }
131   
132    /**
133     * Enumeration of field codes that are parsed from the CAD command line.
134     * @author Matthew Cechini
135     */     
136    public static enum CAD_FIELD_CODES implements Serializable {
137       
138        WITNESS_ADDRESS  ("A/", "WITNESS_ADDRESS"),
139        BEAT             ("B/", "BEAT"),
140        CALLBOX          ("C/", "CALLBOX"),
141        DETAILS          ("D/", "DETAILS"),
142        HANDLING_UNIT    ("H/", "HANDLING_UNIT"),
143        INCIDENT_NUMBER  ("I/", "INCIDENT_NUMBER"),
144        LOCATION         ("L/", "LOCATION"),
145        PRIORITY         ("P/", "PRIORITY"),
146        WITNESS_PHONE    ("N/", "WITNESS_PHONE"),
147        TYPE             ("T/", "TYPE"),
148        TOW              ("V/", "TOW"),
149        WITNESS          ("W/", "WITNESS"),
150        MESSAGE          ("M/", "MESSAGE"),
151        ROUTE            ("R/", "ROUTE"),
152        UNKNOWN          ("", "");
153       
154
155        /** Mnemonic used on command line. */
156        public String mnemonic = "";
157        /** Full text name of command used for XML document creation. */
158        public String fullName = "";
159       
160        private CAD_FIELD_CODES(String new_mnemonic, String new_name) {
161            mnemonic = new_mnemonic;
162            fullName = new_name;
163        }
164       
165        /**
166         * Returns the CAD_FIELD_CODES enumeration value which has a full name
167         * value that matches the parameter value.
168         * @param fName Full name
169         * @throws ScriptException if the parameter value is invalid.
170         * @return CAD_FIELD_CODES for the parameter value.
171         */ 
172        public static CAD_FIELD_CODES fromFullName(String fName) {
173            for(CAD_FIELD_CODES cmd : values()) {
174                if(cmd.fullName.equals(fName))
175                    return cmd;
176            }
177           
178            return UNKNOWN;
179        }
180    }   
181           
182    /**
183     * Enumeration of XML tag and attribute names that are used for XML
184     * document creation.
185     * @author Matthew Cechini
186     */     
187    public static enum DATA_TAGS implements Serializable {
188       
189        POSITION_NUM      ("POSITION_NUM"),
190        USER_ID           ("USER_ID"),
191        LOG_NUM           ("LOG_NUM"),
192        //ORIGINAL_CAD_LINE = "ORIGINAL_CAD_LINE"),
193        SENSITIVE         ("SENSITIVE"),
194        FULL_LOCATION     ("FULL_LOCATION"),
195        TRUNC_LOCATION    ("TRUNC_LOCATION"),               
196        ORIGIN            ("ORIGIN"),
197        DESTINATION       ("DESTINATION"),
198        MESSAGE           ("MESSAGE"),     
199        WITNESS_NAME      ("WITNESS_NAME"),
200        WITNESS_PHONE     ("WITNESS_PHONE"),
201        WITNESS_ADDR      ("WITNESS_ADDR"),
202        UNKNOWN           ("");
203       
204        public String tag;
205       
206        private DATA_TAGS(String t) {
207            tag = t;
208        }
209       
210        /**
211         * Returns the DATA_TAGS enumeration value which has a name
212         * value that matches the parameter value.
213         * @param t Tag name
214         * @throws ScriptException if the parameter value is invalid.
215         * @return DATA_TAGS for the parameter value.
216         */         
217        public static DATA_TAGS fromString(String t) {
218            for(DATA_TAGS data : values()) {
219                if(data.tag.equals(t))
220                    return data;
221            }
222           
223            return UNKNOWN;
224        }       
225    }
226   
227    /**
228     * Enumeration of XML tag names that are used for document creation.
229     * @author Matthew Cechini
230     */     
231    public static enum PARAMICS_COMM_TAGS implements Serializable {
232       
233        ID          ("ID"),
234        ACTION      ("ACTION"),
235        TARGET_FILE ("TARGET_FILE"),
236        INTERVAL    ("INTERVAL"),
237        MESSAGE     ("MESSAGE"),
238        WRITER      ("WRITER"),
239        READER      ("READER"),
240        RESET       ("RESET"),
241        UNKNOWN     ("");
242       
243        public String tag;
244       
245        private PARAMICS_COMM_TAGS(String t) {
246            tag = t;
247        }
248       
249        /**
250         * Returns the PARAMICS_COMM_TAGS enumeration value which has a name
251         * value that matches the parameter value.
252         * @param t Tag name.
253         * @throws ScriptException if the parameter value is invalid.
254         * @return PARAMICS_COMM_TAGS for the parameter value.
255         */         
256        public static PARAMICS_COMM_TAGS fromString(String t) {
257            for(PARAMICS_COMM_TAGS comm : values()) {
258                if(comm.tag.equals(t))
259                    return comm;
260            }
261           
262            return UNKNOWN;
263        }
264    }
265   
266    /**
267     * Enumeration of XML tag name that are used for XML document creation
268     * to perform specific actions in the ParamicsCommunicator.
269     * @author Matthew Cechini
270     */     
271    public static enum PARAMICS_ACTIONS implements Serializable {
272       
273        REGISTER   ("REGISTER"),
274        UNREGISTER ("UNREGISTER"),
275        READ_FILE  ("READ_FILE"),
276        WRITE_FILE ("WRITE_FILE"),
277        UNKNOWN    ("");
278       
279        public String action;
280       
281        private PARAMICS_ACTIONS(String a){
282            action = a;
283        }
284       
285        /**
286         * Returns the PARAMICS_ACTIONS enumeration value which has an action
287         * value that matches the parameter value.
288         * @param a Paramics action.
289         * @throws ScriptException if the parameter value is invalid.
290         * @return PARAMICS_ACTIONS for the parameter value.
291         */ 
292        public static PARAMICS_ACTIONS fromString(String a) {
293            for(PARAMICS_ACTIONS act : values()) {
294                if(act.action.equals(a))
295                    return act;
296            }
297           
298            return UNKNOWN;
299        }       
300    }
301   
302}
303
Note: See TracBrowser for help on using the repository browser.