From 59060a54be0ad2d7940947357ed53f5eabeacc8d Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Tue, 14 Feb 2012 17:55:04 -0500 Subject: [PATCH] Fixed bug in SourceNode The IntanThread was occasionally looking for data after acquisition was disabled, which would trigger the SourceNode to attempt to manually disable callbacks. The only negative effect of this was that if the user was currently viewing a different signal chain, it would switch back to the Intan chain unexpectedly. This is no longer the case, as the SourceNode checks to see whether or not it received a proper disable signal from the ProcessorGraph before notifying the UI that data may have been dropped. --- Builds/Linux/build/savedState.xml | 4 ++ Builds/Linux/build/windowState.xml | 2 +- Source/Processors/SourceNode.cpp | 28 ++++++++------ Source/Processors/SourceNode.h | 2 + .../Visualization/LfpDisplayCanvas.cpp | 38 +++++++++---------- .../Visualization/LfpDisplayCanvas.h | 2 +- 6 files changed, 43 insertions(+), 33 deletions(-) diff --git a/Builds/Linux/build/savedState.xml b/Builds/Linux/build/savedState.xml index f52f35a70..9e0844420 100644 --- a/Builds/Linux/build/savedState.xml +++ b/Builds/Linux/build/savedState.xml @@ -6,4 +6,8 @@ <PROCESSOR name="Filters/Bandpass Filter" insertionPoint="1"/> <PROCESSOR name="Sinks/LFP Viewer" insertionPoint="2"/> </SIGNALCHAIN> + <SIGNALCHAIN> + <PROCESSOR name="Sources/Signal Generator" insertionPoint="0"/> + <PROCESSOR name="Sinks/LFP Viewer" insertionPoint="1"/> + </SIGNALCHAIN> </PROCESSORGRAPH> diff --git a/Builds/Linux/build/windowState.xml b/Builds/Linux/build/windowState.xml index 0ef953c39..fbc6626a1 100644 --- a/Builds/Linux/build/windowState.xml +++ b/Builds/Linux/build/windowState.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <MAINWINDOW> - <BOUNDS x="484" y="308" w="899" h="753" fullscreen="0"/> + <BOUNDS x="1899" y="136" w="971" h="884" fullscreen="0"/> </MAINWINDOW> diff --git a/Source/Processors/SourceNode.cpp b/Source/Processors/SourceNode.cpp index 661273b58..ac4c431d6 100644 --- a/Source/Processors/SourceNode.cpp +++ b/Source/Processors/SourceNode.cpp @@ -16,7 +16,7 @@ SourceNode::SourceNode(const String& name_) : GenericProcessor(name_), dataThread(0), - sourceCheckInterval(1500) + sourceCheckInterval(750), wasDisabled(true) { if (getName().equalsIgnoreCase("Intan Demo Board")) { dataThread = new IntanThread(this); @@ -156,6 +156,8 @@ bool SourceNode::enable() { std::cout << "Source node received enable signal" << std::endl; + wasDisabled = false; + if (dataThread != 0) { if (dataThread->foundInputSource()) @@ -171,6 +173,8 @@ bool SourceNode::enable() { stopTimer(); + + // bool return_code = true; // if (getName().equalsIgnoreCase("Intan Demo Board")) { @@ -203,23 +207,23 @@ bool SourceNode::disable() { startTimer(2000); - // if (dataThread != 0) { - // delete dataThread; - // dataThread = 0; - // } + wasDisabled = true; return true; } void SourceNode::acquisitionStopped() { - if (!dataThread->foundInputSource()) { - std::cout << "Source node sending signal to UI." << std::endl; - UI->disableCallbacks(); - enabledState(false); - GenericEditor* ed = (GenericEditor*) getEditor(); - viewport->updateVisibleEditors(ed, 4); - } + //if (!dataThread->foundInputSource()) { + + if (!wasDisabled) { + std::cout << "Source node sending signal to UI." << std::endl; + UI->disableCallbacks(); + enabledState(false); + GenericEditor* ed = (GenericEditor*) getEditor(); + viewport->updateVisibleEditors(ed, 4); + } + //} } diff --git a/Source/Processors/SourceNode.h b/Source/Processors/SourceNode.h index 5605d2c49..7472e63bf 100644 --- a/Source/Processors/SourceNode.h +++ b/Source/Processors/SourceNode.h @@ -62,6 +62,8 @@ private: int sourceCheckInterval; + bool wasDisabled; + //const String name; void timerCallback(); diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.cpp b/Source/Processors/Visualization/LfpDisplayCanvas.cpp index fc7278df7..4745a7159 100644 --- a/Source/Processors/Visualization/LfpDisplayCanvas.cpp +++ b/Source/Processors/Visualization/LfpDisplayCanvas.cpp @@ -11,7 +11,7 @@ #include "LfpDisplayCanvas.h" LfpDisplayCanvas::LfpDisplayCanvas(LfpDisplayNode* n) : processor(n), - xBuffer(10), yBuffer(10), + xBuffer(0), yBuffer(10), plotHeight(60), selectedChan(-1), screenBufferIndex(0), timebase(1.0f), displayGain(5.0f), displayBufferIndex(0) { @@ -45,7 +45,7 @@ void LfpDisplayCanvas::newOpenGLContextCreated() setUp2DCanvas(); activateAntiAliasing(); - glClearColor (0.8, 0.8, 0.8, 1.0); + glClearColor (0.8, 0.8, 0.9, 1.0); resized(); screenBuffer = new AudioSampleBuffer(nChans, 10000); @@ -187,7 +187,7 @@ void LfpDisplayCanvas::renderOpenGL() if (checkBounds(i)) { setViewport(i); - drawBorder(isSelected); + //drawBorder(isSelected); drawChannelInfo(i,isSelected); drawWaveform(i,isSelected); } @@ -293,12 +293,12 @@ void LfpDisplayCanvas::drawChannelInfo(int chan, bool isSelected) alpha = 1.0f; glColor4f(0.0f,0.0f,0.0f,alpha); - glRasterPos2f(5.0f/getWidth(),0.3); - String s = String("Channel "); + glRasterPos2f(5.0f/getWidth(),0.9); + String s = "";//String("Channel "); s += (chan+1); - getFont(String("miso-regular"))->FaceSize(16); - getFont(String("miso-regular"))->Render(s); + getFont(String("cpmono-extra-light"))->FaceSize(35); + getFont(String("cpmono-extra-light"))->Render(s); } int LfpDisplayCanvas::getTotalHeight() @@ -307,23 +307,23 @@ int LfpDisplayCanvas::getTotalHeight() } -// void LfpDisplayCanvas::mouseDown(const MouseEvent& e) -// { +void LfpDisplayCanvas::mouseDown(const MouseEvent& e) +{ -// Point<int> pos = e.getPosition(); -// int xcoord = pos.getX(); + Point<int> pos = e.getPosition(); + int xcoord = pos.getX(); -// if (xcoord < getWidth()-getScrollBarWidth()) -// { -// int chan = (e.getMouseDownY() + getScrollAmount())/(yBuffer+plotHeight); + if (xcoord < getWidth()-getScrollBarWidth()) + { + int chan = (e.getMouseDownY() + getScrollAmount())/(yBuffer+plotHeight); -// selectedChan = chan; + selectedChan = chan; -// repaint(); -// } + repaint(); + } -// mouseDownInCanvas(e); -// } + mouseDownInCanvas(e); +} // void LfpDisplayCanvas::mouseDrag(const MouseEvent& e) {mouseDragInCanvas(e);} // void LfpDisplayCanvas::mouseMove(const MouseEvent& e) {mouseMoveInCanvas(e);} diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.h b/Source/Processors/Visualization/LfpDisplayCanvas.h index 5ed80dab5..ff39ca0c4 100644 --- a/Source/Processors/Visualization/LfpDisplayCanvas.h +++ b/Source/Processors/Visualization/LfpDisplayCanvas.h @@ -74,7 +74,7 @@ private: int getTotalHeight(); // void resized(); - // void mouseDown(const MouseEvent& e); + void mouseDown(const MouseEvent& e); // void mouseDrag(const MouseEvent& e); // void mouseMove(const MouseEvent& e); // void mouseUp(const MouseEvent& e); -- GitLab