From 33c968959752ead5c996f9aa3c37eddad0c1151d Mon Sep 17 00:00:00 2001 From: Aaron Cuevas Lopez <aacuelo@teleco.upv.es> Date: Fri, 27 Feb 2015 17:41:24 +0100 Subject: [PATCH] Enable again the selection of 16/32ch on 32channel chip --- Builds/VisualStudio2013/open-ephys.vcxproj | 2 +- .../Processors/DataThreads/RHD2000Editor.cpp | 12 +++---- .../Processors/DataThreads/RHD2000Thread.cpp | 33 +++++++++++++++---- Source/Processors/DataThreads/RHD2000Thread.h | 6 +++- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/Builds/VisualStudio2013/open-ephys.vcxproj b/Builds/VisualStudio2013/open-ephys.vcxproj index eb042ca25..91cf93148 100644 --- a/Builds/VisualStudio2013/open-ephys.vcxproj +++ b/Builds/VisualStudio2013/open-ephys.vcxproj @@ -87,7 +87,7 @@ <Optimization>Disabled</Optimization> <DebugInformationFormat>EditAndContinue</DebugInformationFormat> <AdditionalIncludeDirectories>..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;../../Resources/windows-libs/HDF5/include;../../Resources/windows-libs/ZeroMQ/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;_WINDOWS;DEBUG;_DEBUG;NOMINMAX;ZEROMQ;JUCER_VS2013_78A5020=1;JUCE_APP_VERSION=0.3.4;JUCE_APP_VERSION_HEX=0x304;ECUBE_COMPILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>WIN32;_WINDOWS;DEBUG;_DEBUG;NOMINMAX;ZEROMQ;JUCER_VS2013_78A5020=1;JUCE_APP_VERSION=0.3.4;JUCE_APP_VERSION_HEX=0x304;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeTypeInfo>true</RuntimeTypeInfo> <PrecompiledHeader /> diff --git a/Source/Processors/DataThreads/RHD2000Editor.cpp b/Source/Processors/DataThreads/RHD2000Editor.cpp index 8769ec79e..a5b932184 100644 --- a/Source/Processors/DataThreads/RHD2000Editor.cpp +++ b/Source/Processors/DataThreads/RHD2000Editor.cpp @@ -1230,11 +1230,11 @@ void HeadstageOptionsInterface::checkEnabledState() void HeadstageOptionsInterface::buttonClicked(Button* button) { - /* if (!(editor->acquisitionIsActive) && board->foundInputSource()) + if (!(editor->acquisitionIsActive) && board->foundInputSource()) { //std::cout << "Acquisition is not active" << std::endl; - if (button == hsButton1) + if ((button == hsButton1) && (board->getChannelsInHeadstage(hsNumber1))) { if (channelsOnHs1 == 32) channelsOnHs1 = 16; @@ -1246,11 +1246,11 @@ void HeadstageOptionsInterface::buttonClicked(Button* button) hsButton1->setLabel(String(channelsOnHs1)); board->setNumChannels(hsNumber1, channelsOnHs1); - // board->updateChannelNames(); + board->updateChannelNames(); editor->updateSettings(); } - else if (button == hsButton2) + else if ((button == hsButton2) && (board->getChannelsInHeadstage(hsNumber2))) { if (channelsOnHs2 == 32) channelsOnHs2 = 16; @@ -1259,13 +1259,13 @@ void HeadstageOptionsInterface::buttonClicked(Button* button) hsButton2->setLabel(String(channelsOnHs2)); board->setNumChannels(hsNumber2, channelsOnHs2); - // board->updateChannelNames(); + board->updateChannelNames(); editor->updateSettings(); } editor->getEditorViewport()->makeEditorVisible(editor, false, true); - }*/ + } } diff --git a/Source/Processors/DataThreads/RHD2000Thread.cpp b/Source/Processors/DataThreads/RHD2000Thread.cpp index de8fe09d4..e0b933668 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.cpp +++ b/Source/Processors/DataThreads/RHD2000Thread.cpp @@ -685,11 +685,22 @@ bool RHD2000Thread::isAcquisitionActive() return isTransmitting; } -/*void RHD2000Thread::setNumChannels(int hsNum, int numChannels) +void RHD2000Thread::setNumChannels(int hsNum, int numChannels) { - if (numChannelsPerDataStream[hsNum] > 0) - numChannelsPerDataStream.set(hsNum, numChannels); -}*/ + if (headstagesArray[hsNum]->getNumChannels() == 32) + { + if (numChannels < headstagesArray[hsNum]->getNumChannels()) + headstagesArray[hsNum]->setHalfChannels(true); + else + headstagesArray[hsNum]->setHalfChannels(false); + numChannelsPerDataStream.set(hsNum, numChannels); + } +} + +int RHD2000Thread::getHeadstageChannels(int hsNum) +{ + return headstagesArray[hsNum]->getNumChannels(); +} void RHD2000Thread::getEventChannelNames(StringArray& Names) @@ -956,7 +967,7 @@ int RHD2000Thread::getNumHeadstageOutputs() if (headstagesArray[i]->isPlugged()) { - numChannels += headstagesArray[i]->getNumChannels(); + numChannels += headstagesArray[i]->getNumActiveChannels(); } } @@ -2177,7 +2188,7 @@ void RHD2000Thread::runImpedanceTest(Array<int>& streams, Array<int>& channels, RHDHeadstage::RHDHeadstage(Rhd2000EvalBoard::BoardDataSource stream) : - numStreams(0), channelsPerStream(32), dataStream(stream) +numStreams(0), channelsPerStream(32), dataStream(stream), halfChannels(false) { } @@ -2205,6 +2216,16 @@ int RHDHeadstage::getNumStreams() return numStreams; } +void RHDHeadstage::setHalfChannels(bool half) +{ + halfChannels = half; +} + +int RHDHeadstage::getNumActiveChannels() +{ + return (int)(getNumChannels() / (halfChannels ? 2 : 1)); +} + Rhd2000EvalBoard::BoardDataSource RHDHeadstage::getDataStream(int index) { if (index < 0 || index > 1) index = 0; diff --git a/Source/Processors/DataThreads/RHD2000Thread.h b/Source/Processors/DataThreads/RHD2000Thread.h index 70a5edc96..9a5bd3cf6 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.h +++ b/Source/Processors/DataThreads/RHD2000Thread.h @@ -117,13 +117,14 @@ public: void setDefaultNamingScheme(int scheme); String getChannelName(ChannelType t, int str, int ch); + void setNumChannels(int hsNum, int nChannels); + int getHeadstageChannels(int hsNum); private: bool enableHeadstage(int hsNum, bool enabled, int nStr = 1, int strChans = 32); void updateBoardStreams(); void setCableLength(int hsNum, float length); - // void setNumChannels(int hsNum, int nChannels); void setDefaultChannelNamesAndType(); bool channelModified(ChannelType t, int str, int k, String &oldName, float &oldGain, int &index); @@ -217,12 +218,15 @@ public: void setChannelsPerStream(int nchan); int getNumChannels(); int getNumStreams(); + void setHalfChannels(bool half); //mainly used for de 16ch rhd2132 board + int getNumActiveChannels(); Rhd2000EvalBoard::BoardDataSource getDataStream(int index); bool isPlugged(); private: Rhd2000EvalBoard::BoardDataSource dataStream; int numStreams; int channelsPerStream; + bool halfChannels; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RHDHeadstage); }; -- GitLab