2011-10-01 18:45:20 +00:00
|
|
|
/*!
|
2014-04-15 13:03:54 +00:00
|
|
|
* \file control_thread.h
|
2011-12-27 21:21:12 +00:00
|
|
|
* \brief Interface of the receiver control plane
|
2011-10-01 18:45:20 +00:00
|
|
|
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
|
|
|
|
*
|
2011-12-27 21:21:12 +00:00
|
|
|
* GNSS Receiver Control Plane: connects the flowgraph, starts running it,
|
|
|
|
* and while it does not stop, reads the control messages generated by the blocks,
|
2014-04-15 13:03:54 +00:00
|
|
|
* processes them, and applies the corresponding actions.
|
2011-12-27 21:21:12 +00:00
|
|
|
*
|
2011-10-01 18:45:20 +00:00
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2018-05-13 20:49:11 +00:00
|
|
|
* Copyright (C) 2010-2018 (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
|
2014-04-15 13:03:54 +00:00
|
|
|
* (at your option) any later version.
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
|
|
|
* 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
|
2018-05-13 20:49:11 +00:00
|
|
|
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GNSS_SDR_CONTROL_THREAD_H_
|
|
|
|
#define GNSS_SDR_CONTROL_THREAD_H_
|
|
|
|
|
2019-03-05 07:59:04 +00:00
|
|
|
#include "agnss_ref_location.h" // for Agnss_Ref_Location
|
|
|
|
#include "agnss_ref_time.h" // for Agnss_Ref_Time
|
|
|
|
#include "control_message_factory.h" // for ControlMessage
|
|
|
|
#include "gnss_sdr_supl_client.h" // for Gnss_Sdr_Supl_Client
|
|
|
|
#include "tcp_cmd_interface.h" // for TcpCmdInterface
|
|
|
|
#include <armadillo> // for arma::vec
|
|
|
|
#include <boost/thread.hpp> // for boost::thread
|
|
|
|
#include <gnuradio/msg_queue.h> // for msg_queue, msg_queue::sptr
|
|
|
|
#include <ctime> // for time_t
|
|
|
|
#include <memory> // for shared_ptr
|
|
|
|
#include <string> // for string
|
|
|
|
#include <thread> // for std::thread
|
|
|
|
#include <utility> // for pair
|
|
|
|
#include <vector> // for vector
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2019-03-05 07:59:04 +00:00
|
|
|
class ConfigurationInterface;
|
|
|
|
class GNSSFlowgraph;
|
|
|
|
class Gnss_Satellite;
|
2011-10-01 18:45:20 +00:00
|
|
|
|
|
|
|
/*!
|
2014-04-15 13:03:54 +00:00
|
|
|
* \brief This class represents the main thread of the application, so the name is ControlThread.
|
|
|
|
* This is the GNSS Receiver Control Plane: it connects the flowgraph, starts running it,
|
|
|
|
* and while it does not stop, reads the control messages generated by the blocks,
|
|
|
|
* processes them, and applies the corresponding actions.
|
2011-10-01 18:45:20 +00:00
|
|
|
*/
|
|
|
|
class ControlThread
|
|
|
|
{
|
|
|
|
public:
|
2011-12-27 21:21:12 +00:00
|
|
|
/*!
|
|
|
|
* \brief Default constructor
|
|
|
|
*/
|
2011-10-01 18:45:20 +00:00
|
|
|
ControlThread();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Constructor that initializes the class with parameters
|
|
|
|
*
|
|
|
|
* \param[in] configuration Pointer to a ConfigurationInterface
|
|
|
|
*/
|
2014-04-03 21:59:14 +00:00
|
|
|
ControlThread(std::shared_ptr<ConfigurationInterface> configuration);
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2015-01-12 20:05:38 +00:00
|
|
|
//! \brief Destructor
|
|
|
|
~ControlThread();
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2011-12-28 21:36:45 +00:00
|
|
|
/*! \brief Runs the control thread
|
|
|
|
*
|
|
|
|
* This is the main loop that reads and process the control messages:
|
2013-11-17 10:48:27 +00:00
|
|
|
*
|
2011-12-28 21:36:45 +00:00
|
|
|
* - Connect the GNSS receiver flowgraph;
|
2013-11-17 10:48:27 +00:00
|
|
|
*
|
2011-12-28 21:36:45 +00:00
|
|
|
* - Start the GNSS receiver flowgraph;
|
2013-11-17 10:48:27 +00:00
|
|
|
*
|
|
|
|
* while (flowgraph_->running() && !stop_){
|
|
|
|
*
|
2011-12-28 21:36:45 +00:00
|
|
|
* - Read control messages and process them; }
|
|
|
|
*/
|
2018-10-23 14:54:06 +00:00
|
|
|
int run();
|
2011-10-01 18:45:20 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Sets the control_queue
|
|
|
|
*
|
2013-11-17 10:48:27 +00:00
|
|
|
* \param[in] boost::shared_ptr<gr::msg_queue> control_queue
|
2011-10-01 18:45:20 +00:00
|
|
|
*/
|
2019-02-22 12:30:18 +00:00
|
|
|
void set_control_queue(const gr::msg_queue::sptr control_queue); // NOLINT(performance-unnecessary-value-param)
|
2011-10-01 18:45:20 +00:00
|
|
|
|
|
|
|
unsigned int processed_control_messages()
|
|
|
|
{
|
|
|
|
return processed_control_messages_;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int applied_actions()
|
|
|
|
{
|
|
|
|
return applied_actions_;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Instantiates a flowgraph
|
|
|
|
*
|
2014-04-15 13:03:54 +00:00
|
|
|
* \return Returns a smart pointer to a flowgraph object
|
2011-10-01 18:45:20 +00:00
|
|
|
*/
|
2014-04-13 00:51:00 +00:00
|
|
|
std::shared_ptr<GNSSFlowgraph> flowgraph()
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
2014-04-13 00:51:00 +00:00
|
|
|
return flowgraph_;
|
2011-12-28 21:36:45 +00:00
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
|
|
|
|
private:
|
2018-10-19 12:54:03 +00:00
|
|
|
//Telecommand TCP interface
|
|
|
|
TcpCmdInterface cmd_interface_;
|
|
|
|
void telecommand_listener();
|
2019-02-24 12:22:52 +00:00
|
|
|
std::thread cmd_interface_thread_;
|
2013-11-17 10:48:27 +00:00
|
|
|
//SUPL assistance classes
|
2019-02-22 09:47:24 +00:00
|
|
|
Gnss_Sdr_Supl_Client supl_client_acquisition_;
|
|
|
|
Gnss_Sdr_Supl_Client supl_client_ephemeris_;
|
2018-03-03 01:03:39 +00:00
|
|
|
int supl_mcc; // Current network MCC (Mobile country code), 3 digits.
|
|
|
|
int supl_mns; // Current network MNC (Mobile Network code), 2 or 3 digits.
|
|
|
|
int supl_lac; // Current network LAC (Location area code),16 bits, 1-65520 are valid values.
|
|
|
|
int supl_ci; // Cell Identity (16 bits, 0-65535 are valid values).
|
2013-03-15 18:05:37 +00:00
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
void init();
|
2013-11-17 10:48:27 +00:00
|
|
|
|
2014-04-28 14:27:47 +00:00
|
|
|
// Read {ephemeris, iono, utc, ref loc, ref time} assistance from a local XML file previously recorded
|
2016-04-13 14:19:15 +00:00
|
|
|
bool read_assistance_from_XML();
|
2013-08-21 15:17:02 +00:00
|
|
|
|
2014-04-28 14:27:47 +00:00
|
|
|
// Save {ephemeris, iono, utc, ref loc, ref time} assistance to a local XML file
|
2016-04-12 13:28:58 +00:00
|
|
|
//bool save_assistance_to_XML();
|
2014-04-28 14:27:47 +00:00
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
void read_control_messages();
|
2013-08-21 15:17:02 +00:00
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
void process_control_messages();
|
2013-08-21 15:17:02 +00:00
|
|
|
|
|
|
|
/*
|
2014-04-15 13:03:54 +00:00
|
|
|
* Blocking function that reads the GPS assistance queue
|
2013-08-21 15:17:02 +00:00
|
|
|
*/
|
2013-03-20 18:19:26 +00:00
|
|
|
void gps_acq_assist_data_collector();
|
2018-03-03 01:03:39 +00:00
|
|
|
|
2018-11-05 16:53:53 +00:00
|
|
|
/*
|
|
|
|
* Compute elevations for the specified time and position for all the available satellites in ephemeris and almanac queues
|
|
|
|
* returns a vector filled with the available satellites ordered from high elevation to low elevation angle.
|
|
|
|
*/
|
2018-11-08 14:34:58 +00:00
|
|
|
std::vector<std::pair<int, Gnss_Satellite>> get_visible_sats(time_t rx_utc_time, const arma::vec& LLH);
|
2018-11-05 16:53:53 +00:00
|
|
|
|
2016-05-03 10:34:38 +00:00
|
|
|
/*
|
|
|
|
* Read initial GNSS assistance from SUPL server or local XML files
|
|
|
|
*/
|
|
|
|
void assist_GNSS();
|
2018-03-03 01:03:39 +00:00
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
void apply_action(unsigned int what);
|
2014-04-03 21:59:14 +00:00
|
|
|
std::shared_ptr<GNSSFlowgraph> flowgraph_;
|
|
|
|
std::shared_ptr<ConfigurationInterface> configuration_;
|
2017-12-21 12:05:21 +00:00
|
|
|
gr::msg_queue::sptr control_queue_;
|
2014-04-03 21:59:14 +00:00
|
|
|
std::shared_ptr<ControlMessageFactory> control_message_factory_;
|
2014-04-13 00:51:00 +00:00
|
|
|
std::shared_ptr<std::vector<std::shared_ptr<ControlMessage>>> control_messages_;
|
2011-10-01 18:45:20 +00:00
|
|
|
bool stop_;
|
2018-10-23 14:54:06 +00:00
|
|
|
bool restart_;
|
2011-10-01 18:45:20 +00:00
|
|
|
bool delete_configuration_;
|
|
|
|
unsigned int processed_control_messages_;
|
|
|
|
unsigned int applied_actions_;
|
2019-02-28 20:45:30 +00:00
|
|
|
|
2019-02-13 16:48:14 +00:00
|
|
|
boost::thread fpga_helper_thread_;
|
2019-02-28 20:45:30 +00:00
|
|
|
|
2019-02-24 12:22:52 +00:00
|
|
|
std::thread keyboard_thread_;
|
|
|
|
std::thread sysv_queue_thread_;
|
|
|
|
std::thread gps_acq_assist_data_collector_thread_;
|
2018-03-03 01:03:39 +00:00
|
|
|
|
2012-03-16 12:04:36 +00:00
|
|
|
void keyboard_listener();
|
2016-10-01 15:32:38 +00:00
|
|
|
void sysv_queue_listener();
|
2016-10-03 15:43:06 +00:00
|
|
|
int msqid;
|
2014-04-28 14:27:47 +00:00
|
|
|
|
|
|
|
// default filename for assistance data
|
|
|
|
const std::string eph_default_xml_filename = "./gps_ephemeris.xml";
|
|
|
|
const std::string utc_default_xml_filename = "./gps_utc_model.xml";
|
|
|
|
const std::string iono_default_xml_filename = "./gps_iono.xml";
|
|
|
|
const std::string ref_time_default_xml_filename = "./gps_ref_time.xml";
|
|
|
|
const std::string ref_location_default_xml_filename = "./gps_ref_location.xml";
|
2018-10-17 17:17:37 +00:00
|
|
|
const std::string eph_gal_default_xml_filename = "./gal_ephemeris.xml";
|
|
|
|
const std::string eph_cnav_default_xml_filename = "./gps_cnav_ephemeris.xml";
|
2018-10-18 13:46:48 +00:00
|
|
|
const std::string gal_iono_default_xml_filename = "./gal_iono.xml";
|
|
|
|
const std::string gal_utc_default_xml_filename = "./gal_utc_model.xml";
|
2018-10-19 12:48:41 +00:00
|
|
|
const std::string cnav_utc_default_xml_filename = "./gps_cnav_utc_model.xml";
|
2018-10-20 17:30:32 +00:00
|
|
|
const std::string eph_glo_gnav_default_xml_filename = "./glo_gnav_ephemeris.xml";
|
|
|
|
const std::string glo_utc_default_xml_filename = "./glo_utc_model.xml";
|
2018-10-24 22:43:25 +00:00
|
|
|
const std::string gal_almanac_default_xml_filename = "./gal_almanac.xml";
|
2018-10-25 09:01:29 +00:00
|
|
|
const std::string gps_almanac_default_xml_filename = "./gps_almanac.xml";
|
2018-11-20 08:28:47 +00:00
|
|
|
|
|
|
|
Agnss_Ref_Location agnss_ref_location_;
|
|
|
|
Agnss_Ref_Time agnss_ref_time_;
|
2011-10-01 18:45:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /*GNSS_SDR_CONTROL_THREAD_H_*/
|