diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index 9c0de5e37..99285669a 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -37,55 +37,17 @@ #include "tracking_interface.h" #include "telemetry_decoder_interface.h" #include "configuration_interface.h" +#include "channel_msg_receiver_cc.h" using google::LogMessage; -void Channel::msg_handler_events(pmt::pmt_t msg) -{ - try { - long int message=pmt::to_long(msg); - switch (message) - { - case 1: //positive acquisition - DLOG(INFO) << "Channel " << channel_ << " ACQ SUCCESS satellite " << - gnss_synchro_.System << " " << gnss_synchro_.PRN; - channel_fsm_.Event_valid_acquisition(); - break; - case 2: //negative acquisition - DLOG(INFO) << "Channel " << channel_ - << " ACQ FAILED satellite " << gnss_synchro_.System << " " << gnss_synchro_.PRN; - if (repeat_ == true) - { - channel_fsm_.Event_failed_acquisition_repeat(); - } - else - { - channel_fsm_.Event_failed_acquisition_no_repeat(); - } - break; - case 3: // tracking loss of lock event - channel_fsm_.Event_failed_tracking_standby(); - break; - default: - LOG(WARNING) << "Default case, invalid message."; - break; - } - }catch(boost::bad_any_cast& e) - { - LOG(WARNING) << "msg_handler_telemetry Bad any cast!\n"; - } -} // Constructor Channel::Channel(ConfigurationInterface *configuration, unsigned int channel, GNSSBlockInterface *pass_through, AcquisitionInterface *acq, TrackingInterface *trk, TelemetryDecoderInterface *nav, - std::string role, std::string implementation, boost::shared_ptr queue) : - gr::block("galileo_e1_pvt_cc", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) + std::string role, std::string implementation, boost::shared_ptr queue) { - this->message_port_register_in(pmt::mp("events")); - this->set_msg_handler(pmt::mp("events"), boost::bind(&Channel::msg_handler_events, this, _1)); - pass_through_=pass_through; acq_=acq; trk_=trk; @@ -133,11 +95,15 @@ Channel::Channel(ConfigurationInterface *configuration, unsigned int channel, connected_ = false; gnss_signal_ = Gnss_Signal(); + + chennel_msg_rx= channel_msg_receiver_make_cc(&channel_fsm_, repeat_); + } // Destructor Channel::~Channel() { + channel_fsm_.terminate(); } void Channel::connect(gr::top_block_sptr top_block) @@ -165,8 +131,8 @@ void Channel::connect(gr::top_block_sptr top_block) DLOG(INFO) << "MSG FEEDBACK CHANNEL telemetry_decoder -> tracking"; //std::cout<<"has port: "<get_right_block()->has_msg_port(pmt::mp("events"))<msg_connect(acq_->get_right_block(),pmt::mp("events"), gr::basic_block_sptr(this),pmt::mp("events")); - top_block->msg_connect(trk_->get_right_block(),pmt::mp("events"), gr::basic_block_sptr(this),pmt::mp("events")); + top_block->msg_connect(acq_->get_right_block(),pmt::mp("events"), chennel_msg_rx,pmt::mp("events")); + top_block->msg_connect(trk_->get_right_block(),pmt::mp("events"), chennel_msg_rx,pmt::mp("events")); connected_ = true; } diff --git a/src/algorithms/channel/adapters/channel.h b/src/algorithms/channel/adapters/channel.h index b82ee8a7b..0f9e33b58 100644 --- a/src/algorithms/channel/adapters/channel.h +++ b/src/algorithms/channel/adapters/channel.h @@ -42,7 +42,7 @@ #include "channel_interface.h" #include "channel_fsm.h" #include "gnss_synchro.h" - +#include "channel_msg_receiver_cc.h" class ConfigurationInterface; class AcquisitionInterface; @@ -55,7 +55,7 @@ class TelemetryDecoderInterface; * their interaction through a Finite State Machine * */ -class Channel: public ChannelInterface, public gr::block +class Channel: public ChannelInterface { public: @@ -87,6 +87,7 @@ public: private: + channel_msg_receiver_cc_sptr chennel_msg_rx; GNSSBlockInterface *pass_through_; AcquisitionInterface *acq_; TrackingInterface *trk_; @@ -97,8 +98,6 @@ private: Gnss_Synchro gnss_synchro_; Gnss_Signal gnss_signal_; bool connected_; - //bool stop_; - //int message_; bool repeat_; ChannelFsm channel_fsm_; boost::shared_ptr queue_; diff --git a/src/algorithms/channel/libs/CMakeLists.txt b/src/algorithms/channel/libs/CMakeLists.txt index badf5f8b0..e169fd43b 100644 --- a/src/algorithms/channel/libs/CMakeLists.txt +++ b/src/algorithms/channel/libs/CMakeLists.txt @@ -16,7 +16,10 @@ # along with GNSS-SDR. If not, see . # -set(CHANNEL_FSM_SOURCES channel_fsm.cc ) +set(CHANNEL_FSM_SOURCES + channel_fsm.cc + channel_msg_receiver_cc.cc + ) include_directories( $(CMAKE_CURRENT_SOURCE_DIR) diff --git a/src/algorithms/channel/libs/channel_msg_receiver_cc.cc b/src/algorithms/channel/libs/channel_msg_receiver_cc.cc new file mode 100644 index 000000000..9eebfe01d --- /dev/null +++ b/src/algorithms/channel/libs/channel_msg_receiver_cc.cc @@ -0,0 +1,94 @@ +/*! + * \file channel_msg_receiver_cc.cc + * \brief GNURadio block that receives asynchronous channel messages from acquisition and tracking blocks + * \author Javier Arribas, 2016. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2016 (see AUTHORS file for a list of contributors) + * + * 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 + * (at your option) any later version. + * + * 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 + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "channel_msg_receiver_cc.h" +#include +#include +#include + +using google::LogMessage; + + +channel_msg_receiver_cc_sptr channel_msg_receiver_make_cc(ChannelFsm* channel_fsm, bool repeat) +{ + return channel_msg_receiver_cc_sptr(new channel_msg_receiver_cc(channel_fsm, repeat)); +} + +void channel_msg_receiver_cc::msg_handler_events(pmt::pmt_t msg) +{ + try { + long int message=pmt::to_long(msg); + switch (message) + { + case 1: //positive acquisition + //DLOG(INFO) << "Channel " << channel_ << " ACQ SUCCESS satellite " << + // gnss_synchro_.System << " " << gnss_synchro_.PRN; + d_channel_fsm->Event_valid_acquisition(); + break; + case 2: //negative acquisition + //DLOG(INFO) << "Channel " << channel_ + // << " ACQ FAILED satellite " << gnss_synchro_.System << " " << gnss_synchro_.PRN; + if (d_repeat == true) + { + d_channel_fsm->Event_failed_acquisition_repeat(); + } + else + { + d_channel_fsm->Event_failed_acquisition_no_repeat(); + } + break; + case 3: // tracking loss of lock event + d_channel_fsm->Event_failed_tracking_standby(); + break; + default: + LOG(WARNING) << "Default case, invalid message."; + break; + } + }catch(boost::bad_any_cast& e) + { + LOG(WARNING) << "msg_handler_telemetry Bad any cast!\n"; + } +} + +channel_msg_receiver_cc::channel_msg_receiver_cc(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)) +{ + + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&channel_msg_receiver_cc::msg_handler_events, this, _1)); + + d_channel_fsm=channel_fsm; + d_repeat=repeat; +} + +channel_msg_receiver_cc::~channel_msg_receiver_cc() +{} + diff --git a/src/algorithms/channel/libs/channel_msg_receiver_cc.h b/src/algorithms/channel/libs/channel_msg_receiver_cc.h new file mode 100644 index 000000000..1ba051952 --- /dev/null +++ b/src/algorithms/channel/libs/channel_msg_receiver_cc.h @@ -0,0 +1,60 @@ +/*! + * \file channel_msg_receiver_cc.h + * \brief GNURadio block that receives asynchronous channel messages from acquisition and tracking blocks + * \author Javier Arribas, 2016. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2016 (see AUTHORS file for a list of contributors) + * + * 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 + * (at your option) any later version. + * + * 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 + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_CHANNEL_MSG_RECEIVER_CC_H +#define GNSS_SDR_CHANNEL_MSG_RECEIVER_CC_H + +#include +#include "channel_fsm.h" + +class channel_msg_receiver_cc; + +typedef boost::shared_ptr channel_msg_receiver_cc_sptr; + +channel_msg_receiver_cc_sptr channel_msg_receiver_make_cc(ChannelFsm* channel_fsm, bool repeat); + +/*! + * \brief This class implements a block that computes the PVT solution with Galileo E1 signals + */ +class channel_msg_receiver_cc : public gr::block +{ +private: + ChannelFsm* d_channel_fsm; + bool d_repeat; // todo: change FSM to include repeat value + friend channel_msg_receiver_cc_sptr channel_msg_receiver_make_cc(ChannelFsm* channel_fsm, bool repeat); + void msg_handler_events(pmt::pmt_t msg); + channel_msg_receiver_cc(ChannelFsm* channel_fsm, bool repeat); + +public: + ~channel_msg_receiver_cc (); //!< Default destructor + +}; + +#endif