Skip to content

Instantly share code, notes, and snippets.

@Equinox-
Created March 10, 2013 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Equinox-/5127682 to your computer and use it in GitHub Desktop.
Save Equinox-/5127682 to your computer and use it in GitHub Desktop.
Basic structure of a time based termination command.
class CommandThing ... {
private:
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