blob: e2613d7fd015d0f4b12548a81a08012f355f6991 [file] [log] [blame]
Brian Silvermand8f403a2014-12-13 19:12:04 -05001#ifndef FRC971_WPILIB_BUFFERED_PCM_H_
2#define FRC971_WPILIB_BUFFERED_PCM_H_
3
4#include <memory>
5
6#include "SolenoidBase.h"
7
8#include "frc971/wpilib/buffered_solenoid.h"
9
10namespace frc971 {
11namespace wpilib {
12
13// Manages setting values for all solenoids for a single PCM in a single CAN
14// message.
15//
16// The way to use this is to call MakeSolenoid for whichever solenoid numbers
17// you want, call Set on those, and then periodically call Flush on this object
18// to write all of the buffered values out.
19class BufferedPcm : public SolenoidBase {
20 public:
21 explicit BufferedPcm(uint8_t module = GetDefaultSolenoidModule())
22 : SolenoidBase(module) {}
23
24 // Creates a new BufferedSolenoid for a specified port number.
25 ::std::unique_ptr<BufferedSolenoid> MakeSolenoid(int number);
26
27 // Actually sends all of the values out.
28 void Flush();
29
30 private:
31 // WPILib declares this pure virtual and then never calls it...
Austin Schuh3b5b69b2015-10-31 18:55:47 -070032#ifdef WPILIB2015
Brian Silvermand8f403a2014-12-13 19:12:04 -050033 virtual void InitSolenoid() override {}
Austin Schuh3b5b69b2015-10-31 18:55:47 -070034#endif
Brian Silvermand8f403a2014-12-13 19:12:04 -050035
36 void Set(int number, bool value);
37
38 uint8_t values_ = 0;
39
40 friend class BufferedSolenoid;
41};
42
43} // namespace wpilib
44} // namespace frc971
45
46#endif // FRC971_WPILIB_BUFFERED_PCM_H_