[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:
Tyler Veness
2020-10-24 20:18:58 -07:00
committed by GitHub
parent 1e17e40868
commit 7ae8c7b247
5 changed files with 23 additions and 2 deletions

View File

@@ -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.
*

View File

@@ -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");
}