Skip to content

Commit 2af690e

Browse files
committed
Change broadcast messaging to handle JSON formatting
1 parent ee2598d commit 2af690e

3 files changed

Lines changed: 30 additions & 12 deletions

File tree

Plugins/LfpDisplayNode/LfpDisplay.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,6 @@ void LfpDisplay::refresh()
381381
if (numChans == 0)
382382
return;
383383

384-
if(canvasSplit -> shouldRebuildChannelList) {
385-
canvasSplit -> shouldRebuildChannelList = false;
386-
rebuildDrawableChannelsList();
387-
}
388384
// Ensure the lfpChannelBitmap has been initialized
389385
if (lfpChannelBitmap.isNull() || lfpChannelBitmap.getWidth() < getWidth() - canvasSplit->leftmargin)
390386
{

Plugins/LfpDisplayNode/LfpDisplayCanvas.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,8 +1661,13 @@ void LfpDisplaySplitter::visibleAreaChanged()
16611661
void LfpDisplaySplitter::refresh()
16621662
{
16631663
updateScreenBuffer();
1664-
1665-
lfpDisplay->refresh(); // redraws only the new part of the screen buffer, unless fullredraw is set to true
1664+
if(shouldRebuildChannelList) {
1665+
shouldRebuildChannelList = false;
1666+
lfpDisplay->rebuildDrawableChannelsList(); // calls resized()/refresh() after rebuilding list
1667+
}
1668+
else {
1669+
lfpDisplay->refresh(); // redraws only the new part of the screen buffer, unless fullredraw is set to true
1670+
}
16661671
}
16671672

16681673
void LfpDisplaySplitter::comboBoxChanged(juce::ComboBox *comboBox)

Plugins/LfpDisplayNode/LfpDisplayNode.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,17 +333,34 @@ String LfpDisplayNode::handleConfigMessage(String msg) {
333333
}
334334

335335
void LfpDisplayNode::handleBroadcastMessage(String msg) {
336+
DynamicObject::Ptr jsonMessage = JSON::parse(msg).getDynamicObject();
336337
std::cout<< msg<< std::endl;
337338
StringArray parts = StringArray::fromTokens(msg, ";", "");
338-
if(parts.size() < 3 || (parts[0] != "LFPViewer" && parts[1] != "FILTER")) {
339+
String pluginName= jsonMessage -> getProperty("plugin");
340+
if(pluginName != "LFPViewer") {
339341
return;
340342
}
341-
int streamID = parts[2].getIntValue();
342-
parts.removeRange(0, 3);
343-
displayBufferMap[streamID] -> setFilteredChannels(parts);
344-
for(auto split : splitDisplays) {
345-
split -> shouldRebuildChannelList = true;
343+
String command = jsonMessage -> getProperty("command");
344+
DynamicObject::Ptr payload = jsonMessage -> getProperty("payload").getDynamicObject();
345+
if(command == "filter") {
346+
if(payload.get() == nullptr)
347+
return;
348+
int streamID = payload -> getProperty("streamID");
349+
var indexes = payload -> getProperty("indexes");
350+
if(streamID < 0 || indexes.size() == 0 ){
351+
return;
352+
}
353+
StringArray channelNames;
354+
for(int i = 0; i < indexes.size(); i++) {
355+
channelNames.add("CH"+String(indexes[i]));
356+
}
357+
displayBufferMap[streamID] -> setFilteredChannels(channelNames);
358+
for(auto split : splitDisplays) {
359+
split -> shouldRebuildChannelList = true;
360+
}
361+
346362
}
363+
347364

348365
}
349366

0 commit comments

Comments
 (0)