Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constructor that takes channel number to DutyCycleEncoderSim #5118

Merged
merged 2 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

using namespace frc::sim;

DutyCycleEncoderSim::DutyCycleEncoderSim(const frc::DutyCycleEncoder& encoder) {
frc::sim::SimDeviceSim deviceSim{"DutyCycle:DutyCycleEncoder",
encoder.GetSourceChannel()};
DutyCycleEncoderSim::DutyCycleEncoderSim(const frc::DutyCycleEncoder& encoder)
: DutyCycleEncoderSim{encoder.GetSourceChannel()} {}

DutyCycleEncoderSim::DutyCycleEncoderSim(int channel) {
frc::sim::SimDeviceSim deviceSim{"DutyCycle:DutyCycleEncoder", channel};
m_simPosition = deviceSim.GetDouble("position");
m_simDistancePerRotation = deviceSim.GetDouble("distance_per_rot");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ class DutyCycleEncoderSim {
explicit DutyCycleEncoderSim(const DutyCycleEncoder& encoder);

/**
* Set the position tin turns.
* Constructs from a digital input channel.
*
* @param channel digital input channel
*/
explicit DutyCycleEncoderSim(int channel);

/**
* Set the position in turns.
*
* @param turns The position.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ public class DutyCycleEncoderSim {
* @param encoder DutyCycleEncoder to simulate
*/
public DutyCycleEncoderSim(DutyCycleEncoder encoder) {
SimDeviceSim wrappedSimDevice =
new SimDeviceSim("DutyCycle:DutyCycleEncoder" + "[" + encoder.getSourceChannel() + "]");
this(encoder.getSourceChannel());
}

/**
* Constructs from a digital input channel.
*
* @param channel digital input channel.
*/
public DutyCycleEncoderSim(int channel) {
SimDeviceSim wrappedSimDevice = new SimDeviceSim("DutyCycle:DutyCycleEncoder", channel);
m_simPosition = wrappedSimDevice.getDouble("position");
m_simDistancePerRotation = wrappedSimDevice.getDouble("distance_per_rot");
}
Expand Down