|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mars_sim.msp.core.time.MasterClock
public class MasterClock
The MasterClock represents the simulated time clock on virtual Mars. Virtual Mars has only one master clock. The master clock delivers a clock pulse the virtual Mars every second or so, which represents a pulse of simulated time. All actions taken with virtual Mars and its units are synchronized with this clock pulse.
Update: The pulse is now tied to the system clock. This means that each time a timePulse is generated, it is the following length: (realworldseconds since last call ) * timeRatio update: with regard to pauses.. they work. the sim will completely pause when setPause(true) is called, and will resume with setPause(false); However ! Do not make any calls to System.currenttimemillis(), instead use uptimer.getuptimemillis(), as this is "shielded" from showing any passed time while the game is paused. Thank you.
| Field Summary | |
|---|---|
static int |
secspday
|
static int |
secsperyear
|
static int |
secsphour
|
static int |
secspmin
|
| Constructor Summary | |
|---|---|
MasterClock()
Constructor |
|
| Method Summary | |
|---|---|
void |
addClockListener(ClockListener newListener)
Adds a clock listener |
void |
destroy()
Prepare object for garbage collection. |
void |
exitProgram()
Sets the exit program flag. |
void |
fireClockPulse(double time)
Send a clock pulse to all clock listeners. |
void |
firePauseChange()
Send a pulse change event to all clock listeners. |
EarthClock |
getEarthClock()
Returns the Earth clock |
MarsClock |
getInitialMarsTime()
Gets the initial Mars time at the start of the simulation. |
MarsClock |
getMarsClock()
Returns the Martian clock |
double |
getPulsesPerSecond()
|
double |
getTimePulse()
Gets the time pulse length in other words, the number of realworld seconds that have elapsed since it was last called |
double |
getTimeRatio()
Gets the real-time/simulation ratio. |
String |
getTimeString(double seconds)
the following is a utility. |
long |
getTotalPulses()
|
UpTimer |
getUpTimer()
Returns uptime timer |
boolean |
isLoadingSimulation()
Checks if in the process of loading a simulation. |
boolean |
isPaused()
Checks if the simulation is paused or not. |
boolean |
isSavingSimulation()
Checks if in the process of saving a simulation. |
void |
loadSimulation(File file)
Sets the load simulation flag and the file to load from. |
void |
removeClockListener(ClockListener oldListener)
Removes a clock listener |
void |
run()
Run clock |
void |
saveSimulation(File file)
Sets the save simulation flag and the file to save to. |
void |
setPaused(boolean isPaused)
Set if the simulation is paused or not. |
void |
setTimeRatio(double ratio)
setTimeRatio is for setting the Masterclock's time ratio directly. |
void |
stop()
Stop the clock |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int secspmin
public static final int secsphour
public static final int secspday
public static final int secsperyear
| Constructor Detail |
|---|
public MasterClock()
Exception - if clock could not be constructed.| Method Detail |
|---|
public MarsClock getMarsClock()
public MarsClock getInitialMarsTime()
public EarthClock getEarthClock()
public UpTimer getUpTimer()
public final void addClockListener(ClockListener newListener)
newListener - the listener to add.public final void removeClockListener(ClockListener oldListener)
oldListener - the listener to remove.public void loadSimulation(File file)
file - the file to load from.public boolean isLoadingSimulation()
public void saveSimulation(File file)
file - save to file or null if default file.public boolean isSavingSimulation()
public void exitProgram()
public double getTimePulse()
Exception - if time pulse length could not be determined.public long getTotalPulses()
public void setTimeRatio(double ratio)
public double getTimeRatio()
public void run()
run in interface Runnablepublic void fireClockPulse(double time)
time - the amount of time (millisols) in the pulse.public void stop()
public void setPaused(boolean isPaused)
isPaused - true if simulation is paused.public boolean isPaused()
public void firePauseChange()
public double getPulsesPerSecond()
public String getTimeString(double seconds)
public void destroy()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||