GNU Radio's M2K Package
analog_in_source_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2022 Analog Devices Inc..
4 *
5 * SPDX-License-Identifier: GPL-3.0-or-later
6 */
7
8#ifndef INCLUDED_M2K_ANALOG_IN_SOURCE_IMPL_H
9#define INCLUDED_M2K_ANALOG_IN_SOURCE_IMPL_H
10
11
13#include <libm2k/analog/m2kanalogin.hpp>
14#include <map>
15#include <mutex>
16#include <thread>
17#include <condition_variable>
18
19namespace gr {
20 namespace m2k {
21
22 static std::map<std::string, libm2k::context::M2k *> s_contexts;
23 static std::mutex s_ctx_mutex;
24
26 {
27 private:
28 libm2k::analog::M2kAnalogIn *d_analog_in;
29 const std::string d_uri;
30 std::vector<int> d_channels;
31
32 unsigned int d_timeout;
33 bool d_deinit;
34
35 unsigned int d_buffer_size;
36 unsigned int d_sample_index;
37 unsigned long d_items_in_buffer;
38 const short *d_raw_samples;
39 bool d_stream_voltage_values;
40 double d_data_rate;
41
42 pmt::pmt_t d_port_id;
43
44 std::mutex d_mutex;
45 std::condition_variable d_cond_wait;
46 std::thread d_refill_thread;
47 volatile bool d_empty_buffer{}, d_thread_stopped{};
48
49 public:
50 analog_in_source_impl(libm2k::context::M2k *context,
51 int buffer_size,
52 const std::vector<int> &channels,
53 std::vector<int> ranges,
54 double sampling_frequency,
55 int oversampling_ratio,
56 int kernel_buffers,
57 bool calibrate_ADC,
58 bool stream_voltage_values,
59 std::vector<int> trigger_condition,
60 std::vector<int> trigger_mode,
61 int trigger_source,
62 int trigger_delay,
63 std::vector<double> trigger_level,
64 bool streaming,
65 bool deinit,
66 double data_rate);
67
69
71
72 int work(int noutput_items,
73 gr_vector_const_void_star &input_items,
74 gr_vector_void_star &output_items) override;
75
76 bool start() override;
77 bool stop() override;
78
79 void set_params(std::vector<int> ranges,
80 double sampling_frequency,
81 int oversampling_ratio) override;
82
83 void set_trigger(std::vector<int> trigger_condition,
84 std::vector<int> trigger_mode,
85 int trigger_source,
86 int trigger_delay,
87 std::vector<double> trigger_level,
88 bool streaming) override;
89
90 void set_timeout_ms(unsigned int timeout) override;
91
92 void set_data_rate(double rate) override;
93
94 static libm2k::context::M2k *get_context(const std::string &uri);
95
96 static void add_context(libm2k::context::M2k *context);
97
98 static void remove_contexts(const std::string &uri);
99
100 void set_buffer_size(int buffer_size) override;
101 };
102
103 } // namespace m2k
104} // namespace gr
105
106#endif /* INCLUDED_M2K_ANALOG_IN_SOURCE_IMPL_H */
static void remove_contexts(const std::string &uri)
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) override
void set_data_rate(double rate) override
static void add_context(libm2k::context::M2k *context)
void set_buffer_size(int buffer_size) override
void set_timeout_ms(unsigned int timeout) override
static libm2k::context::M2k * get_context(const std::string &uri)
analog_in_source_impl(libm2k::context::M2k *context, int buffer_size, const std::vector< int > &channels, std::vector< int > ranges, double sampling_frequency, int oversampling_ratio, int kernel_buffers, bool calibrate_ADC, bool stream_voltage_values, std::vector< int > trigger_condition, std::vector< int > trigger_mode, int trigger_source, int trigger_delay, std::vector< double > trigger_level, bool streaming, bool deinit, double data_rate)
void set_params(std::vector< int > ranges, double sampling_frequency, int oversampling_ratio) override
void set_trigger(std::vector< int > trigger_condition, std::vector< int > trigger_mode, int trigger_source, int trigger_delay, std::vector< double > trigger_level, bool streaming) override
Source for ADALM2000 with buffered output channels.
Definition analog_in_source.h:26
Definition adf4350_sink.h:15
static std::mutex s_ctx_mutex
Definition analog_in_source_impl.h:23
static std::map< std::string, libm2k::context::M2k * > s_contexts
Definition analog_in_source_impl.h:22
Definition adf4350_sink.h:14