WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
OpMode.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
9namespace wpi {
10
11/**
12 * Top-level interface for opmode classes. Users should generally extend one of
13 * the abstract implementations of this interface (e.g. PeriodicOpMode) rather
14 * than directly implementing this interface.
15 */
16class OpMode {
17 public:
18 /**
19 * The object is destroyed when the opmode is no longer selected on the DS or
20 * after OpModeRun() returns.
21 */
22 virtual ~OpMode() = default;
23
24 /**
25 * This function is called periodically while the opmode is selected on the DS
26 * (robot is disabled). Code that should only run once when the opmode is
27 * selected should go in the opmode constructor.
28 */
29 virtual void DisabledPeriodic() {}
30
31 /**
32 * This function is called when the opmode starts (robot is enabled).
33 *
34 * @param opModeId opmode unique ID
35 */
36 virtual void OpModeRun(int64_t opModeId) = 0;
37
38 /**
39 * This function is called asynchronously when the robot is disabled, to
40 * request the opmode return from OpModeRun().
41 */
42 virtual void OpModeStop() = 0;
43};
44
45} // namespace wpi
Top-level interface for opmode classes.
Definition OpMode.hpp:16
virtual ~OpMode()=default
The object is destroyed when the opmode is no longer selected on the DS or after OpModeRun() returns.
virtual void OpModeStop()=0
This function is called asynchronously when the robot is disabled, to request the opmode return from ...
virtual void DisabledPeriodic()
This function is called periodically while the opmode is selected on the DS (robot is disabled).
Definition OpMode.hpp:29
virtual void OpModeRun(int64_t opModeId)=0
This function is called when the opmode starts (robot is enabled).
Definition CvSource.hpp:15