From eadabaf900a006d8d4fd2ce070e9bd768ae1eca6 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 21 Jun 2018 12:21:35 +0200 Subject: [PATCH] Add more info in acquisition dumps --- .../gnuradio_blocks/pcps_acquisition.cc | 45 ++++++++++++++++--- .../gnuradio_blocks/pcps_acquisition.h | 1 + .../gps_l1_ca_pcps_acquisition_test.cc | 2 +- .../libs/acquisition_dump_reader.cc | 14 +++++- 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index 7f81d68e3..f16855790 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -60,6 +60,7 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu acq_parameters = conf_; d_sample_counter = 0; // SAMPLE COUNTER d_active = false; + d_positive_acq = 0; d_state = 0; d_old_freq = 0; d_well_count = 0; @@ -376,6 +377,36 @@ void pcps_acquisition::dump_results(int effective_fft_size) Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); + matvar = Mat_VarCreate("d_positive_acq", MAT_C_INT32, MAT_T_INT32, 1, dims, &d_positive_acq, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + float aux = static_cast(d_gnss_synchro->Acq_doppler_hz); + matvar = Mat_VarCreate("acq_doppler_hz", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &aux, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + aux = static_cast(d_gnss_synchro->Acq_delay_samples); + matvar = Mat_VarCreate("acq_delay_samples", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &aux, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("test_statistic", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &d_test_statistics, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("threshold", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &d_threshold, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("input_power", MAT_C_SINGLE, MAT_T_SINGLE, 1, dims, &d_input_power, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("sample_counter", MAT_C_UINT64, MAT_T_UINT64, 1, dims, &d_sample_counter, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + Mat_Close(matfp); } } @@ -554,11 +585,6 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count) } } } - // Record results to file if required - if (acq_parameters.dump) - { - pcps_acquisition::dump_results(effective_fft_size); - } lk.lock(); if (!acq_parameters.bit_transition_flag) { @@ -572,6 +598,7 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count) send_positive_acquisition(); d_step_two = false; d_state = 0; // Positive acquisition + d_positive_acq = 1; } else { @@ -583,6 +610,7 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count) { send_positive_acquisition(); d_state = 0; // Positive acquisition + d_positive_acq = 1; } } else if (d_well_count == acq_parameters.max_dwells) @@ -605,6 +633,7 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count) send_positive_acquisition(); d_step_two = false; d_state = 0; // Positive acquisition + d_positive_acq = 1; } else { @@ -616,6 +645,7 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count) { send_positive_acquisition(); d_state = 0; // Positive acquisition + d_positive_acq = 1; } } else @@ -626,6 +656,11 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count) } } d_worker_active = false; + // Record results to file if required + if (acq_parameters.dump) + { + pcps_acquisition::dump_results(effective_fft_size); + } } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h index f0fd69e7f..d34888fd8 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h @@ -100,6 +100,7 @@ private: bool d_worker_active; bool d_cshort; bool d_step_two; + int d_positive_acq; float d_threshold; float d_mag; float d_input_power; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc index 05b374e06..d2c5a96c9 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc @@ -175,7 +175,7 @@ void GpsL1CaPcpsAcquisitionTest::plot_grid() unsigned int sat = static_cast(gnss_synchro.PRN); unsigned int samples_per_code = static_cast(round(4000000 / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); // !! - acquisition_dump_reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code); + acquisition_dump_reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code, 1); if (!acq_dump.read_binary_acq()) std::cout << "Error reading files" << std::endl; diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc index 5fcd1308b..6302f2e63 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc @@ -73,17 +73,27 @@ bool acquisition_dump_reader::read_binary_acq() Mat_Close(matfile); return false; } + matvar_t* var2_ = Mat_VarRead(matfile, "doppler_max"); + d_doppler_max = *static_cast(var2_->data); + Mat_VarFree(var2_); + + var2_ = Mat_VarRead(matfile, "doppler_step"); + d_doppler_step = *static_cast(var2_->data); + Mat_VarFree(var2_); + + var2_ = Mat_VarRead(matfile, "input_power"); + float normalization_factor = *static_cast(var2_->data); + Mat_VarFree(var2_); std::vector >::iterator it1; std::vector::iterator it2; float* aux = static_cast(var_->data); int k = 0; - float normalization_factor = std::pow(d_samples_per_code, 2); for (it1 = mag.begin(); it1 != mag.end(); it1++) { for (it2 = it1->begin(); it2 != it1->end(); it2++) { - *it2 = static_cast(std::sqrt(aux[k])) / normalization_factor; + *it2 = static_cast(aux[k]) / normalization_factor; k++; } }