WPILibC++ 2025.0.0-alpha-1-9-ga2beb75
AnalogTriggerSim.h
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 <memory>
8
10
11namespace frc {
12
13class AnalogTrigger;
14
15namespace sim {
16
17/**
18 * Class to control a simulated analog trigger.
19 */
21 public:
22 /**
23 * Constructs from an AnalogTrigger object.
24 *
25 * @param analogTrigger AnalogTrigger to simulate
26 */
27 explicit AnalogTriggerSim(const AnalogTrigger& analogTrigger);
28
29 /**
30 * Creates an AnalogTriggerSim for an analog input channel.
31 *
32 * @param channel analog input channel
33 * @return Simulated object
34 * @throws std::out_of_range if no AnalogTrigger is configured for that
35 * channel
36 */
38
39 /**
40 * Creates an AnalogTriggerSim for a simulated index.
41 * The index is incremented for each simulated AnalogTrigger.
42 *
43 * @param index simulator index
44 * @return Simulated object
45 */
47
48 /**
49 * Register a callback on whether the analog trigger is initialized.
50 *
51 * @param callback the callback that will be called whenever the analog
52 * trigger is initialized
53 * @param initialNotify if true, the callback will be run on the initial value
54 * @return the CallbackStore object associated with this callback
55 */
56 [[nodiscard]]
57 std::unique_ptr<CallbackStore> RegisterInitializedCallback(
58 NotifyCallback callback, bool initialNotify);
59
60 /**
61 * Check if this analog trigger has been initialized.
62 *
63 * @return true if initialized
64 */
65 bool GetInitialized() const;
66
67 /**
68 * Change whether this analog trigger has been initialized.
69 *
70 * @param initialized the new value
71 */
72 void SetInitialized(bool initialized);
73
74 /**
75 * Register a callback on the lower bound.
76 *
77 * @param callback the callback that will be called whenever the lower bound
78 * is changed
79 * @param initialNotify if true, the callback will be run on the initial value
80 * @return the CallbackStore object associated with this callback
81 */
82 [[nodiscard]]
83 std::unique_ptr<CallbackStore> RegisterTriggerLowerBoundCallback(
84 NotifyCallback callback, bool initialNotify);
85
86 /**
87 * Get the lower bound.
88 *
89 * @return the lower bound
90 */
91 double GetTriggerLowerBound() const;
92
93 /**
94 * Change the lower bound.
95 *
96 * @param triggerLowerBound the new lower bound
97 */
98 void SetTriggerLowerBound(double triggerLowerBound);
99
100 /**
101 * Register a callback on the upper bound.
102 *
103 * @param callback the callback that will be called whenever the upper bound
104 * is changed
105 * @param initialNotify if true, the callback will be run on the initial value
106 * @return the CallbackStore object associated with this callback
107 */
108 [[nodiscard]]
109 std::unique_ptr<CallbackStore> RegisterTriggerUpperBoundCallback(
110 NotifyCallback callback, bool initialNotify);
111
112 /**
113 * Get the upper bound.
114 *
115 * @return the upper bound
116 */
117 double GetTriggerUpperBound() const;
118
119 /**
120 * Change the upper bound.
121 *
122 * @param triggerUpperBound the new upper bound
123 */
124 void SetTriggerUpperBound(double triggerUpperBound);
125
126 /**
127 * Reset all simulation data for this object.
128 */
129 void ResetData();
130
131 private:
132 explicit AnalogTriggerSim(int index) : m_index{index} {}
133
134 int m_index;
135};
136} // namespace sim
137} // namespace frc
Definition: AnalogTrigger.h:21
Class to control a simulated analog trigger.
Definition: AnalogTriggerSim.h:20
std::unique_ptr< CallbackStore > RegisterInitializedCallback(NotifyCallback callback, bool initialNotify)
Register a callback on whether the analog trigger is initialized.
static AnalogTriggerSim CreateForChannel(int channel)
Creates an AnalogTriggerSim for an analog input channel.
AnalogTriggerSim(const AnalogTrigger &analogTrigger)
Constructs from an AnalogTrigger object.
std::unique_ptr< CallbackStore > RegisterTriggerLowerBoundCallback(NotifyCallback callback, bool initialNotify)
Register a callback on the lower bound.
void ResetData()
Reset all simulation data for this object.
double GetTriggerUpperBound() const
Get the upper bound.
static AnalogTriggerSim CreateForIndex(int index)
Creates an AnalogTriggerSim for a simulated index.
void SetInitialized(bool initialized)
Change whether this analog trigger has been initialized.
void SetTriggerUpperBound(double triggerUpperBound)
Change the upper bound.
double GetTriggerLowerBound() const
Get the lower bound.
std::unique_ptr< CallbackStore > RegisterTriggerUpperBoundCallback(NotifyCallback callback, bool initialNotify)
Register a callback on the upper bound.
bool GetInitialized() const
Check if this analog trigger has been initialized.
void SetTriggerLowerBound(double triggerLowerBound)
Change the lower bound.
std::function< void(std::string_view, const HAL_Value *)> NotifyCallback
Definition: CallbackStore.h:14
Definition: AprilTagDetector_cv.h:11