Skip to content

Instantly share code, notes, and snippets.

@Equinox-
Created March 10, 2013 08:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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