1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-24 05:53:16 +00:00

code cleaning

This commit is contained in:
Carles Fernandez 2015-06-06 01:21:00 +02:00
parent 8630cf2fbe
commit 7e04308a67
7 changed files with 334 additions and 353 deletions

View File

@ -124,13 +124,14 @@ int mixed_observables_cc::general_work (int noutput_items, gr_vector_int &ninput
*/
current_gnss_synchro[i].Flag_valid_pseudorange = false;
current_gnss_synchro[i].Pseudorange_m = 0.0;
if(current_gnss_synchro[i].Signal[0]=='2'){
if (current_gnss_synchro[i].Flag_valid_word) //if this channel have valid word
{
//record the word structure in a map for pseudorange computation
current_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(current_gnss_synchro[i].Channel_ID, current_gnss_synchro[i]));
}
}
if(current_gnss_synchro[i].Signal[0] == '2')
{
if (current_gnss_synchro[i].Flag_valid_word) //if this channel have valid word
{
//record the word structure in a map for pseudorange computation
current_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(current_gnss_synchro[i].Channel_ID, current_gnss_synchro[i]));
}
}
}
/*

View File

@ -40,10 +40,10 @@
using google::LogMessage;
// logging levels
#define EVENT 2 // logs important events which don't occur every block
#define FLOW 3 // logs the function calls of block processing functions
#define SAMP_SYNC 4 // about 1 log entry per sample -> high output
#define LMORE 5 //
#define EVENT 2 // logs important events which don't occur every block
#define FLOW 3 // logs the function calls of block processing functions
#define SAMP_SYNC 4 // about 1 log entry per sample -> high output
#define LMORE 5 //
@ -74,18 +74,18 @@ gps_l2_m_telemetry_decoder_cc::gps_l2_m_telemetry_decoder_cc(
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
LOG(INFO) << "GPS L2C M TELEMETRY PROCESSING: satellite " << d_satellite;
d_fs_in = fs_in;
d_block_size = GPS_L2_SAMPLES_PER_SYMBOL * GPS_L2_SYMBOLS_PER_BIT * GPS_L2_CNAV_DATA_PAGE_BITS*2; // two CNAV frames
d_decimation_output_factor=0;
d_block_size = GPS_L2_SAMPLES_PER_SYMBOL * GPS_L2_SYMBOLS_PER_BIT * GPS_L2_CNAV_DATA_PAGE_BITS * 2; // two CNAV frames
d_decimation_output_factor = 0;
//set_output_multiple (1);
d_average_count=0;
d_flag_invert_buffer_symbols=false;
d_flag_invert_input_symbols=false;
d_channel=0;
d_iono_queue=0;
d_ephemeris_queue=0;
d_flag_valid_word=false;
d_TOW_at_current_symbol=0;
d_TOW_at_Preamble=0;
d_average_count = 0;
d_flag_invert_buffer_symbols = false;
d_flag_invert_input_symbols = false;
d_channel = 0;
d_iono_queue = 0;
d_ephemeris_queue = 0;
d_flag_valid_word = false;
d_TOW_at_current_symbol = 0;
d_TOW_at_Preamble = 0;
//set_history(d_samples_per_bit*8); // At least a history of 8 bits are needed to correlate with the preamble
}
@ -97,7 +97,6 @@ gps_l2_m_telemetry_decoder_cc::~gps_l2_m_telemetry_decoder_cc()
}
void gps_l2_m_telemetry_decoder_cc::forecast (int noutput_items, gr_vector_int &ninput_items_required)
{
unsigned ninputs = ninput_items_required.size ();
@ -106,140 +105,118 @@ void gps_l2_m_telemetry_decoder_cc::forecast (int noutput_items, gr_vector_int &
//LOG(INFO) << "forecast(): " << "noutput_items=" << noutput_items << "\tninput_items_required ninput_items_required.size()=" << ninput_items_required.size();
}
void gps_l2_m_telemetry_decoder_cc::set_decimation(int decimation)
{
d_decimation_output_factor = decimation;
}
int gps_l2_m_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{
//LOG(INFO) << "general_work(): " << "noutput_items=" << noutput_items << "\toutput_items real size=" << output_items.size() << "\tninput_items size=" << ninput_items.size() << "\tinput_items real size=" << input_items.size() << "\tninput_items[0]=" << ninput_items[0];
// get pointers on in- and output gnss-synchro objects
const Gnss_Synchro *in = (const Gnss_Synchro *) input_items[0]; // input
Gnss_Synchro *out = (Gnss_Synchro *) output_items[0]; // output
Gnss_Synchro *out = (Gnss_Synchro *) output_items[0]; // output
// store the time stamp of the first sample in the processed sample block
double sample_stamp = in[0].Tracking_timestamp_secs;
bool flag_new_cnav_frame=false;
int last_frame_preamble_start=0;
bool flag_new_cnav_frame = false;
int last_frame_preamble_start = 0;
// copy correlation samples into samples vector
//for (int i = 0; i < noutput_items; i++)
/// {
// check if channel is in tracking state
// {
d_sample_buf.push_back(in[0].Prompt_I);
// }
// }
d_sample_buf.push_back(in[0].Prompt_I);
consume_each(1); //one by one
// decode only if enough samples in buffer
if(d_sample_buf.size() >= d_block_size)
{
if (in[0].Flag_valid_tracking==false) // check if the tracking is locked
{
//LOG(INFO)<< "Discarting channel "<<d_channel<<" tracking not ready!"<<std::endl;
d_flag_valid_word=false;
}else{
d_flag_invert_buffer_symbols=d_flag_invert_input_symbols;
while (true)
{
if (in[0].Flag_valid_tracking == false) // check if the tracking is locked
{
//LOG(INFO)<< "Discarting channel "<<d_channel<<" tracking not ready!"<<std::endl;
d_flag_valid_word = false;
}
else
{
d_flag_invert_buffer_symbols = d_flag_invert_input_symbols;
while (true)
{
if (d_flag_invert_buffer_symbols == true)
{
for (std::vector<double>::iterator symbol_it = d_sample_buf.begin(); symbol_it != d_sample_buf.end(); symbol_it++)
{
*symbol_it = -(*symbol_it);
}
//LOG(INFO)<<"Inverting buffer symbols";
}
// align symbols in pairs
// and obtain the bits by decoding the symbols (viterbi decoder)
// they can be already aligned or shifted by one position
std::vector<int> bits;
bool symbol_alignment = d_symbol_aligner_and_decoder.get_bits(d_sample_buf, bits);
if (d_flag_invert_buffer_symbols==true)
{
// for (int m=0;m<d_sample_buf.size();m++)
// {
// d_sample_buf.at(m)=-d_sample_buf.at(m);
// }
for (std::vector<double>::iterator symbol_it = d_sample_buf.begin(); symbol_it != d_sample_buf.end(); symbol_it++)
{
*symbol_it = -(*symbol_it);
}
//LOG(INFO)<<"Inverting buffer symbols";
}
//std::stringstream ss;
//for (std::vector<int>::const_iterator bit_it = bits.begin(); bit_it < bits.end(); ++bit_it)
// {
// ss << *bit_it;
// }
// LOG(INFO) << "get_bits=" << ss.str() << std::endl;
//debug
// std::stringstream ss2;
// for (std::vector<double>::const_iterator symbol_it = d_sample_buf.begin(); symbol_it < d_sample_buf.end(); ++symbol_it)
// {
//
// ss2<<*symbol_it<<",";
// if(*symbol_it>=0)
// {
// ss2<<'1';
// }else{
// ss2<<'0';
// }
// }
//LOG(INFO)<<"get_symbols="<<ss2.str();
// search for preambles
// and extract the corresponding message candidates
std::vector<msg_candiate_int_t> msg_candidates;
d_frame_detector.get_frame_candidates(bits, msg_candidates);
// align symbols in pairs
// and obtain the bits by decoding the symbols (viterbi decoder)
// they can be already aligned or shifted by one position
std::vector<int> bits;
bool symbol_alignment = d_symbol_aligner_and_decoder.get_bits(d_sample_buf, bits);
std::stringstream ss;
for (std::vector<int>::const_iterator bit_it = bits.begin(); bit_it < bits.end(); ++bit_it)
{
ss << *bit_it;
}
// LOG(INFO)<<"get_bits="<<ss.str()<<std::endl;
// search for preambles
// and extract the corresponding message candidates
std::vector<msg_candiate_int_t> msg_candidates;
d_frame_detector.get_frame_candidates(bits, msg_candidates);
// verify checksum
// and return the valid messages
std::vector<msg_candiate_int_t> valid_msgs;
d_crc_verifier.get_valid_frames(msg_candidates, valid_msgs);
if (valid_msgs.size()==0)
{
if (d_flag_invert_buffer_symbols==d_flag_invert_input_symbols)
{
d_flag_invert_buffer_symbols=not d_flag_invert_buffer_symbols;
}else{//already tested the symbol inversion but CRC still fail
LOG(INFO)<<"Discarting this buffer, no CNAV frames detected CH "<<this->d_channel;
break;
}
}else{ //at least one frame has good CRC, keep the invert sign for the next frames
d_flag_invert_input_symbols=d_flag_invert_buffer_symbols;
std::vector<int> tmp_msg;
std::string msg;
LOG(INFO)<<valid_msgs.size()<<" GOOD L2C CNAV FRAME DETECTED! CH "<<this->d_channel;
for (unsigned int i=0;i<valid_msgs.size();i++)
{
tmp_msg =valid_msgs.at(i).second;
d_CNAV_Message.decode_page(tmp_msg);
std::cout<<"Valid CNAV frame with relative preamble start at "<<valid_msgs.at(i).first<<std::endl;
flag_new_cnav_frame=true;
d_flag_valid_word=true;
last_frame_preamble_start=valid_msgs.at(i).first;
// 4. Push the new navigation data to the queues
if (d_CNAV_Message.have_new_ephemeris() == true)
{
// get ephemeris object for this SV
Gps_CNAV_Ephemeris ephemeris = d_CNAV_Message.get_ephemeris();//notice that the read operation will clear the valid flag
std::cout<<"New GPS CNAV Ephemeris received for SV "<<ephemeris.i_satellite_PRN<<std::endl;
d_ephemeris_queue->push(ephemeris);
}
if (d_CNAV_Message.have_new_iono() == true)
{
Gps_CNAV_Iono iono= d_CNAV_Message.get_iono(); //notice that the read operation will clear the valid flag
std::cout<<"New GPS CNAV IONO model received for SV "<<d_satellite.get_PRN()<<std::endl;
d_iono_queue->push(iono);
}
}
break;
}
}
}
// verify checksum
// and return the valid messages
std::vector<msg_candiate_int_t> valid_msgs;
d_crc_verifier.get_valid_frames(msg_candidates, valid_msgs);
if (valid_msgs.size() == 0)
{
if (d_flag_invert_buffer_symbols == d_flag_invert_input_symbols)
{
d_flag_invert_buffer_symbols = not d_flag_invert_buffer_symbols;
}
else
{//already tested the symbol inversion but CRC still fail
LOG(INFO) << "Discarting this buffer, no CNAV frames detected CH " << this->d_channel;
break;
}
}
else
{ //at least one frame has good CRC, keep the invert sign for the next frames
d_flag_invert_input_symbols = d_flag_invert_buffer_symbols;
std::vector<int> tmp_msg;
std::string msg;
LOG(INFO) << valid_msgs.size() << " GOOD L2C CNAV FRAME DETECTED! CH " <<this->d_channel;
for (unsigned int i = 0;i < valid_msgs.size(); i++)
{
tmp_msg = valid_msgs.at(i).second;
d_CNAV_Message.decode_page(tmp_msg);
std::cout << "Valid CNAV frame with relative preamble start at " << valid_msgs.at(i).first << std::endl;
flag_new_cnav_frame = true;
d_flag_valid_word = true;
last_frame_preamble_start = valid_msgs.at(i).first;
// 4. Push the new navigation data to the queues
if (d_CNAV_Message.have_new_ephemeris() == true)
{
// get ephemeris object for this SV
Gps_CNAV_Ephemeris ephemeris = d_CNAV_Message.get_ephemeris(); //notice that the read operation will clear the valid flag
std::cout << "New GPS CNAV Ephemeris received for SV " << ephemeris.i_satellite_PRN << std::endl;
d_ephemeris_queue->push(ephemeris);
}
if (d_CNAV_Message.have_new_iono() == true)
{
Gps_CNAV_Iono iono = d_CNAV_Message.get_iono(); //notice that the read operation will clear the valid flag
std::cout << "New GPS CNAV IONO model received for SV " << d_satellite.get_PRN() << std::endl;
d_iono_queue->push(iono);
}
}
break;
}
}
}
// clear all processed samples in the input buffer
d_sample_buf.clear();
}
@ -250,36 +227,39 @@ int gps_l2_m_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_in
//1. Copy the current tracking output
current_synchro_data = in[0];
if (d_flag_valid_word==true)
{
double Prn_timestamp_at_preamble_ms=0;
//2. Add the telemetry decoder information
if (flag_new_cnav_frame==true)
{
//update TOW at the preamble instant
Prn_timestamp_at_preamble_ms = (in[0].Tracking_timestamp_secs * 1000.0)-(d_block_size-last_frame_preamble_start)*GPS_L2_M_PERIOD;
d_TOW_at_Preamble = d_CNAV_Message.d_TOW - GPS_L2_CNAV_DATA_PAGE_DURATION_S;
d_TOW_at_current_symbol = d_TOW_at_Preamble + (d_block_size-last_frame_preamble_start)*GPS_L2_M_PERIOD;
current_synchro_data.d_TOW = d_TOW_at_Preamble;
current_synchro_data.d_TOW_at_current_symbol = d_TOW_at_current_symbol;
current_synchro_data.d_TOW_hybrid_at_current_symbol = current_synchro_data.d_TOW_at_current_symbol;
current_synchro_data.Flag_preamble = false;
current_synchro_data.Prn_timestamp_ms = in[0].Tracking_timestamp_secs * 1000.0;
current_synchro_data.Prn_timestamp_at_preamble_ms = Prn_timestamp_at_preamble_ms;
}else{
d_TOW_at_current_symbol = d_TOW_at_Preamble + (d_block_size-last_frame_preamble_start)*GPS_L2_M_PERIOD;
current_synchro_data.d_TOW = d_TOW_at_Preamble;
current_synchro_data.d_TOW_at_current_symbol = d_TOW_at_current_symbol;
current_synchro_data.d_TOW_hybrid_at_current_symbol = current_synchro_data.d_TOW_at_current_symbol;
current_synchro_data.Flag_preamble = false;
current_synchro_data.Prn_timestamp_ms = in[0].Tracking_timestamp_secs * 1000.0;
current_synchro_data.Prn_timestamp_at_preamble_ms = Prn_timestamp_at_preamble_ms;
}
current_synchro_data.Flag_valid_word = true;
}else{
current_synchro_data.Flag_valid_word = false;
}
if (d_flag_valid_word == true)
{
double Prn_timestamp_at_preamble_ms = 0;
//2. Add the telemetry decoder information
if (flag_new_cnav_frame == true)
{
//update TOW at the preamble instant
Prn_timestamp_at_preamble_ms = (in[0].Tracking_timestamp_secs * 1000.0) - (d_block_size - last_frame_preamble_start) * GPS_L2_M_PERIOD;
d_TOW_at_Preamble = d_CNAV_Message.d_TOW - GPS_L2_CNAV_DATA_PAGE_DURATION_S;
d_TOW_at_current_symbol = d_TOW_at_Preamble + (d_block_size - last_frame_preamble_start) * GPS_L2_M_PERIOD;
current_synchro_data.d_TOW = d_TOW_at_Preamble;
current_synchro_data.d_TOW_at_current_symbol = d_TOW_at_current_symbol;
current_synchro_data.d_TOW_hybrid_at_current_symbol = current_synchro_data.d_TOW_at_current_symbol;
current_synchro_data.Flag_preamble = false;
current_synchro_data.Prn_timestamp_ms = in[0].Tracking_timestamp_secs * 1000.0;
current_synchro_data.Prn_timestamp_at_preamble_ms = Prn_timestamp_at_preamble_ms;
}
else
{
d_TOW_at_current_symbol = d_TOW_at_Preamble + (d_block_size - last_frame_preamble_start) * GPS_L2_M_PERIOD;
current_synchro_data.d_TOW = d_TOW_at_Preamble;
current_synchro_data.d_TOW_at_current_symbol = d_TOW_at_current_symbol;
current_synchro_data.d_TOW_hybrid_at_current_symbol = current_synchro_data.d_TOW_at_current_symbol;
current_synchro_data.Flag_preamble = false;
current_synchro_data.Prn_timestamp_ms = in[0].Tracking_timestamp_secs * 1000.0;
current_synchro_data.Prn_timestamp_at_preamble_ms = Prn_timestamp_at_preamble_ms;
}
current_synchro_data.Flag_valid_word = true;
}
else
{
current_synchro_data.Flag_valid_word = false;
}
d_average_count++;
if (d_average_count == d_decimation_output_factor)
@ -346,8 +326,8 @@ void gps_l2_m_telemetry_decoder_cc::symbol_aligner_and_decoder::reset()
bool gps_l2_m_telemetry_decoder_cc::symbol_aligner_and_decoder::get_bits(const std::vector<double> symbols, std::vector<int> &bits)
{
const int traceback_depth = 5*d_KK;
int nbits_requested = symbols.size()/GPS_L2_SYMBOLS_PER_BIT;
const int traceback_depth = 5 * d_KK;
int nbits_requested = symbols.size() / GPS_L2_SYMBOLS_PER_BIT;
int nbits_decoded;
// fill two vectors with the two possible symbol alignments
std::vector<double> symbols_vd1(symbols); // aligned symbol vector -> copy input symbol vector
@ -448,12 +428,12 @@ void gps_l2_m_telemetry_decoder_cc::frame_detector::get_frame_candidates(const s
// ### helper class for checking the CRC of the message candidates ###
void gps_l2_m_telemetry_decoder_cc::crc_verifier::reset()
{
}
void gps_l2_m_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::vector<msg_candiate_int_t> msg_candidates, std::vector<msg_candiate_int_t> &valid_msgs)
{
std::vector <unsigned char> tmp_msg;
@ -481,11 +461,9 @@ void gps_l2_m_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::ve
void gps_l2_m_telemetry_decoder_cc::crc_verifier::zerropad_back_and_convert_to_bytes(const std::vector<int> msg_candidate, std::vector<unsigned char> &bytes)
{
std::stringstream ss;
//std::stringstream ss;
const size_t bits_per_byte = 8;
unsigned char byte = 0;
//LOG(INFO) << "zerropad_back_and_convert_to_bytes():" << byte;
@ -494,7 +472,7 @@ void gps_l2_m_telemetry_decoder_cc::crc_verifier::zerropad_back_and_convert_to_b
int idx_bit = candidate_bit_it - msg_candidate.begin();
int bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte);
byte |= (unsigned char)(*candidate_bit_it) << bit_pos_in_current_byte;
ss << *candidate_bit_it;
// ss << *candidate_bit_it;
if (idx_bit % bits_per_byte == bits_per_byte - 1)
{
bytes.push_back(byte);
@ -512,7 +490,7 @@ void gps_l2_m_telemetry_decoder_cc::crc_verifier::zerropad_back_and_convert_to_b
void gps_l2_m_telemetry_decoder_cc::crc_verifier::zerropad_front_and_convert_to_bytes(const std::vector<int> msg_candidate, std::vector<unsigned char> &bytes)
{
std::stringstream ss;
//std::stringstream ss;
const size_t bits_per_byte = 8;
unsigned char byte = 0;
int idx_bit = 6; // insert 6 zeros at the front to fit the 250bits into a multiple of bytes
@ -521,7 +499,7 @@ void gps_l2_m_telemetry_decoder_cc::crc_verifier::zerropad_front_and_convert_to_
{
int bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte);
byte |= (unsigned char)(*candidate_bit_it) << bit_pos_in_current_byte;
ss << *candidate_bit_it;
// ss << *candidate_bit_it;
if (idx_bit % bits_per_byte == bits_per_byte - 1)
{
bytes.push_back(byte);
@ -536,12 +514,14 @@ void gps_l2_m_telemetry_decoder_cc::crc_verifier::zerropad_front_and_convert_to_
// << std::setfill(' ') << std::resetiosflags(std::ios::hex);
}
void gps_l2_m_telemetry_decoder_cc::set_iono_queue(concurrent_queue<Gps_CNAV_Iono> *iono_queue)
{
d_iono_queue=iono_queue;
d_iono_queue = iono_queue;
}
void gps_l2_m_telemetry_decoder_cc::set_ephemeris_queue(concurrent_queue<Gps_CNAV_Ephemeris> *ephemeris_queue)
{
d_ephemeris_queue=ephemeris_queue;
d_ephemeris_queue = ephemeris_queue;
}

View File

@ -68,9 +68,11 @@ public:
void set_channel(int channel); //!< Set receiver's channel
// queues to communicate broadcasted CNAV data to other blocks of GNSS-SDR
void set_iono_queue(concurrent_queue<Gps_CNAV_Iono> *iono_queue); //!< Set iono queue
void set_ephemeris_queue(concurrent_queue<Gps_CNAV_Ephemeris> *ephemeris_queue); //!< Set ephemeris queue
void set_iono_queue(concurrent_queue<Gps_CNAV_Iono> *iono_queue); //!< Set iono queue
void set_ephemeris_queue(concurrent_queue<Gps_CNAV_Ephemeris> *ephemeris_queue); //!< Set ephemeris queue
void set_decimation(int decimation);
/*!
* \brief This is where all signal processing takes place
*/
@ -158,7 +160,6 @@ private:
void zerropad_back_and_convert_to_bytes(const std::vector<int> msg_candidate, std::vector<unsigned char> &bytes);
} d_crc_verifier;
Gps_CNAV_Navigation_Message d_CNAV_Message;
};

View File

@ -36,7 +36,7 @@
#include <complex>
#include <vector>
#include <utility> // std::pair
#include <gnss_satellite.h>
#include "gnss_satellite.h"
#include "MATH_CONSTANTS.h"
// Physical constants
@ -61,35 +61,35 @@ const int GPS_L2_L_CODE_LENGTH_CHIPS = 767250; //!< GPS L2 L code length [chip
const double GPS_L2_L_PERIOD = 1.5; //!< GPS L2 L code period [seconds]
const int32_t GPS_L2C_M_INIT_REG[115] =
{0742417664, 0756014035,0002747144,0066265724, // 1:4
0601403471, 0703232733, 0124510070,0617316361, // 5:8
0047541621, 0733031046, 0713512145, 0024437606,
0021264003, 0230655351, 0001314400, 0222021506,
0540264026, 0205521705, 0064022144, 0120161274,
0044023533, 0724744327, 0045743577, 0741201660,
0700274134, 0010247261, 0713433445, 0737324162,
0311627434, 0710452007, 0722462133, 0050172213,
0500653703, 0755077436, 0136717361, 0756675453,
0435506112, 0771353753, 0226107701, 0022025110,
0402466344, 0752566114, 0702011164, 0041216771,
0047457275, 0266333164, 0713167356, 0060546335,
0355173035, 0617201036, 0157465571, 0767360553,
0023127030, 0431343777, 0747317317, 0045706125,
0002744276, 0060036467, 0217744147, 0603340174,//57:60
0326616775, 0063240065, 0111460621, //61:63
0604055104, 0157065232, 0013305707, 0603552017,//159:162
0230461355, 0603653437, 0652346475, 0743107103,
0401521277, 0167335110, 0014013575, 0362051132,
0617753265, 0216363634, 0755561123, 0365304033,
0625025543, 0054420334, 0415473671, 0662364360,
0373446602, 0417564100, 0000526452, 0226631300,
0113752074, 0706134401, 0041352546, 0664630154,
0276524255, 0714720530, 0714051771, 0044526647,
0207164322, 0262120161, 0204244652, 0202133131,
0714351204, 0657127260, 0130567507, 0670517677,
0607275514, 0045413633, 0212645405, 0613700455,
0706202440, 0705056276, 0020373522, 0746013617,
0132720621, 0434015513, 0566721727, 0140633660};
{0742417664, 0756014035,0002747144,0066265724, // 1:4
0601403471, 0703232733, 0124510070, 0617316361, // 5:8
0047541621, 0733031046, 0713512145, 0024437606,
0021264003, 0230655351, 0001314400, 0222021506,
0540264026, 0205521705, 0064022144, 0120161274,
0044023533, 0724744327, 0045743577, 0741201660,
0700274134, 0010247261, 0713433445, 0737324162,
0311627434, 0710452007, 0722462133, 0050172213,
0500653703, 0755077436, 0136717361, 0756675453,
0435506112, 0771353753, 0226107701, 0022025110,
0402466344, 0752566114, 0702011164, 0041216771,
0047457275, 0266333164, 0713167356, 0060546335,
0355173035, 0617201036, 0157465571, 0767360553,
0023127030, 0431343777, 0747317317, 0045706125,
0002744276, 0060036467, 0217744147, 0603340174,//57:60
0326616775, 0063240065, 0111460621, //61:63
0604055104, 0157065232, 0013305707, 0603552017,//159:162
0230461355, 0603653437, 0652346475, 0743107103,
0401521277, 0167335110, 0014013575, 0362051132,
0617753265, 0216363634, 0755561123, 0365304033,
0625025543, 0054420334, 0415473671, 0662364360,
0373446602, 0417564100, 0000526452, 0226631300,
0113752074, 0706134401, 0041352546, 0664630154,
0276524255, 0714720530, 0714051771, 0044526647,
0207164322, 0262120161, 0204244652, 0202133131,
0714351204, 0657127260, 0130567507, 0670517677,
0607275514, 0045413633, 0212645405, 0613700455,
0706202440, 0705056276, 0020373522, 0746013617,
0132720621, 0434015513, 0566721727, 0140633660};
// CNAV GPS NAVIGATION MESSAGE STRUCTURE
// NAVIGATION MESSAGE FIELDS POSITIONS (from IS-GPS-200E Appendix III)
@ -99,7 +99,7 @@ const int32_t GPS_L2C_M_INIT_REG[115] =
const int GPS_L2_CNAV_DATA_PAGE_BITS = 300; //!< GPS L2 CNAV page length, including preamble and CRC [bits]
const int GPS_L2_SYMBOLS_PER_BIT = 2;
const int GPS_L2_SAMPLES_PER_SYMBOL = 1;
const int GPS_L2_CNAV_DATA_PAGE_DURATION_S=12;
const int GPS_L2_CNAV_DATA_PAGE_DURATION_S = 12;
const int GPS_L2_CNAV_DATA_PAGE_BITS_EXTENDED_BYTES = 304; //!< GPS L2 CNAV page length, including preamble and CRC [bits]
// common to all messages

View File

@ -36,8 +36,8 @@ Gps_CNAV_Ephemeris::Gps_CNAV_Ephemeris()
{
i_satellite_PRN = 0;
d_Toe1=-1;
d_Toe2=-1;
d_Toe1 = -1;
d_Toe2 = -1;
d_TOW = 0;
d_Crs = 0;

View File

@ -38,9 +38,9 @@
void Gps_CNAV_Navigation_Message::reset()
{
b_flag_ephemeris_1=false;
b_flag_ephemeris_2=false;
b_flag_iono_valid=false;
b_flag_ephemeris_1 = false;
b_flag_ephemeris_2 = false;
b_flag_iono_valid = false;
// satellite positions
d_satpos_X = 0;
@ -57,6 +57,7 @@ void Gps_CNAV_Navigation_Message::reset()
d_satvel_Z = 0;
}
Gps_CNAV_Navigation_Message::Gps_CNAV_Navigation_Message()
{
reset();
@ -68,6 +69,7 @@ Gps_CNAV_Navigation_Message::Gps_CNAV_Navigation_Message()
b_flag_iono_valid = false;
}
void Gps_CNAV_Navigation_Message::print_gps_word_bytes(unsigned int GPS_word)
{
std::cout << " Word =";
@ -75,6 +77,7 @@ void Gps_CNAV_Navigation_Message::print_gps_word_bytes(unsigned int GPS_word)
std::cout << std::endl;
}
bool Gps_CNAV_Navigation_Message::read_navigation_bool(std::bitset<GPS_L2_CNAV_DATA_PAGE_BITS> bits, const std::vector<std::pair<int,int>> parameter)
{
bool value;
@ -172,31 +175,21 @@ signed long int Gps_CNAV_Navigation_Message::read_navigation_signed(std::bitset<
void Gps_CNAV_Navigation_Message::decode_page(std::vector<int> data)
{
std::bitset<GPS_L2_CNAV_DATA_PAGE_BITS> data_bits;
std::bitset<GPS_L2_CNAV_DATA_PAGE_BITS> data_bits;
try {
try
{
for(int i = 0; i < GPS_L2_CNAV_DATA_PAGE_BITS; i++)
{
data_bits[i] = static_cast<uint8_t>(data[GPS_L2_CNAV_DATA_PAGE_BITS - i - 1]);
}
// std::cout<<"data length="<<data.size()<<std::endl;
// std::cout<<"data=";
// for (int p=0;p<data.size();p++)
// {
// std::cout<<data.at(p)<<",";
// }
// std::cout<<std::endl;
for(int i=0;i<GPS_L2_CNAV_DATA_PAGE_BITS;i++)
{
//std::cout<<"byte["<<i<<"]="<<(int)data[i]<<std::endl;
data_bits[i]=(uint8_t)data[GPS_L2_CNAV_DATA_PAGE_BITS-i-1];
}
//std::cout<<"bitset="<<data_bits<<std::endl;
// try {
// data_bits=std::bitset<GPS_L2_CNAV_DATA_PAGE_BITS>(data);
} catch(std::exception &e) {
std::cout << "Exception converting to bitset " << e.what() << std::endl;
return;
}
}
catch(std::exception &e)
{
std::cout << "Exception converting to bitset " << e.what() << std::endl;
return;
}
int PRN;
int page_type;
@ -205,138 +198,143 @@ void Gps_CNAV_Navigation_Message::decode_page(std::vector<int> data)
// common to all messages
PRN = static_cast<int>(read_navigation_unsigned(data_bits, CNAV_PRN));
ephemeris_record.i_satellite_PRN=PRN;
ephemeris_record.i_satellite_PRN = PRN;
d_TOW = static_cast<double>(read_navigation_unsigned(data_bits, CNAV_TOW));
d_TOW=d_TOW*CNAV_TOW_LSB;
ephemeris_record.d_TOW=d_TOW;
d_TOW = d_TOW * CNAV_TOW_LSB;
ephemeris_record.d_TOW = d_TOW;
alert_flag= static_cast<bool>(read_navigation_bool(data_bits, CNAV_ALERT_FLAG));
ephemeris_record.b_alert_flag=alert_flag;
alert_flag = static_cast<bool>(read_navigation_bool(data_bits, CNAV_ALERT_FLAG));
ephemeris_record.b_alert_flag = alert_flag;
page_type = static_cast<int>(read_navigation_unsigned(data_bits, CNAV_MSG_TYPE));
std::cout<<"PRN= "<<PRN<<" TOW="<<d_TOW<<" alert_flag= "<<alert_flag<<" page_type= "<<page_type<<std::endl;
std::cout << "PRN=" << PRN << " TOW=" << d_TOW << " alert_flag=" << alert_flag << " page_type= " << page_type << std::endl;
switch(page_type)
{
case 10: // Ephemeris 1/2
ephemeris_record.i_GPS_week=static_cast<int>(read_navigation_unsigned(data_bits, CNAV_WN));
ephemeris_record.i_signal_health=static_cast<int>(read_navigation_unsigned(data_bits, CNAV_HEALTH));
ephemeris_record.d_Top=static_cast<double>(read_navigation_unsigned(data_bits, CNAV_TOP1));
ephemeris_record.d_Top=ephemeris_record.d_Top*CNAV_TOP1_LSB;
ephemeris_record.d_URA0=static_cast<double>(read_navigation_signed(data_bits, CNAV_URA));
ephemeris_record.d_Toe1=static_cast<double>(read_navigation_unsigned(data_bits, CNAV_TOE1));
ephemeris_record.d_Toe1=ephemeris_record.d_Toe1*CNAV_TOE1_LSB;
ephemeris_record.d_DELTA_A=static_cast<double>(read_navigation_signed(data_bits, CNAV_DELTA_A));
ephemeris_record.d_DELTA_A=ephemeris_record.d_DELTA_A*CNAV_DELTA_A_LSB;
ephemeris_record.d_A_DOT=static_cast<double>(read_navigation_signed(data_bits, CNAV_A_DOT));
ephemeris_record.d_A_DOT=ephemeris_record.d_A_DOT*CNAV_A_DOT_LSB;
ephemeris_record.d_Delta_n=static_cast<double>(read_navigation_signed(data_bits, CNAV_DELTA_N0));
ephemeris_record.d_Delta_n=ephemeris_record.d_Delta_n*CNAV_DELTA_N0_LSB;
ephemeris_record.d_DELTA_DOT_N=static_cast<double>(read_navigation_signed(data_bits, CNAV_DELTA_N0_DOT));
ephemeris_record.d_DELTA_DOT_N=ephemeris_record.d_DELTA_DOT_N*CNAV_DELTA_N0_DOT_LSB;
ephemeris_record.d_M_0=static_cast<double>(read_navigation_signed(data_bits, CNAV_M0));
ephemeris_record.d_M_0=ephemeris_record.d_M_0*CNAV_M0_LSB;
ephemeris_record.d_e_eccentricity=static_cast<double>(read_navigation_signed(data_bits, CNAV_E_ECCENTRICITY));
ephemeris_record.d_e_eccentricity=ephemeris_record.d_e_eccentricity*CNAV_E_ECCENTRICITY_LSB;
ephemeris_record.d_OMEGA=static_cast<double>(read_navigation_signed(data_bits, CNAV_OMEGA));
ephemeris_record.d_OMEGA=ephemeris_record.d_OMEGA*CNAV_OMEGA_LSB;
ephemeris_record.i_GPS_week = static_cast<int>(read_navigation_unsigned(data_bits, CNAV_WN));
ephemeris_record.i_signal_health = static_cast<int>(read_navigation_unsigned(data_bits, CNAV_HEALTH));
ephemeris_record.d_Top = static_cast<double>(read_navigation_unsigned(data_bits, CNAV_TOP1));
ephemeris_record.d_Top = ephemeris_record.d_Top * CNAV_TOP1_LSB;
ephemeris_record.d_URA0 = static_cast<double>(read_navigation_signed(data_bits, CNAV_URA));
ephemeris_record.d_Toe1 = static_cast<double>(read_navigation_unsigned(data_bits, CNAV_TOE1));
ephemeris_record.d_Toe1 = ephemeris_record.d_Toe1 * CNAV_TOE1_LSB;
ephemeris_record.d_DELTA_A = static_cast<double>(read_navigation_signed(data_bits, CNAV_DELTA_A));
ephemeris_record.d_DELTA_A = ephemeris_record.d_DELTA_A * CNAV_DELTA_A_LSB;
ephemeris_record.d_A_DOT = static_cast<double>(read_navigation_signed(data_bits, CNAV_A_DOT));
ephemeris_record.d_A_DOT = ephemeris_record.d_A_DOT * CNAV_A_DOT_LSB;
ephemeris_record.d_Delta_n = static_cast<double>(read_navigation_signed(data_bits, CNAV_DELTA_N0));
ephemeris_record.d_Delta_n = ephemeris_record.d_Delta_n * CNAV_DELTA_N0_LSB;
ephemeris_record.d_DELTA_DOT_N = static_cast<double>(read_navigation_signed(data_bits, CNAV_DELTA_N0_DOT));
ephemeris_record.d_DELTA_DOT_N = ephemeris_record.d_DELTA_DOT_N * CNAV_DELTA_N0_DOT_LSB;
ephemeris_record.d_M_0 = static_cast<double>(read_navigation_signed(data_bits, CNAV_M0));
ephemeris_record.d_M_0 = ephemeris_record.d_M_0 * CNAV_M0_LSB;
ephemeris_record.d_e_eccentricity = static_cast<double>(read_navigation_signed(data_bits, CNAV_E_ECCENTRICITY));
ephemeris_record.d_e_eccentricity = ephemeris_record.d_e_eccentricity * CNAV_E_ECCENTRICITY_LSB;
ephemeris_record.d_OMEGA = static_cast<double>(read_navigation_signed(data_bits, CNAV_OMEGA));
ephemeris_record.d_OMEGA = ephemeris_record.d_OMEGA * CNAV_OMEGA_LSB;
ephemeris_record.b_integrity_status_flag=static_cast<bool>(read_navigation_bool(data_bits, CNAV_INTEGRITY_FLAG));
ephemeris_record.b_l2c_phasing_flag=static_cast<bool>(read_navigation_bool(data_bits, CNAV_L2_PHASING_FLAG));
ephemeris_record.b_integrity_status_flag = static_cast<bool>(read_navigation_bool(data_bits, CNAV_INTEGRITY_FLAG));
ephemeris_record.b_l2c_phasing_flag = static_cast<bool>(read_navigation_bool(data_bits, CNAV_L2_PHASING_FLAG));
b_flag_ephemeris_1=true;
b_flag_ephemeris_1 = true;
break;
case 11: // Ephemeris 2/2
ephemeris_record.d_Toe2=static_cast<double>(read_navigation_unsigned(data_bits, CNAV_TOE2));
ephemeris_record.d_Toe2=ephemeris_record.d_Toe2*CNAV_TOE2_LSB;
ephemeris_record.d_OMEGA0=static_cast<double>(read_navigation_signed(data_bits, CNAV_OMEGA0));
ephemeris_record.d_OMEGA0=ephemeris_record.d_OMEGA0*CNAV_OMEGA0_LSB;
ephemeris_record.d_DELTA_OMEGA_DOT=static_cast<double>(read_navigation_signed(data_bits, CNAV_DELTA_OMEGA_DOT));
ephemeris_record.d_DELTA_OMEGA_DOT=ephemeris_record.d_DELTA_OMEGA_DOT*CNAV_DELTA_OMEGA_DOT_LSB;
ephemeris_record.d_i_0=static_cast<double>(read_navigation_signed(data_bits, CNAV_I0));
ephemeris_record.d_i_0=ephemeris_record.d_i_0*CNAV_I0_LSB;
ephemeris_record.d_IDOT=static_cast<double>(read_navigation_signed(data_bits, CNAV_I0_DOT));
ephemeris_record.d_IDOT=ephemeris_record.d_IDOT*CNAV_I0_DOT_LSB;
ephemeris_record.d_Cis=static_cast<double>(read_navigation_signed(data_bits, CNAV_CIS));
ephemeris_record.d_Cis=ephemeris_record.d_Cis*CNAV_CIS_LSB;
ephemeris_record.d_Cic=static_cast<double>(read_navigation_signed(data_bits, CNAV_CIC));
ephemeris_record.d_Cic=ephemeris_record.d_Cic*CNAV_CIC_LSB;
ephemeris_record.d_Crs=static_cast<double>(read_navigation_signed(data_bits, CNAV_CRS));
ephemeris_record.d_Crs=ephemeris_record.d_Crs*CNAV_CRS_LSB;
ephemeris_record.d_Crc=static_cast<double>(read_navigation_signed(data_bits, CNAV_CRC));
ephemeris_record.d_Cic=ephemeris_record.d_Cic*CNAV_CRC_LSB;
ephemeris_record.d_Cus=static_cast<double>(read_navigation_signed(data_bits, CNAV_CUS));
ephemeris_record.d_Cus=ephemeris_record.d_Cus*CNAV_CUS_LSB;
ephemeris_record.d_Cuc=static_cast<double>(read_navigation_signed(data_bits, CNAV_CUC));
ephemeris_record.d_Cuc=ephemeris_record.d_Cuc*CNAV_CUS_LSB;
b_flag_ephemeris_2=true;
ephemeris_record.d_Toe2 = static_cast<double>(read_navigation_unsigned(data_bits, CNAV_TOE2));
ephemeris_record.d_Toe2 = ephemeris_record.d_Toe2 * CNAV_TOE2_LSB;
ephemeris_record.d_OMEGA0 = static_cast<double>(read_navigation_signed(data_bits, CNAV_OMEGA0));
ephemeris_record.d_OMEGA0 = ephemeris_record.d_OMEGA0 * CNAV_OMEGA0_LSB;
ephemeris_record.d_DELTA_OMEGA_DOT = static_cast<double>(read_navigation_signed(data_bits, CNAV_DELTA_OMEGA_DOT));
ephemeris_record.d_DELTA_OMEGA_DOT = ephemeris_record.d_DELTA_OMEGA_DOT * CNAV_DELTA_OMEGA_DOT_LSB;
ephemeris_record.d_i_0 = static_cast<double>(read_navigation_signed(data_bits, CNAV_I0));
ephemeris_record.d_i_0 = ephemeris_record.d_i_0 * CNAV_I0_LSB;
ephemeris_record.d_IDOT = static_cast<double>(read_navigation_signed(data_bits, CNAV_I0_DOT));
ephemeris_record.d_IDOT = ephemeris_record.d_IDOT * CNAV_I0_DOT_LSB;
ephemeris_record.d_Cis = static_cast<double>(read_navigation_signed(data_bits, CNAV_CIS));
ephemeris_record.d_Cis = ephemeris_record.d_Cis * CNAV_CIS_LSB;
ephemeris_record.d_Cic = static_cast<double>(read_navigation_signed(data_bits, CNAV_CIC));
ephemeris_record.d_Cic = ephemeris_record.d_Cic * CNAV_CIC_LSB;
ephemeris_record.d_Crs = static_cast<double>(read_navigation_signed(data_bits, CNAV_CRS));
ephemeris_record.d_Crs = ephemeris_record.d_Crs * CNAV_CRS_LSB;
ephemeris_record.d_Crc = static_cast<double>(read_navigation_signed(data_bits, CNAV_CRC));
ephemeris_record.d_Cic = ephemeris_record.d_Cic * CNAV_CRC_LSB;
ephemeris_record.d_Cus = static_cast<double>(read_navigation_signed(data_bits, CNAV_CUS));
ephemeris_record.d_Cus = ephemeris_record.d_Cus * CNAV_CUS_LSB;
ephemeris_record.d_Cuc = static_cast<double>(read_navigation_signed(data_bits, CNAV_CUC));
ephemeris_record.d_Cuc = ephemeris_record.d_Cuc * CNAV_CUS_LSB;
b_flag_ephemeris_2 = true;
break;
case 30: // (CLOCK, IONO, GRUP DELAY)
//clock
ephemeris_record.d_Toc=static_cast<double>(read_navigation_unsigned(data_bits, CNAV_TOC));
ephemeris_record.d_Toc=ephemeris_record.d_Toc*CNAV_TOC_LSB;
ephemeris_record.d_Toc = static_cast<double>(read_navigation_unsigned(data_bits, CNAV_TOC));
ephemeris_record.d_Toc = ephemeris_record.d_Toc * CNAV_TOC_LSB;
ephemeris_record.d_URA0 = static_cast<double>(read_navigation_signed(data_bits, CNAV_URA_NED0));
ephemeris_record.d_URA1 = static_cast<double>(read_navigation_unsigned(data_bits, CNAV_URA_NED1));
ephemeris_record.d_URA2 = static_cast<double>(read_navigation_unsigned(data_bits, CNAV_URA_NED2));
ephemeris_record.d_A_f0=static_cast<double>(read_navigation_signed(data_bits, CNAV_AF0));
ephemeris_record.d_A_f0=ephemeris_record.d_A_f0*CNAV_AF0_LSB;
ephemeris_record.d_A_f1=static_cast<double>(read_navigation_signed(data_bits, CNAV_AF1));
ephemeris_record.d_A_f1=ephemeris_record.d_A_f1*CNAV_AF1_LSB;
ephemeris_record.d_A_f2=static_cast<double>(read_navigation_signed(data_bits, CNAV_AF2));
ephemeris_record.d_A_f2=ephemeris_record.d_A_f2*CNAV_AF2_LSB;
ephemeris_record.d_A_f0 = static_cast<double>(read_navigation_signed(data_bits, CNAV_AF0));
ephemeris_record.d_A_f0 = ephemeris_record.d_A_f0 * CNAV_AF0_LSB;
ephemeris_record.d_A_f1 = static_cast<double>(read_navigation_signed(data_bits, CNAV_AF1));
ephemeris_record.d_A_f1 = ephemeris_record.d_A_f1 * CNAV_AF1_LSB;
ephemeris_record.d_A_f2 = static_cast<double>(read_navigation_signed(data_bits, CNAV_AF2));
ephemeris_record.d_A_f2 = ephemeris_record.d_A_f2 * CNAV_AF2_LSB;
//group delays
ephemeris_record.d_TGD=static_cast<double>(read_navigation_signed(data_bits, CNAV_TGD));
ephemeris_record.d_TGD=ephemeris_record.d_TGD*CNAV_TGD_LSB;
ephemeris_record.d_ISCL1=static_cast<double>(read_navigation_signed(data_bits, CNAV_ISCL1));
ephemeris_record.d_ISCL1=ephemeris_record.d_ISCL1*CNAV_ISCL1_LSB;
ephemeris_record.d_ISCL2=static_cast<double>(read_navigation_signed(data_bits, CNAV_ISCL2));
ephemeris_record.d_ISCL2=ephemeris_record.d_ISCL2*CNAV_ISCL2_LSB;
ephemeris_record.d_ISCL5I=static_cast<double>(read_navigation_signed(data_bits, CNAV_ISCL5I));
ephemeris_record.d_ISCL5I=ephemeris_record.d_ISCL5I*CNAV_ISCL5I_LSB;
ephemeris_record.d_ISCL5Q=static_cast<double>(read_navigation_signed(data_bits, CNAV_ISCL5Q));
ephemeris_record.d_ISCL5Q=ephemeris_record.d_ISCL5Q*CNAV_ISCL5Q_LSB;
ephemeris_record.d_TGD = static_cast<double>(read_navigation_signed(data_bits, CNAV_TGD));
ephemeris_record.d_TGD = ephemeris_record.d_TGD * CNAV_TGD_LSB;
ephemeris_record.d_ISCL1 = static_cast<double>(read_navigation_signed(data_bits, CNAV_ISCL1));
ephemeris_record.d_ISCL1 = ephemeris_record.d_ISCL1 * CNAV_ISCL1_LSB;
ephemeris_record.d_ISCL2 = static_cast<double>(read_navigation_signed(data_bits, CNAV_ISCL2));
ephemeris_record.d_ISCL2 = ephemeris_record.d_ISCL2 * CNAV_ISCL2_LSB;
ephemeris_record.d_ISCL5I = static_cast<double>(read_navigation_signed(data_bits, CNAV_ISCL5I));
ephemeris_record.d_ISCL5I = ephemeris_record.d_ISCL5I * CNAV_ISCL5I_LSB;
ephemeris_record.d_ISCL5Q = static_cast<double>(read_navigation_signed(data_bits, CNAV_ISCL5Q));
ephemeris_record.d_ISCL5Q = ephemeris_record.d_ISCL5Q * CNAV_ISCL5Q_LSB;
//iono
iono_record.d_alpha0=static_cast<double>(read_navigation_signed(data_bits, CNAV_ALPHA0));
iono_record.d_alpha0=iono_record.d_alpha0*CNAV_ALPHA0_LSB;
iono_record.d_alpha1=static_cast<double>(read_navigation_signed(data_bits, CNAV_ALPHA1));
iono_record.d_alpha1=iono_record.d_alpha1*CNAV_ALPHA1_LSB;
iono_record.d_alpha2=static_cast<double>(read_navigation_signed(data_bits, CNAV_ALPHA2));
iono_record.d_alpha2=iono_record.d_alpha2*CNAV_ALPHA2_LSB;
iono_record.d_alpha3=static_cast<double>(read_navigation_signed(data_bits, CNAV_ALPHA3));
iono_record.d_alpha3=iono_record.d_alpha3*CNAV_ALPHA3_LSB;
iono_record.d_beta0=static_cast<double>(read_navigation_signed(data_bits, CNAV_BETA0));
iono_record.d_beta0=iono_record.d_beta0*CNAV_BETA0_LSB;
iono_record.d_beta1=static_cast<double>(read_navigation_signed(data_bits, CNAV_BETA1));
iono_record.d_beta1=iono_record.d_beta1*CNAV_BETA1_LSB;
iono_record.d_beta2=static_cast<double>(read_navigation_signed(data_bits, CNAV_BETA2));
iono_record.d_beta2=iono_record.d_beta2*CNAV_BETA2_LSB;
iono_record.d_beta3=static_cast<double>(read_navigation_signed(data_bits, CNAV_BETA3));
iono_record.d_beta3=iono_record.d_beta3*CNAV_BETA3_LSB;
b_flag_iono_valid=true;
iono_record.d_alpha0 = static_cast<double>(read_navigation_signed(data_bits, CNAV_ALPHA0));
iono_record.d_alpha0 = iono_record.d_alpha0 * CNAV_ALPHA0_LSB;
iono_record.d_alpha1 = static_cast<double>(read_navigation_signed(data_bits, CNAV_ALPHA1));
iono_record.d_alpha1 = iono_record.d_alpha1 * CNAV_ALPHA1_LSB;
iono_record.d_alpha2 = static_cast<double>(read_navigation_signed(data_bits, CNAV_ALPHA2));
iono_record.d_alpha2 = iono_record.d_alpha2 * CNAV_ALPHA2_LSB;
iono_record.d_alpha3 = static_cast<double>(read_navigation_signed(data_bits, CNAV_ALPHA3));
iono_record.d_alpha3 = iono_record.d_alpha3 * CNAV_ALPHA3_LSB;
iono_record.d_beta0 = static_cast<double>(read_navigation_signed(data_bits, CNAV_BETA0));
iono_record.d_beta0 = iono_record.d_beta0 * CNAV_BETA0_LSB;
iono_record.d_beta1 = static_cast<double>(read_navigation_signed(data_bits, CNAV_BETA1));
iono_record.d_beta1 = iono_record.d_beta1 * CNAV_BETA1_LSB;
iono_record.d_beta2 = static_cast<double>(read_navigation_signed(data_bits, CNAV_BETA2));
iono_record.d_beta2 = iono_record.d_beta2 * CNAV_BETA2_LSB;
iono_record.d_beta3 = static_cast<double>(read_navigation_signed(data_bits, CNAV_BETA3));
iono_record.d_beta3 = iono_record.d_beta3 * CNAV_BETA3_LSB;
b_flag_iono_valid = true;
break;
default:
break;
}
}
bool Gps_CNAV_Navigation_Message::have_new_ephemeris() //Check if we have a new ephemeris stored in the galileo navigation class
{
if (b_flag_ephemeris_1==true and b_flag_ephemeris_2==true)
{
if (ephemeris_record.d_Toe1 == ephemeris_record.d_Toe2)
if (b_flag_ephemeris_1 == true and b_flag_ephemeris_2 == true)
{
if (ephemeris_record.d_Toe1 == ephemeris_record.d_Toe2)
{
//if all ephemeris pages have the same TOE, then they belong to the same block
// std::cout << "Ephemeris (1, 2) have been received and belong to the same batch" << std::endl;
b_flag_ephemeris_1 = false;// clear the flag
b_flag_ephemeris_2 = false;// clear the flag
return true;
}
else
{
return false;
}
}
else
{
//if all ephemeris pages have the same TOE, then they belong to the same block
// std::cout << "Ephemeris (1, 2) have been received and belong to the same batch" << std::endl;
b_flag_ephemeris_1 = false;// clear the flag
b_flag_ephemeris_2 = false;// clear the flag
return true;
}else{
return false;
}
}else
{
return false;
}
}
}
@ -348,16 +346,18 @@ Gps_CNAV_Ephemeris Gps_CNAV_Navigation_Message::get_ephemeris()
bool Gps_CNAV_Navigation_Message::have_new_iono() //Check if we have a new iono data stored in the galileo navigation class
{
if (b_flag_iono_valid==true)
{
b_flag_iono_valid = false;// clear the flag
return true;
}else
{
return false;
}
if (b_flag_iono_valid == true)
{
b_flag_iono_valid = false;// clear the flag
return true;
}
else
{
return false;
}
}
Gps_CNAV_Iono Gps_CNAV_Navigation_Message::get_iono()
{
return iono_record;

View File

@ -1,6 +1,6 @@
/*!
* \file Gps_CNAV_Navigation_Message.h
* \brief Interface of a GPS NAV Data message decoder
* \file gps_cnav_navigation_message.h
* \brief Interface of a GPS CNAV Data message decoder
* \author Javier Arribas, 2015. jarribas(at)cttc.es
*
* -------------------------------------------------------------------------
@ -32,16 +32,16 @@
#ifndef GNSS_SDR_Gps_CNAV_Navigation_Message_H_
#define GNSS_SDR_Gps_CNAV_Navigation_Message_H_
#include "stdint.h"
#include <algorithm>
#include <bitset>
#include "stdint.h"
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <utility>
#include "boost/assign.hpp"
#include <boost/assign.hpp>
#include "GPS_L2C.h"
#include "gps_cnav_ephemeris.h"
#include "gps_cnav_iono.h"
@ -69,10 +69,9 @@ private:
Gps_CNAV_Utc_Model utc_model_record;
public:
double d_TOW;
bool b_flag_ephemeris_1;
bool b_flag_ephemeris_2;
bool b_flag_ephemeris_1;
bool b_flag_ephemeris_2;
bool b_flag_iono_valid; //!< If set, it indicates that the ionospheric parameters are filled (page 18 has arrived and decoded)
std::map<int,std::string> satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus