From 59b6bf18c5be9a9bfa12509cd5d73c05f546d40c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 25 Apr 2016 20:34:27 +0200 Subject: [PATCH 1/2] code cleaning --- src/algorithms/channel/adapters/channel.cc | 27 +++---- src/algorithms/channel/adapters/channel.h | 2 +- .../channel/libs/channel_msg_receiver_cc.cc | 71 ++++++++++--------- .../channel/libs/channel_msg_receiver_cc.h | 4 +- 4 files changed, 55 insertions(+), 49 deletions(-) diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index 104421ab3..a405a8a0d 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -48,14 +48,14 @@ Channel::Channel(ConfigurationInterface *configuration, unsigned int channel, std::string role, std::string implementation, boost::shared_ptr queue) { - pass_through_=pass_through; - acq_=acq; - trk_=trk; - nav_=nav; - role_=role; - implementation_=implementation; - channel_=channel; - queue_=queue; + pass_through_ = pass_through; + acq_ = acq; + trk_ = trk; + nav_ = nav; + role_ = role; + implementation_ = implementation; + channel_ = channel; + queue_ = queue; acq_->set_channel(channel_); trk_->set_channel(channel_); @@ -97,7 +97,7 @@ Channel::Channel(ConfigurationInterface *configuration, unsigned int channel, gnss_signal_ = Gnss_Signal(implementation_); - chennel_msg_rx= channel_msg_receiver_make_cc(&channel_fsm_, repeat_); + channel_msg_rx = channel_msg_receiver_make_cc(&channel_fsm_, repeat_); } @@ -128,12 +128,12 @@ void Channel::connect(gr::top_block_sptr top_block) DLOG(INFO) << "tracking -> telemetry_decoder"; // Message ports - top_block->msg_connect(nav_->get_left_block(),pmt::mp("preamble_timestamp_s"),trk_->get_right_block(),pmt::mp("preamble_timestamp_s")); + top_block->msg_connect(nav_->get_left_block(), pmt::mp("preamble_timestamp_s"), trk_->get_right_block(), pmt::mp("preamble_timestamp_s")); 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"), chennel_msg_rx,pmt::mp("events")); - top_block->msg_connect(trk_->get_right_block(),pmt::mp("events"), chennel_msg_rx,pmt::mp("events")); + top_block->msg_connect(acq_->get_right_block(), pmt::mp("events"), channel_msg_rx, pmt::mp("events")); + top_block->msg_connect(trk_->get_right_block(), pmt::mp("events"), channel_msg_rx, pmt::mp("events")); connected_ = true; } @@ -156,11 +156,13 @@ void Channel::disconnect(gr::top_block_sptr top_block) connected_ = false; } + gr::basic_block_sptr Channel::get_left_block() { return pass_through_->get_left_block(); } + gr::basic_block_sptr Channel::get_right_block() { return nav_->get_right_block(); @@ -180,6 +182,7 @@ void Channel::set_signal(const Gnss_Signal& gnss_signal) nav_->set_satellite(gnss_signal_.get_satellite()); } + void Channel::start_acquisition() { channel_fsm_.Event_start_acquisition(); diff --git a/src/algorithms/channel/adapters/channel.h b/src/algorithms/channel/adapters/channel.h index 0f9e33b58..664b5ef02 100644 --- a/src/algorithms/channel/adapters/channel.h +++ b/src/algorithms/channel/adapters/channel.h @@ -87,7 +87,7 @@ public: private: - channel_msg_receiver_cc_sptr chennel_msg_rx; + channel_msg_receiver_cc_sptr channel_msg_rx; GNSSBlockInterface *pass_through_; AcquisitionInterface *acq_; TrackingInterface *trk_; diff --git a/src/algorithms/channel/libs/channel_msg_receiver_cc.cc b/src/algorithms/channel/libs/channel_msg_receiver_cc.cc index 9eebfe01d..61b409c5c 100644 --- a/src/algorithms/channel/libs/channel_msg_receiver_cc.cc +++ b/src/algorithms/channel/libs/channel_msg_receiver_cc.cc @@ -1,6 +1,6 @@ /*! * \file channel_msg_receiver_cc.cc - * \brief GNURadio block that receives asynchronous channel messages from acquisition and tracking blocks + * \brief GNU Radio block that receives asynchronous channel messages from acquisition and tracking blocks * \author Javier Arribas, 2016. jarribas(at)cttc.es * * ------------------------------------------------------------------------- @@ -44,51 +44,54 @@ channel_msg_receiver_cc_sptr channel_msg_receiver_make_cc(ChannelFsm* channel_fs 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) + try { - LOG(WARNING) << "msg_handler_telemetry Bad any cast!\n"; + 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!"; } } + 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; + 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 index 1ba051952..195d41e7c 100644 --- a/src/algorithms/channel/libs/channel_msg_receiver_cc.h +++ b/src/algorithms/channel/libs/channel_msg_receiver_cc.h @@ -1,6 +1,6 @@ /*! * \file channel_msg_receiver_cc.h - * \brief GNURadio block that receives asynchronous channel messages from acquisition and tracking blocks + * \brief GNU Radio block that receives asynchronous channel messages from acquisition and tracking blocks * \author Javier Arribas, 2016. jarribas(at)cttc.es * * ------------------------------------------------------------------------- @@ -41,7 +41,7 @@ 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 + * \brief GNU Radio block that receives asynchronous channel messages from acquisition and tracking blocks */ class channel_msg_receiver_cc : public gr::block { From ad9dd713599267f9e54d62ef192405014bbfb8a4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 25 Apr 2016 20:34:56 +0200 Subject: [PATCH 2/2] code cleaning --- .../PVT/gnuradio_blocks/hybrid_pvt_cc.cc | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc index 2a4705859..2411102ae 100644 --- a/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc @@ -54,29 +54,29 @@ void hybrid_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) { // ### GPS EPHEMERIS ### std::shared_ptr gps_eph; - gps_eph= boost::any_cast>(pmt::any_ref(msg)); + gps_eph = boost::any_cast>(pmt::any_ref(msg)); DLOG(INFO) << "Ephemeris record has arrived from SAT ID " << gps_eph->i_satellite_PRN << " (Block " << gps_eph->satelliteBlock[gps_eph->i_satellite_PRN] << ")" << "inserted with Toe="<< gps_eph->d_Toe<<" and GPS Week=" << gps_eph->i_GPS_week; // update/insert new ephemeris record to the global ephemeris map - d_ls_pvt->gps_ephemeris_map[gps_eph->i_satellite_PRN]=*gps_eph; + d_ls_pvt->gps_ephemeris_map[gps_eph->i_satellite_PRN] = *gps_eph; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr) ) { // ### GPS IONO ### std::shared_ptr gps_iono; - gps_iono= boost::any_cast>(pmt::any_ref(msg)); - d_ls_pvt->gps_iono=*gps_iono; + gps_iono = boost::any_cast>(pmt::any_ref(msg)); + d_ls_pvt->gps_iono = *gps_iono; DLOG(INFO) << "New IONO record has arrived "; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr) ) { // ### GPS UTC MODEL ### std::shared_ptr gps_utc_model; - gps_utc_model= boost::any_cast>(pmt::any_ref(msg)); - d_ls_pvt->gps_utc_model=*gps_utc_model; + gps_utc_model = boost::any_cast>(pmt::any_ref(msg)); + d_ls_pvt->gps_utc_model = *gps_utc_model; DLOG(INFO) << "New UTC record has arrived "; } @@ -84,37 +84,37 @@ void hybrid_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg) { // ### Galileo EPHEMERIS ### std::shared_ptr galileo_eph; - galileo_eph= boost::any_cast>(pmt::any_ref(msg)); + galileo_eph = boost::any_cast>(pmt::any_ref(msg)); // insert new ephemeris record DLOG(INFO) << "Galileo New Ephemeris record inserted in global map with TOW =" << galileo_eph->TOW_5 << ", GALILEO Week Number =" << galileo_eph->WN_5 << " and Ephemeris IOD = " << galileo_eph->IOD_ephemeris; // update/insert new ephemeris record to the global ephemeris map - d_ls_pvt->galileo_ephemeris_map[galileo_eph->i_satellite_PRN]=*galileo_eph; + d_ls_pvt->galileo_ephemeris_map[galileo_eph->i_satellite_PRN] = *galileo_eph; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr) ) { // ### Galileo IONO ### std::shared_ptr galileo_iono; - galileo_iono= boost::any_cast>(pmt::any_ref(msg)); - d_ls_pvt->galileo_iono=*galileo_iono; + galileo_iono = boost::any_cast>(pmt::any_ref(msg)); + d_ls_pvt->galileo_iono = *galileo_iono; DLOG(INFO) << "New IONO record has arrived "; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr) ) { // ### Galileo UTC MODEL ### std::shared_ptr galileo_utc_model; - galileo_utc_model= boost::any_cast>(pmt::any_ref(msg)); - d_ls_pvt->galileo_utc_model=*galileo_utc_model; + galileo_utc_model = boost::any_cast>(pmt::any_ref(msg)); + d_ls_pvt->galileo_utc_model = *galileo_utc_model; DLOG(INFO) << "New UTC record has arrived "; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr) ) { // ### Galileo Almanac ### std::shared_ptr galileo_almanac; - galileo_almanac= boost::any_cast>(pmt::any_ref(msg)); + galileo_almanac = boost::any_cast>(pmt::any_ref(msg)); // update/insert new ephemeris record to the global ephemeris map - d_ls_pvt->galileo_almanac=*galileo_almanac; + d_ls_pvt->galileo_almanac = *galileo_almanac; DLOG(INFO) << "New Galileo Almanac has arrived "; } else