libm2k
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>
26 #include <libm2k/analog/enums.hpp>
27 #include <libm2k/m2khardwaretrigger.hpp>
28 #include <vector>
29 #include <map>
30 #include <memory>
31 
32 namespace libm2k {
38 namespace analog {
46 class LIBM2K_API M2kAnalogIn
47 {
48 public:
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 
186  virtual short getVoltageRaw(libm2k::analog::ANALOG_IN_CHANNEL ch) = 0;
187 
188 
195  virtual double getVoltage(libm2k::analog::ANALOG_IN_CHANNEL ch) = 0;
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 
254  virtual double getScalingFactor(libm2k::analog::ANALOG_IN_CHANNEL ch) = 0;
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 
282  virtual libm2k::analog::M2K_RANGE getRange(libm2k::analog::ANALOG_IN_CHANNEL channel) = 0;
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 
467  virtual libm2k::M2kHardwareTrigger* getTrigger() = 0;
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
Controls the analogical input compound.
Definition: m2kanalogin.hpp:46
Analogical enumerations.
Controls the hardware trigger for ADALM2000.
Definition: m2khardwaretrigger.hpp:41
ANALOG_IN_CHANNEL
Indexes of the channels.
Definition: enums.hpp:59
M2K_RANGE
Range of the signal's amplitude.
Definition: enums.hpp:70