2011-10-01 18:45:20 +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,
|
|
|
|
* process them, and apply the corresponding actions.
|
|
|
|
*
|
2011-10-01 18:45:20 +00:00
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2012-10-28 13:20:55 +00:00
|
|
|
* Copyright (C) 2010-2012 (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/>.
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GNSS_SDR_CONTROL_THREAD_H_
|
|
|
|
#define GNSS_SDR_CONTROL_THREAD_H_
|
|
|
|
|
2013-03-15 18:05:37 +00:00
|
|
|
#include <boost/thread/thread.hpp>
|
2011-10-01 18:45:20 +00:00
|
|
|
#include <gnuradio/gr_msg_queue.h>
|
|
|
|
#include "control_message_factory.h"
|
2013-03-15 18:05:37 +00:00
|
|
|
#include "gnss_sdr_supl_client.h"
|
2011-10-01 18:45:20 +00:00
|
|
|
|
|
|
|
class GNSSFlowgraph;
|
|
|
|
class ConfigurationInterface;
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief This class represents the main thread of the application, aka Control Thread.
|
|
|
|
*/
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
ControlThread(ConfigurationInterface *configuration);
|
|
|
|
|
2011-12-27 21:21:12 +00:00
|
|
|
//! \brief Virtual destructor. Derived classes must implement the destructor
|
2011-10-01 18:45:20 +00:00
|
|
|
virtual ~ControlThread();
|
|
|
|
|
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:
|
|
|
|
* - Connect the GNSS receiver flowgraph;
|
|
|
|
* - Start the GNSS receiver flowgraph;
|
|
|
|
* while (flowgraph_->running() && !stop)_{
|
|
|
|
* - Read control messages and process them; }
|
|
|
|
*/
|
2011-10-01 18:45:20 +00:00
|
|
|
void run();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Sets the control_queue
|
|
|
|
*
|
|
|
|
* \param[in] gr_msg_queue_sptr control_queue
|
|
|
|
*/
|
|
|
|
void set_control_queue(gr_msg_queue_sptr control_queue);
|
|
|
|
|
2011-12-27 21:21:12 +00:00
|
|
|
|
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
|
|
|
|
*
|
|
|
|
* \return Returns a flowgraph object
|
|
|
|
*/
|
|
|
|
GNSSFlowgraph* flowgraph()
|
|
|
|
{
|
|
|
|
return flowgraph_;
|
2011-12-28 21:36:45 +00:00
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
2013-03-15 18:05:37 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief SUPL assistance classes
|
|
|
|
*/
|
|
|
|
gnss_sdr_supl_client supl_client_acquisition_;
|
|
|
|
gnss_sdr_supl_client supl_client_ephemeris_;
|
|
|
|
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).
|
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
void init();
|
2013-03-18 18:27:44 +00:00
|
|
|
bool read_assistance_from_XML();
|
2011-10-01 18:45:20 +00:00
|
|
|
void read_control_messages();
|
|
|
|
void process_control_messages();
|
2013-03-15 18:05:37 +00:00
|
|
|
void gps_ephemeris_data_collector();
|
|
|
|
void gps_utc_model_data_collector();
|
|
|
|
void gps_iono_data_collector();
|
2013-03-20 18:19:26 +00:00
|
|
|
void gps_acq_assist_data_collector();
|
2011-10-01 18:45:20 +00:00
|
|
|
void apply_action(unsigned int what);
|
|
|
|
GNSSFlowgraph *flowgraph_;
|
|
|
|
ConfigurationInterface *configuration_;
|
|
|
|
gr_msg_queue_sptr control_queue_;
|
|
|
|
ControlMessageFactory *control_message_factory_;
|
|
|
|
std::vector<ControlMessage*> *control_messages_;
|
|
|
|
bool stop_;
|
|
|
|
bool delete_configuration_;
|
|
|
|
unsigned int processed_control_messages_;
|
|
|
|
unsigned int applied_actions_;
|
2012-03-16 12:04:36 +00:00
|
|
|
boost::thread keyboard_thread_;
|
2013-03-15 18:05:37 +00:00
|
|
|
boost::thread gps_ephemeris_data_collector_thread_;
|
|
|
|
boost::thread gps_iono_data_collector_thread_;
|
|
|
|
boost::thread gps_utc_model_data_collector_thread_;
|
2013-03-20 18:19:26 +00:00
|
|
|
boost::thread gps_acq_assist_data_collector_thread_;
|
2012-03-16 12:04:36 +00:00
|
|
|
void keyboard_listener();
|
2011-10-01 18:45:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /*GNSS_SDR_CONTROL_THREAD_H_*/
|