blob: 924d63ae9cda7fd4b31c81591c66c1f182cd1fec [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 "LiveWindow/LiveWindowSendable.h"
14#include "simulation/SimContinuousOutput.h"
15#include "tables/ITableListener.h"
16
17namespace frc {
18
19/**
20 * DoubleSolenoid class for running 2 channels of high voltage Digital Output
21 * (PCM).
22 *
23 * The DoubleSolenoid class is typically used for pneumatics solenoids that
24 * have two positions controlled by two separate channels.
25 */
26class DoubleSolenoid : public LiveWindowSendable, public ITableListener {
27 public:
28 enum Value { kOff, kForward, kReverse };
29
30 explicit DoubleSolenoid(int forwardChannel, int reverseChannel);
31 DoubleSolenoid(int moduleNumber, int forwardChannel, int reverseChannel);
32 virtual ~DoubleSolenoid();
33 virtual void Set(Value value);
34 virtual Value Get() const;
35
36 void ValueChanged(ITable* source, llvm::StringRef key,
37 std::shared_ptr<nt::Value> value, bool isNew) override;
38 void UpdateTable() override;
39 void StartLiveWindowMode() override;
40 void StopLiveWindowMode() override;
41 std::string GetSmartDashboardType() const override;
42 void InitTable(std::shared_ptr<ITable> subTable) override;
43 std::shared_ptr<ITable> GetTable() const override;
44
45 private:
46 SimContinuousOutput* m_impl;
47 Value m_value;
48 bool m_reversed;
49
50 std::shared_ptr<ITable> m_table;
51};
52
53} // namespace frc