2011-10-01 18:45:20 +00:00
|
|
|
/*!
|
|
|
|
* \file file_signal_source.h
|
2011-12-28 21:36:45 +00:00
|
|
|
* \brief Interface of a class that reads signals samples from a file
|
|
|
|
* and adapts it to a SignalSourceInterface
|
2011-10-01 18:45:20 +00:00
|
|
|
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
|
|
|
|
*
|
2011-12-28 21:36:45 +00:00
|
|
|
* This class represents a file signal source. Internally it uses a GNU Radio's
|
|
|
|
* gr_file_source as a connector to the data.
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2019-07-26 10:38:20 +00:00
|
|
|
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2015-01-08 18:49:59 +00:00
|
|
|
* (at your option) any later version.
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-05-13 20:49:11 +00:00
|
|
|
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2011-12-28 03:05:37 +00:00
|
|
|
#ifndef GNSS_SDR_FILE_SIGNAL_SOURCE_H_
|
|
|
|
#define GNSS_SDR_FILE_SIGNAL_SOURCE_H_
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2019-07-16 15:41:12 +00:00
|
|
|
#include "concurrent_queue.h"
|
2018-02-26 02:15:53 +00:00
|
|
|
#include "gnss_block_interface.h"
|
2013-07-04 13:47:40 +00:00
|
|
|
#include <gnuradio/blocks/file_sink.h>
|
2018-12-09 21:00:09 +00:00
|
|
|
#include <gnuradio/blocks/file_source.h>
|
2013-07-04 13:47:40 +00:00
|
|
|
#include <gnuradio/blocks/throttle.h>
|
|
|
|
#include <gnuradio/hier_block2.h>
|
2019-07-16 15:41:12 +00:00
|
|
|
#include <pmt/pmt.h>
|
2018-08-11 12:31:35 +00:00
|
|
|
#include <cstdint>
|
2019-07-16 15:41:12 +00:00
|
|
|
#include <memory>
|
2018-02-26 02:15:53 +00:00
|
|
|
#include <string>
|
2011-10-01 18:45:20 +00:00
|
|
|
|
|
|
|
class ConfigurationInterface;
|
|
|
|
|
2011-12-28 03:05:37 +00:00
|
|
|
/*!
|
2013-02-04 00:16:22 +00:00
|
|
|
* \brief Class that reads signals samples from a file
|
|
|
|
* and adapts it to a SignalSourceInterface
|
2011-12-28 03:05:37 +00:00
|
|
|
*/
|
2018-03-03 01:03:39 +00:00
|
|
|
class FileSignalSource : public GNSSBlockInterface
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-12-03 18:01:47 +00:00
|
|
|
FileSignalSource(ConfigurationInterface* configuration, const std::string& role,
|
2018-03-03 01:03:39 +00:00
|
|
|
unsigned int in_streams, unsigned int out_streams,
|
2019-09-11 22:31:34 +00:00
|
|
|
const std::shared_ptr<Concurrent_Queue<pmt::pmt_t>>& queue);
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2019-07-21 17:32:52 +00:00
|
|
|
~FileSignalSource() = default;
|
2017-08-15 22:58:10 +00:00
|
|
|
|
2017-08-21 09:45:12 +00:00
|
|
|
inline std::string role() override
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
|
|
|
return role_;
|
|
|
|
}
|
2013-02-04 00:16:22 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns "File_Signal_Source".
|
|
|
|
*/
|
2017-08-21 09:45:12 +00:00
|
|
|
inline std::string implementation() override
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
2012-06-22 14:17:28 +00:00
|
|
|
return "File_Signal_Source";
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
2017-08-15 22:58:10 +00:00
|
|
|
|
2017-08-21 09:45:12 +00:00
|
|
|
inline size_t item_size() override
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
|
|
|
return item_size_;
|
|
|
|
}
|
2017-08-15 22:58:10 +00:00
|
|
|
|
|
|
|
void connect(gr::top_block_sptr top_block) override;
|
|
|
|
void disconnect(gr::top_block_sptr top_block) override;
|
|
|
|
gr::basic_block_sptr get_left_block() override;
|
|
|
|
gr::basic_block_sptr get_right_block() override;
|
|
|
|
|
2017-08-21 09:45:12 +00:00
|
|
|
inline std::string filename() const
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
|
|
|
return filename_;
|
|
|
|
}
|
2017-08-21 09:45:12 +00:00
|
|
|
|
|
|
|
inline std::string item_type() const
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
|
|
|
return item_type_;
|
|
|
|
}
|
2017-08-21 09:45:12 +00:00
|
|
|
|
|
|
|
inline bool repeat() const
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
|
|
|
return repeat_;
|
|
|
|
}
|
2017-08-21 09:45:12 +00:00
|
|
|
|
2019-02-11 16:17:35 +00:00
|
|
|
inline int64_t sampling_frequency() const
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
|
|
|
return sampling_frequency_;
|
|
|
|
}
|
2017-08-21 09:45:12 +00:00
|
|
|
|
2019-02-11 16:17:35 +00:00
|
|
|
inline uint64_t samples() const
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
|
|
|
return samples_;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-08-11 12:31:35 +00:00
|
|
|
uint64_t samples_;
|
2019-02-11 16:17:35 +00:00
|
|
|
int64_t sampling_frequency_;
|
2011-10-01 18:45:20 +00:00
|
|
|
std::string filename_;
|
|
|
|
std::string item_type_;
|
|
|
|
bool repeat_;
|
|
|
|
bool dump_;
|
|
|
|
std::string dump_filename_;
|
|
|
|
std::string role_;
|
2018-08-11 12:31:35 +00:00
|
|
|
uint32_t in_streams_;
|
|
|
|
uint32_t out_streams_;
|
2013-07-04 13:47:40 +00:00
|
|
|
gr::blocks::file_source::sptr file_source_;
|
|
|
|
boost::shared_ptr<gr::block> valve_;
|
|
|
|
gr::blocks::file_sink::sptr sink_;
|
2018-03-03 01:03:39 +00:00
|
|
|
gr::blocks::throttle::sptr throttle_;
|
2019-07-16 15:41:12 +00:00
|
|
|
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue_;
|
2011-10-01 18:45:20 +00:00
|
|
|
size_t item_size_;
|
|
|
|
// Throttle control
|
|
|
|
bool enable_throttle_control_;
|
|
|
|
};
|
|
|
|
|
2019-09-07 14:42:22 +00:00
|
|
|
#endif // GNSS_SDR_FILE_SIGNAL_SOURCE_H_
|