2016-04-18 12:17:09 +00:00
|
|
|
/*!
|
|
|
|
* \file channel_msg_receiver_cc.cc
|
2020-07-19 23:20:15 +00:00
|
|
|
* \brief GNU Radio block that receives asynchronous channel messages from
|
|
|
|
* acquisition and tracking blocks
|
2016-04-18 12:17:09 +00:00
|
|
|
* \author Javier Arribas, 2016. jarribas(at)cttc.es
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2016-04-18 12:17:09 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2016-04-18 12:17:09 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2016-04-18 12:17:09 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2016-04-18 12:17:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "channel_msg_receiver_cc.h"
|
|
|
|
#include <gnuradio/gr_complex.h>
|
|
|
|
#include <gnuradio/io_signature.h>
|
2018-08-10 18:34:03 +00:00
|
|
|
#include <cstdint>
|
2019-03-04 07:12:50 +00:00
|
|
|
#include <utility>
|
2016-04-18 12:17:09 +00:00
|
|
|
|
2024-04-29 06:27:33 +00:00
|
|
|
#if USE_GLOG_AND_GFLAGS
|
|
|
|
#include <glog/logging.h>
|
|
|
|
#else
|
|
|
|
#include <absl/log/log.h>
|
|
|
|
#endif
|
|
|
|
|
2021-10-30 03:43:22 +00:00
|
|
|
#if PMT_USES_BOOST_ANY
|
|
|
|
#include <boost/any.hpp>
|
|
|
|
namespace wht = boost;
|
|
|
|
#else
|
|
|
|
#include <any>
|
|
|
|
namespace wht = std;
|
|
|
|
#endif
|
|
|
|
|
2020-04-25 20:17:15 +00:00
|
|
|
#if HAS_GENERIC_LAMBDA
|
|
|
|
#else
|
2020-06-06 21:41:38 +00:00
|
|
|
#include <boost/bind/bind.hpp>
|
2020-04-25 20:17:15 +00:00
|
|
|
#endif
|
2016-04-18 12:17:09 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
channel_msg_receiver_cc_sptr channel_msg_receiver_make_cc(std::shared_ptr<ChannelFsm> channel_fsm, bool repeat)
|
2016-04-18 12:17:09 +00:00
|
|
|
{
|
2018-12-02 23:46:38 +00:00
|
|
|
return channel_msg_receiver_cc_sptr(new channel_msg_receiver_cc(std::move(channel_fsm), repeat));
|
2016-04-18 12:17:09 +00:00
|
|
|
}
|
|
|
|
|
2018-04-29 08:23:19 +00:00
|
|
|
|
2020-08-03 08:46:07 +00:00
|
|
|
channel_msg_receiver_cc::channel_msg_receiver_cc(std::shared_ptr<ChannelFsm> channel_fsm,
|
|
|
|
bool repeat) : gr::block("channel_msg_receiver_cc", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)),
|
|
|
|
d_channel_fsm(std::move(channel_fsm)),
|
|
|
|
d_repeat(repeat)
|
2019-03-04 07:12:50 +00:00
|
|
|
{
|
|
|
|
this->message_port_register_in(pmt::mp("events"));
|
2020-04-25 20:17:15 +00:00
|
|
|
this->set_msg_handler(pmt::mp("events"),
|
|
|
|
#if HAS_GENERIC_LAMBDA
|
2020-08-03 06:13:21 +00:00
|
|
|
[this](auto&& PH1) { msg_handler_channel_events(PH1); });
|
2020-04-25 20:17:15 +00:00
|
|
|
#else
|
2020-06-12 22:32:40 +00:00
|
|
|
#if USE_BOOST_BIND_PLACEHOLDERS
|
2020-08-03 06:13:21 +00:00
|
|
|
boost::bind(&channel_msg_receiver_cc::msg_handler_channel_events, this, boost::placeholders::_1));
|
2020-05-18 20:50:34 +00:00
|
|
|
#else
|
2020-08-03 06:13:21 +00:00
|
|
|
boost::bind(&channel_msg_receiver_cc::msg_handler_channel_events, this, _1));
|
2020-05-18 20:50:34 +00:00
|
|
|
#endif
|
2020-04-25 20:17:15 +00:00
|
|
|
#endif
|
2019-03-04 07:12:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-03 06:13:21 +00:00
|
|
|
void channel_msg_receiver_cc::msg_handler_channel_events(const pmt::pmt_t& msg)
|
2016-04-18 12:17:09 +00:00
|
|
|
{
|
2018-01-08 09:57:01 +00:00
|
|
|
bool result = false;
|
2016-04-25 18:34:27 +00:00
|
|
|
try
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
2020-08-03 06:13:21 +00:00
|
|
|
const int64_t message = pmt::to_long(msg);
|
2016-04-25 18:34:27 +00:00
|
|
|
switch (message)
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
2018-04-29 08:23:19 +00:00
|
|
|
case 1: // positive acquisition
|
2019-03-20 14:13:17 +00:00
|
|
|
// Now the acquisition block can optionally trigger the event valid acquisition internally,
|
|
|
|
// in order to reduce acquisition to tracking delay.
|
2018-03-03 01:03:39 +00:00
|
|
|
result = d_channel_fsm->Event_valid_acquisition();
|
|
|
|
break;
|
2018-04-29 08:23:19 +00:00
|
|
|
case 2: // negative acquisition
|
2018-03-03 01:03:39 +00:00
|
|
|
if (d_repeat == true)
|
|
|
|
{
|
|
|
|
result = d_channel_fsm->Event_failed_acquisition_repeat();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = d_channel_fsm->Event_failed_acquisition_no_repeat();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3: // tracking loss of lock event
|
|
|
|
result = d_channel_fsm->Event_failed_tracking_standby();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
LOG(WARNING) << "Default case, invalid message.";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-10-30 03:43:22 +00:00
|
|
|
catch (const wht::bad_any_cast& e)
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
2020-08-03 06:13:21 +00:00
|
|
|
LOG(WARNING) << "msg_handler_channel_events Bad any cast: " << e.what();
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
|
|
|
if (!result)
|
2018-01-08 09:57:01 +00:00
|
|
|
{
|
2020-08-03 06:13:21 +00:00
|
|
|
LOG(WARNING) << "msg_handler_channel_events invalid event";
|
2018-01-08 09:57:01 +00:00
|
|
|
}
|
2016-04-18 12:17:09 +00:00
|
|
|
}
|