blob: 8eddfca5c35b1f50a414ac707810717529cfc7ab [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
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080012namespace frc971::wpilib {
Maxwell Hendersonf29e3182023-05-25 06:51:24 -070013class CANSensorReader {
14 public:
15 CANSensorReader(
16 aos::EventLoop *event_loop,
Maxwell Hendersonfcc0d122023-08-05 17:03:34 -070017 std::vector<ctre::phoenix6::BaseStatusSignal *> signals_registry,
Maxwell Henderson10ed5c32024-01-09 12:40:54 -080018 std::vector<std::shared_ptr<TalonFX>> talonfxs,
Maxwell Henderson6c6faaf2023-07-26 19:44:24 -070019 std::function<void(ctre::phoenix::StatusCode status)>
20 flatbuffer_callback);
Maxwell Hendersonf29e3182023-05-25 06:51:24 -070021
22 private:
23 void Loop();
24
25 aos::EventLoop *event_loop_;
26
Maxwell Hendersonfcc0d122023-08-05 17:03:34 -070027 const std::vector<ctre::phoenix6::BaseStatusSignal *> signals_;
Maxwell Hendersonf29e3182023-05-25 06:51:24 -070028
Maxwell Henderson10ed5c32024-01-09 12:40:54 -080029 // This is a vector of talonfxs becuase we don't need to care
30 // about talonfxs individually.
31 std::vector<std::shared_ptr<TalonFX>> talonfxs_;
Maxwell Hendersonf29e3182023-05-25 06:51:24 -070032
33 // Pointer to the timer handler used to modify the wakeup.
34 ::aos::TimerHandler *timer_handler_;
Maxwell Henderson6c6faaf2023-07-26 19:44:24 -070035
36 // Callback used to send the CANPosition flatbuffer
37 std::function<void(ctre::phoenix::StatusCode status)> flatbuffer_callback_;
Maxwell Hendersonf29e3182023-05-25 06:51:24 -070038};
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080039} // namespace frc971::wpilib
Maxwell Hendersonf29e3182023-05-25 06:51:24 -070040#endif // FRC971_WPILIB_CAN_SENSOR_READER_H_