blob: 8ef5fd11a9df11e226c4cd69c1a45a4154318905 [file] [log] [blame]
Maxwell Hendersonf29e3182023-05-25 06:51:24 -07001#ifndef FRC971_WPILIB_CAN_SENSOR_READER_H_
2#define FRC971_WPILIB_CAN_SENSOR_READER_H_
3
4#include <vector>
5
6#include "aos/containers/sized_array.h"
7#include "aos/events/event_loop.h"
8#include "aos/events/shm_event_loop.h"
9#include "aos/realtime.h"
Maxwell Henderson10ed5c32024-01-09 12:40:54 -080010#include "frc971/wpilib/talonfx.h"
Maxwell Hendersonf29e3182023-05-25 06:51:24 -070011
12namespace frc971 {
13namespace wpilib {
14class CANSensorReader {
15 public:
16 CANSensorReader(
17 aos::EventLoop *event_loop,
Maxwell Hendersonfcc0d122023-08-05 17:03:34 -070018 std::vector<ctre::phoenix6::BaseStatusSignal *> signals_registry,
Maxwell Henderson10ed5c32024-01-09 12:40:54 -080019 std::vector<std::shared_ptr<TalonFX>> talonfxs,
Maxwell Henderson6c6faaf2023-07-26 19:44:24 -070020 std::function<void(ctre::phoenix::StatusCode status)>
21 flatbuffer_callback);
Maxwell Hendersonf29e3182023-05-25 06:51:24 -070022
23 private:
24 void Loop();
25
26 aos::EventLoop *event_loop_;
27
Maxwell Hendersonfcc0d122023-08-05 17:03:34 -070028 const std::vector<ctre::phoenix6::BaseStatusSignal *> signals_;
Maxwell Hendersonf29e3182023-05-25 06:51:24 -070029
Maxwell Henderson10ed5c32024-01-09 12:40:54 -080030 // This is a vector of talonfxs becuase we don't need to care
31 // about talonfxs individually.
32 std::vector<std::shared_ptr<TalonFX>> talonfxs_;
Maxwell Hendersonf29e3182023-05-25 06:51:24 -070033
34 // Pointer to the timer handler used to modify the wakeup.
35 ::aos::TimerHandler *timer_handler_;
Maxwell Henderson6c6faaf2023-07-26 19:44:24 -070036
37 // Callback used to send the CANPosition flatbuffer
38 std::function<void(ctre::phoenix::StatusCode status)> flatbuffer_callback_;
Maxwell Hendersonf29e3182023-05-25 06:51:24 -070039};
40} // namespace wpilib
41} // namespace frc971
42#endif // FRC971_WPILIB_CAN_SENSOR_READER_H_