/* * Stop the stimulation. * If it is in the CROSS state, it records the arrow pressed (if there was any) and in the last stimulation * of the sequece it calls the function that generates the results file */ private void endStimulation(bool arrowPressed) { if (screenState == screen_states.CROSS) { elapedTime[textureSeqIndex] = interval.ElapsedMilliseconds; // Save the elapsed time on this texture // Stop the timer and the Stopwatch interval.Stop(); interval.Reset(); timer1.Stop(); } Random rand; telaSpikes.ESPSerial.WriteLine(Protocolos.parar); // Send the command to stop the stimulation serial_States = serial_states.STOPPED; // Change the serial state to STOPPED label_countDown.Visible = false; if (screenState == screen_states.CROSS) { // Records the pressed key in the arrowPressedArr array if (arrowPressed) { arrowPressedArr[textureSeqIndex] = pressedKey; } else { arrowPressedArr[textureSeqIndex] = "NULL"; } // In the last position of the sequence, it generates the results file if (textureSeqIndex >= (texSequence.Length - 1)) { label_countDown.Text = "STOP"; finishProtocol(); } else // Set a new countdown before the next stimulation { textureSeqIndex++; rand = new Random(); showCountDown(rand.Next(5, 8)); updateTexture(0); // Update the texture in the uC } } }
private void checkSerialState() { switch (telaSpikes.stateProtocol) { case 0: serial_States = serial_states.STOPPED; break; case 1: serial_States = serial_states.INITIATED; break; case 2: serial_States = serial_states.UPDATED; break; case 3: serial_States = serial_states.IDLE; break; } }
private void endStimulation(bool arrowPressed) { elapedTime[textureSeqIndex] = interval.ElapsedMilliseconds; // Save the elapsed time on this texture telaSpikes.ESPSerial.WriteLine(Protocolos.parar); // Send the command to stop the stimulation serial_States = serial_states.STOPPED; // Chante de serial state to STOPPED // Stop the timer and the Stopwatch interval.Stop(); interval.Reset(); timer1.Stop(); button_status.BackColor = Color.Green; label_countDown.Text = "STOP"; if (arrowPressed) { arrowPressedArr[textureSeqIndex] = pressedKey; } else { arrowPressedArr[textureSeqIndex] = "NULL"; } increment_progBar.Suspend(); progressBar_cross.Visible = false; if (textureSeqIndex >= (texSequence.Length - 1)) { finishProtocol(); } else { textureSeqIndex++; showCountDown(5); updateTexture(); } }