Skip to content
Snippets Groups Projects
Commit 59060a54 authored by jsiegle's avatar jsiegle
Browse files

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.
parent b4a850ed
No related branches found
No related tags found
No related merge requests found
......@@ -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>
<?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>
......@@ -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);
}
//}
}
......
......@@ -62,6 +62,8 @@ private:
int sourceCheckInterval;
bool wasDisabled;
//const String name;
void timerCallback();
......
......@@ -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);}
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment