2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
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
|
|
|
|
2021-06-05 22:36:39 -07:00
|
|
|
#include <memory>
|
|
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include <hal/Types.h>
|
2021-06-13 16:38:05 -07:00
|
|
|
#include <wpi/sendable/Sendable.h>
|
|
|
|
|
#include <wpi/sendable/SendableHelper.h>
|
2017-08-27 00:11:52 -07:00
|
|
|
|
2021-06-05 22:36:39 -07:00
|
|
|
#include "frc/PneumaticsBase.h"
|
2021-09-16 18:50:27 -07:00
|
|
|
#include "frc/PneumaticsModuleType.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
|
|
|
|
* DoubleSolenoid class for running 2 channels of high voltage Digital Output
|
2021-09-16 18:50:27 -07:00
|
|
|
* on a pneumatics module.
|
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.
|
|
|
|
|
*/
|
2021-06-13 16:38:05 -07:00
|
|
|
class DoubleSolenoid : public wpi::Sendable,
|
|
|
|
|
public wpi::SendableHelper<DoubleSolenoid> {
|
2015-06-25 15:07:55 -04:00
|
|
|
public:
|
|
|
|
|
enum Value { kOff, kForward, kReverse };
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
/**
|
|
|
|
|
* Constructs a double solenoid for a specified module of a specific module
|
|
|
|
|
* type.
|
|
|
|
|
*
|
|
|
|
|
* @param module The module of the solenoid module to use.
|
|
|
|
|
* @param moduleType The module type to use.
|
|
|
|
|
* @param forwardChannel The forward channel on the module to control.
|
|
|
|
|
* @param reverseChannel The reverse channel on the module to control.
|
|
|
|
|
*/
|
|
|
|
|
DoubleSolenoid(int module, PneumaticsModuleType moduleType,
|
|
|
|
|
int forwardChannel, int reverseChannel);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs a double solenoid for a default module of a specific module
|
|
|
|
|
* type.
|
|
|
|
|
*
|
|
|
|
|
* @param moduleType The module type to use.
|
|
|
|
|
* @param forwardChannel The forward channel on the module to control.
|
|
|
|
|
* @param reverseChannel The reverse channel on the module to control.
|
|
|
|
|
*/
|
|
|
|
|
DoubleSolenoid(PneumaticsModuleType moduleType, int forwardChannel,
|
2021-06-05 22:36:39 -07:00
|
|
|
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
|
|
|
|
2020-08-15 08:16:32 -07:00
|
|
|
/**
|
|
|
|
|
* Toggle the value of the solenoid.
|
|
|
|
|
*
|
|
|
|
|
* If the solenoid is set to forward, it'll be set to reverse. If the solenoid
|
|
|
|
|
* is set to reverse, it'll be set to forward. If the solenoid is set to off,
|
|
|
|
|
* nothing happens.
|
|
|
|
|
*/
|
|
|
|
|
void Toggle();
|
|
|
|
|
|
2021-02-17 04:03:57 +02:00
|
|
|
/**
|
|
|
|
|
* Get the forward channel.
|
|
|
|
|
*
|
|
|
|
|
* @return the forward channel.
|
|
|
|
|
*/
|
|
|
|
|
int GetFwdChannel() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the reverse channel.
|
|
|
|
|
*
|
|
|
|
|
* @return the reverse channel.
|
|
|
|
|
*/
|
|
|
|
|
int GetRevChannel() const;
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
2021-06-05 22:36:39 -07:00
|
|
|
* Check if the forward solenoid is Disabled.
|
2018-05-31 20:47:15 -07:00
|
|
|
*
|
2021-06-05 22:36:39 -07:00
|
|
|
* If a solenoid is shorted, it is added to the DisabledList and disabled
|
|
|
|
|
* until power cycle, or until faults are cleared.
|
2018-05-31 20:47:15 -07:00
|
|
|
*
|
2023-06-15 08:14:35 -07:00
|
|
|
* @see ClearAllStickyFaults()
|
2018-05-31 20:47:15 -07:00
|
|
|
* @return If solenoid is disabled due to short.
|
|
|
|
|
*/
|
2021-06-05 22:36:39 -07:00
|
|
|
bool IsFwdSolenoidDisabled() const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
2021-06-05 22:36:39 -07:00
|
|
|
* Check if the reverse solenoid is Disabled.
|
2018-05-31 20:47:15 -07:00
|
|
|
*
|
2021-06-05 22:36:39 -07:00
|
|
|
* If a solenoid is shorted, it is added to the DisabledList and disabled
|
|
|
|
|
* until power cycle, or until faults are cleared.
|
2018-05-31 20:47:15 -07:00
|
|
|
*
|
2023-06-15 08:14:35 -07:00
|
|
|
* @see ClearAllStickyFaults()
|
2018-05-31 20:47:15 -07:00
|
|
|
* @return If solenoid is disabled due to short.
|
|
|
|
|
*/
|
2021-06-05 22:36:39 -07:00
|
|
|
bool IsRevSolenoidDisabled() const;
|
2014-05-02 17:54:01 -04:00
|
|
|
|
2021-06-13 16:38:05 -07:00
|
|
|
void InitSendable(wpi::SendableBuilder& builder) override;
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
private:
|
2021-09-16 18:50:27 -07:00
|
|
|
std::shared_ptr<PneumaticsBase> m_module;
|
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.
|
2021-06-05 22:36:39 -07:00
|
|
|
int m_mask;
|
2013-12-15 18:30:16 -05:00
|
|
|
};
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|