blob: 4ff625b57c22e71b3f70caef6921ca5204b6861d [file] [log] [blame]
#ifndef FRC971_WPILIB_BUFFERED_PCM_H_
#define FRC971_WPILIB_BUFFERED_PCM_H_
#include <memory>
#include "Solenoid.h"
#undef ERROR
#include "frc971/wpilib/buffered_solenoid.h"
namespace frc971 {
namespace wpilib {
// Manages setting values for all solenoids for a single PCM in a single CAN
// message.
//
// The way to use this is to call MakeSolenoid for whichever solenoid numbers
// you want, call Set on those, and then periodically call Flush on this object
// to write all of the buffered values out.
class BufferedPcm : public Solenoid {
public:
explicit BufferedPcm() : Solenoid(0) {}
// Creates a new BufferedSolenoid for a specified port number.
::std::unique_ptr<BufferedSolenoid> MakeSolenoid(int number);
// Actually sends all of the values out.
void Flush();
private:
// WPILib declares this pure virtual and then never calls it...
#ifdef WPILIB2015
virtual void InitSolenoid() override {}
#endif
void DoSet(int number, bool value);
uint8_t values_ = 0;
friend class BufferedSolenoid;
};
} // namespace wpilib
} // namespace frc971
#endif // FRC971_WPILIB_BUFFERED_PCM_H_