@@ -108,13 +108,14 @@ bool OnixSource::disconnectDevices(bool updateStreamInfo)
108108
109109template <class Device >
110110bool OnixSource::configureDevice (OnixDeviceVector& sources,
111- OnixSourceCanvas* canvas ,
111+ OnixSourceEditor* editor ,
112112 std::string deviceName,
113113 std::string hubName,
114114 OnixDeviceType deviceType,
115115 const oni_dev_idx_t deviceIdx,
116116 std::shared_ptr<Onix1> ctx)
117117{
118+ auto canvas = editor->getCanvas ();
118119 std::shared_ptr<Device> device = std::static_pointer_cast<Device>(canvas->getDevicePtr (Device::getDeviceType (), deviceIdx));
119120
120121 if (device != nullptr )
@@ -132,7 +133,20 @@ bool OnixSource::configureDevice(OnixDeviceVector& sources,
132133
133134 if (device == nullptr )
134135 {
135- Onix1::showWarningMessageBoxAsync (" Device Not Found" , " Could not find " + deviceName + " , at address " + std::to_string (deviceIdx) + " on " + hubName);
136+ if (hubName == editor->getHeadstageSelected (OnixDevice::getOffset (deviceIdx)))
137+ {
138+ Onix1::showWarningMessageBoxAsync (
139+ " Device Not Found" ,
140+ " Could not find " + deviceName + " , at address " + std::to_string (deviceIdx) + " on " + hubName);
141+ }
142+ else
143+ {
144+ Onix1::showWarningMessageBoxAsync (
145+ " Invalid Headstage Selection" ,
146+ " Expected to find " + editor->getHeadstageSelected (OnixDevice::getOffset (deviceIdx)) + " on " + OnixDevice::getPortName (deviceIdx) +
147+ " , but found " + hubName + " instead. Confirm that the correct headstage is selected, and try to connect again." );
148+ }
149+
136150 return false ;
137151 }
138152
@@ -266,7 +280,7 @@ bool OnixSource::initializeDevices(device_map_t deviceTable, bool updateStreamIn
266280
267281 if (deviceTable.size () == 0 )
268282 {
269- LOGE (" No devices found ." );
283+ Onix1::showWarningMessageBoxAsync (" No Devices Found " , " Could not find any devices from the connected hardware ." );
270284 if (updateStreamInfo) CoreServices::updateSignalChain (editor);
271285 return false ;
272286 }
@@ -275,7 +289,7 @@ bool OnixSource::initializeDevices(device_map_t deviceTable, bool updateStreamIn
275289
276290 if (hubIds.size () == 0 )
277291 {
278- LOGE (" No hub IDs found ." );
292+ Onix1::showWarningMessageBoxAsync (" No Hubs Found " , " Could not find any hubs from the connected hardware ." );
279293 if (updateStreamInfo) CoreServices::updateSignalChain (editor);
280294 return false ;
281295 }
@@ -288,44 +302,43 @@ bool OnixSource::initializeDevices(device_map_t deviceTable, bool updateStreamIn
288302 if (hubId == ONIX_HUB_FMCHOST) // NB: Breakout Board
289303 {
290304 hubNames.insert ({ hubIndex, BREAKOUT_BOARD_NAME });
291- auto canvas = editor->getCanvas ();
292305
293- devicesFound = configureDevice<Heartbeat >(sources, canvas , " Heartbeat" , BREAKOUT_BOARD_NAME, Heartbeat ::getDeviceType (), hubIndex, context);
294- if (!devicesFound)
306+ devicesFound = configureDevice<PersistentHeartbeat >(sources, editor , " Heartbeat" , BREAKOUT_BOARD_NAME, PersistentHeartbeat ::getDeviceType (), hubIndex, context);
307+ if (!devicesFound)
295308 {
296309 sources.clear ();
297310 return false ;
298311 }
299312
300- devicesFound = configureDevice<OutputClock>(sources, canvas , " Output Clock" , BREAKOUT_BOARD_NAME, OutputClock::getDeviceType (), hubIndex + 5 , context);
313+ devicesFound = configureDevice<OutputClock>(sources, editor , " Output Clock" , BREAKOUT_BOARD_NAME, OutputClock::getDeviceType (), hubIndex + 5 , context);
301314 if (!devicesFound)
302315 {
303316 sources.clear ();
304317 return false ;
305318 }
306319
307- devicesFound = configureDevice<AnalogIO>(sources, canvas , " Analog IO" , BREAKOUT_BOARD_NAME, AnalogIO::getDeviceType (), hubIndex + 6 , context);
320+ devicesFound = configureDevice<AnalogIO>(sources, editor , " Analog IO" , BREAKOUT_BOARD_NAME, AnalogIO::getDeviceType (), hubIndex + 6 , context);
308321 if (!devicesFound)
309322 {
310323 sources.clear ();
311324 return false ;
312325 }
313326
314- devicesFound = configureDevice<DigitalIO>(sources, canvas , " Digital IO" , BREAKOUT_BOARD_NAME, DigitalIO::getDeviceType (), hubIndex + 7 , context);
327+ devicesFound = configureDevice<DigitalIO>(sources, editor , " Digital IO" , BREAKOUT_BOARD_NAME, DigitalIO::getDeviceType (), hubIndex + 7 , context);
315328 if (!devicesFound)
316329 {
317330 sources.clear ();
318331 return false ;
319332 }
320333
321- devicesFound = configureDevice<MemoryMonitor>(sources, canvas , " Memory Monitor" , BREAKOUT_BOARD_NAME, MemoryMonitor::getDeviceType (), hubIndex + 10 , context);
334+ devicesFound = configureDevice<MemoryMonitor>(sources, editor , " Memory Monitor" , BREAKOUT_BOARD_NAME, MemoryMonitor::getDeviceType (), hubIndex + 10 , context);
322335 if (!devicesFound)
323336 {
324337 sources.clear ();
325338 return false ;
326339 }
327340
328- devicesFound = configureDevice<HarpSyncInput>(sources, canvas , " Harp Sync Input" , BREAKOUT_BOARD_NAME, HarpSyncInput::getDeviceType (), hubIndex + 12 , context);
341+ devicesFound = configureDevice<HarpSyncInput>(sources, editor , " Harp Sync Input" , BREAKOUT_BOARD_NAME, HarpSyncInput::getDeviceType (), hubIndex + 12 , context);
329342 if (!devicesFound)
330343 {
331344 sources.clear ();
@@ -335,19 +348,18 @@ bool OnixSource::initializeDevices(device_map_t deviceTable, bool updateStreamIn
335348 else if (hubId == ONIX_HUB_HSNP)
336349 {
337350 hubNames.insert ({ hubIndex, NEUROPIXELSV1F_HEADSTAGE_NAME });
338- auto canvas = editor->getCanvas ();
339351
340352 for (int i = 0 ; i < 2 ; i++)
341353 {
342- devicesFound = configureDevice<Neuropixels1f>(sources, canvas , " Probe" + std::to_string (i), NEUROPIXELSV1F_HEADSTAGE_NAME, Neuropixels1f::getDeviceType (), hubIndex + i, context);
354+ devicesFound = configureDevice<Neuropixels1f>(sources, editor , " Probe" + std::to_string (i), NEUROPIXELSV1F_HEADSTAGE_NAME, Neuropixels1f::getDeviceType (), hubIndex + i, context);
343355 if (!devicesFound)
344356 {
345357 sources.clear ();
346358 return false ;
347359 }
348360 }
349361
350- devicesFound = configureDevice<Bno055>(sources, canvas , " BNO055" , NEUROPIXELSV1F_HEADSTAGE_NAME, Bno055::getDeviceType (), hubIndex + 2 , context);
362+ devicesFound = configureDevice<Bno055>(sources, editor , " BNO055" , NEUROPIXELSV1F_HEADSTAGE_NAME, Bno055::getDeviceType (), hubIndex + 2 , context);
351363 if (!devicesFound)
352364 {
353365 sources.clear ();
@@ -371,20 +383,18 @@ bool OnixSource::initializeDevices(device_map_t deviceTable, bool updateStreamIn
371383 uint32_t hsid = EEPROM->GetHeadStageID ();
372384 LOGD (" Detected headstage " , hsid);
373385
374- auto canvas = editor->getCanvas ();
375-
376386 if (hsid == ONIX_HUB_HSNP2E)
377387 {
378388 auto hubIndex = OnixDevice::getHubIndexFromPassthroughIndex (index);
379389
380- devicesFound = configureDevice<Neuropixels2e>(sources, canvas , " " , NEUROPIXELSV2E_HEADSTAGE_NAME, Neuropixels2e::getDeviceType (), hubIndex, context);
390+ devicesFound = configureDevice<Neuropixels2e>(sources, editor , " Neuropixels 2.0 " , NEUROPIXELSV2E_HEADSTAGE_NAME, Neuropixels2e::getDeviceType (), hubIndex, context);
381391 if (!devicesFound)
382392 {
383393 sources.clear ();
384394 return false ;
385395 }
386396
387- devicesFound = configureDevice<PolledBno055>(sources, canvas , " BNO055" , NEUROPIXELSV2E_HEADSTAGE_NAME, PolledBno055::getDeviceType (), hubIndex + 1 , context);
397+ devicesFound = configureDevice<PolledBno055>(sources, editor , " BNO055" , NEUROPIXELSV2E_HEADSTAGE_NAME, PolledBno055::getDeviceType (), hubIndex + 1 , context);
388398 if (!devicesFound)
389399 {
390400 sources.clear ();
@@ -410,14 +420,14 @@ bool OnixSource::initializeDevices(device_map_t deviceTable, bool updateStreamIn
410420 {
411421 auto hubIndex = OnixDevice::getHubIndexFromPassthroughIndex (index);
412422
413- devicesFound = configureDevice<Neuropixels1e>(sources, canvas , " Probe" , NEUROPIXELSV1E_HEADSTAGE_NAME, Neuropixels1e::getDeviceType (), hubIndex, context);
423+ devicesFound = configureDevice<Neuropixels1e>(sources, editor , " Probe" , NEUROPIXELSV1E_HEADSTAGE_NAME, Neuropixels1e::getDeviceType (), hubIndex, context);
414424 if (!devicesFound)
415425 {
416426 sources.clear ();
417427 return false ;
418428 }
419429
420- devicesFound = configureDevice<PolledBno055>(sources, canvas , " BNO055" , NEUROPIXELSV1E_HEADSTAGE_NAME, PolledBno055::getDeviceType (), hubIndex + 1 , context);
430+ devicesFound = configureDevice<PolledBno055>(sources, editor , " BNO055" , NEUROPIXELSV1E_HEADSTAGE_NAME, PolledBno055::getDeviceType (), hubIndex + 1 , context);
421431 if (!devicesFound)
422432 {
423433 sources.clear ();
0 commit comments