| 1 | package tmcsim.common; |
|---|
| 2 | |
|---|
| 3 | import java.io.Serializable; |
|---|
| 4 | import java.util.Vector; |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | /** |
|---|
| 8 | * CADEnums contains enumerations used to encapsulate specific lists of data. |
|---|
| 9 | * |
|---|
| 10 | * @author Matthew Cechini |
|---|
| 11 | * @version |
|---|
| 12 | */ |
|---|
| 13 | public class CADEnums { |
|---|
| 14 | |
|---|
| 15 | /** |
|---|
| 16 | * Enumeration representing the possible page numbers in the |
|---|
| 17 | * CAD screen. The next() method will cycle through the pages in the following |
|---|
| 18 | * order: ONE - TWO - THREE - FOUR - (repeat). Each enumeration has an integer |
|---|
| 19 | * value equal to that name of the object. |
|---|
| 20 | * @author Matthew Cechini |
|---|
| 21 | */ |
|---|
| 22 | public static enum CADScreenNum |
|---|
| 23 | { |
|---|
| 24 | ONE(1), |
|---|
| 25 | TWO(2), |
|---|
| 26 | THREE(3), |
|---|
| 27 | FOUR(4); |
|---|
| 28 | |
|---|
| 29 | /** Numerical value of the CADScreen number. */ |
|---|
| 30 | public int intNum; |
|---|
| 31 | |
|---|
| 32 | /** |
|---|
| 33 | * Constructor. |
|---|
| 34 | * @param i Screen number value. |
|---|
| 35 | */ |
|---|
| 36 | CADScreenNum(int i) { |
|---|
| 37 | intNum = i; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | /** |
|---|
| 41 | * Returns the CADScreenNum enumeration value which follows the current value. |
|---|
| 42 | * @return Next CADScreen number. |
|---|
| 43 | */ |
|---|
| 44 | public CADScreenNum next() { |
|---|
| 45 | switch(this) { |
|---|
| 46 | case ONE: |
|---|
| 47 | return TWO; |
|---|
| 48 | case TWO: |
|---|
| 49 | return THREE; |
|---|
| 50 | case THREE: |
|---|
| 51 | return FOUR; |
|---|
| 52 | case FOUR: |
|---|
| 53 | default: |
|---|
| 54 | return ONE; |
|---|
| 55 | |
|---|
| 56 | } |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | /** |
|---|
| 60 | * Returns the CADScreenNum enumeration value which has a integer |
|---|
| 61 | * value that matches the parameter value. |
|---|
| 62 | * @param val Page number. |
|---|
| 63 | * @throws ScriptException if the parameter value is invalid. |
|---|
| 64 | * @return CADScreen for page number. |
|---|
| 65 | */ |
|---|
| 66 | public static CADScreenNum fromValue(int val) { |
|---|
| 67 | |
|---|
| 68 | for(CADScreenNum screen : values()) { |
|---|
| 69 | if(screen.intNum == val) |
|---|
| 70 | return screen; |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | return ONE; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | /** |
|---|
| 77 | * Return an ordered list of CADScreenNum objects. The list is ordered from |
|---|
| 78 | * ONE through FOUR. |
|---|
| 79 | * |
|---|
| 80 | * @return Ordered list of CADScreenNum objects. |
|---|
| 81 | */ |
|---|
| 82 | public static Vector<CADScreenNum> orderedList() { |
|---|
| 83 | Vector<CADScreenNum> orderedList = new Vector<CADScreenNum>(); |
|---|
| 84 | |
|---|
| 85 | orderedList.add(ONE); |
|---|
| 86 | orderedList.add(TWO); |
|---|
| 87 | orderedList.add(THREE); |
|---|
| 88 | orderedList.add(FOUR); |
|---|
| 89 | |
|---|
| 90 | return orderedList; |
|---|
| 91 | } |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | /** |
|---|
| 95 | * Enumeration representing the possible CAD Screens that are viewable |
|---|
| 96 | * in the CAD. |
|---|
| 97 | * @author Matthew Cechini |
|---|
| 98 | */ |
|---|
| 99 | public static enum CADScreenType { |
|---|
| 100 | BLANKSCREEN, |
|---|
| 101 | II_INCIDENT_INQUIRY, |
|---|
| 102 | ON_LOGIN_SCREEN, |
|---|
| 103 | SA_INCIDENT_SUMMARY, |
|---|
| 104 | IB_INCIDENT_BOARD, |
|---|
| 105 | TO_ROUTED_MESSAGE |
|---|
| 106 | }; |
|---|
| 107 | |
|---|
| 108 | /** |
|---|
| 109 | * Enumeration containing the key code values for the keyboard keys that |
|---|
| 110 | * are mapped to CAD functions. |
|---|
| 111 | * @author Matthew Cechini |
|---|
| 112 | */ |
|---|
| 113 | public static enum CAD_KEYS implements Serializable { |
|---|
| 114 | COMMAND_LINE_TX (112), |
|---|
| 115 | PGUP (36), |
|---|
| 116 | LEFT_ARROW (37), |
|---|
| 117 | UP_ARROW (38), |
|---|
| 118 | RIGHT_ARROW (39), |
|---|
| 119 | DOWN_ARROW (40), |
|---|
| 120 | PGDN (35), |
|---|
| 121 | REFRESH (34), |
|---|
| 122 | CYCLE (33), |
|---|
| 123 | BACKSPACE (8), |
|---|
| 124 | PREV_QUEUE (121), |
|---|
| 125 | DELETE_QUEUE (120), |
|---|
| 126 | NEXT_QUEUE (119), |
|---|
| 127 | SCREEN_CLEAR (123), |
|---|
| 128 | COMMAND_LINE_CLEAR (122), |
|---|
| 129 | SHIFT_KEY (16), |
|---|
| 130 | ENTER (10), |
|---|
| 131 | UNKNOWN (-1); |
|---|
| 132 | |
|---|
| 133 | public int value; |
|---|
| 134 | |
|---|
| 135 | //{CAD, STD} |
|---|
| 136 | public static String keyboard_type = "STD"; |
|---|
| 137 | |
|---|
| 138 | private CAD_KEYS(int v) { |
|---|
| 139 | value = v; |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | /** |
|---|
| 143 | * Returns the CAD_KEYS enumeration value which has a key |
|---|
| 144 | * value that matches the parameter value. |
|---|
| 145 | * @param v Key value. |
|---|
| 146 | * @throws ScriptException if the parameter value is invalid. |
|---|
| 147 | * @return CAD_KEYS for the parameter value. |
|---|
| 148 | */ |
|---|
| 149 | public static CAD_KEYS fromValue(String kbd_type, int v) { |
|---|
| 150 | |
|---|
| 151 | String prevType = null; |
|---|
| 152 | |
|---|
| 153 | try { |
|---|
| 154 | //Preserve previous keyboard type, if not same as parameter. |
|---|
| 155 | if(!kbd_type.equals(keyboard_type)) { |
|---|
| 156 | prevType = keyboard_type; |
|---|
| 157 | |
|---|
| 158 | if(kbd_type.equals("CAD")) { |
|---|
| 159 | setupCADKeyboard(); |
|---|
| 160 | } |
|---|
| 161 | else { |
|---|
| 162 | setupStandardKeyboard(); |
|---|
| 163 | } |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | //Find matching key. |
|---|
| 167 | for(CAD_KEYS key : values()) { |
|---|
| 168 | if(key.value == v) |
|---|
| 169 | return key; |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | return UNKNOWN; |
|---|
| 173 | } |
|---|
| 174 | finally { |
|---|
| 175 | //Restore previous keyboard type, if saved. |
|---|
| 176 | if(prevType != null) { |
|---|
| 177 | if(prevType.equals("CAD")) { |
|---|
| 178 | setupCADKeyboard(); |
|---|
| 179 | } |
|---|
| 180 | else { |
|---|
| 181 | setupStandardKeyboard(); |
|---|
| 182 | } |
|---|
| 183 | } |
|---|
| 184 | } |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | public static void setupCADKeyboard() { |
|---|
| 188 | SCREEN_CLEAR.value = 61451; |
|---|
| 189 | COMMAND_LINE_CLEAR.value = 61450; |
|---|
| 190 | COMMAND_LINE_TX.value = 61447; |
|---|
| 191 | |
|---|
| 192 | keyboard_type = "CAD"; |
|---|
| 193 | } |
|---|
| 194 | |
|---|
| 195 | public static void setupStandardKeyboard() { |
|---|
| 196 | SCREEN_CLEAR.value = 123; |
|---|
| 197 | COMMAND_LINE_CLEAR.value = 122; |
|---|
| 198 | COMMAND_LINE_TX.value = 112; |
|---|
| 199 | |
|---|
| 200 | keyboard_type = "STD"; |
|---|
| 201 | } |
|---|
| 202 | |
|---|
| 203 | }; |
|---|
| 204 | |
|---|
| 205 | /** |
|---|
| 206 | * Enumeration representing the possible directional arrows that may be pressed. |
|---|
| 207 | * @author Matthew Cechini |
|---|
| 208 | */ |
|---|
| 209 | public static enum ARROW { |
|---|
| 210 | LEFT, |
|---|
| 211 | RIGHT, |
|---|
| 212 | UP, |
|---|
| 213 | DOWN }; |
|---|
| 214 | |
|---|
| 215 | /** |
|---|
| 216 | * Enumeration representing possible errors that may occur as a result of CAD |
|---|
| 217 | * command line parsing. Each object has an associated text message for display. |
|---|
| 218 | * @author Matthew Cechini |
|---|
| 219 | */ |
|---|
| 220 | public static enum CAD_ERROR { |
|---|
| 221 | UNAUTH_CMD ("0002: Unauthorized Command"), |
|---|
| 222 | NO_LOG_NUM ("0744: Must provide log # when no log is on display"), |
|---|
| 223 | KYBD_LOCK ("0796: KYBD Successfuly Locked"), |
|---|
| 224 | INVALID_LOG ("0753: Invalid Log Number"); |
|---|
| 225 | |
|---|
| 226 | /** Error message. */ |
|---|
| 227 | public String message; |
|---|
| 228 | |
|---|
| 229 | /** |
|---|
| 230 | * Constructor. |
|---|
| 231 | * @param m Error message. |
|---|
| 232 | */ |
|---|
| 233 | CAD_ERROR(String m) { |
|---|
| 234 | message = m; |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | /** |
|---|
| 240 | * Enumeration representing possible text styles that will be used in CAD screen |
|---|
| 241 | * document creation. |
|---|
| 242 | * @author Matthew Cechini |
|---|
| 243 | */ |
|---|
| 244 | public static enum TEXT_STYLES { |
|---|
| 245 | BLUE ("blue"), |
|---|
| 246 | BLACK ("black"), |
|---|
| 247 | AQUA ("aqua"), |
|---|
| 248 | RED ("red"), |
|---|
| 249 | GRAY ("gray"), |
|---|
| 250 | CYAN ("cyan"), |
|---|
| 251 | YELLOW ("yellow"), |
|---|
| 252 | WHITE ("white"), |
|---|
| 253 | GREEN ("green"), |
|---|
| 254 | ORANGE ("orange"), |
|---|
| 255 | REVERSE_GREEN ("rev_green"), |
|---|
| 256 | REVERSE_CYAN ("rev_cyan"), |
|---|
| 257 | GREEN_HIGHLIGHT ("green_highlight"), |
|---|
| 258 | |
|---|
| 259 | REGULAR ("regular"), |
|---|
| 260 | ITALIC ("italic"), |
|---|
| 261 | BOLD ("bold"), |
|---|
| 262 | |
|---|
| 263 | COURIER ("Courier"); |
|---|
| 264 | |
|---|
| 265 | /** Style string. */ |
|---|
| 266 | public String style; |
|---|
| 267 | |
|---|
| 268 | /** |
|---|
| 269 | * Constructor. |
|---|
| 270 | * @param s Style string. |
|---|
| 271 | */ |
|---|
| 272 | TEXT_STYLES(String s) { |
|---|
| 273 | style = s; |
|---|
| 274 | } |
|---|
| 275 | } |
|---|
| 276 | |
|---|
| 277 | /** |
|---|
| 278 | * Enumeration representing all possible states that the script may be in. |
|---|
| 279 | * @author Matthew Cechini |
|---|
| 280 | */ |
|---|
| 281 | public static enum SCRIPT_STATUS { |
|---|
| 282 | NO_SCRIPT, |
|---|
| 283 | SCRIPT_STOPPED_NOT_STARTED, |
|---|
| 284 | SCRIPT_PAUSED_STARTED, |
|---|
| 285 | SCRIPT_RUNNING, |
|---|
| 286 | ATMS_SYNCHRONIZATION}; |
|---|
| 287 | |
|---|
| 288 | /** |
|---|
| 289 | * Enumeration representing all possible states of the paramics connection. |
|---|
| 290 | * @author Matthew Cechini |
|---|
| 291 | */ |
|---|
| 292 | public static enum PARAMICS_STATUS { |
|---|
| 293 | UNKNOWN, |
|---|
| 294 | CONNECTING, |
|---|
| 295 | CONNECTED, |
|---|
| 296 | DISCONNECTED, |
|---|
| 297 | SENDING_NETWORK_ID, |
|---|
| 298 | LOADING, |
|---|
| 299 | WARMING, |
|---|
| 300 | LOADED, |
|---|
| 301 | DROPPED, |
|---|
| 302 | UNREACHABLE }; |
|---|
| 303 | |
|---|
| 304 | } |
|---|