Convert all year's robots to proper event loops
Each robot has a couple of event loops, one per thread. Each of these
threads corresponds to the threads from before the change. y2016 has
been tested on real hardware.
Change-Id: I99f726a8bc0498204c1a3b99f15508119eed9ad3
diff --git a/frc971/wpilib/pdp_fetcher.h b/frc971/wpilib/pdp_fetcher.h
index db783f6..fd05d67 100644
--- a/frc971/wpilib/pdp_fetcher.h
+++ b/frc971/wpilib/pdp_fetcher.h
@@ -7,29 +7,28 @@
#include "aos/events/event-loop.h"
#include "frc971/wpilib/pdp_values.q.h"
+namespace frc {
+class PowerDistributionPanel;
+} // namespace frc
+
namespace frc971 {
namespace wpilib {
-// Handles fetching values from the PDP. This is slow, so it has to happen in a
-// separate thread.
+// Handles fetching values from the PDP.
class PDPFetcher {
public:
- PDPFetcher(::aos::EventLoop *event_loop)
- : event_loop_(event_loop),
- pdp_values_sender_(event_loop_->MakeSender<::frc971::PDPValues>(
- ".frc971.pdp_values")) {}
+ PDPFetcher(::aos::EventLoop *event_loop);
- void Quit() { run_ = false; }
-
- // To be called by a ::std::thread.
- void operator()();
+ ~PDPFetcher();
private:
+ void Loop(int iterations);
+
::aos::EventLoop *event_loop_;
::aos::Sender<::frc971::PDPValues> pdp_values_sender_;
- ::std::atomic<bool> run_{true};
+ ::std::unique_ptr<::frc::PowerDistributionPanel> pdp_;
};
} // namespace wpilib