blob: 38c4a5b344d747011b02ec2d43da2ea7c670f4fe [file] [log] [blame]
Brian Silverman425492b2015-12-30 15:23:55 -08001#ifndef FRC971_WPILIB_PDP_FETCHER_H_
2#define FRC971_WPILIB_PDP_FETCHER_H_
3
Brian Silverman425492b2015-12-30 15:23:55 -08004#include <atomic>
Parker Schuhd3b7a8872018-02-19 16:42:27 -08005#include <memory>
Brian Silverman425492b2015-12-30 15:23:55 -08006
Alex Perrycb7da4b2019-08-28 19:35:56 -07007#include "aos/events/event_loop.h"
Austin Schuh217a9782019-12-21 23:02:50 -08008#include "aos/events/shm_event_loop.h"
Alex Perrycb7da4b2019-08-28 19:35:56 -07009#include "frc971/wpilib/pdp_values_generated.h"
Austin Schuh0b545432019-05-12 15:46:12 -070010
Austin Schuhbd1fe9c2019-06-29 16:35:48 -070011namespace frc {
12class PowerDistributionPanel;
13} // namespace frc
14
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080015namespace frc971::wpilib {
Brian Silverman425492b2015-12-30 15:23:55 -080016
Austin Schuhbd1fe9c2019-06-29 16:35:48 -070017// Handles fetching values from the PDP.
Brian Silverman425492b2015-12-30 15:23:55 -080018class PDPFetcher {
19 public:
Austin Schuh217a9782019-12-21 23:02:50 -080020 PDPFetcher(::aos::ShmEventLoop *event_loop);
Austin Schuh0b545432019-05-12 15:46:12 -070021
Austin Schuhbd1fe9c2019-06-29 16:35:48 -070022 ~PDPFetcher();
Brian Silverman425492b2015-12-30 15:23:55 -080023
24 private:
Austin Schuhbd1fe9c2019-06-29 16:35:48 -070025 void Loop(int iterations);
26
Austin Schuh0b545432019-05-12 15:46:12 -070027 ::aos::EventLoop *event_loop_;
28
29 ::aos::Sender<::frc971::PDPValues> pdp_values_sender_;
30
Austin Schuhbd1fe9c2019-06-29 16:35:48 -070031 ::std::unique_ptr<::frc::PowerDistributionPanel> pdp_;
Brian Silverman425492b2015-12-30 15:23:55 -080032};
33
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080034} // namespace frc971::wpilib
Brian Silverman425492b2015-12-30 15:23:55 -080035
36#endif // FRC971_WPILIB_PDP_FETCHER_H_