Skip to content

Commit dec82a3

Browse files
committed
Refactor OnixSourceEditor:
- Update version retrieval, improve context initialization checks, and enhance UI elements in OnixSourceEditor - Add a blank element that is overlaid on existing editor elements if the context cannot be initialized
1 parent d8a1ea3 commit dec82a3

File tree

7 files changed

+142
-158
lines changed

7 files changed

+142
-158
lines changed

Source/Onix1.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ Onix1::Onix1(int hostIndex)
3737
if (rc != ONI_ESUCCESS)
3838
throw error_t(rc);
3939

40-
oni_version(&major, &minor, &patch);
41-
4240
rc = getOption(ONI_OPT_ACQCLKHZ, &ACQ_CLK_HZ);
4341
if (rc != ONI_ESUCCESS)
4442
throw error_t(rc);
@@ -155,9 +153,9 @@ int Onix1::issueReset()
155153
return rc;
156154
}
157155

158-
std::string Onix1::getVersion() const
156+
std::string Onix1::getVersion()
159157
{
160-
return std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch);
158+
return std::to_string(ONI_VERSION_MAJOR) + "." + std::to_string(ONI_VERSION_MINOR) + "." + std::to_string(ONI_VERSION_PATCH);
161159
}
162160

163161
double Onix1::convertTimestampToSeconds(uint64_t timestamp) const

Source/Onix1.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace OnixSourcePlugin
109109

110110
int issueReset();
111111

112-
std::string getVersion() const;
112+
static std::string getVersion();
113113

114114
double convertTimestampToSeconds(uint64_t timestamp) const;
115115

@@ -130,10 +130,6 @@ namespace OnixSourcePlugin
130130
CriticalSection registerLock;
131131
CriticalSection frameLock;
132132

133-
int major;
134-
int minor;
135-
int patch;
136-
137133
uint32_t ACQ_CLK_HZ;
138134

139135
template<typename opt_t>

Source/OnixSource.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,19 @@ OnixSource::OnixSource(SourceNode* sn) :
4141
"Failed to Create Context",
4242
e.what()
4343
);
44-
return;
4544
}
4645
catch (const error_t& e)
4746
{
4847
Onix1::showWarningMessageBoxAsync(
4948
"Failed to Initialize Context",
5049
e.what()
5150
);
52-
return;
5351
}
5452

5553
portA = std::make_shared<PortController>(PortName::PortA, context);
5654
portB = std::make_shared<PortController>(PortName::PortB, context);
5755

58-
if (!context->isInitialized()) { LOGE("Failed to initialize context."); return; }
56+
if (context == nullptr || !context->isInitialized()) { LOGE("Failed to initialize context."); return; }
5957
}
6058

6159
OnixSource::~OnixSource()
@@ -67,14 +65,6 @@ OnixSource::~OnixSource()
6765
}
6866
}
6967

70-
std::string OnixSource::getLiboniVersion()
71-
{
72-
if (context != nullptr && context->isInitialized())
73-
return context->getVersion();
74-
else
75-
return "";
76-
}
77-
7868
void OnixSource::registerParameters()
7969
{
8070
addBooleanParameter(Parameter::PROCESSOR_SCOPE, "passthroughA", "Passthrough A", "Enables passthrough mode for e-variant headstages on Port A", false, true);
@@ -155,7 +145,7 @@ bool OnixSource::configureDevice(OnixDeviceVector& sources,
155145
Onix1::showWarningMessageBoxAsync(
156146
"Invalid Headstage Selection",
157147
"Expected to find " + editor->getHeadstageSelected(OnixDevice::getOffset(deviceIdx)) + " on " + OnixDevice::getPortName(deviceIdx) +
158-
", but found " + hubName + " instead. Confirm that the correct headstage is selected, and try to connect again.");
148+
", but found " + hubName + " instead. Confirm that the correct headstage is selected, and try to connect again.");
159149
}
160150

161151
return false;
@@ -922,15 +912,15 @@ void OnixSource::updateSettings(OwnedArray<ContinuousChannel>* continuousChannel
922912
else
923913
{
924914
Onix1::showWarningMessageBoxAsync(
925-
"Unknown Composite Source",
915+
"Unknown Composite Source",
926916
"Found an unknown composite source (" + source->getName() + ") on hub " + source->getHubName() +
927917
" at address " + std::to_string(source->getDeviceIdx()));
928918
}
929919
}
930920
else
931921
{
932922
Onix1::showWarningMessageBoxAsync(
933-
"Unknown Source",
923+
"Unknown Source",
934924
"Found an unknown source (" + source->getName() + ") on hub " + source->getHubName() +
935925
" at address " + std::to_string(source->getDeviceIdx()));
936926
}

Source/OnixSource.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ namespace OnixSourcePlugin
118118

119119
std::map<int, std::string> getHubNames();
120120

121-
std::string getLiboniVersion();
122-
123121
void updateSourceBuffers();
124122

125123
// DataThread Methods

Source/OnixSourceCanvas.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void OnixSourceCanvas::addHub(std::string hubName, int offset)
5959

6060
if (context == nullptr || !context->isInitialized())
6161
{
62-
Onix1::showWarningMessageBoxAsync("Invalid Context", "Unable to find an initialized context when adding hubs to the canvas.");
62+
LOGE("Unable to find an initialized context when adding " + hubName + " to the canvas.");
6363
return;
6464
}
6565

0 commit comments

Comments
 (0)