Skip to content

Commit 79e396b

Browse files
committed
Update cache key to be unambiguous
1 parent 2d5fbab commit 79e396b

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

Plugins/BasicSpikeDisplay/SpikeDetector/SpikeDetector.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,12 +550,16 @@ SpikeChannel* SpikeDetector::addSpikeChannel (SpikeChannel::Type type,
550550

551551
//Whenever a new spike channel is created, we need to update the unique ID
552552
//TODO: This should be automatically done in the SpikeChannel constructor next time we change the API
553-
const Array<const ContinuousChannel*>& sourceChannels = spikeChannel->getSourceChannels();
554-
std::string cacheKey = std::to_string(sourceChannels[0]->getSourceNodeId());
555-
cacheKey += "|" + spikeChannel->getStreamName().toStdString();
556-
cacheKey += "|" + name.toStdString();
553+
// <SOURCE_NODE_ID> | <STREAM_NAME> | <SPIKE_DETECTOR_NODE_ID> | <CHANNEL/ELECTRODE NAME>
554+
std::string stream_source = std::to_string(getDataStream(currentStream)->getSourceNodeId());
555+
std::string stream_name = getDataStream(currentStream)->getName().toStdString();
556+
std::string spike_source = std::to_string(spikeChannel->getSourceNodeId());
557+
std::string channel_name = spikeChannel->getName().toStdString();
558+
559+
std::string cacheKey = stream_source + "|" + stream_name + "|" + spike_source + "|" + channel_name;
557560

558561
spikeChannel->setIdentifier(cacheKey);
562+
LOGD("Added SpikeChannel w/ identifier: ", cacheKey);
559563

560564
return spikeChannel;
561565

Plugins/BasicSpikeDisplay/SpikeDisplayNode/SpikeDisplayCanvas.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,12 @@ void SpikeDisplayCanvas::update()
156156

157157
if (cache->hasCachedDisplaySettings(cacheKey))
158158
{
159+
LOGD("SpikeDisplayCanvas::update: found exact key for ", cacheKey);
159160
applyCachedDisplaySettings(i, cacheKey);
160161
}
161162
else if (cache->findSimilarKey(cacheKey, streamIdx).size() > 0)
162163
{
164+
LOGD("SpikeDisplayCanvas::update: found similar key for ", cacheKey);
163165
applyCachedDisplaySettings(i, cache->findSimilarKey(cacheKey, streamIdx));
164166
}
165167
}
@@ -253,9 +255,11 @@ void SpikeDisplayCanvas::saveCustomParametersToXml(XmlElement* xml)
253255

254256
XmlElement* plotNode = xmlNode->createNewChildElement("PLOT");
255257

256-
plotNode->setAttribute("name", spikeChannel->getName());
257-
plotNode->setAttribute("stream_name", processor->getDataStream(streamId)->getName());
258258
plotNode->setAttribute("stream_source", processor->getDataStream(streamId)->getSourceNodeId());
259+
plotNode->setAttribute("stream_name", processor->getDataStream(streamId)->getName());
260+
plotNode->setAttribute("source_node", spikeChannel->getSourceNodeId());
261+
plotNode->setAttribute("name", spikeChannel->getName());
262+
259263
plotNode->setAttribute("isMonitored", spikeDisplay->getMonitorStateForPlot(i));
260264

261265
for (int j = 0; j < spikeDisplay->getNumChannelsForPlot(i); j++)
@@ -273,7 +277,6 @@ void SpikeDisplayCanvas::saveCustomParametersToXml(XmlElement* xml)
273277
void SpikeDisplayCanvas::loadCustomParametersFromXml(XmlElement* xml)
274278
{
275279

276-
277280
for (auto* xmlNode : xml->getChildIterator())
278281
{
279282
if (xmlNode->hasTagName("SPIKEDISPLAY"))
@@ -298,11 +301,12 @@ void SpikeDisplayCanvas::loadCustomParametersFromXml(XmlElement* xml)
298301
{
299302
plotIndex++;
300303

301-
std::string source = plotNode->getStringAttribute("stream_source").toStdString();
304+
std::string stream_source = plotNode->getStringAttribute("stream_source").toStdString();
302305
std::string stream_name = plotNode->getStringAttribute("stream_name").toStdString();
306+
std::string source = plotNode->getStringAttribute("source_node").toStdString();
303307
std::string name = plotNode->getStringAttribute("name").toStdString();
304308

305-
std::string cacheKey = source + "|" + stream_name + "|" + name;
309+
std::string cacheKey = stream_source + "|" + stream_name + "|" + source + "|" + name;
306310

307311
cache->setMonitor(cacheKey, plotNode->getBoolAttribute("isMonitored"));
308312

0 commit comments

Comments
 (0)