// FUNCTION: Start: Starts the Sequence // // public void Start() { Reset(); rstateCur = rstate.SeqStart; }
// FUNCTION: Step: Sequencer the State Machine // // public bool Step(RecParam recparam, bool fCathodeDetected) { bool fRecord = false; switch (rstateCur) { // Start of sequence case rstate.SeqStart: cDelay1 = 2; cDelay2 = 2; rstateCur = rstate.NoCathodeDetect; break; // Waiot for cathode case rstate.NoCathodeDetect: if (!fCathodeDetected) // Does sensor see a cathode? { rstateCur = rstate.Delay1; // no - go to next state } break; // First delay case rstate.Delay1: // Check delay counter if (cDelay1 >= recparam.nDelay1) // Counter passed require time? { rstateCur = rstate.CathodeDetect; // yes - go to next state } else { cDelay1++; // nope - increment } break; // Wait for motion case rstate.CathodeDetect: if (fCathodeDetected) // Does sensor see a cathode? { rstateCur = rstate.Delay2; // no - go to next state } break; case rstate.Delay2: // Check delay counter if (cDelay2 >= recparam.nDelay2) // Counter passed require time? { rstateCur = rstate.Record; // yes - go to next state } else { cDelay2++; // nope - increment } break; case rstate.Record: // Record the image rstateCur = rstate.SeqStart; fRecord = true; break; default: //MessageBox.Show("State Machine Failure", "Goddabug"); //System.Diagnostics.Debugger.Break(); break; } return(fRecord); }
// FUNCTION: Reset: Reset the State Machine // // Reset state and state timing counters. // // public void Reset() { rstateCur = rstate.Off; cDelay1 = 0; cDelay2 = 0; }