2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2019-08-25 18:42:00 -07:00
|
|
|
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2016-01-02 03:02:34 -08:00
|
|
|
|
2014-05-02 17:54:01 -04:00
|
|
|
#pragma once
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include <hal/Types.h>
|
2017-08-27 00:11:52 -07:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/SolenoidBase.h"
|
2019-09-14 15:22:54 -05:00
|
|
|
#include "frc/smartdashboard/Sendable.h"
|
|
|
|
|
#include "frc/smartdashboard/SendableHelper.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2019-09-14 15:22:54 -05:00
|
|
|
class SendableBuilder;
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
|
|
|
|
* DoubleSolenoid class for running 2 channels of high voltage Digital Output
|
2014-08-25 15:32:49 -07:00
|
|
|
* (PCM).
|
2014-08-05 14:42:37 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* The DoubleSolenoid class is typically used for pneumatics solenoids that
|
|
|
|
|
* have two positions controlled by two separate channels.
|
|
|
|
|
*/
|
2019-09-14 15:22:54 -05:00
|
|
|
class DoubleSolenoid : public SolenoidBase,
|
|
|
|
|
public Sendable,
|
|
|
|
|
public SendableHelper<DoubleSolenoid> {
|
2015-06-25 15:07:55 -04:00
|
|
|
public:
|
|
|
|
|
enum Value { kOff, kForward, kReverse };
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Constructor.
|
|
|
|
|
*
|
|
|
|
|
* Uses the default PCM ID of 0.
|
|
|
|
|
*
|
|
|
|
|
* @param forwardChannel The forward channel number on the PCM (0..7).
|
|
|
|
|
* @param reverseChannel The reverse channel number on the PCM (0..7).
|
|
|
|
|
*/
|
2016-09-06 00:01:45 -07:00
|
|
|
explicit DoubleSolenoid(int forwardChannel, int reverseChannel);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor.
|
|
|
|
|
*
|
|
|
|
|
* @param moduleNumber The CAN ID of the PCM.
|
|
|
|
|
* @param forwardChannel The forward channel on the PCM to control (0..7).
|
|
|
|
|
* @param reverseChannel The reverse channel on the PCM to control (0..7).
|
|
|
|
|
*/
|
2016-09-06 00:01:45 -07:00
|
|
|
DoubleSolenoid(int moduleNumber, int forwardChannel, int reverseChannel);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
~DoubleSolenoid() override;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
2019-08-25 18:42:00 -07:00
|
|
|
DoubleSolenoid(DoubleSolenoid&&) = default;
|
|
|
|
|
DoubleSolenoid& operator=(DoubleSolenoid&&) = default;
|
2018-09-24 00:08:25 -07:00
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Set the value of a solenoid.
|
|
|
|
|
*
|
|
|
|
|
* @param value The value to set (Off, Forward or Reverse)
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
virtual void Set(Value value);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Read the current value of the solenoid.
|
|
|
|
|
*
|
|
|
|
|
* @return The current value of the solenoid.
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
virtual Value Get() const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if the forward solenoid is blacklisted.
|
|
|
|
|
*
|
|
|
|
|
* If a solenoid is shorted, it is added to the blacklist and disabled until
|
|
|
|
|
* power cycle, or until faults are cleared.
|
|
|
|
|
*
|
|
|
|
|
* @see ClearAllPCMStickyFaults()
|
|
|
|
|
* @return If solenoid is disabled due to short.
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
bool IsFwdSolenoidBlackListed() const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if the reverse solenoid is blacklisted.
|
|
|
|
|
*
|
|
|
|
|
* If a solenoid is shorted, it is added to the blacklist and disabled until
|
|
|
|
|
* power cycle, or until faults are cleared.
|
|
|
|
|
*
|
|
|
|
|
* @see ClearAllPCMStickyFaults()
|
|
|
|
|
* @return If solenoid is disabled due to short.
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
bool IsRevSolenoidBlackListed() const;
|
2014-05-02 17:54:01 -04:00
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
void InitSendable(SendableBuilder& builder) override;
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
private:
|
2017-11-16 00:33:51 -08:00
|
|
|
int m_forwardChannel; // The forward channel on the module to control.
|
|
|
|
|
int m_reverseChannel; // The reverse channel on the module to control.
|
|
|
|
|
int m_forwardMask; // The mask for the forward channel.
|
|
|
|
|
int m_reverseMask; // The mask for the reverse channel.
|
2019-08-25 18:42:00 -07:00
|
|
|
hal::Handle<HAL_SolenoidHandle> m_forwardHandle;
|
|
|
|
|
hal::Handle<HAL_SolenoidHandle> m_reverseHandle;
|
2013-12-15 18:30:16 -05:00
|
|
|
};
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|