コード例 #1
0
 private void button_start_Click(object sender, EventArgs e)
 {
     if (testStep == test_step.STOPPED)
     {
         button_start.Visible = false;
         testStep             = test_step.TEXTURE_IMAGES;
         screenState          = screen_states.COUNTDOWN;
         sequenceIndex        = 1;
         showCountDown(5);
         button_status.Focus();
     }
 }
コード例 #2
0
        // Constructor to pass the previous form as a parameter to use its thread for serial communication
        public TestProtocol(SpikesForm _telaSpikes)
        {
            InitializeComponent();
            telaSpikes = _telaSpikes;

            // Generate the 15 texture sequence
            generateSequence();

            testStep = test_step.STOPPED;
            Console.WriteLine(telaSpikes.th.IsAlive.ToString());
            telaSpikes.testProtocolOn = true;
        }
コード例 #3
0
        public TestProtocol(SpikesForm _telaSpikes)
        {
            InitializeComponent();
            telaSpikes = _telaSpikes;

            generateSequence();

            testStep = test_step.STOPPED;
            Console.WriteLine(telaSpikes.th.IsAlive.ToString());
            telaSpikes.testProtocolOn = true;
            initThreadProgBar();
            increment_progBar.Start();
            increment_progBar.Suspend();
        }
コード例 #4
0
        /*
         * Event called whrn the button 'Start' is pressed.
         * It changes the system's states in order to start the protocol.
         */
        private void button_start_Click(object sender, EventArgs e)
        {
            if (testStep == test_step.STOPPED)
            {
                button_start.Visible = false;                    // Hide the button
                testStep             = test_step.TEXTURE_IMAGES; // Change the stimulation state
                screenState          = screen_states.COUNTDOWN;  // Change the screen state
                sequenceIndex        = 1;                        // Set the first texture of the sequence
                updateTexture(sequenceIndex);                    // Transfer the spike data to uC
                showCountDown(5);                                // Start the countdown

                button_status.Focus();                           // Focus on a hidden button
            }
        }
コード例 #5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            switch (screenState)
            {
            case screen_states.COUNTDOWN:
                countdown--;
                if (countdown == 0)
                {
                    timer1.Stop();

                    if (testStep == test_step.TEXTURE_IMAGES)
                    {
                        label_countDown.Visible = false;
                        screenState             = screen_states.IMAGE;
                        showTextures();
                    }
                    else if (testStep == test_step.WAITING_FOR_START)
                    {
                        testStep = test_step.STIMULATION_ON;
                        Console.WriteLine("Before start");
                        startStimulation();
                        Console.WriteLine("Started");
                    }
                    else if (testStep == test_step.STIMULATION_ON)
                    {
                        startStimulation();
                    }

                    break;
                }
                label_countDown.Text = countdown.ToString();
                break;

            case screen_states.IMAGE:

                if (sequenceIndex == 3)
                {
                    sequenceIndex = 0;
                    timer1.Stop();
                    testStep = test_step.WAITING_FOR_START;
                    pictureBox_textura.Image = null;
                    screenState = screen_states.COUNTDOWN;
                    showCountDown(10);
                    sequenceIndex = 0;
                    updateTexture();

                    break;
                }

                timer1.Stop();
                timer1.Enabled           = false;
                screenState              = screen_states.COUNTDOWN;
                pictureBox_textura.Image = null;
                showCountDown(5);
                sequenceIndex++;
                break;

            case screen_states.CROSS:

                endStimulation(false);

                break;
            }
        }
コード例 #6
0
        /*
         * The function called each time a tick occurs in the timer1
         *
         * If the screen is in COUNTDOWN state, it decreases the 'countdown' variable each tick.
         * When it reached 0, it starts an stimulation according to the 'test_step' state
         *
         * If the screen is in IMAGE state, it removes the image from the screen and restart the countdown
         */
        private void timer1_Tick(object sender, EventArgs e)
        {
            switch (screenState)
            {
            // COUNTDOWN is the screen state where the screen is black
            case screen_states.COUNTDOWN:
                countdown--;
                if (countdown == 0)
                {
                    timer1.Stop();
                    if (testStep == test_step.TEXTURE_IMAGES) // Step of showing the textures with images
                    {
                        screenState = screen_states.IMAGE;    // Change the scren state
                        startStimulation();                   // Start the stimulation with the texture image
                        showTextures();                       // Show the texture image
                    }

                    // After showing images and before starting the 15 stimualtions sequence
                    else if (testStep == test_step.WAITING_FOR_START)
                    {
                        testStep = test_step.STIMULATION_ON; // Change test step
                        Console.WriteLine("Before start");
                        startStimulation();                  // Start the first stimulation of the 15 sequence
                        Console.WriteLine("Started");
                    }

                    // The 15 sequence has already started
                    else if (testStep == test_step.STIMULATION_ON)
                    {
                        startStimulation();
                    }
                    break;
                }
                break;

            case screen_states.IMAGE:       // When showing the texture images
                endStimulation(false);      // Stop the stimulation

                // If it is the last image, pass to the next step of the protocol
                if (sequenceIndex == 3)
                {
                    sequenceIndex = 0;                      // Reset the sequence
                    timer1.Stop();
                    testStep = test_step.WAITING_FOR_START; // Chenge the protocol step
                    pictureBox_textura.Image = null;        // Removes the image from the screen
                    screenState = screen_states.COUNTDOWN;  // Updates the screen state
                    showCountDown(10);                      // Start a 10 seconds countdown
                    sequenceIndex = 0;
                    updateTexture(0);                       // Load the texture into the uC
                    break;
                }

                // If its not the last image, set a  seconds countdown before the next image
                timer1.Stop();
                timer1.Enabled           = false;
                screenState              = screen_states.COUNTDOWN;
                pictureBox_textura.Image = null;
                updateTexture(sequenceIndex);
                showCountDown(5);
                sequenceIndex++;
                break;


            case screen_states.CROSS:       // The 15 sequence stimulations
                endStimulation(false);      // Stop the stimulation and prepare for the next
                break;
            }
        }