-
Notifications
You must be signed in to change notification settings - Fork 634
/
Copy pathSolenoidSim.cpp
60 lines (45 loc) · 1.71 KB
/
SolenoidSim.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 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.
#include "frc/simulation/SolenoidSim.h"
#include <memory>
#include <utility>
#include "frc/PneumaticsBase.h"
using namespace frc;
using namespace frc::sim;
SolenoidSim::SolenoidSim(std::shared_ptr<PneumaticsBaseSim> moduleSim,
int channel)
: m_module{std::move(moduleSim)}, m_channel{channel} {}
SolenoidSim::SolenoidSim(int module, PneumaticsModuleType type, int channel)
: m_module{PneumaticsBaseSim::GetForType(module, type)},
m_channel{channel} {}
SolenoidSim::SolenoidSim(PneumaticsModuleType type, int channel)
: m_module{PneumaticsBaseSim::GetForType(
PneumaticsBase::GetDefaultForType(type), type)},
m_channel{channel} {}
bool SolenoidSim::GetOutput() const {
return m_module->GetSolenoidOutput(m_channel);
}
void SolenoidSim::SetOutput(bool output) {
m_module->SetSolenoidOutput(m_channel, output);
}
bool SolenoidSim::IsOn() {
return m_module->GetSolenoidOutput(m_channel);
}
bool SolenoidSim::IsOff() {
return !m_module->GetSolenoidOutput(m_channel);
}
void SolenoidSim::SetOn() {
m_module->SetSolenoidOutput(m_channel, true);
}
void SolenoidSim::SetOff() {
m_module->SetSolenoidOutput(m_channel, false);
}
std::unique_ptr<CallbackStore> SolenoidSim::RegisterOutputCallback(
NotifyCallback callback, bool initialNotify) {
return m_module->RegisterSolenoidOutputCallback(m_channel, callback,
initialNotify);
}
std::shared_ptr<PneumaticsBaseSim> SolenoidSim::GetModuleSim() const {
return m_module;
}