Changeset 347 in tmcsimulator for trunk


Ignore:
Timestamp:
03/25/2019 07:35:45 PM (7 years ago)
Author:
jdalbey
Message:

Coordinator.java: Enhance tick() method to write current time to a json file, for use by web clients. Also update build.xml so Sim Mgr jar includes needed time selector library.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/IDE_metadata/NetBeans/TMCSim/build.xml

    r310 r347  
    194194            tmcsim/client/cadclientgui/**, tmcsim/interfaces/**" 
    195195       excludes="**/Test.class"> 
    196         <zipgroupfileset dir="dist/lib" includes="xercesImpl.jar"/> 
     196        <zipgroupfileset dir="dist/lib" includes="xercesImpl.jar,SimTimeSelector_r28.jar"/> 
    197197        <manifest> 
    198198            <attribute name="Main-Class" value="tmcsim.simulationmanager.SimulationManager"/> 
  • trunk/src/tmcsim/application.properties

    r346 r347  
    1 #Sun, 24 Mar 2019 20:49:11 -0700 
     1#Mon, 25 Mar 2019 20:51:26 -0700 
    22 
    3 Application.revision=345 
     3Application.revision=346 
    44 
    5 Application.buildnumber=110 
     5Application.buildnumber=112 
  • trunk/src/tmcsim/cadsimulator/Coordinator.java

    r310 r347  
    22 
    33import java.io.File; 
     4import java.io.FileWriter; 
     5import java.io.PrintWriter; 
    46import java.rmi.RemoteException; 
    57import java.rmi.server.UnicastRemoteObject; 
     
    6870import tmcsim.interfaces.CoordinatorInterface; 
    6971import tmcsim.interfaces.SimulationManagerInterface; 
     72import tmcsim.simulationmanager.SimulationManagerView; 
    7073 
    7174/** 
     
    9093{ 
    9194    /** 
     95     * The name of the file where the simulation clock time is written 
     96     */ 
     97    public static final String kSimClockFilename = "webapps/sim_clock.json"; 
     98    /** 
    9299     * Error logger. 
    93100     */ 
     
    700707 
    701708                    CADServer.theIncidentMgr.tick(currentSimTime); 
    702                 } 
     709                    /* Write the currentSimTime to a file.  
     710                       This will be read asynchronously by web clients, e.g., 
     711                       the electronic instructor notebook, that want to display 
     712                       the current simulation time. 
     713                    */ 
     714                    PrintWriter writer = null; 
     715                    try { 
     716                        writer = new PrintWriter(new FileWriter(kSimClockFilename)); 
     717                        // Format output as json 
     718                        String lineout =  "{\"clock\":\""  
     719                                + SimulationManagerView.longToTime(currentSimTime) + "\"}"; 
     720                        writer.println(lineout); 
     721                        writer.close(); 
     722                        } catch (Exception ex)  
     723                        { 
     724                        coorLogger.logp(Level.SEVERE, "Coordinator", "tick:run", 
     725                                "Failed to write current sim time to file.", ex); 
     726                        }  
     727                        } 
    703728            }; 
    704729 
Note: See TracChangeset for help on using the changeset viewer.