blob: 0a25870be3610ab23c1b6080bf19dd318afd228b [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008-2017. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
7
8#pragma once
9
10#include <memory>
11#include <string>
12
13#include "HAL/Types.h"
14#include "LiveWindow/LiveWindowSendable.h"
15#include "SolenoidBase.h"
16#include "tables/ITableListener.h"
17
18namespace frc {
19
20/**
21 * DoubleSolenoid class for running 2 channels of high voltage Digital Output
22 * (PCM).
23 *
24 * The DoubleSolenoid class is typically used for pneumatics solenoids that
25 * have two positions controlled by two separate channels.
26 */
27class DoubleSolenoid : public SolenoidBase,
28 public LiveWindowSendable,
29 public ITableListener {
30 public:
31 enum Value { kOff, kForward, kReverse };
32
33 explicit DoubleSolenoid(int forwardChannel, int reverseChannel);
34 DoubleSolenoid(int moduleNumber, int forwardChannel, int reverseChannel);
35 virtual ~DoubleSolenoid();
36 virtual void Set(Value value);
37 virtual Value Get() const;
38 bool IsFwdSolenoidBlackListed() const;
39 bool IsRevSolenoidBlackListed() const;
40
41 void ValueChanged(ITable* source, llvm::StringRef key,
42 std::shared_ptr<nt::Value> value, bool isNew);
43 void UpdateTable();
44 void StartLiveWindowMode();
45 void StopLiveWindowMode();
46 std::string GetSmartDashboardType() const;
47 void InitTable(std::shared_ptr<ITable> subTable);
48 std::shared_ptr<ITable> GetTable() const;
49
50 private:
51 int m_forwardChannel; ///< The forward channel on the module to control.
52 int m_reverseChannel; ///< The reverse channel on the module to control.
53 int m_forwardMask; ///< The mask for the forward channel.
54 int m_reverseMask; ///< The mask for the reverse channel.
55 HAL_SolenoidHandle m_forwardHandle = HAL_kInvalidHandle;
56 HAL_SolenoidHandle m_reverseHandle = HAL_kInvalidHandle;
57
58 std::shared_ptr<ITable> m_table;
59};
60
61} // namespace frc