Constructor and Description |
---|
FtcEventLoop(HardwareFactory hardwareFactory,
OpModeRegister register,
UpdateUI.Callback callback,
Context robotControllerContext) |
Modifier and Type | Method and Description |
---|---|
OpModeManager |
getOpModeManager() |
void |
init(EventLoopManager eventLoopManager)
Init method
|
void |
loop()
Loop method, this will be called repeatedly while the robot is running.
|
void |
processCommand(Command command)
If the driver station sends over a command, it will be routed to this method.
|
void |
teardown()
Teardown method
|
public FtcEventLoop(HardwareFactory hardwareFactory, OpModeRegister register, UpdateUI.Callback callback, Context robotControllerContext)
public OpModeManager getOpModeManager()
getOpModeManager
in interface EventLoop
public void init(EventLoopManager eventLoopManager) throws RobotCoreException, java.lang.InterruptedException
This code will run when the robot first starts up. Place any initialization code in this method.
It is important to save a copy of the event loop manager from this method, as that is how you'll get access to the gamepad.
If an Exception is thrown then the event loop manager will not start the robot.
init
in interface EventLoop
eventLoopManager
- event loop manager that is responsible for this event loopRobotCoreException
- if a RobotCoreException is thrown, it will be handled
by the event loop manager. The manager will report that the robot failed
to start.java.lang.InterruptedException
public void loop() throws RobotCoreException
loop
in interface EventLoop
RobotCoreException
- if a RobotCoreException is thrown, it will be handled
by the event loop manager. The manager may decide to either stop processing
this iteration of the loop, or it may decide to shut down the robot.EventLoop.loop()
public void teardown() throws RobotCoreException
This method will be called when the robot is being shut down. This method should stop the robot. There will be no more changes to write to the hardware after this method is called.
If an exception is thrown, then the event loop manager will attempt to shut down the robot without the benefit of this method.
teardown
in interface EventLoop
RobotCoreException
- if a RobotCoreException is thrown, it will be handled by the event
loop manager. The manager will then attempt to shut down the robot without the benefit
of the teardown method.EventLoop.teardown()
public void processCommand(Command command)
processCommand
in interface EventLoop
command
- command to process