Skip to content

Commit 4908184

Browse files
committed
Enable AnalogIO/DigitalIO individually
- Remove AuxiliaryIO device and tabs - Adjusted OnixSource.cpp to configure DigitalIO and AnalogIO devices directly instead of through AuxiliaryIO. - Made minor UI adjustments in AnalogIOInterface and DigitalIOInterface for button positioning. - Added TypeString for consistency using strings across files - Added method that calculates the passthrough index from the given hub index - Added private method to check if a passthrough index is valid
1 parent 9c1f4ef commit 4908184

12 files changed

+154
-654
lines changed

Source/Devices/AuxiliaryIO.cpp

Lines changed: 0 additions & 81 deletions
This file was deleted.

Source/Devices/AuxiliaryIO.h

Lines changed: 0 additions & 62 deletions
This file was deleted.

Source/Devices/DeviceList.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
2121
*/
2222

23-
#include "AuxiliaryIO.h"
2423
#include "AnalogIO.h"
2524
#include "Bno055.h"
2625
#include "DigitalIO.h"

Source/OnixDevice.cpp

Lines changed: 38 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@
2424

2525
using namespace OnixSourcePlugin;
2626

27+
const std::map<OnixDeviceType, std::string> OnixDevice::TypeString = {
28+
{OnixDeviceType::BNO, "BNO055"},
29+
{OnixDeviceType::POLLEDBNO, "BNO055"},
30+
{OnixDeviceType::NEUROPIXELSV1E, "Neuropixels 1.0e"},
31+
{OnixDeviceType::NEUROPIXELSV1F, "Neuropixels 1.0f"},
32+
{OnixDeviceType::NEUROPIXELSV2E, "Neuropixels 2.0"},
33+
{OnixDeviceType::PORT_CONTROL, "Port Control"},
34+
{OnixDeviceType::MEMORYMONITOR, "Memory Monitor"},
35+
{OnixDeviceType::OUTPUTCLOCK, "Output Clock"},
36+
{OnixDeviceType::HARPSYNCINPUT, "Harp Sync Input"},
37+
{OnixDeviceType::ANALOGIO, "Analog IO"},
38+
{OnixDeviceType::DIGITALIO, "Digital IO"}
39+
};
40+
2741
OnixDevice::OnixDevice(std::string name_, std::string hubName, OnixDeviceType type_, const oni_dev_idx_t deviceIdx_, std::shared_ptr<Onix1> ctx, bool passthrough)
2842
: type(type_), deviceIdx(deviceIdx_), frameQueue(32)
2943
{
@@ -57,22 +71,40 @@ std::string OnixDevice::createStreamName(std::vector<std::string> names)
5771
return streamName;
5872
}
5973

74+
bool OnixDevice::isValidPassthroughIndex(oni_dev_idx_t passthroughIndex)
75+
{
76+
return passthroughIndex == (uint32_t)PassthroughIndex::A || passthroughIndex == (uint32_t)PassthroughIndex::B;
77+
}
78+
6079
oni_dev_idx_t OnixDevice::getHubIndexFromPassthroughIndex(oni_dev_idx_t passthroughIndex)
6180
{
62-
if (passthroughIndex != (uint32_t)PassthroughIndex::A && passthroughIndex != (uint32_t)PassthroughIndex::B)
81+
if (!isValidPassthroughIndex(passthroughIndex))
6382
{
64-
LOGE("Invalid passthrough index given. Value was ", passthroughIndex);
83+
Onix1::showWarningMessageBoxAsync("Invalid Index", "Invalid passthrough index given. Value was " + std::to_string(passthroughIndex));
6584
return 0;
6685
}
6786

6887
return (passthroughIndex - 7) << 8;
6988
}
7089

90+
oni_dev_idx_t OnixDevice::getPassthroughIndexFromHubIndex(oni_dev_idx_t hubIndex)
91+
{
92+
auto index = (hubIndex >> 8) + 7;
93+
94+
if (!isValidPassthroughIndex(index))
95+
{
96+
Onix1::showWarningMessageBoxAsync("Invalid Index", "Invalid hub index given. Value was " + std::to_string(hubIndex));
97+
return 0;
98+
}
99+
100+
return index;
101+
}
102+
71103
oni_dev_idx_t OnixDevice::getDeviceIndexFromPassthroughIndex(oni_dev_idx_t passthroughIndex) const
72104
{
73-
if (passthroughIndex != (uint32_t)PassthroughIndex::A && passthroughIndex != (uint32_t)PassthroughIndex::B)
105+
if (!isValidPassthroughIndex(passthroughIndex))
74106
{
75-
LOGE("Invalid passthrough index given. Value was ", passthroughIndex);
107+
Onix1::showWarningMessageBoxAsync("Invalid Index", "Invalid passthrough index given. Value was " + std::to_string(passthroughIndex));
76108
return 0;
77109
}
78110

@@ -203,8 +235,8 @@ std::vector<int> OnixDevice::getUniqueOffsets(OnixDeviceMap devices, bool ignore
203235
{
204236
std::vector<int> indices;
205237

206-
for (const auto& [key, _] : devices)
207-
{
238+
for (const auto& [key, _] : devices)
239+
{
208240
indices.emplace_back(key);
209241
}
210242

@@ -241,141 +273,3 @@ void OnixDevice::stopAcquisition()
241273
oni_destroy_frame(frame);
242274
}
243275
}
244-
245-
CompositeDevice::CompositeDevice(std::string name_, std::string hubName, CompositeDeviceType type_, const oni_dev_idx_t devIdx, OnixDeviceVector devices_, std::shared_ptr<Onix1> oni_ctx)
246-
: OnixDevice(name_, hubName, OnixDeviceType::COMPOSITE, devIdx, oni_ctx)
247-
{
248-
compositeType = type_;
249-
devices = devices_;
250-
}
251-
252-
CompositeDeviceType CompositeDevice::getCompositeDeviceType() const
253-
{
254-
return compositeType;
255-
}
256-
257-
bool CompositeDevice::compareIndex(uint32_t index)
258-
{
259-
for (const auto& device : devices)
260-
{
261-
if (device->getDeviceIdx() == index)
262-
return true;
263-
}
264-
265-
return false;
266-
}
267-
268-
bool CompositeDevice::isEnabled() const
269-
{
270-
bool enabled = true;
271-
272-
for (const auto& device : devices)
273-
{
274-
enabled &= device->isEnabled();
275-
}
276-
277-
return enabled;
278-
}
279-
280-
bool CompositeDevice::isEnabled(uint32_t index)
281-
{
282-
for (const auto& device : devices)
283-
{
284-
if (device->compareIndex(index))
285-
return device->isEnabled();
286-
}
287-
288-
Onix1::showWarningMessageBoxAsync(
289-
"Unknown Index",
290-
"Could not get the enabled status of a device at index " + std::to_string(index) + ", it was not found in " + getName()
291-
);
292-
293-
return false;
294-
}
295-
296-
void CompositeDevice::setEnabled(bool newState)
297-
{
298-
for (const auto& device : devices)
299-
{
300-
device->setEnabled(newState);
301-
}
302-
}
303-
304-
void CompositeDevice::setEnabled(uint32_t index, bool newState)
305-
{
306-
for (const auto& device : devices)
307-
{
308-
if (device->compareIndex(index))
309-
{
310-
device->setEnabled(newState);
311-
return;
312-
}
313-
}
314-
315-
Onix1::showWarningMessageBoxAsync(
316-
"Unknown Index",
317-
"Could not set the enabled status of a device at index " + std::to_string(index) + ", it was not found in " + getName()
318-
);
319-
320-
return;
321-
}
322-
323-
int CompositeDevice::configureDevice()
324-
{
325-
int result = ONI_ESUCCESS;
326-
327-
for (const auto& device : devices)
328-
{
329-
result |= device->configureDevice();
330-
}
331-
332-
return result;
333-
}
334-
335-
bool CompositeDevice::updateSettings()
336-
{
337-
bool result = true;
338-
339-
for (const auto& device : devices)
340-
{
341-
result &= device->updateSettings();
342-
}
343-
344-
return result;
345-
}
346-
347-
void CompositeDevice::startAcquisition()
348-
{
349-
for (const auto& device : devices)
350-
{
351-
device->startAcquisition();
352-
}
353-
}
354-
355-
void CompositeDevice::stopAcquisition()
356-
{
357-
for (const auto& device : devices)
358-
{
359-
device->stopAcquisition();
360-
}
361-
}
362-
363-
void CompositeDevice::addSourceBuffers(OwnedArray<DataBuffer>& sourceBuffers)
364-
{
365-
for (const auto& device : devices)
366-
{
367-
device->addSourceBuffers(sourceBuffers);
368-
}
369-
}
370-
371-
void CompositeDevice::addFrame(oni_frame_t* frame)
372-
{
373-
for (const auto& device : devices)
374-
{
375-
if (device->compareIndex(frame->dev_idx))
376-
{
377-
device->addFrame(frame);
378-
return;
379-
}
380-
}
381-
}

0 commit comments

Comments
 (0)