blob: 122a4396279bfbf3cdc851e7e873868a0851e611 [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
5/*----------------------------------------------------------------------------*/
6#pragma once
7
8#include "simulation/SimContinuousOutput.h"
9#include "LiveWindow/LiveWindowSendable.h"
10#include "tables/ITableListener.h"
11
12#include <memory>
13
14/**
15 * DoubleSolenoid class for running 2 channels of high voltage Digital Output
16 * (PCM).
17 *
18 * The DoubleSolenoid class is typically used for pneumatics solenoids that
19 * have two positions controlled by two separate channels.
20 */
21class DoubleSolenoid : public LiveWindowSendable, public ITableListener
22{
23public:
24 enum Value
25 {
26 kOff,
27 kForward,
28 kReverse
29 };
30
31 explicit DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel);
32 DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel, uint32_t reverseChannel);
33 virtual ~DoubleSolenoid();
34 virtual void Set(Value value);
35 virtual Value Get() const;
36
37 void ValueChanged(ITable* source, llvm::StringRef key,
38 std::shared_ptr<nt::Value> value, bool isNew) override;
39 void UpdateTable() override;
40 void StartLiveWindowMode() override;
41 void StopLiveWindowMode() override;
42 std::string GetSmartDashboardType() const override;
43 void InitTable(std::shared_ptr<ITable> subTable) override;
44 std::shared_ptr<ITable> GetTable() const override;
45
46private:
47 SimContinuousOutput* m_impl;
48 Value m_value;
49 bool m_reversed;
50
51 std::shared_ptr<ITable> m_table;
52};