Skip to content

Commit d313197

Browse files
committed
Prevent multiple processors from accessing NWB resources
1 parent a6ac5bb commit d313197

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Source/Processors/ProcessorGraph/ProcessorGraph.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "../AudioNode/AudioNode.h"
3333
#include "../RecordNode/RecordNode.h"
34+
#include "../FileReader/FileReader.h"
3435
#include "../MessageCenter/MessageCenter.h"
3536
#include "../MessageCenter/MessageCenterEditor.h"
3637
#include "../Merger/Merger.h"
@@ -1359,11 +1360,42 @@ bool ProcessorGraph::isReady()
13591360

13601361
LOGD("Checking that all processors are enabled...");
13611362

1363+
int NWBCounter = 0;
1364+
13621365
for (int i = 0; i < getNumNodes(); i++)
13631366
{
13641367

13651368
Node* node = getNode(i);
13661369

1370+
String name = node->getProcessor()->getName();
1371+
1372+
// 1. Check that NWB resources are only used by a single processor.
1373+
if (name == "File Reader")
1374+
{
1375+
FileReader* fr = static_cast<FileReader*>(node->getProcessor());
1376+
1377+
if (File(fr->getFile()).getFileExtension() == ".nwb")
1378+
NWBCounter += 1;
1379+
}
1380+
else if (name == "Record Node")
1381+
{
1382+
RecordNode* rn = static_cast<RecordNode*>(node->getProcessor());
1383+
1384+
if (rn->getEngineId() == "NWB2")
1385+
NWBCounter += 1;
1386+
}
1387+
1388+
if (NWBCounter > 1)
1389+
{
1390+
AccessClass::getUIComponent()->disableCallbacks();
1391+
1392+
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
1393+
"WARNING", "Open Ephys currently does not support multiple processors using NWB format. Please modify the signal chain accordingly to proceed with acquisition.");
1394+
1395+
return false;
1396+
}
1397+
1398+
// 2. Check that all processors are enabled and ready for acquisition.
13671399
if (node->nodeID != NodeID(OUTPUT_NODE_ID))
13681400
{
13691401
GenericProcessor* p = (GenericProcessor*)node->getProcessor();

0 commit comments

Comments
 (0)