Loading...
Searching...
No Matches
m2kanalogout.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 M2KANALOGOUT_HPP
#define M2KANALOGOUT_HPP
#include <libm2k/m2kglobal.hpp>
#include <libm2k/enums.hpp>
#include <libm2k/m2khardwaretrigger.hpp>
#include <vector>
#include <memory>
#include <map>
extern "C" {
struct iio_context;
}
namespace libm2k {
namespace analog {
class LIBM2K_API M2kAnalogOut
{
public:
virtual ~M2kAnalogOut() {}
virtual void reset() = 0;
virtual std::vector<int> getOversamplingRatio() = 0;
virtual int getOversamplingRatio(unsigned int chn) = 0;
virtual std::vector<int> setOversamplingRatio(std::vector<int> oversampling_ratio) = 0;
virtual int setOversamplingRatio(unsigned int chn, int oversampling_ratio) = 0;
virtual std::vector<double> getSampleRate() = 0;
virtual double getSampleRate(unsigned int chn) = 0;
virtual std::vector<double> getAvailableSampleRates(unsigned int chn) = 0;
virtual std::vector<double> setSampleRate(std::vector<double> samplerates) = 0;
virtual double setSampleRate(unsigned int chn, double samplerate) = 0;
virtual void setSyncedDma(bool en, int chn = -1) = 0;
virtual bool getSyncedDma(int chn = -1) = 0;
virtual void setSyncedStartDma(bool en, int chn = -1) = 0;
virtual bool getSyncedStartDma(int chn = -1) = 0;
virtual void setCyclic(bool en) = 0;
virtual void setCyclic(unsigned int chn, bool en) = 0;
virtual bool getCyclic(unsigned int chn) = 0;
virtual double getScalingFactor(unsigned int chn) = 0;
virtual double getFilterCompensation(double samplerate) = 0;
virtual void pushBytes(unsigned int chnIdx, double *data, unsigned int nb_samples) = 0;
virtual void pushRawBytes(unsigned int chnIdx, short *data, unsigned int nb_samples) = 0;
virtual void pushInterleaved(double *data, unsigned int nb_channels, unsigned int nb_samples) = 0;
virtual void pushRawInterleaved(short *data, unsigned int nb_channels, unsigned int nb_samples) = 0;
virtual void push(unsigned int chnIdx, std::vector<double> const &data) = 0;
virtual void pushRaw(unsigned int chnIdx, std::vector<short> const &data) = 0;
virtual void push(std::vector<std::vector<double>> const &data) = 0;
virtual void pushRaw(std::vector<std::vector<short>> const &data) = 0;
virtual void stop() = 0;
virtual void stop(unsigned int chn) = 0;
virtual void cancelBuffer() = 0;
virtual void cancelBuffer(unsigned int chn) = 0;
virtual void enableChannel(unsigned int chnIdx, bool enable) = 0;
virtual bool isChannelEnabled(unsigned int chnIdx) = 0;
virtual bool isPushDone(unsigned int chnIdx) const = 0;
virtual void setKernelBuffersCount(unsigned int chnIdx, unsigned int count) = 0;
virtual unsigned int getKernelBuffersCount(unsigned int chnIdx) const = 0;
virtual short convertVoltsToRaw(unsigned int channel, double voltage) = 0;
virtual double convertRawToVolts(unsigned int channel, short raw) = 0;
virtual struct IIO_OBJECTS getIioObjects() = 0;
virtual unsigned int getNbChannels() = 0;
virtual std::string getChannelName(unsigned int channel) = 0;
virtual double getMaximumSamplerate(unsigned int chn_idx) = 0;
virtual unsigned short setVoltage(unsigned int chn_idx, double volts) = 0;
virtual unsigned short setVoltageRaw(unsigned int chn_idx, unsigned short raw) = 0;
virtual libm2k::M2kHardwareTrigger* getTrigger() = 0;
virtual void setBufferRearmOnTrigger(bool enable) = 0;
virtual bool getBufferRearmOnTrigger() const = 0;
};
}
}
#endif //M2KANALOGOUT_HPP
libm2k::M2kHardwareTrigger
Controls the hardware trigger for ADALM2000.
Definition m2khardwaretrigger.hpp:42
libm2k::analog::M2kAnalogOut
Controls the analogical output compound.
Definition m2kanalogout.hpp:53
enums.hpp
Generic M2K enumerations.
libm2k::analog::M2kAnalogOut::stop
virtual void stop(unsigned int chn)=0
Stop the given channels from sending the signals.
libm2k::analog::M2kAnalogOut::isPushDone
virtual bool isPushDone(unsigned int chnIdx) const =0
Check if the generation of the signal (only for non-cyclic buffer) is done.
libm2k::analog::M2kAnalogOut::enableChannel
virtual void enableChannel(unsigned int chnIdx, bool enable)=0
Enable or disable the given digital channel.
libm2k::analog::M2kAnalogOut::setKernelBuffersCount
virtual void setKernelBuffersCount(unsigned int chnIdx, unsigned int count)=0
Set the kernel buffers to a specific value.
libm2k::analog::M2kAnalogOut::pushRawInterleaved
virtual void pushRawInterleaved(short *data, unsigned int nb_channels, unsigned int nb_samples)=0
Send samples to all the channels.
libm2k::analog::M2kAnalogOut::getBufferRearmOnTrigger
virtual bool getBufferRearmOnTrigger() const =0
Retrieve the value of the attribute that controls buffer rearm on trigger.
libm2k::analog::M2kAnalogOut::getSampleRate
virtual std::vector< double > getSampleRate()=0
Retrieve the sample rate of both DACs.
libm2k::analog::M2kAnalogOut::getKernelBuffersCount
virtual unsigned int getKernelBuffersCount(unsigned int chnIdx) const =0
Get the number of kernel buffers.
libm2k::analog::M2kAnalogOut::setOversamplingRatio
virtual int setOversamplingRatio(unsigned int chn, int oversampling_ratio)=0
Set the oversampling ratio for the given channel.
libm2k::analog::M2kAnalogOut::getFilterCompensation
virtual double getFilterCompensation(double samplerate)=0
Retrieve the filter compensation for the given sample rate.
libm2k::analog::M2kAnalogOut::getAvailableSampleRates
virtual std::vector< double > getAvailableSampleRates(unsigned int chn)=0
getAvailableSampleRates
libm2k::analog::M2kAnalogOut::isChannelEnabled
virtual bool isChannelEnabled(unsigned int chnIdx)=0
Check if the given channel is enabled.
libm2k::analog::M2kAnalogOut::cancelBuffer
virtual void cancelBuffer(unsigned int chn)=0
Cancel all buffer operations of the given channel.
libm2k::analog::M2kAnalogOut::setOversamplingRatio
virtual std::vector< int > setOversamplingRatio(std::vector< int > oversampling_ratio)=0
Set the value of the oversampling ratio for each channel.
libm2k::analog::M2kAnalogOut::pushBytes
virtual void pushBytes(unsigned int chnIdx, double *data, unsigned int nb_samples)=0
Send the samples to the given channel.
libm2k::analog::M2kAnalogOut::setCyclic
virtual void setCyclic(bool en)=0
Enable or disable the cyclic mode for all digital channels.
libm2k::analog::M2kAnalogOut::setSampleRate
virtual std::vector< double > setSampleRate(std::vector< double > samplerates)=0
Set the sample rate for both channels.
libm2k::analog::M2kAnalogOut::pushRawBytes
virtual void pushRawBytes(unsigned int chnIdx, short *data, unsigned int nb_samples)=0
Send the samples to the given channel.
libm2k::analog::M2kAnalogOut::push
virtual void push(unsigned int chnIdx, std::vector< double > const &data)=0
Send the samples to the given channel.
libm2k::analog::M2kAnalogOut::setSampleRate
virtual double setSampleRate(unsigned int chn, double samplerate)=0
Set the sample rate for the given channel.
libm2k::analog::M2kAnalogOut::getMaximumSamplerate
virtual double getMaximumSamplerate(unsigned int chn_idx)=0
Get the maximum samplerate for the DAC.
libm2k::analog::M2kAnalogOut::setCyclic
virtual void setCyclic(unsigned int chn, bool en)=0
Enable or disable the cyclic mode for all digital channels.
libm2k::analog::M2kAnalogOut::stop
virtual void stop()=0
Stop all channels from sending the signals.
libm2k::analog::M2kAnalogOut::getTrigger
virtual libm2k::M2kHardwareTrigger * getTrigger()=0
Get the hardware trigger handler.
libm2k::analog::M2kAnalogOut::getSampleRate
virtual double getSampleRate(unsigned int chn)=0
Retrieve the sample rate for the given channel.
libm2k::analog::M2kAnalogOut::setBufferRearmOnTrigger
virtual void setBufferRearmOnTrigger(bool enable)=0
Allows sequential output of multiple buffers with each trigger event.
libm2k::analog::M2kAnalogOut::pushRaw
virtual void pushRaw(unsigned int chnIdx, std::vector< short > const &data)=0
Send the samples to the given channel.
libm2k::analog::M2kAnalogOut::push
virtual void push(std::vector< std::vector< double > > const &data)=0
Send samples to channels.
libm2k::analog::M2kAnalogOut::getOversamplingRatio
virtual std::vector< int > getOversamplingRatio()=0
Retrieve the global oversampling ratio.
libm2k::analog::M2kAnalogOut::pushRaw
virtual void pushRaw(std::vector< std::vector< short > > const &data)=0
Send samples to channels.
libm2k::analog::M2kAnalogOut::cancelBuffer
virtual void cancelBuffer()=0
Cancel all buffer operations of enabled channels.
libm2k::analog::M2kAnalogOut::setVoltageRaw
virtual unsigned short setVoltageRaw(unsigned int chn_idx, unsigned short raw)=0
Sets the raw output of the DAC channel.
libm2k::analog::M2kAnalogOut::convertVoltsToRaw
virtual short convertVoltsToRaw(unsigned int channel, double voltage)=0
Convert the volts value of a sample into raw.
libm2k::analog::M2kAnalogOut::getScalingFactor
virtual double getScalingFactor(unsigned int chn)=0
Retrieve the scaling factor for the given channel.
libm2k::analog::M2kAnalogOut::getCyclic
virtual bool getCyclic(unsigned int chn)=0
Retrieve the value of the cyclic mode.
libm2k::analog::M2kAnalogOut::pushInterleaved
virtual void pushInterleaved(double *data, unsigned int nb_channels, unsigned int nb_samples)=0
Send samples to all the channels.
libm2k::analog::M2kAnalogOut::getOversamplingRatio
virtual int getOversamplingRatio(unsigned int chn)=0
Retrieve the oversampling ratio for the given channel.
libm2k::analog::M2kAnalogOut::convertRawToVolts
virtual double convertRawToVolts(unsigned int channel, short raw)=0
Convert the raw value of a sample into volts.
libm2k::analog::M2kAnalogOut::getNbChannels
virtual unsigned int getNbChannels()=0
Retrieve the number of analogical channels.
libm2k::analog::M2kAnalogOut::getChannelName
virtual std::string getChannelName(unsigned int channel)=0
Get the channel name for each DAC channel.
libm2k::analog::M2kAnalogOut::setVoltage
virtual unsigned short setVoltage(unsigned int chn_idx, double volts)=0
Sets the voltage output of the DAC channel.