Skip to content

Commit 62b6311

Browse files
committed
Make spike channel cache keys dynamic to allow for source changes
1 parent dfd2a6f commit 62b6311

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

Plugins/BasicSpikeDisplay/SpikeDisplayNode/SpikeDisplayCanvas.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,15 @@ void SpikeDisplayCanvas::saveCustomParametersToXml(XmlElement* xml)
228228

229229
spikePlotIdx++;
230230

231+
const SpikeChannel* spikeChannel = processor->getSpikeChannel(i);
232+
233+
const uint16 streamId = spikeChannel->getStreamId();
234+
231235
XmlElement* plotNode = xmlNode->createNewChildElement("PLOT");
232236

233-
plotNode->setAttribute("name", processor->getSpikeChannel(i)->getIdentifier());
237+
plotNode->setAttribute("name", spikeChannel->getName());
238+
plotNode->setAttribute("stream_name", processor->getDataStream(streamId)->getName());
239+
plotNode->setAttribute("stream_source", processor->getDataStream(streamId)->getSourceNodeId());
234240
plotNode->setAttribute("isMonitored", spikeDisplay->getMonitorStateForPlot(i));
235241

236242
for (int j = 0; j < spikeDisplay->getNumChannelsForPlot(i); j++)
@@ -273,7 +279,11 @@ void SpikeDisplayCanvas::loadCustomParametersFromXml(XmlElement* xml)
273279
{
274280
plotIndex++;
275281

276-
std::string cacheKey = processor->getSpikeChannel(plotIndex)->getIdentifier().toStdString();
282+
std::string source = plotNode->getStringAttribute("stream_source").toStdString();
283+
std::string stream_name = plotNode->getStringAttribute("stream_name").toStdString();
284+
std::string name = plotNode->getStringAttribute("name").toStdString();
285+
286+
std::string cacheKey = source + "|" + stream_name + "|" + name;
277287

278288
cache->setMonitor(cacheKey, plotNode->getBoolAttribute("isMonitored"));
279289

Plugins/BasicSpikeDisplay/SpikeDisplayNode/SpikePlots.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ void SpikePlot::buttonClicked(Button* button)
293293
setLimitsOnAxes();
294294

295295
canvas->cache->setMonitor(identifier, monitorButton->getToggleState());
296+
canvas->cache->setRange(identifier, index, ranges[index]);
296297

297298
}
298299

@@ -374,6 +375,7 @@ float SpikePlot::getRangeForChannel(int i)
374375
void SpikePlot::setRangeForChannel(int i, float range)
375376
{
376377
//std::cout << "Setting range to " << range << std::endl;
378+
ranges.set(i, range);
377379
waveAxes[i]->setRange(range);
378380
rangeButtons[i]->setLabel(String(int(range)));
379381
}

leetcode

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 1. TwoSum
2+
3+
Use a map to store the number we've already visited as a key and its index as the value.
4+
If the target minus the current number is an existing key, return the current index and the existing key's value
5+
6+
This runs in O(n) since we only need to pass through the list once.

0 commit comments

Comments
 (0)