Basic structure of a time based termination command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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