Skip to content

Commit

Permalink
Reset probe pointers when refreshing plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiegle committed Nov 2, 2024
1 parent 29bd987 commit e18fce8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 20 deletions.
13 changes: 6 additions & 7 deletions Source/NeuropixCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ NeuropixCanvas::NeuropixCanvas (GenericProcessor* processor_, NeuropixEditor* ed
topLevelTabComponent = std::make_unique<CustomTabComponent> (editor, true);
addAndMakeVisible (topLevelTabComponent.get());

LOGC ("Creating new NeuropixCanvas");

Array<Basestation*> availableBasestations = thread->getBasestations();

int topLevelTabNumber = 0;
Expand All @@ -99,6 +101,8 @@ NeuropixCanvas::NeuropixCanvas (GenericProcessor* processor_, NeuropixEditor* ed
basestationTab,
true);

LOGC ("Adding tab for ", String (" Slot " + String (basestation->slot) + " "));

basestationTab->setTabBarDepth (26);
basestationTab->setIndent (0); // gap to leave around the edge
basestationTab->setOutline (0);
Expand All @@ -111,13 +115,6 @@ NeuropixCanvas::NeuropixCanvas (GenericProcessor* processor_, NeuropixEditor* ed

topLevelTabComponent->setCurrentTabIndex (topLevelTabNumber - 1);

//neuropixViewport->setViewedComponent(settingsInterfaces.getFirst(), false);
//addAndMakeVisible(neuropixViewport);

//settingsInterfaces[0]->viewport->setVisible(true);

//resized();

savedSettings.probeType = ProbeType::NONE;
}

Expand All @@ -129,6 +126,8 @@ void NeuropixCanvas::populateSourceTabs(Basestation* basestation, CustomTabCompo

int basestationTabNumber = 0;

LOGC ("Found ", probeCount, " probes in slot ", basestation->slot, " with ", availableDataSources.size(), " data sources")

for (auto source : availableDataSources)
{
if (source->sourceType == DataSourceType::PROBE && source->basestation == basestation)
Expand Down
18 changes: 16 additions & 2 deletions Source/NeuropixEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "NeuropixCanvas.h"
#include "NeuropixComponents.h"
#include "NeuropixThread.h"
#include "UI/NeuropixInterface.h"

RefreshButton::RefreshButton() : Button ("Refresh")
{
Expand Down Expand Up @@ -778,7 +779,8 @@ void NeuropixEditor::comboBoxChanged (ComboBox* comboBox)
if (asOutput)
{
thread->setSyncOutput (slotIndex);
syncFrequencyLabel->setVisible (true);
if(background->numBasestations > 0)
syncFrequencyLabel->setVisible (true);
background->setFreqSelectAvailable (true);
}
else
Expand Down Expand Up @@ -881,6 +883,15 @@ void NeuropixEditor::buttonClicked (Button* button)
btn->stopTimer();
}

for (auto& settingsInterface : canvas->settingsInterfaces)
{
if (settingsInterface->type == SettingsInterface::PROBE_SETTINGS_INTERFACE)
{
NeuropixInterface* ni = (NeuropixInterface*) settingsInterface;
ni->probe = nullptr;
}
}

if (thread->getBasestations()[0]->type == BasestationType::SIMULATED)
{
uiLoaderWithProgressWindow->updateProbeMap(); // call outside of thread
Expand All @@ -889,6 +900,7 @@ void NeuropixEditor::buttonClicked (Button* button)
{
thread->isRefreshing = true;
uiLoaderWithProgressWindow->runThread();
LOGD ("Finished refresh thread.");
}

LOGD ("Resetting canvas...");
Expand All @@ -898,6 +910,7 @@ void NeuropixEditor::buttonClicked (Button* button)
LOGD ("Updating settings interfaces...");
for (auto& interface : canvas->settingsInterfaces)
{

for (auto probe : thread->getProbes())
{
if (interface->dataSource != nullptr && interface->dataSource->getName() == probe->getName())
Expand Down Expand Up @@ -1052,7 +1065,8 @@ void NeuropixEditor::loadVisualizerEditorParameters (XmlElement* xml)
{
inputOutputSyncSelector->setSelectedItemIndex (1, dontSendNotification);
thread->setSyncOutput (mainSyncSlotIndex);
syncFrequencyLabel->setVisible (true);
if(background->numBasestations > 0)
syncFrequencyLabel->setVisible (true);
background->setFreqSelectAvailable (true);
// syncFrequencySelector->setSelectedItemIndex (frequencyIndex, dontSendNotification);
thread->setSyncFrequency (mainSyncSlotIndex, frequencyIndex);
Expand Down
3 changes: 2 additions & 1 deletion Source/NeuropixEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,12 @@ class EditorBackground : public Component, public ComponentListener
slotButtons[i]->isEnabled = isEnabled;
}

int numBasestations;

private:
/** Draws the background */
void paint (Graphics& g);

int numBasestations;
bool freqSelectEnabled;

/* An array of Basestation objections, one for each basestation detected */
Expand Down
2 changes: 2 additions & 0 deletions Source/NeuropixThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ void NeuropixThread::updateStreamInfo (bool enabledStateChanged)
}
}
}

LOGD ("Finished updating stream info");
}

NeuropixThread::~NeuropixThread()
Expand Down
24 changes: 14 additions & 10 deletions Source/UI/NeuropixInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1503,9 +1503,6 @@ bool NeuropixInterface::applyProbeSettings (ProbeSettings p, bool shouldUpdatePr
return false;
}

//if (electrodeConfigurationComboBox != 0)
// electrodeConfigurationComboBox->setSelectedId(p.electrodeConfigurationIndex + 2, dontSendNotification);

// update display
if (apGainComboBox != 0)
apGainComboBox->setSelectedId (p.apGainIndex + 1, dontSendNotification);
Expand Down Expand Up @@ -1570,6 +1567,9 @@ bool NeuropixInterface::applyProbeSettings (ProbeSettings p, bool shouldUpdatePr
}
}

probe->updateNamingScheme (basestation->getNamingScheme());
updateInfoString();

// apply settings in background thread
if (shouldUpdateProbe)
{
Expand Down Expand Up @@ -1876,28 +1876,32 @@ void NeuropixInterface::loadParameters (XmlElement* xml)
String PN = xmlNode->getStringAttribute ("probe_part_number");
ProbeType type = ProbeType::NP1;

if (PN.equalsIgnoreCase ("NP1010"))
if (PN.equalsIgnoreCase ("NP1010") || PN.equalsIgnoreCase ("NP1011") || PN.equalsIgnoreCase ("NP1012") || PN.equalsIgnoreCase ("NP1013")
|| PN.equalsIgnoreCase ("NP1015") || PN.equalsIgnoreCase ("NP1016"))
type = ProbeType::NHP10;

else if (PN.equalsIgnoreCase ("NP1020") || PN.equalsIgnoreCase ("NP1021"))
else if (PN.equalsIgnoreCase ("NP1020") || PN.equalsIgnoreCase ("NP1021") || PN.equalsIgnoreCase ("NP1022"))
type = ProbeType::NHP25;

else if (PN.equalsIgnoreCase ("NP1030") || PN.equalsIgnoreCase ("NP1031"))
else if (PN.equalsIgnoreCase ("NP1030") || PN.equalsIgnoreCase ("NP1031") || PN.equalsIgnoreCase ("NP1032"))
type = ProbeType::NHP45;

else if (PN.equalsIgnoreCase ("NP1200") || PN.equalsIgnoreCase ("NP1210"))
type = ProbeType::NHP1;

else if (PN.equalsIgnoreCase ("PRB2_1_2_0640_0") || PN.equalsIgnoreCase ("NP2000"))
else if (PN.equalsIgnoreCase ("PRB2_1_2_0640_0") || PN.equalsIgnoreCase ("NP2000") || PN.equalsIgnoreCase ("NP2003") || PN.equalsIgnoreCase ("NP2004"))
type = ProbeType::NP2_1;

else if (PN.equalsIgnoreCase ("PRB2_4_2_0640_0") || PN.equalsIgnoreCase ("NP2010"))
else if (PN.equalsIgnoreCase ("PRB2_4_2_0640_0") || PN.equalsIgnoreCase ("NP2010") || PN.equalsIgnoreCase ("NP2013") || PN.equalsIgnoreCase ("NP2014"))
type = ProbeType::NP2_4;

else if (PN.equalsIgnoreCase ("PRB_1_4_0480_1") || PN.equalsIgnoreCase ("PRB_1_4_0480_1_C"))
else if (PN.equalsIgnoreCase ("NP2020"))
type = ProbeType::QUAD_BASE;

else if (PN.equalsIgnoreCase ("PRB_1_4_0480_1") || PN.equalsIgnoreCase ("PRB_1_4_0480_1_C") || PN.equalsIgnoreCase ("PRB_1_2_0480_2"))
type = ProbeType::NP1;

else if (PN.equalsIgnoreCase ("NP1100"))
else if (PN.equalsIgnoreCase ("NP1100") || PN.equalsIgnoreCase ("NP1120") || PN.equalsIgnoreCase ("NP1121") || PN.equalsIgnoreCase ("NP1122") || PN.equalsIgnoreCase ("NP1123"))
type = ProbeType::UHD1;

else if (PN.equalsIgnoreCase ("NP1110"))
Expand Down

0 comments on commit e18fce8

Please sign in to comment.