- Timestamp:
- 03/16/2017 09:53:13 AM (9 years ago)
- Location:
- trunk/src/tmcsim
- Files:
-
- 2 edited
-
application.properties (modified) (1 diff)
-
client/cadclientgui/data/CADData.java (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/application.properties
r64 r65 1 #Thu, 16 Mar 2017 08: 26:10 -07001 #Thu, 16 Mar 2017 08:31:30 -0700 2 2 3 Application.revision=6 33 Application.revision=64 4 4 5 Application.buildnumber=4 45 Application.buildnumber=45 -
trunk/src/tmcsim/client/cadclientgui/data/CADData.java
r3 r65 4 4 import java.awt.event.ActionListener; 5 5 import java.io.Serializable; 6 import java.rmi.RemoteException;7 import java.rmi.server.UnicastRemoteObject;8 6 import java.util.Collections; 9 7 import java.util.Vector; 10 8 import java.util.logging.Level; 9 import java.util.logging.Logger; 11 10 import javax.swing.Timer; 12 11 import javax.swing.table.DefaultTableModel; 13 import javax.swing.table.TableColumn;14 import javax.swing.table.TableColumnModel;15 16 12 import tmcsim.client.cadclientgui.enums.IncidentEnums; 17 13 import tmcsim.client.cadclientgui.enums.TableHeaders; 18 14 import tmcsim.client.cadclientgui.enums.UnitStatusEnums; 19 import tmcsim.interfaces.CADClientInterface;20 15 21 16 /** 22 17 * This class holds the data for all the units and incidents. It is responsible 23 18 * for sending out data to all the screens. 24 * 19 * 25 20 * @author Vincent 26 * 21 * 27 22 */ 28 public class CADData implements Serializable {29 23 public class CADData implements Serializable 24 { 30 25 private final int ONE_SECOND = 1000; 31 32 26 private static Vector<Unit> units; 33 27 private static Vector<Incident> incidents; … … 45 39 private static DefaultTableModel assignedIncidentsTableModel; 46 40 private static DefaultTableModel incidentEditorModel; 47 48 public CADData() { 41 private static Logger logger = Logger.getLogger("tmcsim.client"); 42 43 public CADData() 44 { 49 45 units = new Vector<Unit>(); 50 46 incidents = new Vector<Incident>(); … … 66 62 handleUpdateTimes(); 67 63 } 68 69 public void clearData(){ 64 65 public void clearData() 66 { 70 67 units = new Vector<Unit>(); 71 68 incidents = new Vector<Incident>(); 72 69 } 73 74 public void resetSimulation(){ 75 for(Incident inc : incidents){ 70 71 public void resetSimulation() 72 { 73 for (Incident inc : incidents) 74 { 76 75 inc.resetCADDataSimulation(); 77 76 } 78 for(Unit unit : units){ 77 for (Unit unit : units) 78 { 79 79 unit.resetCADDataSimulation(); 80 80 } 81 81 } 82 82 83 private void initializeAssignedIncidentsSettings() { 83 private void initializeAssignedIncidentsSettings() 84 { 84 85 Collections 85 86 .addAll(assignedIncidentsHeaders, TableHeaders.ASSIGNED_INCIDENTS_HEADERS); 86 assignedIncidentsTableModel = new DefaultTableModel() { 87 public boolean isCellEditable(int row, int column) { 87 assignedIncidentsTableModel = new DefaultTableModel() 88 { 89 public boolean isCellEditable(int row, int column) 90 { 88 91 return false;// This causes all cells to be not editable 89 92 } … … 93 96 } 94 97 95 private void initializeUnitStatusSettings() { 98 private void initializeUnitStatusSettings() 99 { 96 100 Collections.addAll(unitStatusHeaders, TableHeaders.UNIT_STATUS_HEADERS); 97 unitStatusTableModel = new DefaultTableModel() { 98 public boolean isCellEditable(int row, int column) { 101 unitStatusTableModel = new DefaultTableModel() 102 { 103 public boolean isCellEditable(int row, int column) 104 { 99 105 return false;// This causes all cells to be not editable 100 106 } … … 103 109 } 104 110 105 private void initializeIncidentEditorSettings() { 111 private void initializeIncidentEditorSettings() 112 { 106 113 Collections.addAll(incidentEditorHeaders, TableHeaders.INCIDENT_EDITOR_HEADERS); 107 incidentEditorModel = new DefaultTableModel() { 108 public boolean isCellEditable(int row, int column) { 114 incidentEditorModel = new DefaultTableModel() 115 { 116 public boolean isCellEditable(int row, int column) 117 { 109 118 return false;// This causes all cells to be not editable 110 119 } … … 113 122 } 114 123 115 private void initializePendingIncidentsSettings() { 124 private void initializePendingIncidentsSettings() 125 { 116 126 Collections.addAll(pendingIncidentsHeaders, TableHeaders.PENDING_INCIDENTS_HEADERS); 117 pendingIncidentsTableModel = new DefaultTableModel() { 118 public boolean isCellEditable(int row, int column) { 127 pendingIncidentsTableModel = new DefaultTableModel() 128 { 129 public boolean isCellEditable(int row, int column) 130 { 119 131 return false;// This causes all cells to be not editable 120 132 } … … 126 138 /** 127 139 * Obtains the list of units from the XML. 128 * 129 * @param unit 130 * the new list of units.131 */132 public void setUnitsFromXML(Vector<Unit> unit){140 * 141 * @param unit the new list of units. 142 */ 143 public void setUnitsFromXML(Vector<Unit> unit) 144 { 133 145 units = unit; 134 146 } … … 136 148 /** 137 149 * Obtains the list of incidents from the XML. 138 * 139 * @param incident 140 * the new list of incidents.141 */142 public void setIncidentsFromXML(Vector<Incident> incident){150 * 151 * @param incident the new list of incidents. 152 */ 153 public void setIncidentsFromXML(Vector<Incident> incident) 154 { 143 155 incidents = incident; 144 156 } … … 147 159 * Returns the specified unitNum 148 160 */ 149 public Unit getUnit(String unitNum) { 150 for (int i = 0; i < units.size(); i++) { 151 if (units.get(i).getUnitNum().equals(unitNum)) { 161 public Unit getUnit(String unitNum) 162 { 163 for (int i = 0; i < units.size(); i++) 164 { 165 if (units.get(i).getUnitNum().equals(unitNum)) 166 { 152 167 return units.get(i); 153 168 } … … 159 174 * Check if it contains an incident with the specified Id. 160 175 */ 161 public boolean checkForValidId(int incidentId) { 162 for (int i = 0; i < incidents.size(); i++) { 163 if (incidents.get(i).getLogNum() == incidentId) { 176 public boolean checkForValidId(int incidentId) 177 { 178 for (int i = 0; i < incidents.size(); i++) 179 { 180 if (incidents.get(i).getLogNum() == incidentId) 181 { 164 182 return true; 165 183 } … … 170 188 /** 171 189 * Uses an Incident's masterInc to look up its corresponding ID. 172 * 173 * @param masterInc 174 * the Incident's masterInc 190 * 191 * @param masterInc the Incident's masterInc 175 192 * @return the Incident's ID, -1 if invalid masterInc 176 193 */ 177 public int getIncidentId(String masterInc) { 178 for (int i = 0; i < incidents.size(); i++) { 179 if (incidents.get(i).getMasterInc().equals(masterInc)) { 194 public int getIncidentId(String masterInc) 195 { 196 for (int i = 0; i < incidents.size(); i++) 197 { 198 if (incidents.get(i).getMasterInc().equals(masterInc)) 199 { 180 200 return incidents.get(i).getLogNum(); 181 201 } … … 187 207 * Returns the specified incident 188 208 */ 189 public Incident getIncident(int incidentId) { 190 for (int i = 0; i < incidents.size(); i++) { 191 if (incidents.get(i).getLogNum() == incidentId) { 209 public Incident getIncident(int incidentId) 210 { 211 for (int i = 0; i < incidents.size(); i++) 212 { 213 if (incidents.get(i).getLogNum() == incidentId) 214 { 192 215 return incidents.get(i); 193 216 } 194 217 } 195 return null; 218 logger.logp(Level.INFO, "CADData", 219 "getIncident", "id=" + incidentId, "incident not found."); 220 return new Incident(0, "", 0); 196 221 } 197 222 198 223 /** 199 224 * Sends all the objects for UnitStatus 200 * 225 * 201 226 * @return DefaultTableModel for UnitStatus 202 227 */ 203 public DefaultTableModel tableForUnitStatus() { 228 public DefaultTableModel tableForUnitStatus() 229 { 204 230 toUnitTableVector.clear(); 205 for (int i = 0; i < units.size(); i++) { 231 for (int i = 0; i < units.size(); i++) 232 { 206 233 toUnitTableVector.add(units.get(i).toVector()); 207 234 } … … 213 240 /** 214 241 * Sends all the objects for AssignedIncidents 215 * 242 * 216 243 * @return DefaultTableModel for AssignedIncidents 217 244 */ 218 public DefaultTableModel tableForAssignedIncidents() { 245 public DefaultTableModel tableForAssignedIncidents() 246 { 219 247 toAssignedTableVector.clear(); 220 for (int i = 0; i < incidents.size(); i++) { 248 for (int i = 0; i < incidents.size(); i++) 249 { 221 250 if (incidents.get(i).hasOccured() 222 && incidents.get(i).getIncidentStatus() == IncidentEnums.Assigned) { 251 && incidents.get(i).getIncidentStatus() == IncidentEnums.Assigned) 252 { 223 253 toAssignedTableVector.add(incidents.get(i) 224 254 .toVectorForAssignedIncidents()); … … 232 262 /** 233 263 * Sends all the objects for PendingIncidents 234 * 264 * 235 265 * @return DefaultTableModel for PendingIncidents 236 266 */ 237 public DefaultTableModel tableForPendingIncidents() { 267 public DefaultTableModel tableForPendingIncidents() 268 { 238 269 toPendingTableVector.clear(); 239 for (int i = 0; i < incidents.size(); i++) { 270 for (int i = 0; i < incidents.size(); i++) 271 { 240 272 if (incidents.get(i).hasOccured() 241 && incidents.get(i).getIncidentStatus() == IncidentEnums.Pending) { 273 && incidents.get(i).getIncidentStatus() == IncidentEnums.Pending) 274 { 242 275 toPendingTableVector.add(incidents.get(i) 243 276 .toVectorForPendingIncidents()); … … 251 284 /** 252 285 * Sends all the objects for IncidentEditor 253 * 286 * 254 287 * @return DefaultTableModel for IncidentEditor 255 288 */ 256 public DefaultTableModel tableForIncidentEditor() { 289 public DefaultTableModel tableForIncidentEditor() 290 { 257 291 toIncidentEditorVector.clear(); 258 for (int i = 0; i < incidents.size(); i++) { 259 if (incidents.get(i).hasOccured()) { 292 for (int i = 0; i < incidents.size(); i++) 293 { 294 if (incidents.get(i).hasOccured()) 295 { 260 296 toIncidentEditorVector.add(incidents.get(i) 261 297 .toVectorForIncidentEditor()); … … 270 306 * Sets up a timer to subtract one from the unit's timer every second. 271 307 */ 272 public void handleUpdateTimes() { 273 Timer timer = new Timer(ONE_SECOND, new ActionListener() { 274 public void actionPerformed(ActionEvent e) { 275 for (int i = 0; i < units.size(); i++) { 308 public void handleUpdateTimes() 309 { 310 Timer timer = new Timer(ONE_SECOND, new ActionListener() 311 { 312 public void actionPerformed(ActionEvent e) 313 { 314 for (int i = 0; i < units.size(); i++) 315 { 276 316 units.get(i).TimerMinusSecond(); 277 317 } … … 280 320 timer.start(); 281 321 } 282 283 /** 284 * Assigns the specified unit to the specified incident and updates information in both screens 322 323 /** 324 * Assigns the specified unit to the specified incident and updates 325 * information in both screens 326 * 285 327 * @param unitNum the unit being assigned 286 328 * @param incidentNum the incident being assigned to 287 329 * @param primary whether or not the assigned unit is the primary unit 288 330 */ 289 290 public void unitAssignedToIncident(String unitNum, int incidentNum, boolean primary){ 291 if(primary){ 331 public void unitAssignedToIncident(String unitNum, int incidentNum, boolean primary) 332 { 333 if (primary) 334 { 292 335 getIncident(incidentNum).setPrimaryAssignedUnitNum(unitNum); 293 336 getIncident(incidentNum).setIncidentStatus(IncidentEnums.Assigned); 294 }else{ 337 } 338 else 339 { 295 340 getIncident(incidentNum).addAssignedUnitNum(unitNum); 296 341 } 297 342 298 343 getUnit(unitNum).setAssignedIncidentId(incidentNum); 299 344 getUnit(unitNum).setMasterInc(getIncident(incidentNum).getMasterInc()); … … 302 347 getUnit(unitNum).setType(getIncident(incidentNum).getAdditionalInfo().getType()); 303 348 getUnit(unitNum).setDestination(getIncident(incidentNum).getIncidentLocation().getAddress()); 304 getUnit(unitNum).setArea(getIncident(incidentNum).getIncidentLocation().getArea()); 349 getUnit(unitNum).setArea(getIncident(incidentNum).getIncidentLocation().getArea()); 305 350 getUnit(unitNum).setP(getIncident(incidentNum).getP()); 306 351 } 307 308 /** 309 * Updates information in both incident and unit screens for when a unit has arrived at scene 310 * aka that the unit status is "10-97" 352 353 /** 354 * Updates information in both incident and unit screens for when a unit has 355 * arrived at scene aka that the unit status is "10-97" 356 * 311 357 * @param unitNum the unit which arrived at the scene 312 358 */ 313 public void unitArrivedAtIncidentScene(String unitNum, int incidentNum, boolean primary){ 314 if(getUnit(unitNum).getAssignedIncidentId() != incidentNum){ 315 if(primary){ 359 public void unitArrivedAtIncidentScene(String unitNum, int incidentNum, boolean primary) 360 { 361 if (getUnit(unitNum).getAssignedIncidentId() != incidentNum) 362 { 363 if (primary) 364 { 316 365 getIncident(incidentNum).setPrimaryAssignedUnitNum(unitNum); 317 366 getIncident(incidentNum).setIncidentStatus(IncidentEnums.Assigned); 318 }else{ 367 } 368 else 369 { 319 370 getIncident(incidentNum).addAssignedUnitNum(unitNum); 320 371 } … … 323 374 getUnit(unitNum).setType(getIncident(incidentNum).getAdditionalInfo().getType()); 324 375 getUnit(unitNum).setDestination(getIncident(incidentNum).getIncidentLocation().getAddress()); 325 getUnit(unitNum).setArea(getIncident(incidentNum).getIncidentLocation().getArea()); 376 getUnit(unitNum).setArea(getIncident(incidentNum).getIncidentLocation().getArea()); 326 377 getUnit(unitNum).setP(getIncident(incidentNum).getP()); 327 378 } … … 330 381 getUnit(unitNum).setCurrentLocation(getUnit(unitNum).getDestination()); 331 382 } 332 333 /** 334 * Updates information in both incident and unit screens for when a unit has become available again 335 * aka that the unit status is "10-98" 383 384 /** 385 * Updates information in both incident and unit screens for when a unit has 386 * become available again aka that the unit status is "10-98" 387 * 336 388 * @param unitNum the unit which arrived at the scene 337 389 */ 338 public void unitAvailable(String unitNum){ 390 public void unitAvailable(String unitNum) 391 { 339 392 getIncident(getUnit(unitNum).getAssignedIncidentId()).removeAssignedUnitNum(unitNum); 340 393 341 394 getUnit(unitNum).setStatus("10-98"); 342 395 getUnit(unitNum).setUnitStatus(UnitStatusEnums.Assignable); … … 346 399 getUnit(unitNum).setDestination(""); 347 400 getUnit(unitNum).setP(""); 348 401 349 402 } 350 403 }
Note: See TracChangeset
for help on using the changeset viewer.
