Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Basic structure of a time based termination command.
class CommandThing ... {
long startTime;
//classy stuff
void CommandThing::Initialize() {
startTime = GetFPGATime(); // Get a reference point
void CommandThing::Execute() {
if (startTime+delay<GetFPGATime()) { // Check to see if 'delay' is passed.
pneumatic->Set(Solenoid::kReverse); // If so, start disarming
} else {
pneumatic->Set(Solenoid::kForward); // Otherwise, keep arming
bool CommandThing::IsFinished() {
return startTime+delay<GetFPGATime() && microSwitchActive; // Check if the delay is passed, and the switch is active.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment