Changeset 123 in tmcsimulator for trunk/src/tmcsim/cadsimulator/Coordinator.java


Ignore:
Timestamp:
10/15/2017 03:59:42 PM (9 years ago)
Author:
jdalbey
Message:

Multiple renaming of classes to improve clarity. Remove check for Paramics running before starting sim.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/cadsimulator/Coordinator.java

    r54 r123  
    2727import tmcsim.cadsimulator.managers.MediaManager; 
    2828import tmcsim.cadsimulator.managers.ParamicsSimulationManager; 
    29 import tmcsim.cadsimulator.managers.SimulationControlManager; 
    30 import tmcsim.cadsimulator.viewer.model.CADSimulatorModel; 
     29import tmcsim.cadsimulator.managers.SimulationClockManager; 
     30import tmcsim.cadsimulator.viewer.model.CADSimulatorState; 
    3131import tmcsim.client.cadclientgui.CardfileReader; 
    3232import tmcsim.client.cadclientgui.ScriptHandler; 
     
    8080 * @see MediaManager 
    8181 * @see ParamicsSimulationManager 
    82  * @see SimulationControlManager 
     82 * @see SimulationClockManager 
    8383 * @author Matthew Cechini 
    8484 * @version 
     
    103103     * connected Manager, this object is set to null. 
    104104     */ 
    105     private static SimulationManagerInterface managerInt = null; 
     105    private static SimulationManagerInterface simMgr = null; 
    106106    private static LinkedList<CADClientInterface> clientList; 
    107107    private static CADData cadData; 
    108108    private static CardfileData cardfileData; 
    109     private CADSimulatorModel cadModel; 
     109    private CADSimulatorState cadModel; 
    110110 
    111111    /** 
     
    115115     * @throws RemoteException 
    116116     */ 
    117     public Coordinator(CADSimulatorModel model) throws RemoteException 
     117    public Coordinator(CADSimulatorState model) throws RemoteException 
    118118    { 
    119119        super(); 
     
    153153    public void registerForCallback(SimulationManagerInterface simManInt) throws RemoteException 
    154154    { 
    155         managerInt = simManInt; 
     155        simMgr = simManInt; 
    156156        cadModel.setSimManagerStatus(true); 
    157157    } 
     
    159159    public void unregisterForCallback(SimulationManagerInterface simManInt) throws RemoteException 
    160160    { 
    161         managerInt = null; 
     161        simMgr = null; 
    162162        cadModel.setSimManagerStatus(false); 
    163163    } 
     
    166166    { 
    167167 
    168         if (!CADSimulator.theIncidentMgr.areIncidentsLoaded()) 
     168        if (!CADServer.theIncidentMgr.areIncidentsLoaded()) 
    169169        { 
    170170            throw new ScriptException(ScriptException.NO_SCRIPT_LOADED); 
    171171        } 
    172         else if (CADSimulator.theParamicsSimMgr.isConnected()) 
     172        else if (CADServer.theParamicsSimMgr.isConnected()) 
    173173        { 
    174174            Runnable startRun = new Runnable() 
     
    184184                         * Is some process happening on the ATMS side that we need to wait for? 
    185185                         */ 
    186                         long currentATMSTime = CADSimulator.theATMSMgr.getCurrentTime(); 
     186                        long currentATMSTime = CADServer.theATMSMgr.getCurrentTime(); 
    187187                        /* Seems like it waits 0-30 seconds, depending on what the time is on 
    188188                         * the ATMS server.  Does something happen every 30 seconds over there? 
     
    205205                    } finally 
    206206                    { 
    207                         CADSimulator.theSimulationCntrlMgr.startSimulation(); 
    208                         CADSimulator.theParamicsSimMgr.startSimulation(); 
    209                         CADSimulator.theSoundPlayer.setAudioEnabled(true); 
     207                        CADServer.theSimulationCntrlMgr.startSimulation(); 
     208                        CADServer.theParamicsSimMgr.startSimulation(); 
     209                        CADServer.theSoundPlayer.setAudioEnabled(true); 
    210210                    } 
    211211                } 
     
    217217        else 
    218218        { 
    219             CADSimulator.theSimulationCntrlMgr.startSimulation(); 
    220             CADSimulator.theSoundPlayer.setAudioEnabled(true); 
     219            CADServer.theSimulationCntrlMgr.startSimulation(); 
     220            CADServer.theSoundPlayer.setAudioEnabled(true); 
    221221        } 
    222222    } 
     
    224224    public void pauseSimulation() throws RemoteException 
    225225    { 
    226         CADSimulator.theSimulationCntrlMgr.pauseSimulation(); 
    227         CADSimulator.theSoundPlayer.setAudioEnabled(false); 
     226        CADServer.theSimulationCntrlMgr.pauseSimulation(); 
     227        CADServer.theSoundPlayer.setAudioEnabled(false); 
    228228    } 
    229229 
     
    231231    { 
    232232 
    233         CADSimulator.theIncidentMgr.resetIncidents(); 
     233        CADServer.theIncidentMgr.resetIncidents(); 
    234234        cadData.resetSimulation(); 
    235235 
    236         CADSimulator.theSoundPlayer.setAudioEnabled(false); 
    237         CADSimulator.theSoundPlayer.deQueueAll(); 
     236        CADServer.theSoundPlayer.setAudioEnabled(false); 
     237        CADServer.theSoundPlayer.deQueueAll(); 
    238238 
    239239        cadModel.setTime(0); 
     
    243243        CMSDiversionDB.getInstance().resetDiversions(); 
    244244 
    245         CADSimulator.theSimulationCntrlMgr.resetSimulation(); 
    246         CADSimulator.theParamicsSimMgr.resetSimulation(); 
     245        CADServer.theSimulationCntrlMgr.resetSimulation(); 
     246        CADServer.theParamicsSimMgr.resetSimulation(); 
    247247 
    248248        notifyObservers(new ObserverMessage(ObserverMessage.messageType.RESET_SIMULATION, null)); 
     
    253253    { 
    254254 
    255         boolean audioWasEnabled = CADSimulator.theSoundPlayer.getAudioEnabled(); 
    256  
    257         CADSimulator.theSoundPlayer.setAudioEnabled(false); 
     255        boolean audioWasEnabled = CADServer.theSoundPlayer.getAudioEnabled(); 
     256 
     257        CADServer.theSoundPlayer.setAudioEnabled(false); 
    258258 
    259259        long tempTime = 0; 
     
    262262            tempTime++; 
    263263 
    264             CADSimulator.theIncidentMgr.tick(tempTime); 
    265         } 
    266         CADSimulator.theSoundPlayer.setAudioEnabled(audioWasEnabled); 
    267  
    268  
    269         CADSimulator.theSimulationCntrlMgr.gotoSimulationTime(newSimTime); 
     264            CADServer.theIncidentMgr.tick(tempTime); 
     265        } 
     266        CADServer.theSoundPlayer.setAudioEnabled(audioWasEnabled); 
     267 
     268 
     269        CADServer.theSimulationCntrlMgr.gotoSimulationTime(newSimTime); 
    270270 
    271271        Runnable gotoRun = new Runnable() 
     
    275275                cadModel.setTime(newSimTime); 
    276276 
    277                 if (managerInt != null) 
     277                if (simMgr != null) 
    278278                { 
    279279                    try 
    280280                    { 
    281                         managerInt.tick(newSimTime); 
     281                        simMgr.tick(newSimTime); 
    282282                    } catch (RemoteException re) 
    283283                    { 
    284284                        //Simulation Manager has disappeared 
    285                         managerInt = null; 
     285                        simMgr = null; 
    286286                        cadModel.setSimManagerStatus(false); 
    287287 
     
    312312                cadModel.setScriptStatus(status); 
    313313 
    314                 if (managerInt != null) 
     314                if (simMgr != null) 
    315315                { 
    316316                    try 
    317317                    { 
    318                         managerInt.setScriptStatus(status); 
     318                        simMgr.setScriptStatus(status); 
    319319                    } catch (RemoteException re) 
    320320                    { 
    321321                        //Simulation Manager has disappeared 
    322                         managerInt = null; 
     322                        simMgr = null; 
    323323                        cadModel.setSimManagerStatus(false); 
    324324 
     
    362362                } 
    363363 
    364                 if (managerInt != null) 
     364                if (simMgr != null) 
    365365                { 
    366366                    try 
    367367                    { 
    368                         managerInt.setParamicsStatus(status); 
     368                        simMgr.setParamicsStatus(status); 
    369369                    } catch (RemoteException re) 
    370370                    { 
    371371                        //Simulation Manager has disappeared 
    372                         managerInt = null; 
     372                        simMgr = null; 
    373373                        cadModel.setSimManagerStatus(false); 
    374374 
     
    387387    public void connectToParamics() throws RemoteException 
    388388    { 
    389         CADSimulator.theParamicsSimMgr.connectToParamics(); 
     389        CADServer.theParamicsSimMgr.connectToParamics(); 
    390390    } 
    391391 
    392392    public void disconnectFromParamics() throws RemoteException 
    393393    { 
    394         CADSimulator.theParamicsSimMgr.disconnectFromParamics(); 
     394        CADServer.theParamicsSimMgr.disconnectFromParamics(); 
    395395    } 
    396396 
    397397    public void loadParamicsNetwork(int networkID) throws RemoteException, SimulationException 
    398398    { 
    399         CADSimulator.theParamicsSimMgr.loadParamicsNetwork(networkID); 
     399        CADServer.theParamicsSimMgr.loadParamicsNetwork(networkID); 
    400400    } 
    401401 
    402402    public PARAMICS_STATUS getParamicsStatus() throws RemoteException 
    403403    { 
    404         return CADSimulator.theParamicsSimMgr.getParamicsStatus(); 
     404        return CADServer.theParamicsSimMgr.getParamicsStatus(); 
    405405    } 
    406406 
    407407    public int getParamicsNetworkLoaded() throws RemoteException 
    408408    { 
    409         return CADSimulator.theParamicsSimMgr.getParamicsNetworkLoaded(); 
     409        return CADServer.theParamicsSimMgr.getParamicsNetworkLoaded(); 
    410410    } 
    411411 
    412412    public long getCurrentSimulationTime() throws RemoteException 
    413413    { 
    414         return CADSimulator.theSimulationCntrlMgr.getCurrentSimTime(); 
     414        return CADServer.theSimulationCntrlMgr.getCurrentSimTime(); 
    415415    } 
    416416 
     
    418418    { 
    419419 
    420         if (!CADSimulator.theSimulationCntrlMgr.simulationStarted()) 
     420        if (!CADServer.theSimulationCntrlMgr.simulationStarted()) 
    421421        { 
    422422            throw new ScriptException(ScriptException.SIM_NOT_STARTED); 
    423423        } 
    424         else if (!CADSimulator.theIncidentMgr.areIncidentsLoaded()) 
     424        else if (!CADServer.theIncidentMgr.areIncidentsLoaded()) 
    425425        { 
    426426            throw new ScriptException(ScriptException.NO_SCRIPT_LOADED); 
    427427        } 
    428428 
    429         CADSimulator.theIncidentMgr.triggerIncident(incidentNumber, 
    430                 CADSimulator.theSimulationCntrlMgr.getCurrentSimTime()); 
     429        CADServer.theIncidentMgr.triggerIncident(incidentNumber, 
     430                CADServer.theSimulationCntrlMgr.getCurrentSimTime()); 
    431431    } 
    432432 
    433433    public void deleteIncident(Integer incidentNumber) throws RemoteException, ScriptException 
    434434    { 
    435         CADSimulator.theIncidentMgr.deleteIncident(incidentNumber); 
    436  
    437         if (CADSimulator.theIncidentMgr.getIncidentList().size() == 0) 
     435        CADServer.theIncidentMgr.deleteIncident(incidentNumber); 
     436 
     437        if (CADServer.theIncidentMgr.getIncidentList().size() == 0) 
    438438        { 
    439439            setScriptStatus(SCRIPT_STATUS.NO_SCRIPT); 
    440440        } 
    441441 
    442         if (managerInt != null) 
     442        if (simMgr != null) 
    443443        { 
    444444            try 
    445445            { 
    446                 managerInt.incidentRemoved(incidentNumber); 
     446                simMgr.incidentRemoved(incidentNumber); 
    447447            } catch (RemoteException re) 
    448448            { 
    449449                //Simulation Manager has disappeared 
    450                 managerInt = null; 
     450                simMgr = null; 
    451451                cadModel.setSimManagerStatus(false); 
    452452 
     
    461461    { 
    462462 
    463         if (newTime < CADSimulator.theSimulationCntrlMgr.getCurrentSimTime()) 
     463        if (newTime < CADServer.theSimulationCntrlMgr.getCurrentSimTime()) 
    464464        { 
    465465            throw new ScriptException(ScriptException.TIME_PASSED); 
    466466        } 
    467467 
    468         CADSimulator.theIncidentMgr.rescheduleIncident(incidentNumber, newTime); 
     468        CADServer.theIncidentMgr.rescheduleIncident(incidentNumber, newTime); 
    469469    } 
    470470 
     
    472472    { 
    473473 
    474         CADSimulator.theIncidentMgr.addIncident(newIncident); 
    475  
    476         if (managerInt != null) 
     474        CADServer.theIncidentMgr.addIncident(newIncident); 
     475 
     476        if (simMgr != null) 
    477477        { 
    478478            try 
    479479            { 
    480                 managerInt.incidentAdded(newIncident); 
     480                simMgr.incidentAdded(newIncident); 
    481481            } catch (RemoteException re) 
    482482            { 
    483483                //Simulation Manager has disappeared 
    484                 managerInt = null; 
     484                simMgr = null; 
    485485                cadModel.setSimManagerStatus(false); 
    486486 
     
    497497        try 
    498498        { 
    499             CADSimulator.theIncidentMgr.clearIncidents(); 
     499            CADServer.theIncidentMgr.clearIncidents(); 
    500500            cadData.clearData(); 
    501501 
     
    507507            cadData.setUnitsFromXML(sh.getUnits()); 
    508508            refreshClients(); 
    509             CADSimulator.theIncidentMgr.addIncidents(sh.getIncidents()); 
     509            CADServer.theIncidentMgr.addIncidents(sh.getIncidents()); 
    510510 
    511511            resetSimulation(); 
     
    519519    public Vector<Incident> getIncidentList() throws RemoteException 
    520520    { 
    521         return CADSimulator.theIncidentMgr.getIncidentList(); 
     521        return CADServer.theIncidentMgr.getIncidentList(); 
    522522    } 
    523523 
    524524    public TreeMap<Integer, Vector<IncidentEvent>> getTriggeredEvents() throws RemoteException 
    525525    { 
    526         return CADSimulator.theIncidentMgr.getTriggeredEvents(); 
     526        return CADServer.theIncidentMgr.getTriggeredEvents(); 
    527527    } 
    528528 
    529529    public SCRIPT_STATUS getScriptStatus() throws RemoteException 
    530530    { 
    531         if (CADSimulator.theIncidentMgr.areIncidentsLoaded()) 
    532         { 
    533             if (CADSimulator.theSimulationCntrlMgr.simulationStarted()) 
     531        if (CADServer.theIncidentMgr.areIncidentsLoaded()) 
     532        { 
     533            if (CADServer.theSimulationCntrlMgr.simulationStarted()) 
    534534            { 
    535535                return SCRIPT_STATUS.SCRIPT_RUNNING; 
     
    537537            else 
    538538            { 
    539                 for (Incident inc : CADSimulator.theIncidentMgr.getIncidentList()) 
     539                for (Incident inc : CADServer.theIncidentMgr.getIncidentList()) 
    540540                { 
    541541                    if (inc.hasOccured() == true) 
     
    599599    { 
    600600        CMSDiversionDB.getInstance().updateDiversions(theDiversion); 
    601         CADSimulator.theParamicsSimMgr.updateDiversion(theDiversion); 
     601        CADServer.theParamicsSimMgr.updateDiversion(theDiversion); 
    602602    } 
    603603 
     
    614614    { 
    615615 
    616         long currentSimTime = CADSimulator.theSimulationCntrlMgr.getCurrentSimTime(); 
     616        long currentSimTime = CADServer.theSimulationCntrlMgr.getCurrentSimTime(); 
    617617 
    618618        IncidentEvent triggeredEvent = new IncidentEvent(currentSimTime); 
    619619        triggeredEvent.eventInfo = modelInfo; 
    620620 
    621         triggeredEvent.finalizeEvent(currentSimTime, CADSimulator.getCADTime()); 
    622  
    623         CADSimulator.theIncidentMgr.updateIncident(modelInfo.getLogNumber(), triggeredEvent); 
     621        triggeredEvent.finalizeEvent(currentSimTime, CADServer.getCADTime()); 
     622 
     623        CADServer.theIncidentMgr.updateIncident(modelInfo.getLogNumber(), triggeredEvent); 
    624624 
    625625        updateIncidentInGUI(modelInfo.getLogNumber(), triggeredEvent); 
     
    633633     * ParamicsControlManager to send an IncidentUpdate. 
    634634     * 
    635      * @see SimulationControlManager 
     635     * @see SimulationClockManager 
    636636     * @see ParamicsControlManager 
    637637     * @see IncidentManager 
     
    639639    public void tick() 
    640640    { 
    641         if (CADSimulator.theSimulationCntrlMgr.simulationStarted()) 
    642         { 
    643  
    644             final long currentSimTime = CADSimulator.theSimulationCntrlMgr.getCurrentSimTime(); 
     641        if (CADServer.theSimulationCntrlMgr.simulationStarted()) 
     642        { 
     643 
     644            final long currentSimTime = CADServer.theSimulationCntrlMgr.getCurrentSimTime(); 
    645645 
    646646            Runnable timeRun = new Runnable() 
     
    653653                    if (currentSimTime % 30 == 0) 
    654654                    { 
    655                         CADSimulator.theParamicsSimMgr.sendIncidentUpdate(currentSimTime); 
     655                        CADServer.theParamicsSimMgr.sendIncidentUpdate(currentSimTime); 
    656656                    } 
    657657 
    658                     if (managerInt != null) 
     658                    if (simMgr != null) 
    659659                    { 
    660660                        try 
    661661                        { 
    662                             managerInt.tick(currentSimTime); 
     662                            simMgr.tick(currentSimTime); 
    663663                        } catch (RemoteException re) 
    664664                        { 
    665665                            //Simulation Manager has disappeared 
    666                             managerInt = null; 
     666                            simMgr = null; 
    667667                            cadModel.setSimManagerStatus(false); 
    668668 
     
    672672                    } 
    673673 
    674                     CADSimulator.theIncidentMgr.tick(currentSimTime); 
     674                    CADServer.theIncidentMgr.tick(currentSimTime); 
    675675                } 
    676676            }; 
     
    699699            public void run() 
    700700            { 
    701                 if (managerInt != null) 
     701                if (simMgr != null) 
    702702                { 
    703703                    try 
    704704                    { 
    705                         managerInt.incidentStarted(completedEvent.eventInfo.getLogNumber()); 
     705                        simMgr.incidentStarted(completedEvent.eventInfo.getLogNumber()); 
    706706                    } catch (RemoteException re) 
    707707                    { 
    708708                        //Simulation Manager has disappeared 
    709                         managerInt = null; 
     709                        simMgr = null; 
    710710                        cadModel.setSimManagerStatus(false); 
    711711 
     
    740740        for (XMLIncident xmlInc : completedEvent.XMLIncidents) 
    741741        { 
    742             CADSimulator.theParamicsSimMgr.updateIncident(xmlInc); 
     742            CADServer.theParamicsSimMgr.updateIncident(xmlInc); 
    743743        } 
    744744 
     
    753753            public void run() 
    754754            { 
    755                 if (managerInt != null) 
     755                if (simMgr != null) 
    756756                { 
    757757                    try 
    758758                    { 
    759                         managerInt.eventOccured( 
     759                        simMgr.eventOccured( 
    760760                                completedEvent.eventInfo.getLogNumber(), 
    761761                                completedEvent); 
     
    763763                    { 
    764764                        //Simulation Manager has disappeared 
    765                         managerInt = null; 
     765                        simMgr = null; 
    766766                        cadModel.setSimManagerStatus(false); 
    767767 
     
    782782    public boolean incidentExists(Integer logNumber) 
    783783    { 
    784         return CADSimulator.theIncidentMgr.incidentExists(logNumber); 
     784        return CADServer.theIncidentMgr.incidentExists(logNumber); 
    785785    } 
    786786 
     
    790790    public Vector<IncidentBoardModel_obj> getIncidentBoardModelObjects() 
    791791    { 
    792         return CADSimulator.theIncidentMgr.getIncidentBoardModelObjects(); 
     792        return CADServer.theIncidentMgr.getIncidentBoardModelObjects(); 
    793793    } 
    794794 
     
    798798    public Vector<IncidentInquiryModel_obj> getIncidentInquiryModelObjects(Integer logNumber) 
    799799    { 
    800         return CADSimulator.theIncidentMgr.getIncidentInquiryModelObjects(logNumber); 
     800        return CADServer.theIncidentMgr.getIncidentInquiryModelObjects(logNumber); 
    801801    } 
    802802 
     
    806806    public Vector<IncidentSummaryModel_obj> getIncidentSummaryModelObjects() 
    807807    { 
    808         return CADSimulator.theIncidentMgr.getIncidentSummaryModelObjects(); 
     808        return CADServer.theIncidentMgr.getIncidentSummaryModelObjects(); 
    809809    } 
    810810 
Note: See TracChangeset for help on using the changeset viewer.