Changeset 123 in tmcsimulator for trunk/src/tmcsim/cadsimulator/Coordinator.java
- Timestamp:
- 10/15/2017 03:59:42 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/tmcsim/cadsimulator/Coordinator.java (modified) (40 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/cadsimulator/Coordinator.java
r54 r123 27 27 import tmcsim.cadsimulator.managers.MediaManager; 28 28 import tmcsim.cadsimulator.managers.ParamicsSimulationManager; 29 import tmcsim.cadsimulator.managers.SimulationC ontrolManager;30 import tmcsim.cadsimulator.viewer.model.CADSimulator Model;29 import tmcsim.cadsimulator.managers.SimulationClockManager; 30 import tmcsim.cadsimulator.viewer.model.CADSimulatorState; 31 31 import tmcsim.client.cadclientgui.CardfileReader; 32 32 import tmcsim.client.cadclientgui.ScriptHandler; … … 80 80 * @see MediaManager 81 81 * @see ParamicsSimulationManager 82 * @see SimulationC ontrolManager82 * @see SimulationClockManager 83 83 * @author Matthew Cechini 84 84 * @version … … 103 103 * connected Manager, this object is set to null. 104 104 */ 105 private static SimulationManagerInterface managerInt= null;105 private static SimulationManagerInterface simMgr = null; 106 106 private static LinkedList<CADClientInterface> clientList; 107 107 private static CADData cadData; 108 108 private static CardfileData cardfileData; 109 private CADSimulator ModelcadModel;109 private CADSimulatorState cadModel; 110 110 111 111 /** … … 115 115 * @throws RemoteException 116 116 */ 117 public Coordinator(CADSimulator Modelmodel) throws RemoteException117 public Coordinator(CADSimulatorState model) throws RemoteException 118 118 { 119 119 super(); … … 153 153 public void registerForCallback(SimulationManagerInterface simManInt) throws RemoteException 154 154 { 155 managerInt= simManInt;155 simMgr = simManInt; 156 156 cadModel.setSimManagerStatus(true); 157 157 } … … 159 159 public void unregisterForCallback(SimulationManagerInterface simManInt) throws RemoteException 160 160 { 161 managerInt= null;161 simMgr = null; 162 162 cadModel.setSimManagerStatus(false); 163 163 } … … 166 166 { 167 167 168 if (!CADS imulator.theIncidentMgr.areIncidentsLoaded())168 if (!CADServer.theIncidentMgr.areIncidentsLoaded()) 169 169 { 170 170 throw new ScriptException(ScriptException.NO_SCRIPT_LOADED); 171 171 } 172 else if (CADS imulator.theParamicsSimMgr.isConnected())172 else if (CADServer.theParamicsSimMgr.isConnected()) 173 173 { 174 174 Runnable startRun = new Runnable() … … 184 184 * Is some process happening on the ATMS side that we need to wait for? 185 185 */ 186 long currentATMSTime = CADS imulator.theATMSMgr.getCurrentTime();186 long currentATMSTime = CADServer.theATMSMgr.getCurrentTime(); 187 187 /* Seems like it waits 0-30 seconds, depending on what the time is on 188 188 * the ATMS server. Does something happen every 30 seconds over there? … … 205 205 } finally 206 206 { 207 CADS imulator.theSimulationCntrlMgr.startSimulation();208 CADS imulator.theParamicsSimMgr.startSimulation();209 CADS imulator.theSoundPlayer.setAudioEnabled(true);207 CADServer.theSimulationCntrlMgr.startSimulation(); 208 CADServer.theParamicsSimMgr.startSimulation(); 209 CADServer.theSoundPlayer.setAudioEnabled(true); 210 210 } 211 211 } … … 217 217 else 218 218 { 219 CADS imulator.theSimulationCntrlMgr.startSimulation();220 CADS imulator.theSoundPlayer.setAudioEnabled(true);219 CADServer.theSimulationCntrlMgr.startSimulation(); 220 CADServer.theSoundPlayer.setAudioEnabled(true); 221 221 } 222 222 } … … 224 224 public void pauseSimulation() throws RemoteException 225 225 { 226 CADS imulator.theSimulationCntrlMgr.pauseSimulation();227 CADS imulator.theSoundPlayer.setAudioEnabled(false);226 CADServer.theSimulationCntrlMgr.pauseSimulation(); 227 CADServer.theSoundPlayer.setAudioEnabled(false); 228 228 } 229 229 … … 231 231 { 232 232 233 CADS imulator.theIncidentMgr.resetIncidents();233 CADServer.theIncidentMgr.resetIncidents(); 234 234 cadData.resetSimulation(); 235 235 236 CADS imulator.theSoundPlayer.setAudioEnabled(false);237 CADS imulator.theSoundPlayer.deQueueAll();236 CADServer.theSoundPlayer.setAudioEnabled(false); 237 CADServer.theSoundPlayer.deQueueAll(); 238 238 239 239 cadModel.setTime(0); … … 243 243 CMSDiversionDB.getInstance().resetDiversions(); 244 244 245 CADS imulator.theSimulationCntrlMgr.resetSimulation();246 CADS imulator.theParamicsSimMgr.resetSimulation();245 CADServer.theSimulationCntrlMgr.resetSimulation(); 246 CADServer.theParamicsSimMgr.resetSimulation(); 247 247 248 248 notifyObservers(new ObserverMessage(ObserverMessage.messageType.RESET_SIMULATION, null)); … … 253 253 { 254 254 255 boolean audioWasEnabled = CADS imulator.theSoundPlayer.getAudioEnabled();256 257 CADS imulator.theSoundPlayer.setAudioEnabled(false);255 boolean audioWasEnabled = CADServer.theSoundPlayer.getAudioEnabled(); 256 257 CADServer.theSoundPlayer.setAudioEnabled(false); 258 258 259 259 long tempTime = 0; … … 262 262 tempTime++; 263 263 264 CADS imulator.theIncidentMgr.tick(tempTime);265 } 266 CADS imulator.theSoundPlayer.setAudioEnabled(audioWasEnabled);267 268 269 CADS imulator.theSimulationCntrlMgr.gotoSimulationTime(newSimTime);264 CADServer.theIncidentMgr.tick(tempTime); 265 } 266 CADServer.theSoundPlayer.setAudioEnabled(audioWasEnabled); 267 268 269 CADServer.theSimulationCntrlMgr.gotoSimulationTime(newSimTime); 270 270 271 271 Runnable gotoRun = new Runnable() … … 275 275 cadModel.setTime(newSimTime); 276 276 277 if ( managerInt!= null)277 if (simMgr != null) 278 278 { 279 279 try 280 280 { 281 managerInt.tick(newSimTime);281 simMgr.tick(newSimTime); 282 282 } catch (RemoteException re) 283 283 { 284 284 //Simulation Manager has disappeared 285 managerInt= null;285 simMgr = null; 286 286 cadModel.setSimManagerStatus(false); 287 287 … … 312 312 cadModel.setScriptStatus(status); 313 313 314 if ( managerInt!= null)314 if (simMgr != null) 315 315 { 316 316 try 317 317 { 318 managerInt.setScriptStatus(status);318 simMgr.setScriptStatus(status); 319 319 } catch (RemoteException re) 320 320 { 321 321 //Simulation Manager has disappeared 322 managerInt= null;322 simMgr = null; 323 323 cadModel.setSimManagerStatus(false); 324 324 … … 362 362 } 363 363 364 if ( managerInt!= null)364 if (simMgr != null) 365 365 { 366 366 try 367 367 { 368 managerInt.setParamicsStatus(status);368 simMgr.setParamicsStatus(status); 369 369 } catch (RemoteException re) 370 370 { 371 371 //Simulation Manager has disappeared 372 managerInt= null;372 simMgr = null; 373 373 cadModel.setSimManagerStatus(false); 374 374 … … 387 387 public void connectToParamics() throws RemoteException 388 388 { 389 CADS imulator.theParamicsSimMgr.connectToParamics();389 CADServer.theParamicsSimMgr.connectToParamics(); 390 390 } 391 391 392 392 public void disconnectFromParamics() throws RemoteException 393 393 { 394 CADS imulator.theParamicsSimMgr.disconnectFromParamics();394 CADServer.theParamicsSimMgr.disconnectFromParamics(); 395 395 } 396 396 397 397 public void loadParamicsNetwork(int networkID) throws RemoteException, SimulationException 398 398 { 399 CADS imulator.theParamicsSimMgr.loadParamicsNetwork(networkID);399 CADServer.theParamicsSimMgr.loadParamicsNetwork(networkID); 400 400 } 401 401 402 402 public PARAMICS_STATUS getParamicsStatus() throws RemoteException 403 403 { 404 return CADS imulator.theParamicsSimMgr.getParamicsStatus();404 return CADServer.theParamicsSimMgr.getParamicsStatus(); 405 405 } 406 406 407 407 public int getParamicsNetworkLoaded() throws RemoteException 408 408 { 409 return CADS imulator.theParamicsSimMgr.getParamicsNetworkLoaded();409 return CADServer.theParamicsSimMgr.getParamicsNetworkLoaded(); 410 410 } 411 411 412 412 public long getCurrentSimulationTime() throws RemoteException 413 413 { 414 return CADS imulator.theSimulationCntrlMgr.getCurrentSimTime();414 return CADServer.theSimulationCntrlMgr.getCurrentSimTime(); 415 415 } 416 416 … … 418 418 { 419 419 420 if (!CADS imulator.theSimulationCntrlMgr.simulationStarted())420 if (!CADServer.theSimulationCntrlMgr.simulationStarted()) 421 421 { 422 422 throw new ScriptException(ScriptException.SIM_NOT_STARTED); 423 423 } 424 else if (!CADS imulator.theIncidentMgr.areIncidentsLoaded())424 else if (!CADServer.theIncidentMgr.areIncidentsLoaded()) 425 425 { 426 426 throw new ScriptException(ScriptException.NO_SCRIPT_LOADED); 427 427 } 428 428 429 CADS imulator.theIncidentMgr.triggerIncident(incidentNumber,430 CADS imulator.theSimulationCntrlMgr.getCurrentSimTime());429 CADServer.theIncidentMgr.triggerIncident(incidentNumber, 430 CADServer.theSimulationCntrlMgr.getCurrentSimTime()); 431 431 } 432 432 433 433 public void deleteIncident(Integer incidentNumber) throws RemoteException, ScriptException 434 434 { 435 CADS imulator.theIncidentMgr.deleteIncident(incidentNumber);436 437 if (CADS imulator.theIncidentMgr.getIncidentList().size() == 0)435 CADServer.theIncidentMgr.deleteIncident(incidentNumber); 436 437 if (CADServer.theIncidentMgr.getIncidentList().size() == 0) 438 438 { 439 439 setScriptStatus(SCRIPT_STATUS.NO_SCRIPT); 440 440 } 441 441 442 if ( managerInt!= null)442 if (simMgr != null) 443 443 { 444 444 try 445 445 { 446 managerInt.incidentRemoved(incidentNumber);446 simMgr.incidentRemoved(incidentNumber); 447 447 } catch (RemoteException re) 448 448 { 449 449 //Simulation Manager has disappeared 450 managerInt= null;450 simMgr = null; 451 451 cadModel.setSimManagerStatus(false); 452 452 … … 461 461 { 462 462 463 if (newTime < CADS imulator.theSimulationCntrlMgr.getCurrentSimTime())463 if (newTime < CADServer.theSimulationCntrlMgr.getCurrentSimTime()) 464 464 { 465 465 throw new ScriptException(ScriptException.TIME_PASSED); 466 466 } 467 467 468 CADS imulator.theIncidentMgr.rescheduleIncident(incidentNumber, newTime);468 CADServer.theIncidentMgr.rescheduleIncident(incidentNumber, newTime); 469 469 } 470 470 … … 472 472 { 473 473 474 CADS imulator.theIncidentMgr.addIncident(newIncident);475 476 if ( managerInt!= null)474 CADServer.theIncidentMgr.addIncident(newIncident); 475 476 if (simMgr != null) 477 477 { 478 478 try 479 479 { 480 managerInt.incidentAdded(newIncident);480 simMgr.incidentAdded(newIncident); 481 481 } catch (RemoteException re) 482 482 { 483 483 //Simulation Manager has disappeared 484 managerInt= null;484 simMgr = null; 485 485 cadModel.setSimManagerStatus(false); 486 486 … … 497 497 try 498 498 { 499 CADS imulator.theIncidentMgr.clearIncidents();499 CADServer.theIncidentMgr.clearIncidents(); 500 500 cadData.clearData(); 501 501 … … 507 507 cadData.setUnitsFromXML(sh.getUnits()); 508 508 refreshClients(); 509 CADS imulator.theIncidentMgr.addIncidents(sh.getIncidents());509 CADServer.theIncidentMgr.addIncidents(sh.getIncidents()); 510 510 511 511 resetSimulation(); … … 519 519 public Vector<Incident> getIncidentList() throws RemoteException 520 520 { 521 return CADS imulator.theIncidentMgr.getIncidentList();521 return CADServer.theIncidentMgr.getIncidentList(); 522 522 } 523 523 524 524 public TreeMap<Integer, Vector<IncidentEvent>> getTriggeredEvents() throws RemoteException 525 525 { 526 return CADS imulator.theIncidentMgr.getTriggeredEvents();526 return CADServer.theIncidentMgr.getTriggeredEvents(); 527 527 } 528 528 529 529 public SCRIPT_STATUS getScriptStatus() throws RemoteException 530 530 { 531 if (CADS imulator.theIncidentMgr.areIncidentsLoaded())532 { 533 if (CADS imulator.theSimulationCntrlMgr.simulationStarted())531 if (CADServer.theIncidentMgr.areIncidentsLoaded()) 532 { 533 if (CADServer.theSimulationCntrlMgr.simulationStarted()) 534 534 { 535 535 return SCRIPT_STATUS.SCRIPT_RUNNING; … … 537 537 else 538 538 { 539 for (Incident inc : CADS imulator.theIncidentMgr.getIncidentList())539 for (Incident inc : CADServer.theIncidentMgr.getIncidentList()) 540 540 { 541 541 if (inc.hasOccured() == true) … … 599 599 { 600 600 CMSDiversionDB.getInstance().updateDiversions(theDiversion); 601 CADS imulator.theParamicsSimMgr.updateDiversion(theDiversion);601 CADServer.theParamicsSimMgr.updateDiversion(theDiversion); 602 602 } 603 603 … … 614 614 { 615 615 616 long currentSimTime = CADS imulator.theSimulationCntrlMgr.getCurrentSimTime();616 long currentSimTime = CADServer.theSimulationCntrlMgr.getCurrentSimTime(); 617 617 618 618 IncidentEvent triggeredEvent = new IncidentEvent(currentSimTime); 619 619 triggeredEvent.eventInfo = modelInfo; 620 620 621 triggeredEvent.finalizeEvent(currentSimTime, CADS imulator.getCADTime());622 623 CADS imulator.theIncidentMgr.updateIncident(modelInfo.getLogNumber(), triggeredEvent);621 triggeredEvent.finalizeEvent(currentSimTime, CADServer.getCADTime()); 622 623 CADServer.theIncidentMgr.updateIncident(modelInfo.getLogNumber(), triggeredEvent); 624 624 625 625 updateIncidentInGUI(modelInfo.getLogNumber(), triggeredEvent); … … 633 633 * ParamicsControlManager to send an IncidentUpdate. 634 634 * 635 * @see SimulationC ontrolManager635 * @see SimulationClockManager 636 636 * @see ParamicsControlManager 637 637 * @see IncidentManager … … 639 639 public void tick() 640 640 { 641 if (CADS imulator.theSimulationCntrlMgr.simulationStarted())642 { 643 644 final long currentSimTime = CADS imulator.theSimulationCntrlMgr.getCurrentSimTime();641 if (CADServer.theSimulationCntrlMgr.simulationStarted()) 642 { 643 644 final long currentSimTime = CADServer.theSimulationCntrlMgr.getCurrentSimTime(); 645 645 646 646 Runnable timeRun = new Runnable() … … 653 653 if (currentSimTime % 30 == 0) 654 654 { 655 CADS imulator.theParamicsSimMgr.sendIncidentUpdate(currentSimTime);655 CADServer.theParamicsSimMgr.sendIncidentUpdate(currentSimTime); 656 656 } 657 657 658 if ( managerInt!= null)658 if (simMgr != null) 659 659 { 660 660 try 661 661 { 662 managerInt.tick(currentSimTime);662 simMgr.tick(currentSimTime); 663 663 } catch (RemoteException re) 664 664 { 665 665 //Simulation Manager has disappeared 666 managerInt= null;666 simMgr = null; 667 667 cadModel.setSimManagerStatus(false); 668 668 … … 672 672 } 673 673 674 CADS imulator.theIncidentMgr.tick(currentSimTime);674 CADServer.theIncidentMgr.tick(currentSimTime); 675 675 } 676 676 }; … … 699 699 public void run() 700 700 { 701 if ( managerInt!= null)701 if (simMgr != null) 702 702 { 703 703 try 704 704 { 705 managerInt.incidentStarted(completedEvent.eventInfo.getLogNumber());705 simMgr.incidentStarted(completedEvent.eventInfo.getLogNumber()); 706 706 } catch (RemoteException re) 707 707 { 708 708 //Simulation Manager has disappeared 709 managerInt= null;709 simMgr = null; 710 710 cadModel.setSimManagerStatus(false); 711 711 … … 740 740 for (XMLIncident xmlInc : completedEvent.XMLIncidents) 741 741 { 742 CADS imulator.theParamicsSimMgr.updateIncident(xmlInc);742 CADServer.theParamicsSimMgr.updateIncident(xmlInc); 743 743 } 744 744 … … 753 753 public void run() 754 754 { 755 if ( managerInt!= null)755 if (simMgr != null) 756 756 { 757 757 try 758 758 { 759 managerInt.eventOccured(759 simMgr.eventOccured( 760 760 completedEvent.eventInfo.getLogNumber(), 761 761 completedEvent); … … 763 763 { 764 764 //Simulation Manager has disappeared 765 managerInt= null;765 simMgr = null; 766 766 cadModel.setSimManagerStatus(false); 767 767 … … 782 782 public boolean incidentExists(Integer logNumber) 783 783 { 784 return CADS imulator.theIncidentMgr.incidentExists(logNumber);784 return CADServer.theIncidentMgr.incidentExists(logNumber); 785 785 } 786 786 … … 790 790 public Vector<IncidentBoardModel_obj> getIncidentBoardModelObjects() 791 791 { 792 return CADS imulator.theIncidentMgr.getIncidentBoardModelObjects();792 return CADServer.theIncidentMgr.getIncidentBoardModelObjects(); 793 793 } 794 794 … … 798 798 public Vector<IncidentInquiryModel_obj> getIncidentInquiryModelObjects(Integer logNumber) 799 799 { 800 return CADS imulator.theIncidentMgr.getIncidentInquiryModelObjects(logNumber);800 return CADServer.theIncidentMgr.getIncidentInquiryModelObjects(logNumber); 801 801 } 802 802 … … 806 806 public Vector<IncidentSummaryModel_obj> getIncidentSummaryModelObjects() 807 807 { 808 return CADS imulator.theIncidentMgr.getIncidentSummaryModelObjects();808 return CADServer.theIncidentMgr.getIncidentSummaryModelObjects(); 809 809 } 810 810
Note: See TracChangeset
for help on using the changeset viewer.
