2011-10-01 18:45:20 +00:00
|
|
|
/*!
|
|
|
|
* \file gnss_flowgraph.cc
|
2011-12-28 21:36:45 +00:00
|
|
|
* \brief Implementation of a GNSS receiver flowgraph
|
2011-10-01 18:45:20 +00:00
|
|
|
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
|
2012-03-02 17:17:51 +00:00
|
|
|
* Luis Esteve, 2012. luis(at)epsilon-formacion.com
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
|
|
|
* Detailed description of the file here if needed.
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2014-03-16 19:58:29 +00:00
|
|
|
* Copyright (C) 2010-2014 (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
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gnss_flowgraph.h"
|
|
|
|
#include "unistd.h"
|
2014-03-16 19:58:29 +00:00
|
|
|
#include <exception>
|
2011-12-21 00:21:20 +00:00
|
|
|
#include <iostream>
|
2014-04-03 21:59:14 +00:00
|
|
|
#include <memory>
|
2014-03-16 19:58:29 +00:00
|
|
|
#include <set>
|
2011-12-14 16:50:36 +00:00
|
|
|
#include <boost/lexical_cast.hpp>
|
2011-10-01 18:45:20 +00:00
|
|
|
#include <glog/logging.h>
|
|
|
|
#include "configuration_interface.h"
|
|
|
|
#include "gnss_block_interface.h"
|
|
|
|
#include "channel_interface.h"
|
|
|
|
#include "gnss_block_factory.h"
|
|
|
|
|
2014-02-18 19:40:44 +00:00
|
|
|
#define GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS 8
|
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
using google::LogMessage;
|
|
|
|
|
2014-04-03 21:59:14 +00:00
|
|
|
GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configuration,
|
2013-07-04 13:47:40 +00:00
|
|
|
boost::shared_ptr<gr::msg_queue> queue)
|
2012-04-14 18:04:27 +00:00
|
|
|
{
|
|
|
|
connected_ = false;
|
|
|
|
running_ = false;
|
|
|
|
configuration_ = configuration;
|
2014-04-11 18:18:59 +00:00
|
|
|
//blocks_ = new std::vector<GNSSBlockInterface*>();
|
|
|
|
std::shared_ptr<std::vector<std::shared_ptr<GNSSBlockInterface>>> blocks_ = std::make_shared<std::vector<std::shared_ptr<GNSSBlockInterface>>>();
|
2012-04-14 18:04:27 +00:00
|
|
|
queue_ = queue;
|
|
|
|
init();
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
GNSSFlowgraph::~GNSSFlowgraph()
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < blocks_->size(); i++)
|
|
|
|
{
|
2014-04-11 18:18:59 +00:00
|
|
|
//delete blocks_->at(i);
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
|
|
|
blocks_->clear();
|
2014-04-11 18:18:59 +00:00
|
|
|
//delete blocks_;
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
void GNSSFlowgraph::start()
|
|
|
|
{
|
|
|
|
if (running_)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Already running";
|
2012-04-14 18:04:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
top_block_->start();
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Unable to start flowgraph";
|
|
|
|
LOG(ERROR) << e.what();
|
2012-04-14 18:04:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
running_ = true;
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-03-02 17:17:51 +00:00
|
|
|
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
void GNSSFlowgraph::stop()
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < channels_count_; i++)
|
|
|
|
{
|
2012-10-28 10:56:04 +00:00
|
|
|
// if(channels_state_[i]==2) channel(i)->
|
2012-04-14 18:04:27 +00:00
|
|
|
channel(i)->stop();
|
|
|
|
}
|
|
|
|
for (unsigned int i = 0; i < channels_count_; i++)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Channel " << i << " in state " << channels_state_[i] << std::endl;
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Threads finished. Return to main program.";
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->stop();
|
|
|
|
running_ = false;
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
|
|
|
|
void GNSSFlowgraph::connect()
|
|
|
|
{
|
|
|
|
/* Connects the blocks in the flowgraph
|
|
|
|
*
|
|
|
|
* Signal Source > Signal conditioner >> Channels >> Observables >> PVT > Output filter
|
|
|
|
*/
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Connecting flowgraph";
|
2012-04-14 18:04:27 +00:00
|
|
|
if (connected_)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "flowgraph already connected";
|
2012-04-14 18:04:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2014-04-11 18:18:59 +00:00
|
|
|
std::cout << "helllllo" << std::endl;
|
|
|
|
//signal_source()->connect(top_block_);
|
|
|
|
blocks_->at(0)->connect(top_block_);
|
|
|
|
std::cout << "helllllo" << std::endl;
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Can't connect signal source block internally";
|
|
|
|
LOG(ERROR) << e.what();
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->disconnect_all();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Signal Source > Signal conditioner >
|
|
|
|
try
|
|
|
|
{
|
|
|
|
signal_conditioner()->connect(top_block_);
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Can't connect signal conditioner block internally";
|
|
|
|
LOG(ERROR) << e.what();
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->disconnect_all();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < channels_count_; i++)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
channel(i)->connect(top_block_);
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Can't connect channel " << i << " internally";
|
|
|
|
LOG(ERROR) << e.what();
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->disconnect_all();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
observables()->connect(top_block_);
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Can't connect observables block internally";
|
|
|
|
LOG(ERROR) << e.what();
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->disconnect_all();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Signal Source > Signal conditioner >> Channels >> Observables > PVT
|
|
|
|
try
|
|
|
|
{
|
|
|
|
pvt()->connect(top_block_);
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Can't connect PVT block internally";
|
|
|
|
LOG(ERROR) << e.what();
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->disconnect_all();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Signal Source > Signal conditioner >> Channels >> Observables > PVT > Output Filter
|
|
|
|
try
|
|
|
|
{
|
|
|
|
output_filter()->connect(top_block_);
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Can't connect output filter block internally";
|
|
|
|
LOG(ERROR) << e.what();
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->disconnect_all();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DLOG(INFO) << "blocks connected internally";
|
|
|
|
|
|
|
|
// Signal Source > Signal conditioner >
|
2014-02-18 19:40:44 +00:00
|
|
|
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
try
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
if(signal_source()->implementation().compare("Raw_Array_Signal_Source") == 0)
|
|
|
|
{
|
|
|
|
//Multichannel Array
|
|
|
|
std::cout << "ARRAY MODE" << std::endl;
|
|
|
|
for (int i = 0; i < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; i++)
|
|
|
|
{
|
|
|
|
std::cout << "connecting ch "<< i << std::endl;
|
|
|
|
top_block_->connect(signal_source()->get_right_block(), i, signal_conditioner()->get_left_block(), i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//single channel
|
|
|
|
// std::cout<<"NORMAL MODE"<<std::endl;
|
|
|
|
top_block_->connect(signal_source()->get_right_block(), 0, signal_conditioner()->get_left_block(), 0);
|
|
|
|
}
|
2014-02-18 19:40:44 +00:00
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Can't connect signal source to signal conditioner";
|
|
|
|
LOG(ERROR) << e.what();
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->disconnect_all();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DLOG(INFO) << "Signal source connected to signal conditioner";
|
|
|
|
|
|
|
|
// Signal Source > Signal conditioner >> channels_count_ number of Channels in parallel
|
|
|
|
for (unsigned int i = 0; i < channels_count_; i++)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
top_block_->connect(signal_conditioner()->get_right_block(), 0,
|
|
|
|
channel(i)->get_left_block(), 0);
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Can't connect signal conditioner to channel " << i;
|
|
|
|
LOG(ERROR) << e.what();
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->disconnect_all();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DLOG(INFO) << "signal conditioner connected to channel " << i;
|
|
|
|
|
|
|
|
// Signal Source > Signal conditioner >> Channels >> Observables
|
|
|
|
try
|
|
|
|
{
|
|
|
|
top_block_->connect(channel(i)->get_right_block(), 0,
|
|
|
|
observables()->get_left_block(), i);
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Can't connect channel " << i << " to observables";
|
|
|
|
LOG(ERROR) << e.what();
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->disconnect_all();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
channel(i)->set_signal(available_GNSS_signals_.front());
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Channel " << i << " assigned to " << available_GNSS_signals_.front();
|
2012-04-14 18:04:27 +00:00
|
|
|
available_GNSS_signals_.pop_front();
|
|
|
|
channel(i)->start();
|
|
|
|
if (channels_state_[i] == 1)
|
|
|
|
{
|
|
|
|
channel(i)->start_acquisition();
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Channel " << i
|
|
|
|
<< " connected to observables and ready for acquisition";
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Channel " << i
|
|
|
|
<< " connected to observables in standby mode";
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Connect the observables output of each channel to the PVT block
|
|
|
|
*/
|
|
|
|
try
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < channels_count_; i++)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
top_block_->connect(observables()->get_right_block(), i, pvt()->get_left_block(), i);
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Can't connect observables to PVT";
|
|
|
|
LOG(ERROR) << e.what();
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->disconnect_all();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
top_block_->connect(pvt()->get_right_block(), 0, output_filter()->get_left_block(), 0);
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Can't connect PVT to output filter";
|
|
|
|
LOG(ERROR) << e.what();
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->disconnect_all();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DLOG(INFO) << "PVT connected to output filter";
|
|
|
|
connected_ = true;
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Flowgraph connected";
|
2012-04-14 18:04:27 +00:00
|
|
|
top_block_->dump();
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GNSSFlowgraph::wait()
|
|
|
|
{
|
|
|
|
if (!running_)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Can't apply wait. Flowgraph is not running";
|
2012-04-14 18:04:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
top_block_->wait();
|
|
|
|
DLOG(INFO) << "Flowgraph finished calculations";
|
|
|
|
running_ = false;
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-28 21:36:45 +00:00
|
|
|
/*
|
|
|
|
* Applies an action to the flowgraph
|
|
|
|
*
|
|
|
|
* \param[in] who Who generated the action
|
|
|
|
* \param[in] what What is the action 0: acquisition failed
|
|
|
|
*/
|
2012-04-14 18:04:27 +00:00
|
|
|
void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "received " << what << " from " << who;
|
2012-04-14 18:04:27 +00:00
|
|
|
|
|
|
|
switch (what)
|
|
|
|
{
|
|
|
|
case 0:
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Channel " << who << " ACQ FAILED satellite " << channel(who)->get_signal().get_satellite();
|
2012-04-14 18:04:27 +00:00
|
|
|
available_GNSS_signals_.push_back(channel(who)->get_signal());
|
2012-09-05 13:50:59 +00:00
|
|
|
|
2014-03-16 19:58:29 +00:00
|
|
|
while (channel(who)->get_signal().get_satellite().get_system() != available_GNSS_signals_.front().get_satellite().get_system())
|
|
|
|
{
|
2012-09-05 13:50:59 +00:00
|
|
|
available_GNSS_signals_.push_back(available_GNSS_signals_.front());
|
|
|
|
available_GNSS_signals_.pop_front();
|
2014-03-16 19:58:29 +00:00
|
|
|
}
|
2012-04-14 18:04:27 +00:00
|
|
|
channel(who)->set_signal(available_GNSS_signals_.front());
|
|
|
|
available_GNSS_signals_.pop_front();
|
|
|
|
channel(who)->start_acquisition();
|
2012-09-05 13:50:59 +00:00
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
break;
|
|
|
|
// TODO: Tracking messages
|
|
|
|
|
|
|
|
case 1:
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Channel " << who << " ACQ SUCCESS satellite " << channel(who)->get_signal().get_satellite();
|
2012-04-14 18:04:27 +00:00
|
|
|
channels_state_[who] = 2;
|
|
|
|
acq_channels_count_--;
|
|
|
|
if (acq_channels_count_ < max_acq_channels_)
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < channels_count_; i++)
|
|
|
|
{
|
|
|
|
if (channels_state_[i] == 0)
|
|
|
|
{
|
|
|
|
channels_state_[i] = 1;
|
|
|
|
acq_channels_count_++;
|
|
|
|
channel(i)->start_acquisition();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < channels_count_; i++)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Channel " << i << " in state " << channels_state_[i] << std::endl;
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Channel " << who << " TRK FAILED satellite " << channel(who)->get_signal().get_satellite();
|
2012-04-14 18:04:27 +00:00
|
|
|
if (acq_channels_count_ < max_acq_channels_)
|
|
|
|
{
|
|
|
|
channels_state_[who] = 1;
|
|
|
|
acq_channels_count_++;
|
|
|
|
channel(who)->start_acquisition();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
channels_state_[who] = 0;
|
|
|
|
channel(who)->standby();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < channels_count_; i++)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Channel " << i << " in state " << channels_state_[i] << std::endl;
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Number of available satellites: " << available_GNSS_signals_.size();
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-03 21:59:14 +00:00
|
|
|
void GNSSFlowgraph::set_configuration(std::shared_ptr<ConfigurationInterface> configuration)
|
2012-04-14 18:04:27 +00:00
|
|
|
{
|
|
|
|
if (running_)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Unable to update configuration while flowgraph running";
|
2012-04-14 18:04:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (connected_)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Unable to update configuration while flowgraph connected";
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
|
|
|
configuration_ = configuration;
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
|
|
|
|
|
2014-04-11 18:18:59 +00:00
|
|
|
std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::signal_source()
|
2012-04-14 18:04:27 +00:00
|
|
|
{
|
2014-04-11 18:18:59 +00:00
|
|
|
//std::shared_ptr<GNSSBlockInterface> cond_ { blocks_->at(0) };
|
|
|
|
//return cond_;
|
|
|
|
//return blocks_->at(0);
|
|
|
|
std::shared_ptr<GNSSBlockInterface> source_ = std::move(blocks_->at(0));
|
|
|
|
return source_;
|
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
|
|
|
|
|
2014-04-11 18:18:59 +00:00
|
|
|
std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::signal_conditioner()
|
2012-04-14 18:04:27 +00:00
|
|
|
{
|
|
|
|
return blocks_->at(1);
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
|
|
|
|
|
2014-04-11 18:18:59 +00:00
|
|
|
std::shared_ptr<ChannelInterface> GNSSFlowgraph::channel(unsigned int index)
|
2012-04-14 18:04:27 +00:00
|
|
|
{
|
2014-04-11 18:18:59 +00:00
|
|
|
//return (ChannelInterface*) blocks_->at(index + 5);
|
|
|
|
//std::shared_ptr<ChannelInterface> sptr = std::make_shared<GNSSBlockInterface>(blocks_->at(index + 5));
|
|
|
|
//return blocks_->at(index + 5);
|
|
|
|
std::shared_ptr<GNSSBlockInterface> chan_ = blocks_->at(index + 5);
|
|
|
|
|
|
|
|
std::shared_ptr<ChannelInterface> chan = std::dynamic_pointer_cast<ChannelInterface>(chan_);
|
|
|
|
|
|
|
|
return chan;
|
|
|
|
//return sptr;
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
|
|
|
|
|
2014-04-11 18:18:59 +00:00
|
|
|
std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::observables()
|
2012-04-14 18:04:27 +00:00
|
|
|
{
|
|
|
|
return blocks_->at(2);
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
|
|
|
|
|
2014-04-11 18:18:59 +00:00
|
|
|
std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::pvt()
|
2012-04-14 18:04:27 +00:00
|
|
|
{
|
|
|
|
return blocks_->at(3);
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
|
|
|
|
|
2014-04-11 18:18:59 +00:00
|
|
|
std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::output_filter()
|
2012-04-14 18:04:27 +00:00
|
|
|
{
|
|
|
|
return blocks_->at(4);
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-01-16 18:27:31 +00:00
|
|
|
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
void GNSSFlowgraph::init()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Instantiates the receiver blocks
|
|
|
|
*/
|
2014-04-11 18:18:59 +00:00
|
|
|
std::shared_ptr<GNSSBlockFactory> block_factory_ = std::make_shared<GNSSBlockFactory>();
|
|
|
|
std::shared_ptr<std::vector<std::shared_ptr<GNSSBlockInterface>>> blocks_ = std::make_shared<std::vector<std::shared_ptr<GNSSBlockInterface>>>();
|
|
|
|
|
|
|
|
std::unique_ptr<GNSSBlockInterface> signal_source_ = block_factory_->GetSignalSource(configuration_, queue_);
|
|
|
|
std::shared_ptr<GNSSBlockInterface> cond_ = block_factory_->GetSignalConditioner(configuration_, queue_);
|
|
|
|
std::shared_ptr<GNSSBlockInterface> obs_ = block_factory_->GetObservables(configuration_, queue_);
|
|
|
|
std::shared_ptr<GNSSBlockInterface> pvt_ = block_factory_->GetPVT(configuration_, queue_);
|
|
|
|
std::shared_ptr<GNSSBlockInterface> output_ = block_factory_->GetOutputFilter(configuration_, queue_);
|
|
|
|
|
|
|
|
blocks_->push_back(std::move(signal_source_));
|
|
|
|
blocks_->push_back(cond_);
|
|
|
|
blocks_->push_back(obs_);
|
|
|
|
blocks_->push_back(pvt_);
|
|
|
|
blocks_->push_back(output_);
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
|
2014-04-11 18:18:59 +00:00
|
|
|
std::shared_ptr<std::vector<std::unique_ptr<GNSSBlockInterface>>> channels = block_factory_->GetChannels(configuration_, queue_);
|
2012-01-16 18:27:31 +00:00
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
channels_count_ = channels->size();
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2014-04-11 18:18:59 +00:00
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
for (unsigned int i = 0; i < channels_count_; i++)
|
|
|
|
{
|
2014-04-11 18:18:59 +00:00
|
|
|
std::shared_ptr<GNSSBlockInterface> chan_ = std::move(channels->at(i));
|
|
|
|
blocks_->push_back(chan_);
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2013-07-04 13:47:40 +00:00
|
|
|
top_block_ = gr::make_top_block("GNSSFlowgraph");
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2014-04-11 18:18:59 +00:00
|
|
|
//delete channels;
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
// fill the available_GNSS_signals_ queue with the satellites ID's to be searched by the acquisition
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
set_signals_list();
|
|
|
|
set_channels_state();
|
2012-03-02 17:17:51 +00:00
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
applied_actions_ = 0;
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
DLOG(INFO) << "Blocks instantiated. " << channels_count_ << " channels.";
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
void GNSSFlowgraph::set_signals_list()
|
|
|
|
{
|
|
|
|
/*
|
2013-07-20 07:58:59 +00:00
|
|
|
* Sets a sequential list of GNSS satellites
|
2012-04-14 18:04:27 +00:00
|
|
|
*/
|
|
|
|
|
2013-07-20 07:58:59 +00:00
|
|
|
std::set<unsigned int>::iterator available_gnss_prn_iter;
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
/*
|
|
|
|
* \TODO Describe GNSS satellites more nicely, with RINEX notation
|
|
|
|
* See http://igscb.jpl.nasa.gov/igscb/data/format/rinex301.pdf (page 5)
|
|
|
|
*/
|
|
|
|
|
2013-10-25 16:07:24 +00:00
|
|
|
/*
|
|
|
|
* Read GNSS-SDR default GNSS system and signal
|
|
|
|
*/
|
2012-04-14 18:04:27 +00:00
|
|
|
|
2014-03-16 19:58:29 +00:00
|
|
|
std::string default_system = configuration_->property("Channel.system", std::string("GPS"));
|
|
|
|
std::string default_signal = configuration_->property("Channel.signal", std::string("1C"));
|
2013-05-26 23:59:04 +00:00
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
/*
|
|
|
|
* Loop to create the list of GNSS Signals
|
|
|
|
* To add signals from other systems, add another loop 'for'
|
|
|
|
*/
|
|
|
|
|
2014-03-16 19:58:29 +00:00
|
|
|
if (default_system.compare(std::string("GPS")) == 0)
|
2013-10-25 16:07:24 +00:00
|
|
|
{
|
2014-04-11 18:18:59 +00:00
|
|
|
/*
|
|
|
|
* Loop to create GPS L1 C/A signals
|
|
|
|
*/
|
|
|
|
std::set<unsigned int> available_gps_prn = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
|
|
|
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28,
|
|
|
|
29, 30, 31, 32 };
|
|
|
|
|
|
|
|
for (available_gnss_prn_iter = available_gps_prn.begin();
|
|
|
|
available_gnss_prn_iter != available_gps_prn.end();
|
|
|
|
available_gnss_prn_iter++)
|
|
|
|
{
|
|
|
|
available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("GPS"),
|
|
|
|
*available_gnss_prn_iter), std::string("1C")));
|
|
|
|
}
|
2013-10-25 16:07:24 +00:00
|
|
|
}
|
2013-07-20 07:58:59 +00:00
|
|
|
|
|
|
|
|
2014-03-16 19:58:29 +00:00
|
|
|
if (default_system.compare(std::string("SBAS")) == 0)
|
2013-10-25 16:07:24 +00:00
|
|
|
{
|
2014-04-11 18:18:59 +00:00
|
|
|
/*
|
|
|
|
* Loop to create SBAS L1 C/A signals
|
|
|
|
*/
|
|
|
|
std::set<unsigned int> available_sbas_prn = {120, 124, 126};
|
|
|
|
|
|
|
|
for (available_gnss_prn_iter = available_sbas_prn.begin();
|
|
|
|
available_gnss_prn_iter != available_sbas_prn.end();
|
|
|
|
available_gnss_prn_iter++)
|
|
|
|
{
|
|
|
|
available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("SBAS"),
|
|
|
|
*available_gnss_prn_iter), std::string("1C")));
|
|
|
|
}
|
2013-10-25 16:07:24 +00:00
|
|
|
}
|
2013-07-20 07:58:59 +00:00
|
|
|
|
|
|
|
|
2014-03-16 19:58:29 +00:00
|
|
|
if (default_system.compare(std::string("Galileo")) == 0)
|
2013-10-25 16:07:24 +00:00
|
|
|
{
|
2013-05-26 23:59:04 +00:00
|
|
|
/*
|
|
|
|
* Loop to create the list of Galileo E1 B signals
|
|
|
|
*/
|
2013-10-25 16:07:24 +00:00
|
|
|
std::set<unsigned int> available_galileo_prn = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
|
|
|
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28,
|
|
|
|
29, 30, 31, 32, 33, 34, 35, 36};
|
2012-09-03 11:58:28 +00:00
|
|
|
|
2014-03-16 19:58:29 +00:00
|
|
|
for (available_gnss_prn_iter = available_galileo_prn.begin();
|
|
|
|
available_gnss_prn_iter != available_galileo_prn.end();
|
|
|
|
available_gnss_prn_iter++)
|
2012-09-03 11:58:28 +00:00
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("Galileo"),
|
|
|
|
*available_gnss_prn_iter), std::string("1B")));
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
2013-10-25 16:07:24 +00:00
|
|
|
}
|
2013-07-20 07:58:59 +00:00
|
|
|
|
2013-05-26 23:59:04 +00:00
|
|
|
/*
|
|
|
|
* Ordering the list of signals from configuration file
|
|
|
|
*/
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
std::list<Gnss_Signal>::iterator gnss_it = available_GNSS_signals_.begin();
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < channels_count_; i++)
|
|
|
|
{
|
|
|
|
std::string gnss_system = (configuration_->property("Channel"
|
|
|
|
+ boost::lexical_cast<std::string>(i) + ".system",
|
|
|
|
default_system));
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Channel " << i << " system " << gnss_system;
|
2013-05-26 23:59:04 +00:00
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
std::string gnss_signal = (configuration_->property("Channel"
|
|
|
|
+ boost::lexical_cast<std::string>(i) + ".signal",
|
|
|
|
default_signal));
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Channel " << i << " signal " << gnss_signal;
|
2013-05-26 23:59:04 +00:00
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
unsigned int sat = configuration_->property("Channel"
|
|
|
|
+ boost::lexical_cast<std::string>(i) + ".satellite", 0);
|
|
|
|
|
|
|
|
if ((sat == 0) || (sat == gnss_it->get_satellite().get_PRN())) // 0 = not PRN in configuration file
|
|
|
|
{
|
|
|
|
gnss_it++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
Gnss_Signal signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal);
|
2013-05-26 23:59:04 +00:00
|
|
|
DLOG(INFO) << "Channel " << i << " " << signal_value;
|
2012-04-14 18:04:27 +00:00
|
|
|
available_GNSS_signals_.remove(signal_value);
|
|
|
|
available_GNSS_signals_.insert(gnss_it, signal_value);
|
|
|
|
}
|
|
|
|
}
|
2013-05-26 23:59:04 +00:00
|
|
|
// **** FOR DEBUGGING THE LIST OF GNSS SIGNALS ****
|
|
|
|
//
|
2013-10-25 16:07:24 +00:00
|
|
|
//std::cout<<"default_system="<<default_system<<std::endl;
|
|
|
|
//std::cout<<"default_signal="<<default_signal<<std::endl;
|
2013-05-26 23:59:04 +00:00
|
|
|
// std::list<Gnss_Signal>::iterator available_gnss_list_iter;
|
|
|
|
// for (available_gnss_list_iter = available_GNSS_signals_.begin(); available_gnss_list_iter
|
|
|
|
// != available_GNSS_signals_.end(); available_gnss_list_iter++)
|
|
|
|
// {
|
2014-04-11 18:18:59 +00:00
|
|
|
// std::cout << *available_gnss_list_iter << std::endl;
|
2013-05-26 23:59:04 +00:00
|
|
|
// }
|
2012-03-02 17:17:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-14 18:04:27 +00:00
|
|
|
void GNSSFlowgraph::set_channels_state()
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
max_acq_channels_ = (configuration_->property("Channels.in_acquisition", channels_count_));
|
2012-04-14 18:04:27 +00:00
|
|
|
if (max_acq_channels_ > channels_count_)
|
|
|
|
{
|
|
|
|
max_acq_channels_ = channels_count_;
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << "Channels_in_acquisition is bigger than number of channels. Variable acq_channels_count_ is set to "
|
|
|
|
<< channels_count_;
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
|
|
|
channels_state_.reserve(channels_count_);
|
|
|
|
for (unsigned int i = 0; i < channels_count_; i++)
|
|
|
|
{
|
|
|
|
if (i < max_acq_channels_)
|
|
|
|
{
|
|
|
|
channels_state_.push_back(1);
|
2014-03-16 19:58:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
channels_state_.push_back(0);
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
|
|
|
acq_channels_count_ = max_acq_channels_;
|
|
|
|
DLOG(INFO) << acq_channels_count_ << " channels in acquisition state";
|
|
|
|
for (unsigned int i = 0; i < channels_count_; i++)
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(INFO) << "Channel " << i << " in state " << channels_state_[i];
|
2012-04-14 18:04:27 +00:00
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|