/// <summary> /// Enables or disables debug mode. /// </summary> /// <param name="enable">Whether to enable or not.</param> /// <returns>True, if the mode has the desired value at the end of the function.</returns> public bool SetDebugMode(bool enable) { if (impl.nonDebugNonGuiExitOnError) { return(true); } if (enable) { if (impl.curShellProcEnv == null) { impl.errOut.WriteLine("Debug mode will be enabled as soon as a graph has been created!"); pendingDebugEnable = true; return(false); } if (InDebugMode && CheckDebuggerAlive()) { impl.errOut.WriteLine("You are already in debug mode!"); return(true); } Dictionary <String, String> optMap; impl.debugLayoutOptions.TryGetValue(impl.debugLayout, out optMap); try { debugger = new Debugger(this, impl.curShellProcEnv, impl.realizers, impl.debugLayout, optMap, impl.detailModePreMatchEnabled, impl.detailModePostMatchEnabled); impl.curShellProcEnv.ProcEnv.UserProxy = debugger; } catch (Exception ex) { if (ex.Message != "Connection to yComp lost") { impl.errOut.WriteLine(ex.Message); } return(false); } pendingDebugEnable = false; } else { if (impl.curShellProcEnv == null && pendingDebugEnable) { impl.debugOut.WriteLine("Debug mode will not be enabled anymore when a graph has been created."); pendingDebugEnable = false; return(true); } if (!InDebugMode) { impl.errOut.WriteLine("You are not in debug mode!"); return(true); } impl.curShellProcEnv.ProcEnv.UserProxy = null; debugger.Close(); debugger = null; } return(true); }
static int Close(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); Debugger.Close(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
//Called after data acq. is complete, resets buttons and stops tasks. private void reset() { // Disable asychronous activity taskRunning = false; // Start by resetting the hardware settings UpdateRecordingSettings(); //Grab display gains for later use if (spikePlotData != null) { if (spikePlotData.getGain() != null) { Properties.Settings.Default.SpikeDisplayGain = spikePlotData.getGain(); } } if (Properties.Settings.Default.UseLFPs & (lfpPlotData != null)) { Properties.Settings.Default.LFPDisplayGain = lfpPlotData.getGain(); } if (waveformPlotData != null) { if (waveformPlotData.getGain() != null) { Properties.Settings.Default.SpkWfmDisplayGain = waveformPlotData.getGain(); } } Console.WriteLine("reset: gains saved"); if (triggerWriter != null) { byte[] b_array = new byte[3] { 0, 0, 0 }; DigitalWaveform wfm = new DigitalWaveform(3, 8, DigitalState.ForceDown); wfm = NationalInstruments.DigitalWaveform.FromPort(b_array); triggerTask = new Task("TriggerTask"); triggerTask.DOChannels.CreateChannel(Properties.Settings.Default.CineplexDevice + "/Port0/line0:7", "", ChannelLineGrouping.OneChannelForAllLines); triggerWriter = new DigitalSingleChannelWriter(triggerTask.Stream); triggerWriter.WriteWaveform(true, wfm); triggerTask.WaitUntilDone(); } Console.WriteLine("reset: trigger cleared"); // Kill the background workers lock (this) { Console.WriteLine("reset: entered lock"); if (bwSpikes != null) { try { for (int i = 0; i < bwSpikes.Count; ++i) { //block while bw finishes if (bwSpikes[i] != null) { Console.WriteLine("reset: " + bwSpikes[i].ToString() + " " + i.ToString() + "is busy"); while (bwSpikes[i].IsBusy) { Application.DoEvents(); } Console.WriteLine("reset: " + bwSpikes[i].ToString() + " " + i.ToString() + "finished"); } } } catch { Console.WriteLine("reset: error while clearing spike tasks"); //All the bw workers are done, so we'll kill them for (int i = 0; i < bwSpikes.Count; ++i) { bwSpikes[i].Dispose(); } bwSpikes.Clear(); bwSpikes = null; } } Console.WriteLine("reset: left lock"); } Console.WriteLine("reset: spike tasks cleared"); if (waveformPlotData != null) { waveformPlotData.stop(); } if (Properties.Settings.Default.SeparateLFPBoard && lfpTask != null) { lfpTask.Dispose(); } if (Properties.Settings.Default.UseEEG && eegTask != null) { eegTask.Dispose(); } if (BNCOutput != null) { BNCOutput.Dispose(); BNCOutput = null; } if (stimTimeTask != null) { stimTimeTask.Dispose(); } if (triggerTask != null) { triggerTask.Dispose(); } if (auxAnInTask != null) { auxAnInTask.Dispose(); } if (auxDigInTask != null) { auxDigInTask.Dispose(); } Console.WriteLine("reset: tasks disposed of"); buttonStop.Enabled = false; buttonStart.Enabled = true; spikeDet.numPreSamples.Enabled = true; spikeDet.numPostSamples.Enabled = true; settingsToolStripMenuItem.Enabled = true; button_Train.Enabled = true; button_SetRecordingStreams.Enabled = true; switch_record.Enabled = true; //processingSettingsToolStripMenuItem.Enabled = true; button_startStimFromFile.Enabled = true; button_startClosedLoopStim.Enabled = true; //numericUpDown_NumSnipsDisplayed.Enabled = true; button_stopClosedLoopStim.Enabled = false; button_startClosedLoopStim.Enabled = true; checkBox_SALPA.Enabled = true; Console.WriteLine("reset: gui updated"); // Clean up data streams recordingSettings.Flush(); Console.WriteLine("reset: recording streams flushed"); if (triggerWriter != null) { triggerWriter = null; } channelOut.Enabled = Properties.Settings.Default.UseSingleChannelPlayback; led_recording.OnColor = Color.Lime; if (!button_startStimFromFile.Enabled) { button_startStimFromFile.Enabled = true; } //debugger if (Debugger != null) { Debugger.Close(); Debugger = null; } timer_timeElapsed.Enabled = false; Console.WriteLine("Reset Complete"); }