blob: ca38f1d159d3c4bcab65b9e5a14176fef7e2efbf [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05002/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
Brian Silverman26e4e522015-12-17 01:56:40 -05003/* Open Source Software - may be modified and shared by FRC teams. The code */
Brian Silverman1a675112016-02-20 20:42:49 -05004/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
Brian Silverman26e4e522015-12-17 01:56:40 -05006/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05007
Brian Silverman26e4e522015-12-17 01:56:40 -05008#pragma once
9
10#include "simulation/SimContinuousOutput.h"
11#include "LiveWindow/LiveWindowSendable.h"
12#include "tables/ITableListener.h"
13
14#include <memory>
15
16/**
17 * DoubleSolenoid class for running 2 channels of high voltage Digital Output
18 * (PCM).
19 *
20 * The DoubleSolenoid class is typically used for pneumatics solenoids that
21 * have two positions controlled by two separate channels.
22 */
23class DoubleSolenoid : public LiveWindowSendable, public ITableListener
24{
25public:
26 enum Value
27 {
28 kOff,
29 kForward,
30 kReverse
31 };
32
33 explicit DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel);
34 DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel, uint32_t reverseChannel);
35 virtual ~DoubleSolenoid();
36 virtual void Set(Value value);
37 virtual Value Get() const;
38
39 void ValueChanged(ITable* source, llvm::StringRef key,
40 std::shared_ptr<nt::Value> value, bool isNew) override;
41 void UpdateTable() override;
42 void StartLiveWindowMode() override;
43 void StopLiveWindowMode() override;
44 std::string GetSmartDashboardType() const override;
45 void InitTable(std::shared_ptr<ITable> subTable) override;
46 std::shared_ptr<ITable> GetTable() const override;
47
48private:
49 SimContinuousOutput* m_impl;
50 Value m_value;
51 bool m_reversed;
52
53 std::shared_ptr<ITable> m_table;
54};