Beispiel #1
0
        private void btnStartStop_Click(object sender, EventArgs e)
        {
            // If we are already streaming, end the stream and thread
            if (streamRunning)
            {
                instellingenToolStripMenuItem.Enabled = true;
                gbxInstellingen.Enabled = true;
                // Tell the user that we are busy because
                // we have to wait for the thread to close
                btnStartStop.Text    = "Wachten...";
                btnStartStop.Enabled = false;
                Update();

                // Stop the stream
                streamRunning = false;
                streamThread.Join(); // Wait for the thread to close
                stopStreaming();

                //stop grafiek
                frmGrafiek.blMagVanMain = false;
                frmGrafiek.Reset();

                // Reconfigure start button
                btnStartStop.Text    = "Start";
                btnStartStop.Enabled = true;

                //set grafiek tool strip menu
                grafiekToolStripMenuItem.Checked = frmGrafiek.Visible;
            }

            // Otherwise, start the stream and thread
            else
            {
                refreshSettings();
                instellingenToolStripMenuItem.Enabled = false;
                //grafiek form opnieuw instellen
                if (frmGrafiek != null)
                {
                    frmGrafiek.Close();
                }
                frmGrafiek = new frmGraph(metingInfo.aantalGeselecteerdeKanalen, ref metingInfo.sampleFrequentie, ref dataChannel, ref metingInfo.delayms,
                                          metingInfo.blIsHetKanaalGeselecteerd);
                //grafiek mag worden getekend
                frmGrafiek.blMagVanMain = true;
                //grafiek laten zien
                if (grafiekToolStripMenuItem.Checked)
                {
                    frmGrafiek.Show();
                }

                // Set up the stream
                if (metingInfo.aantalGeselecteerdeKanalen == 0)
                {
                    MessageBox.Show("Geen kanalen geselecteerd.");
                }
                else if (u3 != null && StartStreaming())
                {
                    streamRunning           = true;
                    gbxInstellingen.Enabled = false;

                    // Start stream thread
                    streamThread              = new Thread(new ThreadStart(MakeReadings));
                    streamThread.Priority     = ThreadPriority.AboveNormal;
                    streamThread.IsBackground = false;
                    streamThread.Start();

                    // Reconfigure start button
                    btnStartStop.Text = "Stop";
                }
            }
        }
Beispiel #2
0
        private void btnStartStop_Click(object sender, EventArgs e)
        {
            // If we are already streaming, end the stream and thread
            if (streamRunning)
            {
                instellingenToolStripMenuItem.Enabled = true;
                gbxInstellingen.Enabled = true;
                // Tell the user that we are busy because
                // we have to wait for the thread to close
                btnStartStop.Text = "Wachten...";
                btnStartStop.Enabled = false;
                Update();

                // Stop the stream
                streamRunning = false;
                streamThread.Join(); // Wait for the thread to close
                stopStreaming();

                //stop grafiek
                frmGrafiek.blMagVanMain = false;
                frmGrafiek.Reset();

                // Reconfigure start button
                btnStartStop.Text = "Start";
                btnStartStop.Enabled = true;

                //set grafiek tool strip menu
                 grafiekToolStripMenuItem.Checked = frmGrafiek.Visible;
            }

            // Otherwise, start the stream and thread
            else
            {
                refreshSettings();
                instellingenToolStripMenuItem.Enabled = false;
                //grafiek form opnieuw instellen
                if (frmGrafiek != null)
                    frmGrafiek.Close();
                frmGrafiek = new frmGraph(metingInfo.aantalGeselecteerdeKanalen, ref metingInfo.sampleFrequentie, ref dataChannel, ref metingInfo.delayms,
                    metingInfo.blIsHetKanaalGeselecteerd);
                //grafiek mag worden getekend
                frmGrafiek.blMagVanMain = true;
                //grafiek laten zien
                if (grafiekToolStripMenuItem.Checked)
                    frmGrafiek.Show();

                // Set up the stream
                if (metingInfo.aantalGeselecteerdeKanalen == 0)
                    MessageBox.Show("Geen kanalen geselecteerd.");
                else if (u3 != null  && StartStreaming())
                {
                    streamRunning = true;
                    gbxInstellingen.Enabled = false;

                    // Start stream thread
                    streamThread = new Thread(new ThreadStart(MakeReadings));
                    streamThread.Priority = ThreadPriority.AboveNormal;
                    streamThread.IsBackground = false;
                    streamThread.Start();

                    // Reconfigure start button
                    btnStartStop.Text = "Stop";
                }
            }
        }