2018-09-07 12:36:11 +00:00
|
|
|
/*!
|
|
|
|
* \file acquisition_msg_rx.cc
|
|
|
|
* \brief This is a helper class to catch the asynchronous messages
|
|
|
|
* emitted by an acquisition block.
|
|
|
|
* \author Carles Fernandez-Prades, 2018. cfernandez(at)cttc.cat
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2019-07-26 10:38:20 +00:00
|
|
|
* Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors)
|
2018-09-07 12:36:11 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2018-09-07 12:36:11 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "acquisition_msg_rx.h"
|
|
|
|
#include <gflags/gflags.h>
|
|
|
|
#include <glog/logging.h>
|
2018-12-09 21:00:09 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <utility>
|
2020-04-26 06:41:49 +00:00
|
|
|
#if HAS_GENERIC_LAMBDA
|
|
|
|
#else
|
|
|
|
#include <boost/bind.hpp>
|
|
|
|
#endif
|
2018-09-07 12:36:11 +00:00
|
|
|
|
|
|
|
Acquisition_msg_rx_sptr Acquisition_msg_rx_make()
|
|
|
|
{
|
|
|
|
return Acquisition_msg_rx_sptr(new Acquisition_msg_rx());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-11 22:31:34 +00:00
|
|
|
void Acquisition_msg_rx::msg_handler_events(const pmt::pmt_t& msg)
|
2018-09-07 12:36:11 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2019-09-13 06:56:37 +00:00
|
|
|
int64_t message = pmt::to_long(msg);
|
2018-09-07 12:36:11 +00:00
|
|
|
rx_message = message;
|
|
|
|
top_block->stop(); // stop the flowgraph
|
|
|
|
}
|
|
|
|
catch (boost::bad_any_cast& e)
|
|
|
|
{
|
|
|
|
LOG(WARNING) << "msg_handler_acquisition Bad cast!\n";
|
|
|
|
rx_message = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Acquisition_msg_rx::Acquisition_msg_rx() : gr::block("Acquisition_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0))
|
|
|
|
{
|
|
|
|
this->message_port_register_in(pmt::mp("events"));
|
2020-04-25 21:03:44 +00:00
|
|
|
this->set_msg_handler(pmt::mp("events"),
|
|
|
|
#if HAS_GENERIC_LAMBDA
|
2020-04-26 10:28:24 +00:00
|
|
|
[this](pmt::pmt_t&& PH1) { msg_handler_events(PH1); });
|
2020-04-25 21:03:44 +00:00
|
|
|
#else
|
2020-05-18 16:58:39 +00:00
|
|
|
boost::bind(&Acquisition_msg_rx::msg_handler_events, this, boost::placeholders::_1));
|
2020-04-25 21:03:44 +00:00
|
|
|
#endif
|
2018-09-07 12:36:11 +00:00
|
|
|
rx_message = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-03 10:12:10 +00:00
|
|
|
Acquisition_msg_rx::~Acquisition_msg_rx() = default;
|