net.sourceforge.frcsimulator.mistware
Class Simulator
java.lang.Object
java.lang.Thread
net.sourceforge.frcsimulator.mistware.Simulator
- All Implemented Interfaces:
- java.lang.Runnable
public class Simulator
- extends java.lang.Thread
The actual simulator, which runs the robot software. Handles initializing the
given MIDlet, catching various exceptions, and other tasks.
NB: It's mistware because it's even softer than software, but isn't in the cloud.
- Author:
- wolf
Nested Class Summary |
static class |
Simulator.Status
Represents the various states the simulator can be in--initalizing, running,
stopped, erring, etc. |
Nested classes/interfaces inherited from class java.lang.Thread |
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary |
Simulator(java.lang.String midletClass)
|
Method Summary |
static void |
callErrorMethod(java.lang.reflect.Method handler,
SimulatorError se)
|
static void |
callStatusChangeMethod(java.lang.reflect.Method handler,
Simulator.Status newStatus,
Simulator.Status oldStatus)
|
static void |
displayError(SimulatorError e)
Prints a short status method and a stack trace for the given SimulatorError. |
static void |
err(java.lang.Class source,
java.lang.Thread thread,
java.lang.String error)
|
static void |
fixme(java.lang.Class source,
java.lang.Thread thread,
java.lang.String reason)
|
SimulatorError |
getError()
Get the error which caused the simulator to stop, or null if there was no
such error. |
java.util.logging.Logger |
getLogger()
|
Simulator.Status |
getStatus()
|
static void |
msg(java.lang.Class source,
java.lang.Thread thread,
java.lang.String message)
|
java.lang.reflect.Method |
onError(java.lang.reflect.Method handler)
Set a method to call if the simulator throws an error. |
java.lang.reflect.Method |
onStatusChange(java.lang.reflect.Method handler)
Set a method to be called when the status of the simulator changes. |
void |
run()
|
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Simulator
public Simulator(java.lang.String midletClass)
throws java.lang.ClassNotFoundException,
java.lang.ClassCastException
- Parameters:
midletClass
- The name of the MIDlet class which should be run inside the simulator; eg. "edu.wpi.first.wpilibj.SimpleRobot
- Throws:
java.lang.ClassNotFoundException
- if the class name given does not actually exist
java.lang.ClassCastException
- if the class exists, but doesn't extend MIDlet.
run
public void run()
- Specified by:
run
in interface java.lang.Runnable
- Overrides:
run
in class java.lang.Thread
callErrorMethod
public static void callErrorMethod(java.lang.reflect.Method handler,
SimulatorError se)
displayError
public static void displayError(SimulatorError e)
- Prints a short status method and a stack trace for the given SimulatorError.
- Parameters:
e
- The error
onError
public java.lang.reflect.Method onError(java.lang.reflect.Method handler)
- Set a method to call if the simulator throws an error.
This method must be static, and will be called with one parameter--the
error.
- Parameters:
handler
- The method to call when an error occurs.
- Returns:
- The previous method, which can be called with @link{callErrorMethod()} to chain the methods together.
getStatus
public Simulator.Status getStatus()
callStatusChangeMethod
public static void callStatusChangeMethod(java.lang.reflect.Method handler,
Simulator.Status newStatus,
Simulator.Status oldStatus)
onStatusChange
public java.lang.reflect.Method onStatusChange(java.lang.reflect.Method handler)
- Set a method to be called when the status of the simulator changes.
- Parameters:
handler
- The method to call
- Returns:
- The previous method, which can be called with @link{callStatusChangeMethod()} to chain the methods together.
getError
public SimulatorError getError()
- Get the error which caused the simulator to stop, or null if there was no
such error.
- Returns:
- The error which caused the simulator to stop.
getLogger
public java.util.logging.Logger getLogger()
msg
public static void msg(java.lang.Class source,
java.lang.Thread thread,
java.lang.String message)
fixme
public static void fixme(java.lang.Class source,
java.lang.Thread thread,
java.lang.String reason)
err
public static void err(java.lang.Class source,
java.lang.Thread thread,
java.lang.String error)