Skip to content

Commit 4e9ab70

Browse files
committed
Check if link state is active before starting acquisition
1 parent e8fec31 commit 4e9ab70

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

Source/OnixSource.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ bool OnixSource::isReady()
446446
if (!devicesFound)
447447
return false;
448448

449+
if (editor->isHeadstageSelected(PortName::PortA) && !portA.checkLinkState(ctx)) return false;
450+
if (editor->isHeadstageSelected(PortName::PortB) && !portB.checkLinkState(ctx)) return false;
451+
449452
for (auto source : sources)
450453
{
451454
if (!source->isEnabled()) continue;

Source/OnixSourceEditor.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void OnixSourceEditor::buttonClicked(Button* b)
123123
if (connectButton->getToggleState() == true)
124124
{
125125
// NB: Configure port voltages, using either the automated voltage discovery algorithm, or the explicit voltage value given
126-
if (headstageComboBoxA->getSelectedItemIndex() > 0)
126+
if (isHeadstageSelected(PortName::PortA))
127127
{
128128
if (!thread->configurePortVoltage(PortName::PortA, portVoltageValueA->getText()))
129129
{
@@ -133,7 +133,7 @@ void OnixSourceEditor::buttonClicked(Button* b)
133133
}
134134
}
135135

136-
if (headstageComboBoxB->getSelectedItemIndex() > 0)
136+
if (isHeadstageSelected(PortName::PortB))
137137
{
138138
if (!thread->configurePortVoltage(PortName::PortB, portVoltageValueB->getText()))
139139
{
@@ -243,15 +243,15 @@ void OnixSourceEditor::resetCanvas()
243243
}
244244
}
245245

246-
float OnixSourceEditor::getPortVoltage(PortName port)
246+
bool OnixSourceEditor::isHeadstageSelected(PortName port)
247247
{
248248
switch (port)
249249
{
250250
case PortName::PortA:
251-
return 0.0f;
251+
return headstageComboBoxA->getSelectedItemIndex() > 0;
252252
case PortName::PortB:
253-
return 0.0f;
253+
return headstageComboBoxB->getSelectedItemIndex() > 0;
254254
default:
255-
return 0.0f;
255+
return false;
256256
}
257257
}

Source/OnixSourceEditor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class OnixSourceEditor : public VisualizerEditor,
7474

7575
void resetCanvas();
7676

77-
float getPortVoltage(PortName port);
77+
bool isHeadstageSelected(PortName port);
7878

7979
OnixSourceCanvas* canvas;
8080

0 commit comments

Comments
 (0)