DutyCycleEncoder: Set ownsDutyCycle for channel constructor (#2436)

Also close dutyCycle before closing digitalInput.
This commit is contained in:
Peter Johnson
2020-03-21 10:36:31 -07:00
committed by GitHub
parent 35b236651e
commit 184fae4ba5

View File

@@ -41,6 +41,7 @@ public class DutyCycleEncoder implements Sendable, AutoCloseable {
*/
public DutyCycleEncoder(int channel) {
m_digitalInput = new DigitalInput(channel);
m_ownsDutyCycle = true;
m_dutyCycle = new DutyCycle(m_digitalInput);
init();
}
@@ -218,12 +219,12 @@ public class DutyCycleEncoder implements Sendable, AutoCloseable {
if (m_analogTrigger != null) {
m_analogTrigger.close();
}
if (m_digitalInput != null) {
m_digitalInput.close();
}
if (m_ownsDutyCycle) {
m_dutyCycle.close();
}
if (m_digitalInput != null) {
m_digitalInput.close();
}
if (m_simDevice != null) {
m_simDevice.close();
}