diff --git a/Source/Devices/AnalogIO.cpp b/Source/Devices/AnalogIO.cpp index 5c0cc0d..3d28db7 100644 --- a/Source/Devices/AnalogIO.cpp +++ b/Source/Devices/AnalogIO.cpp @@ -27,6 +27,8 @@ using namespace OnixSourcePlugin; AnalogIO::AnalogIO (std::string name, std::string hubName, const oni_dev_idx_t deviceIdx_, std::shared_ptr oni_ctx) : OnixDevice (name, hubName, AnalogIO::getDeviceType(), deviceIdx_, oni_ctx) { + const ContinuousChannel::InputRange inputRange { -10.0f, 10.0f }; + StreamInfo analogInputStream = StreamInfo ( OnixDevice::createStreamName ({ getHubName(), name, "AnalogInput" }), "Analog Input data", @@ -38,7 +40,9 @@ AnalogIO::AnalogIO (std::string name, std::string hubName, const oni_dev_idx_t d getVoltsPerDivision (AnalogIOVoltageRange::TenVolts), // NB: +/- 10 Volts "V", {}, - { "input" }); + { "input" }, + {}, + { inputRange }); streamInfos.add (analogInputStream); for (int i = 0; i < numFrames; i++) diff --git a/Source/Devices/Bno055.cpp b/Source/Devices/Bno055.cpp index 14547ef..2847942 100644 --- a/Source/Devices/Bno055.cpp +++ b/Source/Devices/Bno055.cpp @@ -30,6 +30,11 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic auto streamIdentifier = getStreamIdentifier(); std::string port = getPortName (deviceIdx); + + const ContinuousChannel::InputRange eulerYawRange { -360.0f, 360.0f }; + const ContinuousChannel::InputRange eulerRollRange { -180.0f, 180.0f }; + const ContinuousChannel::InputRange eulerPitchRange { -90.0f, 90.0f }; + StreamInfo eulerAngleStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), "Euler" }), "Bosch Bno055 9-axis inertial measurement unit (IMU) Euler angle", @@ -39,12 +44,15 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic "Eul", ContinuousChannel::Type::AUX, eulerAngleScale, - "Degrees", + "Deg.", { "Y", "R", "P" }, "euler", - { "y", "r", "p" }); + { "y", "r", "p" }, + { eulerYawRange, eulerRollRange, eulerPitchRange }); streamInfos.add (eulerAngleStream); + const ContinuousChannel::InputRange quaternionRange { -1.0f, 1.0f }; + StreamInfo quaternionStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), "Quaternion" }), "Bosch Bno055 9-axis inertial measurement unit (IMU) Quaternion", @@ -54,12 +62,15 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic "Quat", ContinuousChannel::Type::AUX, quaternionScale, - "u", // NB: Quaternion data is unitless by definition + "", // NB: Quaternion data is unitless by definition { "W", "X", "Y", "Z" }, "quaternion", - { "w", "x", "y", "z" }); + { "w", "x", "y", "z" }, + { quaternionRange }); streamInfos.add (quaternionStream); + const ContinuousChannel::InputRange accelerationRange { -100.0f, 100.0f }; + StreamInfo accelerationStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), "Acceleration" }), "Bosch Bno055 9-axis inertial measurement unit (IMU) Acceleration", @@ -72,9 +83,12 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic "m/s^2", { "X", "Y", "Z" }, "acceleration", - { "x", "y", "z" }); + { "x", "y", "z" }, + { accelerationRange }); streamInfos.add (accelerationStream); + const ContinuousChannel::InputRange gravityRange { -10.0f, 10.0f }; + StreamInfo gravityStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), "Gravity" }), "Bosch Bno055 9-axis inertial measurement unit (IMU) Gravity", @@ -87,9 +101,12 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic "m/s^2", { "X", "Y", "Z" }, "gravity", - { "x", "y", "z" }); + { "x", "y", "z" }, + { gravityRange }); streamInfos.add (gravityStream); + const ContinuousChannel::InputRange temperatureRange { -100.0f, 100.0f }; + StreamInfo temperatureStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), "Temperature" }), "Bosch Bno055 9-axis inertial measurement unit (IMU) Temperature", @@ -99,11 +116,15 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic "Temp", ContinuousChannel::Type::AUX, 1.0f, - "Celsius", + String::fromUTF8 ("\xc2\xb0") + String ("C"), // NB: "\xc2\xb0" --> degree symbol { "" }, - "temperature"); + "temperature", + {}, + { temperatureRange }); streamInfos.add (temperatureStream); + const ContinuousChannel::InputRange calibrationRange { -3.0f, 3.0f }; + StreamInfo calibrationStatusStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), "Calibration" }), "Bosch Bno055 9-axis inertial measurement unit (IMU) Calibration status", @@ -116,7 +137,8 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic "", { "Mag", "Acc", "Gyr", "Sys" }, "calibration", - { "magnetometer", "acceleration", "gyroscope", "system" }); + { "magnetometer", "acceleration", "gyroscope", "system" }, + { calibrationRange }); streamInfos.add (calibrationStatusStream); for (int i = 0; i < numFrames; i++) diff --git a/Source/Devices/DigitalIO.cpp b/Source/Devices/DigitalIO.cpp index acd6de9..e81e935 100644 --- a/Source/Devices/DigitalIO.cpp +++ b/Source/Devices/DigitalIO.cpp @@ -28,6 +28,8 @@ using namespace OnixSourcePlugin; DigitalIO::DigitalIO (std::string name, std::string hubName, const oni_dev_idx_t deviceIdx_, std::shared_ptr oni_ctx) : OnixDevice (name, hubName, DigitalIO::getDeviceType(), deviceIdx_, oni_ctx) { + const ContinuousChannel::InputRange digitalRange { 0.0f, 1.0f }; + StreamInfo digitalInputStream = StreamInfo ( OnixDevice::createStreamName ({ getHubName(), name, "DigitalInputs" }), "Digital Inputs data", @@ -39,7 +41,9 @@ DigitalIO::DigitalIO (std::string name, std::string hubName, const oni_dev_idx_t 1.0, "u", // NB: Digital data is unitless by definition {}, - { "input" }); + { "input" }, + {}, + { digitalRange }); streamInfos.add (digitalInputStream); StreamInfo digitalButtonStream = StreamInfo ( @@ -53,7 +57,9 @@ DigitalIO::DigitalIO (std::string name, std::string hubName, const oni_dev_idx_t 1.0, "u", // NB: Digital data is unitless by definition { "Moon", "Triangle", "X", "Check", "Circle", "Square" }, - { "input" }); + { "input" }, + {}, + { digitalRange }); streamInfos.add (digitalButtonStream); eventCodes.fill (0); diff --git a/Source/Devices/HarpSyncInput.cpp b/Source/Devices/HarpSyncInput.cpp index 9e24cc8..837ef7a 100644 --- a/Source/Devices/HarpSyncInput.cpp +++ b/Source/Devices/HarpSyncInput.cpp @@ -40,7 +40,9 @@ HarpSyncInput::HarpSyncInput (std::string name, std::string hubName, const oni_d 1.0f, "s", { "" }, - "harptime"); + "harptime", + {}, + {}); streamInfos.add (harpTimeStream); for (int i = 0; i < numFrames; i++) diff --git a/Source/Devices/MemoryMonitor.cpp b/Source/Devices/MemoryMonitor.cpp index 8843852..a569e79 100644 --- a/Source/Devices/MemoryMonitor.cpp +++ b/Source/Devices/MemoryMonitor.cpp @@ -77,6 +77,8 @@ void MemoryMonitorUsage::stopAcquisition() MemoryMonitor::MemoryMonitor (std::string name, std::string hubName, const oni_dev_idx_t deviceIdx_, std::shared_ptr oni_ctx) : OnixDevice (name, hubName, MemoryMonitor::getDeviceType(), deviceIdx_, oni_ctx) { + const ContinuousChannel::InputRange percentRange { -100.0f, 100.0f }; + StreamInfo percentUsedStream = StreamInfo ( OnixDevice::createStreamName ({ getHubName(), getName(), "PercentUsed" }), "Percent of available memory that is currently used", @@ -88,7 +90,9 @@ MemoryMonitor::MemoryMonitor (std::string name, std::string hubName, const oni_d 1.0f, "%", { "" }, - "percent"); + "percent", + {}, + { percentRange }); streamInfos.add (percentUsedStream); } diff --git a/Source/Devices/Neuropixels1e.cpp b/Source/Devices/Neuropixels1e.cpp index ae9a995..05f3a0f 100644 --- a/Source/Devices/Neuropixels1e.cpp +++ b/Source/Devices/Neuropixels1e.cpp @@ -79,6 +79,7 @@ Neuropixels1e::Neuropixels1e (std::string name, std::string hubName, const oni_d : Neuropixels1 (name, hubName, OnixDeviceType::NEUROPIXELSV1E, deviceIdx_, ctx_) { std::string port = getPortName (getDeviceIdx()); + StreamInfo apStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), STREAM_NAME_AP }), "Neuropixels 1.0 AP band data stream", @@ -90,7 +91,9 @@ Neuropixels1e::Neuropixels1e (std::string name, std::string hubName, const oni_d 0.195f, "uV", {}, - "ap"); + "ap", + {}, + {}); streamInfos.add (apStream); StreamInfo lfpStream = StreamInfo ( @@ -104,7 +107,9 @@ Neuropixels1e::Neuropixels1e (std::string name, std::string hubName, const oni_d 0.195f, "uV", {}, - "lfp"); + "lfp", + {}, + {}); streamInfos.add (lfpStream); defineMetadata (settings[0].get()); diff --git a/Source/Devices/Neuropixels1f.cpp b/Source/Devices/Neuropixels1f.cpp index e7e77cd..620d1af 100644 --- a/Source/Devices/Neuropixels1f.cpp +++ b/Source/Devices/Neuropixels1f.cpp @@ -78,7 +78,9 @@ Neuropixels1f::Neuropixels1f (std::string name, std::string hubName, const oni_d 0.195f, "uV", {}, - "ap"); + "ap", + {}, + {}); streamInfos.add (apStream); StreamInfo lfpStream = StreamInfo ( @@ -92,7 +94,9 @@ Neuropixels1f::Neuropixels1f (std::string name, std::string hubName, const oni_d 0.195f, "uV", {}, - "lfp"); + "lfp", + {}, + {}); streamInfos.add (lfpStream); defineMetadata (settings[0].get()); diff --git a/Source/Devices/Neuropixels2e.cpp b/Source/Devices/Neuropixels2e.cpp index fbce27b..1638f5a 100644 --- a/Source/Devices/Neuropixels2e.cpp +++ b/Source/Devices/Neuropixels2e.cpp @@ -67,7 +67,9 @@ void Neuropixels2e::createDataStream (int n) 0.195f, "uV", {}, - "ap"); + "ap", + {}, + {}); streamInfos.add (apStream); } diff --git a/Source/Devices/PolledBno055.cpp b/Source/Devices/PolledBno055.cpp index db8cc37..2f50220 100644 --- a/Source/Devices/PolledBno055.cpp +++ b/Source/Devices/PolledBno055.cpp @@ -31,6 +31,10 @@ PolledBno055::PolledBno055 (std::string name, std::string hubName, const oni_dev { auto streamIdentifier = getStreamIdentifier(); + const ContinuousChannel::InputRange eulerYawRange { -360.0f, 360.0f }; + const ContinuousChannel::InputRange eulerRollRange { -180.0f, 180.0f }; + const ContinuousChannel::InputRange eulerPitchRange { -90.0f, 90.0f }; + std::string port = getPortName (deviceIdx); StreamInfo eulerAngleStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), "Euler" }), @@ -41,12 +45,15 @@ PolledBno055::PolledBno055 (std::string name, std::string hubName, const oni_dev "Eul", ContinuousChannel::Type::AUX, EulerAngleScale, - "Degrees", + "Deg.", { "Y", "R", "P" }, "euler", - { "y", "r", "p" }); + { "y", "r", "p" }, + { eulerYawRange, eulerRollRange, eulerPitchRange }); streamInfos.add (eulerAngleStream); + const ContinuousChannel::InputRange quaternionRange { -1.0f, 1.0f }; + StreamInfo quaternionStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), "Quaternion" }), "Bosch Bno055 9-axis inertial measurement unit (IMU) Quaternion", @@ -56,12 +63,15 @@ PolledBno055::PolledBno055 (std::string name, std::string hubName, const oni_dev "Quat", ContinuousChannel::Type::AUX, QuaternionScale, - "", + "", // NB: Quaternion data is unitless by definition { "W", "X", "Y", "Z" }, "quaternion", - { "w", "x", "y", "z" }); + { "w", "x", "y", "z" }, + { quaternionRange }); streamInfos.add (quaternionStream); + const ContinuousChannel::InputRange accelerationRange { -100.0f, 100.0f }; + StreamInfo accelerationStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), "Acceleration" }), "Bosch Bno055 9-axis inertial measurement unit (IMU) Acceleration", @@ -71,12 +81,15 @@ PolledBno055::PolledBno055 (std::string name, std::string hubName, const oni_dev "Acc", ContinuousChannel::Type::AUX, AccelerationScale, - "m / s ^ 2", + "m/s^2", { "X", "Y", "Z" }, "acceleration", - { "x", "y", "z" }); + { "x", "y", "z" }, + { accelerationRange }); streamInfos.add (accelerationStream); + const ContinuousChannel::InputRange gravityRange { -10.0f, 10.0f }; + StreamInfo gravityStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), "Gravity" }), "Bosch Bno055 9-axis inertial measurement unit (IMU) Gravity", @@ -89,9 +102,12 @@ PolledBno055::PolledBno055 (std::string name, std::string hubName, const oni_dev "m/s^2", { "X", "Y", "Z" }, "gravity", - { "x", "y", "z" }); + { "x", "y", "z" }, + { gravityRange }); streamInfos.add (gravityStream); + const ContinuousChannel::InputRange temperatureRange { -100.0f, 100.0f }; + StreamInfo temperatureStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), "Temperature" }), "Bosch Bno055 9-axis inertial measurement unit (IMU) Temperature", @@ -101,11 +117,15 @@ PolledBno055::PolledBno055 (std::string name, std::string hubName, const oni_dev "Temp", ContinuousChannel::Type::AUX, 1.0f, - "Celsius", + String::fromUTF8 ("\xc2\xb0") + String ("C"), // NB: "\xc2\xb0" --> degree symbol { "" }, - "temperature"); + "temperature", + {}, + { temperatureRange }); streamInfos.add (temperatureStream); + const ContinuousChannel::InputRange calibrationRange { -3.0f, 3.0f }; + StreamInfo calibrationStatusStream = StreamInfo ( OnixDevice::createStreamName ({ port, getHubName(), getName(), "Calibration" }), "Bosch Bno055 9-axis inertial measurement unit (IMU) Calibration status", @@ -118,7 +138,8 @@ PolledBno055::PolledBno055 (std::string name, std::string hubName, const oni_dev "", { "Mag", "Acc", "Gyr", "Sys" }, "calibration", - { "magnetometer", "acceleration", "gyroscope", "system" }); + { "magnetometer", "acceleration", "gyroscope", "system" }, + { calibrationRange }); streamInfos.add (calibrationStatusStream); for (int i = 0; i < NumFrames; i++) diff --git a/Source/OnixDevice.h b/Source/OnixDevice.h index 1ff9dcf..5ca40c6 100644 --- a/Source/OnixDevice.h +++ b/Source/OnixDevice.h @@ -71,10 +71,11 @@ struct StreamInfo std::string channelPrefix, ContinuousChannel::Type channelType, float bitVolts, - std::string units, + String units, std::vector channelNameSuffixes, std::string channelIdentifierDataType, - std::vector channelIdentifierSubTypes = {}) + std::vector channelIdentifierSubTypes, + std::vector inputRanges) { m_name = name; m_description = description; @@ -88,6 +89,7 @@ struct StreamInfo m_channelNameSuffixes = channelNameSuffixes; m_channelIdentifierDataType = channelIdentifierDataType; m_channelIdentifierSubTypes = channelIdentifierSubTypes; + channelInputRanges = inputRanges; if (m_numChannels != m_channelNameSuffixes.size()) { @@ -127,6 +129,28 @@ struct StreamInfo } } } + + if (channelInputRanges.size() == 0) + { + LOGE ("Must specify at least one channel input range."); + + channelInputRanges.push_back (ContinuousChannel::InputRange()); + } + else + { + ContinuousChannel::InputRange range = channelInputRanges[0]; + + if (channelInputRanges.size() == 1) + { + channelInputRanges.assign (m_numChannels, range); + } + else if (m_numChannels != channelInputRanges.size()) + { + LOGE ("Invalid number of channel input ranges given. Must either be one input range for all channels, or the same number of input ranges as channels."); + + channelInputRanges.assign (m_numChannels, range); + } + } }; std::string getName() const { return m_name; } @@ -137,10 +161,11 @@ struct StreamInfo std::string getChannelPrefix() const { return m_channelPrefix; } ContinuousChannel::Type getChannelType() const { return m_channelType; } float getBitVolts() const { return m_bitVolts; } - std::string getUnits() const { return m_units; } + String getUnits() const { return m_units; } std::vector getChannelNameSuffixes() const { return m_channelNameSuffixes; } std::string getChannelIdentifierDataType() const { return m_channelIdentifierDataType; } std::vector getChannelIdentifierSubTypes() const { return m_channelIdentifierSubTypes; } + ContinuousChannel::InputRange getChannelInputRange (int index) const { return channelInputRanges.at (index); } private: std::string m_name = "name"; @@ -151,10 +176,11 @@ struct StreamInfo std::string m_channelPrefix = "channelPrefix"; ContinuousChannel::Type m_channelType = ContinuousChannel::Type::INVALID; float m_bitVolts = 1.0f; - std::string m_units = "units"; + String m_units = "units"; std::vector m_channelNameSuffixes = { "suffixes" }; std::string m_channelIdentifierDataType = "datatype"; std::vector m_channelIdentifierSubTypes = { "subtypes" }; + std::vector channelInputRanges = {}; }; using OnixDeviceMap = std::map; diff --git a/Source/OnixSource.cpp b/Source/OnixSource.cpp index 76946ba..c4ddb27 100644 --- a/Source/OnixSource.cpp +++ b/Source/OnixSource.cpp @@ -991,6 +991,7 @@ void OnixSource::addCombinedStreams (DataStream::Settings dataStreamSettings, }; continuousChannels->add (new ContinuousChannel (channelSettings)); continuousChannels->getLast()->setUnits (streamInfo.getUnits()); + continuousChannels->getLast()->inputRange = streamInfo.getChannelInputRange (chan); } } }