Skip to content

Commit 7f3b2b6

Browse files
authored
Merge pull request #115 from open-ephys-plugins/issue-108
Hide UI elements if context is uninitialized
2 parents c754796 + dec82a3 commit 7f3b2b6

File tree

8 files changed

+150
-162
lines changed

8 files changed

+150
-162
lines changed

CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ foreach( src_file IN ITEMS ${SRC_FILES})
6767
source_group("${group_name}" FILES "${src_file}")
6868
endforeach()
6969

70-
7170
function(vs_set_all_configurations target_name target_config_name)
7271
foreach(config ${CMAKE_CONFIGURATION_TYPES})
7372
string(TOUPPER ${config} config_upper)
@@ -78,7 +77,6 @@ function(vs_set_all_configurations target_name target_config_name)
7877
endforeach()
7978
endfunction()
8079

81-
8280
# add liboni project
8381

8482
set(LIBONI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/liboni/api/liboni")
@@ -106,14 +104,15 @@ target_link_libraries(${PLUGIN_NAME} "${LIBONI_NAME}")
106104
set(RIFFA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/liboni/drivers/riffa/windows/lib")
107105
set(RIFFA_NAME riffa)
108106
set(RIFFA_PNAME "submodule_${RIFFA_NAME}")
107+
set(RELEASE_CONFIGURATION "Release")
109108

110109
include_external_msproject (
111110
${RIFFA_PNAME}
112111
"${RIFFA_DIR}/riffa.vcxproj"
113112
PLATFORM ${CMAKE_LIBRARY_ARCHITECTURE}
114113
)
115114

116-
vs_set_all_configurations(${RIFFA_PNAME} "Release")
115+
vs_set_all_configurations(${RIFFA_PNAME} "${RELEASE_CONFIGURATION}")
117116

118117
# add onidriver_riffa project
119118

@@ -127,11 +126,10 @@ include_external_msproject (
127126
PLATFORM ${CMAKE_LIBRARY_ARCHITECTURE}
128127
)
129128

130-
vs_set_all_configurations(${ONIDRIVER_RIFFA_PNAME} "Release")
131-
129+
vs_set_all_configurations(${ONIDRIVER_RIFFA_PNAME} "${RELEASE_CONFIGURATION}")
132130

133131
add_dependencies(${ONIDRIVER_RIFFA_PNAME} ${RIFFA_PNAME})
134132

135133
# Ensure needed DLLs are installed to the shared folder
136134

137-
install(FILES "${CMAKE_BINARY_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}/$<CONFIG>/riffa.dll" "${CMAKE_BINARY_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}/$<CONFIG>/${ONIDRIVER_RIFFA_NAME}.dll" DESTINATION ${GUI_BIN_DIR}/shared)
135+
install(FILES "${CMAKE_BINARY_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}/${RELEASE_CONFIGURATION}/riffa.dll" "${CMAKE_BINARY_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}/${RELEASE_CONFIGURATION}/${ONIDRIVER_RIFFA_NAME}.dll" DESTINATION ${GUI_BIN_DIR}/shared)

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: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,23 @@ OnixSource::OnixSource(SourceNode* sn) :
3737
}
3838
catch (const std::system_error& e)
3939
{
40-
LOGE("Failed to create context. ", e.what());
41-
CoreServices::sendStatusMessage("Failed to create context." + std::string(e.what()));
42-
AlertWindow::showMessageBox(
43-
MessageBoxIconType::WarningIcon,
40+
Onix1::showWarningMessageBoxAsync(
4441
"Failed to Create Context",
45-
"There was an error creating the context. Check the error logs for more details."
42+
e.what()
4643
);
47-
return;
4844
}
4945
catch (const error_t& e)
5046
{
51-
LOGE("Failed to initialize context. ", e.what());
52-
CoreServices::sendStatusMessage("Failed to create context. " + std::string(e.what()));
53-
AlertWindow::showMessageBox(
54-
MessageBoxIconType::WarningIcon,
47+
Onix1::showWarningMessageBoxAsync(
5548
"Failed to Initialize Context",
56-
"There was an error initializing the context. Check the error logs for more details."
49+
e.what()
5750
);
58-
return;
5951
}
6052

6153
portA = std::make_shared<PortController>(PortName::PortA, context);
6254
portB = std::make_shared<PortController>(PortName::PortB, context);
6355

64-
if (!context->isInitialized()) { LOGE("Failed to initialize context."); return; }
56+
if (context == nullptr || !context->isInitialized()) { LOGE("Failed to initialize context."); return; }
6557
}
6658

6759
OnixSource::~OnixSource()
@@ -73,14 +65,6 @@ OnixSource::~OnixSource()
7365
}
7466
}
7567

76-
std::string OnixSource::getLiboniVersion()
77-
{
78-
if (context != nullptr && context->isInitialized())
79-
return context->getVersion();
80-
else
81-
return "";
82-
}
83-
8468
void OnixSource::registerParameters()
8569
{
8670
addBooleanParameter(Parameter::PROCESSOR_SCOPE, "passthroughA", "Passthrough A", "Enables passthrough mode for e-variant headstages on Port A", false, true);
@@ -161,7 +145,7 @@ bool OnixSource::configureDevice(OnixDeviceVector& sources,
161145
Onix1::showWarningMessageBoxAsync(
162146
"Invalid Headstage Selection",
163147
"Expected to find " + editor->getHeadstageSelected(OnixDevice::getOffset(deviceIdx)) + " on " + OnixDevice::getPortName(deviceIdx) +
164-
", 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.");
165149
}
166150

167151
return false;
@@ -928,15 +912,15 @@ void OnixSource::updateSettings(OwnedArray<ContinuousChannel>* continuousChannel
928912
else
929913
{
930914
Onix1::showWarningMessageBoxAsync(
931-
"Unknown Composite Source",
915+
"Unknown Composite Source",
932916
"Found an unknown composite source (" + source->getName() + ") on hub " + source->getHubName() +
933917
" at address " + std::to_string(source->getDeviceIdx()));
934918
}
935919
}
936920
else
937921
{
938922
Onix1::showWarningMessageBoxAsync(
939-
"Unknown Source",
923+
"Unknown Source",
940924
"Found an unknown source (" + source->getName() + ") on hub " + source->getHubName() +
941925
" at address " + std::to_string(source->getDeviceIdx()));
942926
}

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)