libm2k
Loading...
Searching...
No Matches
m2kanalogin.hpp
1/*
2 * Copyright (c) 2019 Analog Devices Inc.
3 *
4 * This file is part of libm2k
5 * (see http://www.github.com/analogdevicesinc/libm2k).
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 2.1 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef M2KANALOGIN_HPP
23#define M2KANALOGIN_HPP
24
25#include <libm2k/m2kglobal.hpp>
27#include <libm2k/m2khardwaretrigger.hpp>
28#include <vector>
29#include <map>
30#include <memory>
31
32namespace libm2k {
38namespace analog {
46class LIBM2K_API M2kAnalogIn
47{
48public:
52 virtual ~M2kAnalogIn() {}
53
57 virtual void reset() = 0;
58
63 virtual void startAcquisition(unsigned int nb_samples) = 0;
64
65
69 virtual void stopAcquisition() = 0;
70
71
82 virtual std::vector<std::vector<double>> getSamples(unsigned int nb_samples) = 0;
83
84
95 virtual std::vector<std::vector<double>> getSamplesRaw(unsigned int nb_samples) = 0;
96
97
110 virtual const double* getSamplesInterleaved(unsigned int nb_samples_per_channel) = 0;
111
112
125 virtual const short* getSamplesRawInterleaved(unsigned int nb_samples_per_channel) = 0;
126
127
142 virtual const double* getSamplesInterleaved_matlab(unsigned int nb_samples) = 0;
143
144
159 virtual const short* getSamplesRawInterleaved_matlab(unsigned int nb_samples) = 0;
160
161
168 virtual short getVoltageRaw(unsigned int ch) = 0;
169
170
177 virtual double getVoltage(unsigned int ch) = 0;
178
179
187
188
196
197
205 virtual std::vector<short> getVoltageRaw() = 0;
206
207
215 virtual std::vector<double> getVoltage() = 0;
216
217
223 virtual const short *getVoltageRawP() = 0;
224
225
231 virtual const double *getVoltageP() = 0;
232
238 virtual void setVerticalOffset(ANALOG_IN_CHANNEL channel, double vertOffset) = 0;
239
245 virtual double getVerticalOffset(ANALOG_IN_CHANNEL channel) = 0;
246
247
255
256
263 virtual void setRange(ANALOG_IN_CHANNEL channel, M2K_RANGE range) = 0;
264
265
273 virtual void setRange(ANALOG_IN_CHANNEL channel, double min, double max) = 0;
274
275
283
284
291 virtual std::pair<double, double> getRangeLimits(libm2k::analog::M2K_RANGE range) = 0;
292
293
299 virtual std::vector<std::pair<std::string, std::pair<double, double>>> getAvailableRanges() = 0;
300
301
307 virtual int getOversamplingRatio() = 0;
308
309
316 virtual int getOversamplingRatio(unsigned int chn_idx) = 0;
317
318
325 virtual int setOversamplingRatio(int oversampling) = 0;
326
327
335 virtual int setOversamplingRatio(unsigned int chn_idx, int oversampling) = 0;
336
337
343 virtual double getSampleRate() = 0;
344
345
350 virtual std::vector<double> getAvailableSampleRates() = 0;
351
358 virtual double setSampleRate(double samplerate) = 0;
359
360
367 virtual std::pair<double, double> getHysteresisRange(ANALOG_IN_CHANNEL chn) = 0;
368
369
376 virtual double getFilterCompensation(double samplerate) = 0;
377
378
385 virtual double getValueForRange(M2K_RANGE range) = 0;
386
387
394 virtual double convertRawToVolts(unsigned int channel, short raw) = 0;
395
396
404 virtual short convertVoltsToRaw(unsigned int channel, double voltage) = 0;
405
406
412 virtual unsigned int getNbChannels() = 0;
413
414
420 virtual std::string getName() = 0;
421
422
429 virtual void enableChannel(unsigned int chnIdx, bool enable) = 0;
430
431
439 virtual bool isChannelEnabled(unsigned int chnIdx) = 0;
440
441
446 virtual void cancelAcquisition() = 0;
447
448
453 virtual void setKernelBuffersCount(unsigned int count) = 0;
454
459 virtual unsigned int getKernelBuffersCount() const = 0;
460
461
468
474 virtual struct IIO_OBJECTS getIioObjects() = 0;
475
476
488 virtual void getSamples(std::vector<std::vector<double>> &data, unsigned int nb_samples) = 0;
489
495 virtual std::string getChannelName(unsigned int channel) = 0;
496
501 virtual double getMaximumSamplerate() = 0;
502
503};
504}
505}
506
507#endif //M2KANALOGIN_HPP
Analogical enumerations.
M2K_RANGE
Range of the signal's amplitude.
Definition analog/enums.hpp:70
ANALOG_IN_CHANNEL
Indexes of the channels.
Definition analog/enums.hpp:59
Controls the hardware trigger for ADALM2000.
Definition m2khardwaretrigger.hpp:42
Controls the analogical input compound.
Definition m2kanalogin.hpp:47
virtual double getScalingFactor(libm2k::analog::ANALOG_IN_CHANNEL ch)=0
Retrieve the scaling factor.
virtual std::pair< double, double > getRangeLimits(libm2k::analog::M2K_RANGE range)=0
Retrieve the bounds for the given range.
virtual double setSampleRate(double samplerate)=0
Set the global sample rate.
virtual double getFilterCompensation(double samplerate)=0
Retrieve the filter compensation for the given sample rate.
virtual std::string getChannelName(unsigned int channel)=0
Get the channel name for each ADC channel.
virtual int setOversamplingRatio(unsigned int chn_idx, int oversampling)=0
Set the oversampling ratio for the given channel.
virtual const double * getSamplesInterleaved_matlab(unsigned int nb_samples)=0
Retrieve a specific number of samples from both channels.
virtual const short * getSamplesRawInterleaved(unsigned int nb_samples_per_channel)=0
Retrieve a specific number of raw samples from each channel.
virtual libm2k::analog::M2K_RANGE getRange(libm2k::analog::ANALOG_IN_CHANNEL channel)=0
Retrieve the range for the given channel.
virtual double convertRawToVolts(unsigned int channel, short raw)=0
Convert the raw value of a sample into volts.
virtual void setKernelBuffersCount(unsigned int count)=0
Set the kernel buffers to a specific value.
virtual std::vector< short > getVoltageRaw()=0
Retrieve the average raw value for each channel.
virtual short getVoltageRaw(libm2k::analog::ANALOG_IN_CHANNEL ch)=0
Retrieve the average raw value of the given channel.
virtual short getVoltageRaw(unsigned int ch)=0
Retrieve the average raw value of the given channel.
virtual void stopAcquisition()=0
Destroy the buffer and stop the acquisition.
virtual int getOversamplingRatio()=0
Retrieve the global oversampling ratio.
virtual double getVoltage(unsigned int ch)=0
Retrieve the average voltage of the given channel.
virtual bool isChannelEnabled(unsigned int chnIdx)=0
Retrieve the state of the given channel.
virtual const short * getSamplesRawInterleaved_matlab(unsigned int nb_samples)=0
Retrieve a specific number of raw samples from both channels.
virtual double getSampleRate()=0
Retrieve the global sample rate.
virtual const double * getVoltageP()=0
Retrieve the average voltage for both channels.
virtual void enableChannel(unsigned int chnIdx, bool enable)=0
Enable or disable the given channel.
virtual void setVerticalOffset(ANALOG_IN_CHANNEL channel, double vertOffset)=0
Set the vertical offset, in Volts, of a specific channel.
virtual void getSamples(std::vector< std::vector< double > > &data, unsigned int nb_samples)=0
Retrieve a specific number of samples from each channel.
virtual std::vector< std::vector< double > > getSamples(unsigned int nb_samples)=0
Retrieve a specific number of samples from each channel.
virtual std::vector< std::pair< std::string, std::pair< double, double > > > getAvailableRanges()=0
Retrieve all ranges that are available.
virtual const short * getVoltageRawP()=0
Retrieve the average raw value for both channels.
virtual void startAcquisition(unsigned int nb_samples)=0
Create the buffer for both channels and start the acquisition.
virtual void cancelAcquisition()=0
Cancel all buffer operations.
virtual double getValueForRange(M2K_RANGE range)=0
Retrieve the numeric value corresponding to the given range.
virtual std::vector< double > getAvailableSampleRates()=0
getAvailableSampleRates
virtual void setRange(ANALOG_IN_CHANNEL channel, double min, double max)=0
Set the range for the given channel.
virtual double getVoltage(libm2k::analog::ANALOG_IN_CHANNEL ch)=0
Retrieve the average voltage of the given channel.
virtual libm2k::M2kHardwareTrigger * getTrigger()=0
Get the hardware trigger handler.
virtual std::string getName()=0
Retrieve the name of the device.
virtual short convertVoltsToRaw(unsigned int channel, double voltage)=0
Convert the voltage value of a sample into raw.
virtual int getOversamplingRatio(unsigned int chn_idx)=0
Retrieve the oversampling ratio for the given channel.
virtual unsigned int getKernelBuffersCount() const =0
Get the number of kernel buffers.
virtual double getMaximumSamplerate()=0
Get the maximum samplerate for the ADC.
virtual const double * getSamplesInterleaved(unsigned int nb_samples_per_channel)=0
Retrieve a specific number of samples from each channel.
virtual double getVerticalOffset(ANALOG_IN_CHANNEL channel)=0
getVerticalOffset
virtual std::vector< std::vector< double > > getSamplesRaw(unsigned int nb_samples)=0
Retrieve a specific number of raw samples from each channel.
virtual std::vector< double > getVoltage()=0
Retrieve the average voltage for each channel.
virtual void setRange(ANALOG_IN_CHANNEL channel, M2K_RANGE range)=0
Set the range for the given channel.
virtual unsigned int getNbChannels()=0
Retrieve the number of analogical channels.
virtual int setOversamplingRatio(int oversampling)=0
Set the global oversampling ratio.
virtual std::pair< double, double > getHysteresisRange(ANALOG_IN_CHANNEL chn)=0
Retrieve the bounds of the analogical trigger's hysteresis for the given channel.