Implement PCM One Shot feature. Fixes artf4731 (#539)

This commit is contained in:
sciencewhiz
2017-11-26 12:55:21 -08:00
committed by Peter Johnson
parent a338ee8be0
commit 7a250a1b93
11 changed files with 297 additions and 1 deletions

View File

@@ -98,6 +98,30 @@ public class Solenoid extends SolenoidBase implements LiveWindowSendable {
return value != 0;
}
/**
* Set the pulse duration in the PCM. This is used in conjunction with
* the startPulse method to allow the PCM to control the timing of a pulse.
* The timing can be controlled in 0.01 second increments.
*
* @param durationSeconds The duration of the pulse, from 0.01 to 2.55 seconds.
*
* @see #startPulse()
*/
public void setPulseDuration(double durationSeconds) {
long durationMS = (long) (durationSeconds * 1000);
SolenoidJNI.setOneShotDuration(m_solenoidHandle, durationMS);
}
/**
* Trigger the PCM to generate a pulse of the duration set in
* setPulseDuration.
*
* @see #setPulseDuration()
*/
public void startPulse() {
SolenoidJNI.fireOneShot(m_solenoidHandle);
}
/*
* Live Window code, only does anything if live window is activated.
*/

View File

@@ -29,4 +29,8 @@ public class SolenoidJNI extends JNIWrapper {
public static native boolean getPCMSolenoidVoltageFault(int module);
public static native void clearAllPCMStickyFaults(int module);
public static native void setOneShotDuration(int portHandle, long durationMS);
public static native void fireOneShot(int portHandle);
}