From 8274a14ebc5bf003628c43586f0454c0a18931b9 Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Sat, 6 Apr 2013 18:56:55 -0400 Subject: [PATCH] RHD2000Editor can no longer enable/disable headstages while acquisition is active --- Builds/Linux/Makefile | 6 +++--- Source/Processors/DataThreads/RHD2000Thread.cpp | 15 +++++++++++---- Source/Processors/DataThreads/RHD2000Thread.h | 6 +++++- Source/Processors/Editors/GenericEditor.cpp | 5 ++++- Source/Processors/Editors/GenericEditor.h | 4 ++++ Source/Processors/Editors/RHD2000Editor.cpp | 12 ++++++++---- open-ephys.jucer | 2 +- 7 files changed, 36 insertions(+), 14 deletions(-) diff --git a/Builds/Linux/Makefile b/Builds/Linux/Makefile index 3998a067c..f3527e8da 100644 --- a/Builds/Linux/Makefile +++ b/Builds/Linux/Makefile @@ -17,12 +17,12 @@ ifeq ($(CONFIG),Debug) LIBDIR := build OBJDIR := build/intermediate/Debug OUTDIR := build - CPPFLAGS := $(DEPFLAGS) -D "LINUX=1" -D "DEBUG=1" -D "_DEBUG=1" -D "JUCER_LINUX_MAKE_7346DA2A=1" -I /usr/include -I /usr/include/freetype2 -I ../../JuceLibraryCode - CFLAGS += $(CPPFLAGS) $(TARGET_ARCH) -g -ggdb -O0 + CPPFLAGS := $(DEPFLAGS) -D "LINUX=1" -D "NDEBUG=1" -D "JUCER_LINUX_MAKE_7346DA2A=1" -I /usr/include -I /usr/include/freetype2 -I ../../JuceLibraryCode + CFLAGS += $(CPPFLAGS) $(TARGET_ARCH) -O3 CXXFLAGS += $(CFLAGS) -export-dynamic -g -pg LDFLAGS += -L$(BINDIR) -L$(LIBDIR) -L/usr/X11R6/lib/ -lGL -lX11 -lXext -lXinerama -lasound -ldl -lfreetype -lpthread -lrt -lftdi -lftgl -pg -ldl -lXext LDDEPS := - RESFLAGS := -D "LINUX=1" -D "DEBUG=1" -D "_DEBUG=1" -D "JUCER_LINUX_MAKE_7346DA2A=1" -I /usr/include -I /usr/include/freetype2 -I ../../JuceLibraryCode + RESFLAGS := -D "LINUX=1" -D "NDEBUG=1" -D "JUCER_LINUX_MAKE_7346DA2A=1" -I /usr/include -I /usr/include/freetype2 -I ../../JuceLibraryCode TARGET := open-ephys BLDCMD = $(CXX) -o $(OUTDIR)/$(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(TARGET_ARCH) endif diff --git a/Source/Processors/DataThreads/RHD2000Thread.cpp b/Source/Processors/DataThreads/RHD2000Thread.cpp index 70c6d38b9..59172015c 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.cpp +++ b/Source/Processors/DataThreads/RHD2000Thread.cpp @@ -24,7 +24,7 @@ #include "RHD2000Thread.h" #include "../SourceNode.h" -RHD2000Thread::RHD2000Thread(SourceNode* sn) : DataThread(sn) +RHD2000Thread::RHD2000Thread(SourceNode* sn) : DataThread(sn), isTransmitting(false) { evalBoard = new Rhd2000EvalBoard; dataBlock = new Rhd2000DataBlock(1); @@ -123,6 +123,10 @@ RHD2000Thread::~RHD2000Thread() } +bool RHD2000Thread::isAcquisitionActive() +{ + return isTransmitting; +} int RHD2000Thread::getNumChannels() { @@ -159,7 +163,7 @@ bool RHD2000Thread::foundInputSource() } -void RHD2000Thread::enableHeadstage(int hsNum, bool enabled) +bool RHD2000Thread::enableHeadstage(int hsNum, bool enabled) { evalBoard->enableDataStream(hsNum, enabled); @@ -179,6 +183,8 @@ void RHD2000Thread::enableHeadstage(int hsNum, bool enabled) std::cout << "Enabled data streams: " << evalBoard->getNumEnabledDataStreams() << std::endl; dataBuffer->resize(getNumChannels(), 10000); + + return true; } bool RHD2000Thread::isHeadstageEnabled(int hsNum) @@ -245,8 +251,7 @@ bool RHD2000Thread::startAcquisition() startThread(); - // isTransmitting = true; - // accumulator = 0; + isTransmitting = true; return true; } @@ -283,6 +288,8 @@ bool RHD2000Thread::stopAcquisition() int ledArray[8] = {1, 0, 0, 0, 0, 0, 0, 0}; evalBoard->setLedDisplay(ledArray); + isTransmitting = false; + return true; } diff --git a/Source/Processors/DataThreads/RHD2000Thread.h b/Source/Processors/DataThreads/RHD2000Thread.h index 14c8293bb..e1542d32e 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.h +++ b/Source/Processors/DataThreads/RHD2000Thread.h @@ -63,12 +63,14 @@ public: bool isHeadstageEnabled(int hsNum); - void enableHeadstage(int hsNum, bool enabled); + bool enableHeadstage(int hsNum, bool enabled); void setCableLength(int hsNum, float length); void setNumChannels(int hsNum, int nChannels); int getNumEventChannels(); + bool isAcquisitionActive(); + private: ScopedPointer<Rhd2000EvalBoard> evalBoard; @@ -84,6 +86,8 @@ private: int blockSize; + bool isTransmitting; + bool startAcquisition(); bool stopAcquisition(); diff --git a/Source/Processors/Editors/GenericEditor.cpp b/Source/Processors/Editors/GenericEditor.cpp index 215ad007d..9e16de9ef 100755 --- a/Source/Processors/Editors/GenericEditor.cpp +++ b/Source/Processors/Editors/GenericEditor.cpp @@ -37,7 +37,7 @@ GenericEditor::GenericEditor(GenericProcessor* owner, bool useDefaultParameterEd : AudioProcessorEditor(owner), desiredWidth(150), isFading(false), accumulator(0.0), drawerButton(0), channelSelector(0), - isSelected(false), isEnabled(true), tNum(-1) + isSelected(false), isEnabled(true), tNum(-1), acquisitionIsActive(false) { constructorInitialize(owner, useDefaultParameterEditors); } @@ -258,6 +258,8 @@ void GenericEditor::startAcquisition() } + acquisitionIsActive = true; + } void GenericEditor::stopAcquisition() @@ -273,6 +275,7 @@ void GenericEditor::stopAcquisition() } + acquisitionIsActive = false; } diff --git a/Source/Processors/Editors/GenericEditor.h b/Source/Processors/Editors/GenericEditor.h index ec14f362e..a2a092bf8 100755 --- a/Source/Processors/Editors/GenericEditor.h +++ b/Source/Processors/Editors/GenericEditor.h @@ -222,6 +222,9 @@ public: /** Stores the font used to display the editor's name. */ Font titleFont; + /** True if data acquisition has begun. */ + bool acquisitionIsActive; + protected: @@ -259,6 +262,7 @@ private: bool isSelected; bool isEnabled; + int tNum; /**initializing function Used to share constructor functions*/ diff --git a/Source/Processors/Editors/RHD2000Editor.cpp b/Source/Processors/Editors/RHD2000Editor.cpp index a10d65d6c..6b9d4428c 100644 --- a/Source/Processors/Editors/RHD2000Editor.cpp +++ b/Source/Processors/Editors/RHD2000Editor.cpp @@ -99,8 +99,11 @@ HeadstageOptionsInterface::~HeadstageOptionsInterface() void HeadstageOptionsInterface::buttonClicked(Button* button) { - if (~(board->isThreadRunning())) + + if (!(editor->acquisitionIsActive)) { + + //std::cout << "Acquisition is not active" << std::endl; if (isEnabled) { isEnabled = false; @@ -109,11 +112,12 @@ void HeadstageOptionsInterface::buttonClicked(Button* button) } board->enableHeadstage(hsNumber, isEnabled); - } - repaint(); + repaint(); - editor->getEditorViewport()->makeEditorVisible(editor, false, true); + editor->getEditorViewport()->makeEditorVisible(editor, false, true); + } + } // void HeadstageOptionsInterface::mouseUp(const MouseEvent& event) diff --git a/open-ephys.jucer b/open-ephys.jucer index 0acde5af3..1bcdb71a1 100644 --- a/open-ephys.jucer +++ b/open-ephys.jucer @@ -23,7 +23,7 @@ <LINUX_MAKE targetFolder="Builds/Linux" vstFolder="~/SDKs/vstsdk2.4" juceFolder="JuceLibraryCode" extraLinkerFlags="-lftdi -lftgl -pg -ldl -lXext" extraCompilerFlags="-export-dynamic -g -pg"> <CONFIGURATIONS> - <CONFIGURATION name="Debug" isDebug="1" optimisation="1" targetName="open-ephys" + <CONFIGURATION name="Debug" isDebug="0" optimisation="3" targetName="open-ephys" libraryPath="/usr/X11R6/lib/"/> <CONFIGURATION name="Release" isDebug="0" optimisation="3" targetName="open-ephys" libraryPath="/usr/X11R6/lib/"/> -- GitLab