mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[sim] Use DutyCycleEncoder FPGA index for sim device number (#2803)
The source channel doesn't necessarily correspond with the HALSIM device index.
This commit is contained in:
@@ -236,6 +236,16 @@ public class DutyCycleEncoder implements Sendable, AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the FPGA index for the DutyCycleEncoder.
|
||||
*
|
||||
* @return the FPGA index
|
||||
*/
|
||||
@SuppressWarnings("AbbreviationAsWordInName")
|
||||
public int getFPGAIndex() {
|
||||
return m_dutyCycle.getFPGAIndex();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channel of the source.
|
||||
*
|
||||
|
||||
@@ -23,7 +23,7 @@ public class DutyCycleEncoderSim {
|
||||
* @param encoder DutyCycleEncoder to simulate
|
||||
*/
|
||||
public DutyCycleEncoderSim(DutyCycleEncoder encoder) {
|
||||
SimDeviceSim wrappedSimDevice = new SimDeviceSim("DutyCycleEncoder" + "[" + encoder.getSourceChannel() + "]");
|
||||
SimDeviceSim wrappedSimDevice = new SimDeviceSim("DutyCycleEncoder" + "[" + encoder.getFPGAIndex() + "]");
|
||||
m_simPosition = wrappedSimDevice.getDouble("Position");
|
||||
m_simDistancePerRotation = wrappedSimDevice.getDouble("DistancePerRotation");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user