public class PingThread extends SimEntityBase implements java.lang.Runnable, VCRController
An extremely simple way to animate Simkit programs. a Ping event occurs every deltaT units of simulated time, which correspond roughly to millisPerSimTime milliseconds of real time (your mileage may vary). Any listeners to Ping may do as they wish, such as updating the position of units drawn on a screen.
Modifier and Type | Field and Description |
---|---|
private double |
adjustFactor
Adjusts sleep time to try to match target rate
|
static double |
DEFAULT_ADJUST_FACTOR |
static double |
DEFAULT_DELTA_T |
static double |
DEFAULT_MILLIS_PER_SIM_TIME |
private double |
deltaT
Time between Ping events
|
private double |
millisPerSimtime
Real time per simulated time
|
protected boolean |
pinging
True if currently active
|
private long |
realTimeStep
Actual amount of time taken by a time step
|
protected boolean |
resetOnce
True if Schedule.reset() has been called by this instance.
|
protected long |
startStep
Clock time a step was started.
|
eventList, property
DEFAULT_ENTITY_NAME, DEFAULT_EVENT_NAME, DEFAULT_PRIORITY, EVENT_METHOD_PREFIX, NL
Constructor and Description |
---|
PingThread() |
PingThread(double deltaT,
double millisPerSimTime) |
PingThread(double deltaT,
double millisPerSimtime,
boolean pinging) |
Modifier and Type | Method and Description |
---|---|
void |
doPing()
The main point of the class is the Ping event, which
actually does nothing in and of itself other than
schedule the next Ping event.
|
void |
fastForward()
Go at full speed (no "Pings")
|
double |
getAdjustFactor() |
double |
getDeltaT() |
double |
getDesiredPingTime() |
double |
getMillisPerSimtime() |
boolean |
isPinging() |
boolean |
isResetOnce() |
void |
pause() |
void |
reset()
Reset state: pinging and resetOnce to false
|
void |
resume() |
void |
rewind() |
void |
run()
Thread entry point.
|
void |
setAdjustFactor(double factor) |
void |
setDeltaT(double dt) |
void |
setMillisPerSimtime(double mpst) |
void |
start() |
void |
startPinging()
Start pinging and and wait forever (or until the Thread is
stopped).
|
void |
step() |
void |
stop() |
void |
stopPinging()
Stops Pinging and cancels next Ping event
|
coldReset, dumpDoMethods, dumpDoMethodsStr, dumpNamesAndSignatures, dumpNamesAndSignaturesStr, getFullMethodName, getSignatureString, handleSimEvent, isAssignableFrom, isDebug, processSimEvent, setDebug, stopAtTime, stopOnTime
addPropertyChangeListener, addPropertyChangeListener, attemptSchedule, clearAddedProperty, compareTo, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAddedProperties, getEventList, getEventListID, getName, getPriority, getPropertiesString, getProperty, getProperty, getPropertyChangeListeners, getSerial, interrupt, interrupt, interruptAll, interruptAll, interruptAll, interruptAllWithArgs, interruptAllWithArgs, isClearAddedPropertiesOnReset, isJustDefinedProperties, isPersistant, isReRunnable, isVerbose, parametersMatch, removePropertyChangeListener, removePropertyChangeListener, resetNextSerial, setClearAddedPropertiesOnReset, setEventList, setEventListID, setJustDefinedProperties, setName, setPersistant, setPriority, setProperty, setVerbose, toString, waitDelay, waitDelay, waitDelay, waitDelay
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
public static final double DEFAULT_DELTA_T
public static final double DEFAULT_MILLIS_PER_SIM_TIME
public static final double DEFAULT_ADJUST_FACTOR
private double deltaT
private double millisPerSimtime
private double adjustFactor
private long realTimeStep
protected long startStep
protected boolean pinging
protected boolean resetOnce
public PingThread(double deltaT, double millisPerSimtime, boolean pinging)
public PingThread(double deltaT, double millisPerSimTime)
public PingThread()
public void reset()
reset
in interface ReRunnable
reset
in class BasicSimEntity
public void startPinging()
public void run()
run
in interface java.lang.Runnable
public void step()
step
in interface VCRController
public void stopPinging()
public void doPing()
public void stop()
stop
in interface VCRController
public void resume()
public void rewind()
rewind
in interface VCRController
public void setDeltaT(double dt)
setDeltaT
in interface VCRController
public void setMillisPerSimtime(double mpst)
setMillisPerSimtime
in interface VCRController
public double getDeltaT()
public double getMillisPerSimtime()
public boolean isPinging()
public boolean isResetOnce()
public double getDesiredPingTime()
public void start()
start
in interface VCRController
public void pause()
pause
in interface VCRController
public void fastForward()
fastForward
in interface VCRController
public void setAdjustFactor(double factor)
public double getAdjustFactor()