public class OpModeManagerImpl extends java.lang.Object implements OpModeManager, OpModeManagerNotifier
Modifier and Type | Class and Description |
---|---|
static class |
OpModeManagerImpl.DefaultOpMode
OpModeManagerImpl.DefaultOpMode is the opmode that the system runs when no user opmode is active. |
protected static class |
OpModeManagerImpl.OpModeObjectAndMeta |
protected static class |
OpModeManagerImpl.OpModeState |
protected class |
OpModeManagerImpl.OpModeStuckCodeMonitor
A utility class that detects infinite loops in user code
|
OpModeManagerNotifier.Notifications
Modifier and Type | Field and Description |
---|---|
protected OpMode |
activeOpMode |
protected java.lang.String |
activeOpModeName |
protected boolean |
callToInitNeeded |
protected boolean |
callToStartNeeded |
protected Context |
context |
static OpMode |
DEFAULT_OP_MODE |
static java.lang.String |
DEFAULT_OP_MODE_NAME |
protected EventLoopManager |
eventLoopManager |
protected boolean |
gamepadResetNeeded |
protected HardwareMap |
hardwareMap |
protected |
listeners |
protected static java.util.WeakHashMap<Activity,OpModeManagerImpl> |
mapActivityToOpModeManager |
protected java.util.concurrent.atomic.AtomicReference<com.qualcomm.robotcore.eventloop.opmode.OpModeManagerImpl.OpModeStateTransition> |
nextOpModeState |
protected java.util.Map<java.lang.String,OpModeAndMeta> |
opModeClasses |
protected java.util.Map<java.lang.String,OpModeManagerImpl.OpModeObjectAndMeta> |
opModeObjects |
protected boolean |
opmodesAreRegistered |
protected OpModeManagerImpl.OpModeState |
opModeState |
protected boolean |
opModeSwapNeeded |
protected java.lang.String |
queuedOpModeName |
protected OpModeManagerImpl.OpModeStuckCodeMonitor |
stuckMonitor |
protected boolean |
telemetryClearNeeded |
Constructor and Description |
---|
OpModeManagerImpl(Activity activity,
HardwareMap hardwareMap) |
Modifier and Type | Method and Description |
---|---|
boolean |
areOpModesRegistered() |
protected void |
callActiveOpModeInit() |
protected void |
callActiveOpModeInitLoop() |
protected void |
callActiveOpModeLoop() |
protected void |
callActiveOpModeStart() |
protected void |
callActiveOpModeStop() |
protected void |
detectStuck(int msTimeout,
java.lang.String method,
java.lang.Runnable runnable) |
protected void |
detectStuck(int msTimeout,
java.lang.String method,
java.lang.Runnable runnable,
boolean resetDebuggerCheck) |
OpMode |
getActiveOpMode() |
java.lang.String |
getActiveOpModeName() |
HardwareMap |
getHardwareMap() |
static OpModeManagerImpl |
getOpModeManagerOfActivity(Activity activity) |
java.util.List<OpModeMeta> |
getOpModes() |
void |
init(EventLoopManager eventLoopManager) |
void |
initActiveOpMode(java.lang.String name) |
void |
logOpModes() |
void |
refreshUserTelemetry(TelemetryMessage telemetry,
double sInterval)
Update's the user portion of the driver station screen with the contents of the telemetry object
here provided if a sufficiently long duration has passed since the last update.
|
void |
register(OpModeMeta meta,
java.lang.Class opMode)
Registers a class for display on the driver station and availability for game play.
|
void |
register(OpModeMeta meta,
OpMode opMode)
Register an *instance* of a class for display on the driver station and availability
for game play.
|
void |
register(java.lang.String name,
java.lang.Class opMode)
Registers an OpMode class with the name by which it should be known in the driver station.
|
void |
register(java.lang.String name,
OpMode opMode)
Registers an OpMode instance with the name by which it should be known in the driver station.
|
OpMode |
registerListener(OpModeManagerNotifier.Notifications listener)
Registers an object as explicitly interested in receiving notifications as
to the coming and going of opmodes.
|
void |
registerOpModes(OpModeRegister register) |
void |
requestOpModeStop(OpMode opModeToStopIfActive)
Requests that an OpMode be stopped.
|
protected void |
resetHardwareForOpMode() |
void |
runActiveOpMode(Gamepad[] gamepads) |
protected void |
setActiveOpMode(OpMode opMode,
java.lang.String activeOpModeName) |
void |
setHardwareMap(HardwareMap hardwareMap) |
void |
startActiveOpMode() |
void |
stopActiveOpMode() |
void |
teardown() |
void |
unregisterListener(OpModeManagerNotifier.Notifications listener)
Unregisters a previously registered listener.
|
static void |
updateTelemetryNow(OpMode opMode,
TelemetryMessage telemetry)
For the use of
TelemetryImpl . |
public static final java.lang.String DEFAULT_OP_MODE_NAME
public static final OpMode DEFAULT_OP_MODE
protected Context context
protected java.util.Map<java.lang.String,OpModeAndMeta> opModeClasses
protected java.util.Map<java.lang.String,OpModeManagerImpl.OpModeObjectAndMeta> opModeObjects
protected volatile boolean opmodesAreRegistered
protected java.lang.String activeOpModeName
protected OpMode activeOpMode
protected java.lang.String queuedOpModeName
protected HardwareMap hardwareMap
protected EventLoopManager eventLoopManager
protected finallisteners
protected OpModeManagerImpl.OpModeStuckCodeMonitor stuckMonitor
protected OpModeManagerImpl.OpModeState opModeState
protected boolean opModeSwapNeeded
protected boolean callToInitNeeded
protected boolean callToStartNeeded
protected boolean gamepadResetNeeded
protected boolean telemetryClearNeeded
protected java.util.concurrent.atomic.AtomicReference<com.qualcomm.robotcore.eventloop.opmode.OpModeManagerImpl.OpModeStateTransition> nextOpModeState
protected static final java.util.WeakHashMap<Activity,OpModeManagerImpl> mapActivityToOpModeManager
public OpModeManagerImpl(Activity activity, HardwareMap hardwareMap)
public static OpModeManagerImpl getOpModeManagerOfActivity(Activity activity)
public void init(EventLoopManager eventLoopManager)
public void teardown()
public OpMode registerListener(OpModeManagerNotifier.Notifications listener)
OpModeManagerNotifier
registerListener
in interface OpModeManagerNotifier
listener
- the object which is to receive notificationsOpModeManagerNotifier.unregisterListener(Notifications)
public void unregisterListener(OpModeManagerNotifier.Notifications listener)
OpModeManagerNotifier
unregisterListener
in interface OpModeManagerNotifier
listener
- the listener to be unregistered.protected void setActiveOpMode(OpMode opMode, java.lang.String activeOpModeName)
public void registerOpModes(OpModeRegister register)
public boolean areOpModesRegistered()
public void setHardwareMap(HardwareMap hardwareMap)
public HardwareMap getHardwareMap()
public java.util.List<OpModeMeta> getOpModes()
public java.lang.String getActiveOpModeName()
public OpMode getActiveOpMode()
public void initActiveOpMode(java.lang.String name)
public void startActiveOpMode()
public void stopActiveOpMode()
public void runActiveOpMode(Gamepad[] gamepads)
protected void resetHardwareForOpMode()
public void logOpModes()
public void register(java.lang.String name, java.lang.Class opMode)
register
in interface OpModeManager
name
- the name of the OpMode in the driver stationopMode
- the OpMode class to instantiate when that OpMode is selectedpublic void register(OpModeMeta meta, java.lang.Class opMode)
OpModeManager
register
in interface OpModeManager
meta
- metadata regarding the class, including the name to show on the DS menuopMode
- the class of the OpMode to createpublic void register(java.lang.String name, OpMode opMode)
register
in interface OpModeManager
name
- the name of the OpMode in the driver stationopMode
- the OpMode instance to use when that OpMode is selectedpublic void register(OpModeMeta meta, OpMode opMode)
OpModeManager
register
in interface OpModeManager
meta
- metadata regarding the opmode, including the name to show on the driver station menuopMode
- the object instance to use for that menu itemprotected void callActiveOpModeStop()
protected void detectStuck(int msTimeout, java.lang.String method, java.lang.Runnable runnable)
protected void detectStuck(int msTimeout, java.lang.String method, java.lang.Runnable runnable, boolean resetDebuggerCheck)
protected void callActiveOpModeInit()
protected void callActiveOpModeStart()
protected void callActiveOpModeInitLoop()
protected void callActiveOpModeLoop()
public static void updateTelemetryNow(OpMode opMode, TelemetryMessage telemetry)
TelemetryImpl
.public void refreshUserTelemetry(TelemetryMessage telemetry, double sInterval)
telemetry
- the telemetry object to sendsInterval
- the required minimum interval. NaN indicates that a system default interval should be used.
A value of zero will cause immediate transmission.EventLoop.TELEMETRY_DEFAULT_INTERVAL
public void requestOpModeStop(OpMode opModeToStopIfActive)
opModeToStopIfActive
- the OpMode to stop if it is the currently active OpModeOpMode.requestOpModeStop()