Loading...
Searching...
No Matches
m2kanalogin.hpp
/*
* Copyright (c) 2019 Analog Devices Inc.
*
* This file is part of libm2k
* (see http://www.github.com/analogdevicesinc/libm2k).
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef M2KANALOGIN_HPP
#define M2KANALOGIN_HPP
#include <libm2k/m2kglobal.hpp>
#include <libm2k/analog/enums.hpp>
#include <libm2k/m2khardwaretrigger.hpp>
#include <vector>
#include <map>
#include <memory>
namespace libm2k {
namespace analog {
class LIBM2K_API M2kAnalogIn
{
public:
virtual ~M2kAnalogIn() {}
virtual void reset() = 0;
virtual void startAcquisition(unsigned int nb_samples) = 0;
virtual void stopAcquisition() = 0;
virtual std::vector<std::vector<double>> getSamples(unsigned int nb_samples) = 0;
virtual std::vector<std::vector<double>> getSamplesRaw(unsigned int nb_samples) = 0;
virtual const double* getSamplesInterleaved(unsigned int nb_samples_per_channel) = 0;
virtual const short* getSamplesRawInterleaved(unsigned int nb_samples_per_channel) = 0;
virtual const double* getSamplesInterleaved_matlab(unsigned int nb_samples) = 0;
virtual const short* getSamplesRawInterleaved_matlab(unsigned int nb_samples) = 0;
virtual short getVoltageRaw(unsigned int ch) = 0;
virtual double getVoltage(unsigned int ch) = 0;
virtual short getVoltageRaw(libm2k::analog::ANALOG_IN_CHANNEL ch) = 0;
virtual double getVoltage(libm2k::analog::ANALOG_IN_CHANNEL ch) = 0;
virtual std::vector<short> getVoltageRaw() = 0;
virtual std::vector<double> getVoltage() = 0;
virtual const short *getVoltageRawP() = 0;
virtual const double *getVoltageP() = 0;
virtual void setVerticalOffset(ANALOG_IN_CHANNEL channel, double vertOffset) = 0;
virtual double getVerticalOffset(ANALOG_IN_CHANNEL channel) = 0;
virtual double getScalingFactor(libm2k::analog::ANALOG_IN_CHANNEL ch) = 0;
virtual void setRange(ANALOG_IN_CHANNEL channel, M2K_RANGE range) = 0;
virtual void setRange(ANALOG_IN_CHANNEL channel, double min, double max) = 0;
virtual libm2k::analog::M2K_RANGE getRange(libm2k::analog::ANALOG_IN_CHANNEL channel) = 0;
virtual std::pair<double, double> getRangeLimits(libm2k::analog::M2K_RANGE range) = 0;
virtual std::vector<std::pair<std::string, std::pair<double, double>>> getAvailableRanges() = 0;
virtual int getOversamplingRatio() = 0;
virtual int getOversamplingRatio(unsigned int chn_idx) = 0;
virtual int setOversamplingRatio(int oversampling) = 0;
virtual int setOversamplingRatio(unsigned int chn_idx, int oversampling) = 0;
virtual double getSampleRate() = 0;
virtual std::vector<double> getAvailableSampleRates() = 0;
virtual double setSampleRate(double samplerate) = 0;
virtual std::pair<double, double> getHysteresisRange(ANALOG_IN_CHANNEL chn) = 0;
virtual double getFilterCompensation(double samplerate) = 0;
virtual double getValueForRange(M2K_RANGE range) = 0;
virtual double convertRawToVolts(unsigned int channel, short raw) = 0;
virtual short convertVoltsToRaw(unsigned int channel, double voltage) = 0;
virtual unsigned int getNbChannels() = 0;
virtual std::string getName() = 0;
virtual void enableChannel(unsigned int chnIdx, bool enable) = 0;
virtual bool isChannelEnabled(unsigned int chnIdx) = 0;
virtual void cancelAcquisition() = 0;
virtual void setKernelBuffersCount(unsigned int count) = 0;
virtual unsigned int getKernelBuffersCount() const = 0;
virtual libm2k::M2kHardwareTrigger* getTrigger() = 0;
virtual struct IIO_OBJECTS getIioObjects() = 0;
virtual void getSamples(std::vector<std::vector<double>> &data, unsigned int nb_samples) = 0;
virtual std::string getChannelName(unsigned int channel) = 0;
virtual double getMaximumSamplerate() = 0;
};
}
}
#endif //M2KANALOGIN_HPP
enums.hpp
Analogical enumerations.
libm2k::analog::M2K_RANGE
M2K_RANGE
Range of the signal's amplitude.
Definition analog/enums.hpp:70
libm2k::analog::ANALOG_IN_CHANNEL
ANALOG_IN_CHANNEL
Indexes of the channels.
Definition analog/enums.hpp:59
libm2k::M2kHardwareTrigger
Controls the hardware trigger for ADALM2000.
Definition m2khardwaretrigger.hpp:42
libm2k::analog::M2kAnalogIn
Controls the analogical input compound.
Definition m2kanalogin.hpp:47
libm2k::analog::M2kAnalogIn::getScalingFactor
virtual double getScalingFactor(libm2k::analog::ANALOG_IN_CHANNEL ch)=0
Retrieve the scaling factor.
libm2k::analog::M2kAnalogIn::getRangeLimits
virtual std::pair< double, double > getRangeLimits(libm2k::analog::M2K_RANGE range)=0
Retrieve the bounds for the given range.
libm2k::analog::M2kAnalogIn::setSampleRate
virtual double setSampleRate(double samplerate)=0
Set the global sample rate.
libm2k::analog::M2kAnalogIn::getFilterCompensation
virtual double getFilterCompensation(double samplerate)=0
Retrieve the filter compensation for the given sample rate.
libm2k::analog::M2kAnalogIn::getChannelName
virtual std::string getChannelName(unsigned int channel)=0
Get the channel name for each ADC channel.
libm2k::analog::M2kAnalogIn::setOversamplingRatio
virtual int setOversamplingRatio(unsigned int chn_idx, int oversampling)=0
Set the oversampling ratio for the given channel.
libm2k::analog::M2kAnalogIn::getSamplesInterleaved_matlab
virtual const double * getSamplesInterleaved_matlab(unsigned int nb_samples)=0
Retrieve a specific number of samples from both channels.
libm2k::analog::M2kAnalogIn::getSamplesRawInterleaved
virtual const short * getSamplesRawInterleaved(unsigned int nb_samples_per_channel)=0
Retrieve a specific number of raw samples from each channel.
libm2k::analog::M2kAnalogIn::getRange
virtual libm2k::analog::M2K_RANGE getRange(libm2k::analog::ANALOG_IN_CHANNEL channel)=0
Retrieve the range for the given channel.
libm2k::analog::M2kAnalogIn::convertRawToVolts
virtual double convertRawToVolts(unsigned int channel, short raw)=0
Convert the raw value of a sample into volts.
libm2k::analog::M2kAnalogIn::setKernelBuffersCount
virtual void setKernelBuffersCount(unsigned int count)=0
Set the kernel buffers to a specific value.
libm2k::analog::M2kAnalogIn::getVoltageRaw
virtual std::vector< short > getVoltageRaw()=0
Retrieve the average raw value for each channel.
libm2k::analog::M2kAnalogIn::getVoltageRaw
virtual short getVoltageRaw(libm2k::analog::ANALOG_IN_CHANNEL ch)=0
Retrieve the average raw value of the given channel.
libm2k::analog::M2kAnalogIn::getVoltageRaw
virtual short getVoltageRaw(unsigned int ch)=0
Retrieve the average raw value of the given channel.
libm2k::analog::M2kAnalogIn::stopAcquisition
virtual void stopAcquisition()=0
Destroy the buffer and stop the acquisition.
libm2k::analog::M2kAnalogIn::getOversamplingRatio
virtual int getOversamplingRatio()=0
Retrieve the global oversampling ratio.
libm2k::analog::M2kAnalogIn::getVoltage
virtual double getVoltage(unsigned int ch)=0
Retrieve the average voltage of the given channel.
libm2k::analog::M2kAnalogIn::isChannelEnabled
virtual bool isChannelEnabled(unsigned int chnIdx)=0
Retrieve the state of the given channel.
libm2k::analog::M2kAnalogIn::getSamplesRawInterleaved_matlab
virtual const short * getSamplesRawInterleaved_matlab(unsigned int nb_samples)=0
Retrieve a specific number of raw samples from both channels.
libm2k::analog::M2kAnalogIn::getSampleRate
virtual double getSampleRate()=0
Retrieve the global sample rate.
libm2k::analog::M2kAnalogIn::getVoltageP
virtual const double * getVoltageP()=0
Retrieve the average voltage for both channels.
libm2k::analog::M2kAnalogIn::enableChannel
virtual void enableChannel(unsigned int chnIdx, bool enable)=0
Enable or disable the given channel.
libm2k::analog::M2kAnalogIn::setVerticalOffset
virtual void setVerticalOffset(ANALOG_IN_CHANNEL channel, double vertOffset)=0
Set the vertical offset, in Volts, of a specific channel.
libm2k::analog::M2kAnalogIn::getSamples
virtual void getSamples(std::vector< std::vector< double > > &data, unsigned int nb_samples)=0
Retrieve a specific number of samples from each channel.
libm2k::analog::M2kAnalogIn::getSamples
virtual std::vector< std::vector< double > > getSamples(unsigned int nb_samples)=0
Retrieve a specific number of samples from each channel.
libm2k::analog::M2kAnalogIn::getAvailableRanges
virtual std::vector< std::pair< std::string, std::pair< double, double > > > getAvailableRanges()=0
Retrieve all ranges that are available.
libm2k::analog::M2kAnalogIn::getVoltageRawP
virtual const short * getVoltageRawP()=0
Retrieve the average raw value for both channels.
libm2k::analog::M2kAnalogIn::startAcquisition
virtual void startAcquisition(unsigned int nb_samples)=0
Create the buffer for both channels and start the acquisition.
libm2k::analog::M2kAnalogIn::cancelAcquisition
virtual void cancelAcquisition()=0
Cancel all buffer operations.
libm2k::analog::M2kAnalogIn::getValueForRange
virtual double getValueForRange(M2K_RANGE range)=0
Retrieve the numeric value corresponding to the given range.
libm2k::analog::M2kAnalogIn::getAvailableSampleRates
virtual std::vector< double > getAvailableSampleRates()=0
getAvailableSampleRates
libm2k::analog::M2kAnalogIn::setRange
virtual void setRange(ANALOG_IN_CHANNEL channel, double min, double max)=0
Set the range for the given channel.
libm2k::analog::M2kAnalogIn::getVoltage
virtual double getVoltage(libm2k::analog::ANALOG_IN_CHANNEL ch)=0
Retrieve the average voltage of the given channel.
libm2k::analog::M2kAnalogIn::getTrigger
virtual libm2k::M2kHardwareTrigger * getTrigger()=0
Get the hardware trigger handler.
libm2k::analog::M2kAnalogIn::getName
virtual std::string getName()=0
Retrieve the name of the device.
libm2k::analog::M2kAnalogIn::convertVoltsToRaw
virtual short convertVoltsToRaw(unsigned int channel, double voltage)=0
Convert the voltage value of a sample into raw.
libm2k::analog::M2kAnalogIn::getOversamplingRatio
virtual int getOversamplingRatio(unsigned int chn_idx)=0
Retrieve the oversampling ratio for the given channel.
libm2k::analog::M2kAnalogIn::getKernelBuffersCount
virtual unsigned int getKernelBuffersCount() const =0
Get the number of kernel buffers.
libm2k::analog::M2kAnalogIn::getMaximumSamplerate
virtual double getMaximumSamplerate()=0
Get the maximum samplerate for the ADC.
libm2k::analog::M2kAnalogIn::getSamplesInterleaved
virtual const double * getSamplesInterleaved(unsigned int nb_samples_per_channel)=0
Retrieve a specific number of samples from each channel.
libm2k::analog::M2kAnalogIn::getVerticalOffset
virtual double getVerticalOffset(ANALOG_IN_CHANNEL channel)=0
getVerticalOffset
libm2k::analog::M2kAnalogIn::getSamplesRaw
virtual std::vector< std::vector< double > > getSamplesRaw(unsigned int nb_samples)=0
Retrieve a specific number of raw samples from each channel.
libm2k::analog::M2kAnalogIn::getVoltage
virtual std::vector< double > getVoltage()=0
Retrieve the average voltage for each channel.
libm2k::analog::M2kAnalogIn::setRange
virtual void setRange(ANALOG_IN_CHANNEL channel, M2K_RANGE range)=0
Set the range for the given channel.
libm2k::analog::M2kAnalogIn::getNbChannels
virtual unsigned int getNbChannels()=0
Retrieve the number of analogical channels.
libm2k::analog::M2kAnalogIn::setOversamplingRatio
virtual int setOversamplingRatio(int oversampling)=0
Set the global oversampling ratio.
libm2k::analog::M2kAnalogIn::getHysteresisRange
virtual std::pair< double, double > getHysteresisRange(ANALOG_IN_CHANNEL chn)=0
Retrieve the bounds of the analogical trigger's hysteresis for the given channel.