Wrapper for Solenoid that turns off after delay

I remember seeing once while perusing other teams code in Github an implementation of a wrapper of DoubleSolenoid that, after turning on the Solenoid coils, would schedule a TimerTask to turn them back off so they were not always energized. It would also cancel the TimerTask if the solenoid where subsequently changed…

My students just wrote one that looks solid, but I wanted to look at an existing implementation to see if they missed anything.

Does anyone have a pointer to an existing implementation of such a thing?

See https://github.com/Mercury1089/2016-robot-code/blob/master/src/org/usfirst/frc/team1089/robot/DoubleSolShooter.java

thanks. has anyone seen one that leaves a DoubleSolenoid in kOff when done?

Found the one I was looking for; just needed fewer terms in the Google Search.

Team 2168: https://github.com/Team2168/2016_Main_Robot/blob/master/src/org/team2168/utils/MomentaryDoubleSolenoid.java

I’m the author of the linked class. Glad to see someone may be using it (even if only for reference).

We’ve kept it up to date each year in our utils package. Last public release was the 2017 baseline for your reference: https://github.com/Team2168/2017_Main_Robot/blob/develop/src/org/team2168/utils/MomentaryDoubleSolenoid.java

If you have any questions feel free to reach out, hopefully it’s clear from the comments how to use it, my email is in the header of the class source.