/// <summary> /// Starts the test /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StartTest(object sender=null, EventArgs e=null) { _testAborted = false; NetMessage msg = new NetMessage(); // Get number of samples for this test _samplesRequested = MaxSamples; // Start running the test _dataReader.RunWorkerAsync(); // Blank/hide the plots ResetTest(); // Tell the chip to START the test if (SendCommand(Command.Start, new[] {(byte)samplerate.SelectedIndex})) { // Configure buttons and notify client RunButton.Enabled = false; ResetButton.Enabled = true; StopButton.Enabled = true; laRunning.Visible = true; laStopped.Visible = false; msg.AddMessage("buttonRun", ControlProperties.Enabled, "false"); msg.AddMessage("buttonReset", ControlProperties.Enabled, "true"); msg.AddMessage("buttonStop", ControlProperties.Enabled, "true"); _nc.SendMessage(msg); } else if (_generateFakeData) { // If we're faking data, configure buttons and notify the client RunButton.Enabled = false; ResetButton.Enabled = true; StopButton.Enabled = true; laRunning.Visible = true; laStopped.Visible = false; msg.AddMessage("buttonRun", ControlProperties.Enabled, "false"); msg.AddMessage("buttonReset", ControlProperties.Enabled, "true"); msg.AddMessage("buttonStop", ControlProperties.Enabled, "true"); _nc.SendMessage(msg); } }
/// <summary> /// Clears the test output and resets buttons /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ResetTest(object sender=null, EventArgs e=null) { NetMessage msg = new NetMessage(); if (_fc.IsConnected || _generateFakeData) msg.AddMessage("buttonRun", ControlProperties.Enabled, "true"); else msg.AddMessage("buttonRun", ControlProperties.Enabled, "false"); msg.AddMessage("buttonReset", ControlProperties.Enabled, "true"); msg.AddMessage("buttonStop", ControlProperties.Enabled, "false"); _nc.SendMessage(msg); if (sender == null) return; // Blank out the charts if we hit the reset button SetupChart(refa2, 0); SetupChart(chart2, 1); SetupChart(chart3, 2); SetupChart(chart4, 3); SetupChart(chart5, 4); SetupChart(chart6, 5); SetupChart(chart7, 6); /*refa2.Series[0].Points.AddXY(-1, -1); chart2.Series[0].Points.AddXY(-1, -1); chart3.Series[0].Points.AddXY(-1, -1); chart4.Series[0].Points.AddXY(-1, -1); chart5.Series[0].Points.AddXY(-1, -1); chart6.Series[0].Points.AddXY(-1, -1); chart7.Series[0].Points.AddXY(-1, -1);*/ _samplesReceived = 0; }
private void DataComplete(object sender, RunWorkerCompletedEventArgs e) { // Called when data is displayed. NOTICE: Executes in MAIN THREAD. _testAborted = true; NetMessage msg = new NetMessage(); RunButton.Enabled = _fc.IsConnected || _generateFakeData; StopButton.Enabled = false; ResetButton.Enabled = true; laRunning.Visible = false; laStopped.Visible = true; if (_fc.IsConnected || _generateFakeData) msg.AddMessage("buttonRun", ControlProperties.Enabled, "true"); else msg.AddMessage("buttonRun", ControlProperties.Enabled, "false"); msg.AddMessage("buttonReset", ControlProperties.Enabled, "true"); msg.AddMessage("buttonStop", ControlProperties.Enabled, "false"); _nc.SendMessage(msg); }
private void Disconnect(object sender, EventArgs e) { _fc.Disconnect(); if (!_fc.IsConnected) { NetMessage msg = new NetMessage(); RunButton.Enabled = false; ResetButton.Enabled = true; StopButton.Enabled = false; laRunning.Visible = false; laStopped.Visible = true; msg.AddMessage("buttonRun", ControlProperties.Enabled, "false"); msg.AddMessage("buttonReset", ControlProperties.Enabled, "true"); msg.AddMessage("buttonStop", ControlProperties.Enabled, "false"); ConnectButton.Enabled = true; DisconnectButton.Enabled = false; } }
/// <summary> /// Halts the test (after receiving the currently buffered data) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AbortTest(object sender = null, EventArgs e = null) { NetMessage msg = new NetMessage(); ResetTest(); if (!_generateFakeData) { SendCommand(Command.Stop); } _testAborted = true; _fc.StopWaiting(); RunButton.Enabled = _fc.IsConnected || _generateFakeData; ResetButton.Enabled = true; StopButton.Enabled = false; laRunning.Visible = false; laStopped.Visible = true; if (_fc.IsConnected || _generateFakeData) msg.AddMessage("buttonRun", ControlProperties.Enabled, "true"); else msg.AddMessage("buttonRun", ControlProperties.Enabled, "false"); msg.AddMessage("buttonReset", ControlProperties.Enabled, "true"); msg.AddMessage("buttonStop", ControlProperties.Enabled, "false"); _nc.SendMessage(msg); }