From c428fe21c53db022241dd84d477b1c2cd55e23ec Mon Sep 17 00:00:00 2001 From: Luis Esteve Date: Fri, 2 Mar 2012 17:17:51 +0000 Subject: [PATCH] Changes in flowgraph and channel_fsm. Now the number of channels in acquisition mode can be controlled from the config file. git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@179 64b25241-fba3-4117-9849-534c7e92360d --- conf/gnss-sdr.conf | 16 +- src/algorithms/channel/adapters/channel.cc | 13 +- src/algorithms/channel/adapters/channel.h | 2 +- .../channel/libs/gps_l1_ca_channel_fsm.cc | 265 ++++++++---------- .../channel/libs/gps_l1_ca_channel_fsm.h | 3 +- .../gps_l1_ca_dll_fll_pll_tracking_cc.cc | 11 +- .../gps_l1_ca_dll_pll_tracking_cc.cc | 11 +- src/core/interfaces/channel_interface.h | 1 + src/core/receiver/gnss_flowgraph.cc | 118 +++++++- src/core/receiver/gnss_flowgraph.h | 5 +- 10 files changed, 263 insertions(+), 182 deletions(-) diff --git a/conf/gnss-sdr.conf b/conf/gnss-sdr.conf index 63e04abaf..e99ffa22b 100644 --- a/conf/gnss-sdr.conf +++ b/conf/gnss-sdr.conf @@ -3,7 +3,7 @@ ;######### GLOBAL OPTIONS ################## ;internal_fs_hz: Internal signal sampling frequency after the signal conditioning stage [Hz]. -GNSS-SDR.internal_fs_hz=2046000 +GNSS-SDR.internal_fs_hz=2048000 ;######### CONTROL_THREAD CONFIG ############ ControlThread.wait_for_flowgraph=false @@ -14,6 +14,7 @@ SignalSource.implementation=File_Signal_Source ;#filename: path to file with the captured GNSS signal samples to be processed SignalSource.filename=/home/luis/Project/signals/cap2/agilent_cap2.dat +;SignalSource.filename=/media/My Passport/spirent scenario 2/data/sc2_d8.dat ;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version. SignalSource.item_type=gr_complex @@ -124,12 +125,13 @@ Resampler.item_type=gr_complex Resampler.sample_freq_in=4000000 ;#sample_freq_out: the desired sample frequency of the output signal -Resampler.sample_freq_out=2046000 +Resampler.sample_freq_out=2048000 ;######### CHANNELS GLOBAL CONFIG ############ ;#count: Number of available satellite channels. Channels.count=4 +Channels.in_acquisition=2 ;######### CHANNEL 0 CONFIG ############ ;#system: GPS, GLONASS, GALILEO, SBAS or COMPASS @@ -242,7 +244,7 @@ Acquisition.sampled_ms=1 Acquisition0.implementation=GPS_L1_CA_PCPS_Acquisition ;#threshold: Acquisition threshold -Acquisition0.threshold=70 +Acquisition0.threshold=50 ;#doppler_max: Maximum expected Doppler shift [Hz] Acquisition0.doppler_max=10000 @@ -256,28 +258,28 @@ Acquisition0.doppler_step=250 ;######### ACQUISITION CH 1 CONFIG ############ Acquisition1.implementation=GPS_L1_CA_PCPS_Acquisition -Acquisition1.threshold=70 +Acquisition1.threshold=50 Acquisition1.doppler_max=10000 Acquisition1.doppler_step=250 ;Acquisition1.repeat_satellite=true ;######### ACQUISITION CH 2 CONFIG ############ Acquisition2.implementation=GPS_L1_CA_PCPS_Acquisition -Acquisition2.threshold=70 +Acquisition2.threshold=50 Acquisition2.doppler_max=10000 Acquisition2.doppler_step=250 ;Acquisition2.repeat_satellite=true ;######### ACQUISITION CH 3 CONFIG ############ Acquisition3.implementation=GPS_L1_CA_PCPS_Acquisition -Acquisition3.threshold=70 +Acquisition3.threshold=50 Acquisition3.doppler_max=10000 Acquisition3.doppler_step=250 ;Acquisition3.repeat_satellite=true ;######### ACQUISITION CH 4 CONFIG ############ Acquisition4.implementation=GPS_L1_CA_PCPS_Acquisition -Acquisition4.threshold=70 +Acquisition4.threshold=50 Acquisition4.doppler_max=10000 Acquisition4.doppler_step=250 ;Acquisition4.repeat_satellite=true diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index 82ffdfc89..9a97e3d9d 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -200,7 +200,6 @@ void Channel::start() void Channel::run() { - start_acquisition(); while (!stop_) { channel_internal_queue_.wait_and_pop(message_); @@ -208,6 +207,9 @@ void Channel::run() } } +void Channel::standby(){ + channel_fsm_.Event_gps_failed_tracking_standby(); +} /* * Set stop_ to true and blocks the calling thread until @@ -215,8 +217,8 @@ void Channel::run() */ void Channel::stop() { - stop_ = true; channel_internal_queue_.push(0); //message to stop channel + stop_ = true; /* When the boost::thread object that represents a thread of execution * is destroyed the thread becomes detached. Once a thread is detached, @@ -262,12 +264,7 @@ void Channel::process_channel_messages() } break; - case 3: - LOG_AT_LEVEL(INFO) << "Channel " << channel_ - << " TRACKING FAILED satellite " << gnss_synchro_.System << " "<< gnss_synchro_.PRN - << ", reacquisition."; - channel_fsm_.Event_gps_failed_tracking(); - break; + default: LOG_AT_LEVEL(WARNING) << "Default case, invalid message."; diff --git a/src/algorithms/channel/adapters/channel.h b/src/algorithms/channel/adapters/channel.h index 4f8b855b4..0461f16cb 100644 --- a/src/algorithms/channel/adapters/channel.h +++ b/src/algorithms/channel/adapters/channel.h @@ -91,7 +91,7 @@ public: void start_acquisition(); void set_signal(Gnss_Signal gnss_signal_); void start(); - + void standby(); /*! * \brief Set stop_ to true and blocks the calling thread until * the thread of the constructor has completed diff --git a/src/algorithms/channel/libs/gps_l1_ca_channel_fsm.cc b/src/algorithms/channel/libs/gps_l1_ca_channel_fsm.cc index 21cb225cf..a75eeea1b 100644 --- a/src/algorithms/channel/libs/gps_l1_ca_channel_fsm.cc +++ b/src/algorithms/channel/libs/gps_l1_ca_channel_fsm.cc @@ -34,185 +34,164 @@ #include #include -struct Ev_gps_channel_start_acquisition: sc::event -{}; - -struct Ev_gps_channel_valid_acquisition: sc::event -{}; - -struct Ev_gps_channel_failed_acquisition_repeat: sc::event -{}; - -struct Ev_gps_channel_failed_acquisition_no_repeat: sc::event -{}; - -struct Ev_gps_channel_failed_tracking: sc::event -{}; - -struct gps_channel_idle_fsm_S0: public sc::state -{ -public: - // sc::transition(event, next state) - typedef sc::transition reactions; - gps_channel_idle_fsm_S0(my_context ctx) : - my_base(ctx) - { - //std::cout << "Enter Channel_Idle_S0 " << std::endl; - } +struct Ev_gps_channel_start_acquisition: sc::event< + Ev_gps_channel_start_acquisition> { }; - -struct gps_channel_acquiring_fsm_S1: public sc::state -{ -public: - typedef mpl::list, - sc::transition, - sc::transition >reactions; - - gps_channel_acquiring_fsm_S1(my_context ctx) : my_base(ctx) - { - //std::cout << "Enter Channel_Acq_S1 " << std::endl; - context ().start_acquisition(); - } +struct Ev_gps_channel_valid_acquisition: sc::event< + Ev_gps_channel_valid_acquisition> { }; - - -struct gps_channel_tracking_fsm_S2: public sc::state -{ -public: - typedef sc::transition reactions; - - gps_channel_tracking_fsm_S2(my_context ctx) : my_base(ctx) - { - //std::cout << "Enter Channel_tracking_S2 " << std::endl; - context ().start_tracking(); - } +struct Ev_gps_channel_failed_acquisition_repeat: sc::event< + Ev_gps_channel_failed_acquisition_repeat> { }; - - -struct gps_channel_waiting_fsm_S3: public sc::state -{ -public: - typedef sc::transition reactions; - - gps_channel_waiting_fsm_S3(my_context ctx) : my_base(ctx) - { - //std::cout << "Enter Channel_waiting_S3 " << std::endl; - context ().request_satellite(); - } +struct Ev_gps_channel_failed_acquisition_no_repeat: sc::event< + Ev_gps_channel_failed_acquisition_no_repeat> { }; +struct Ev_gps_channel_failed_tracking_standby: sc::event { +}; +//struct Ev_gps_channel_failed_tracking_reacq: sc::event { +//}; -GpsL1CaChannelFsm::GpsL1CaChannelFsm() -{ - initiate(); //start the FSM +struct gps_channel_idle_fsm_S0: public sc::state { +public: + // sc::transition(event, next state) + typedef sc::transition reactions; + gps_channel_idle_fsm_S0(my_context ctx) : + my_base(ctx) { + //std::cout << "Enter Channel_Idle_S0 " << std::endl; + } +}; + +struct gps_channel_acquiring_fsm_S1: public sc::state< + gps_channel_acquiring_fsm_S1, GpsL1CaChannelFsm> { +public: + typedef mpl::list, sc::transition< + Ev_gps_channel_failed_acquisition_repeat, + gps_channel_acquiring_fsm_S1>, sc::transition< + Ev_gps_channel_valid_acquisition, gps_channel_tracking_fsm_S2> > + reactions; + + gps_channel_acquiring_fsm_S1(my_context ctx) : + my_base(ctx) { + //std::cout << "Enter Channel_Acq_S1 " << std::endl; + context ().start_acquisition(); + } +}; + +struct gps_channel_tracking_fsm_S2: public sc::state< + gps_channel_tracking_fsm_S2, GpsL1CaChannelFsm> { +public: + typedef mpl::list, sc::transition> reactions; + + gps_channel_tracking_fsm_S2(my_context ctx) : + my_base(ctx) { + //std::cout << "Enter Channel_tracking_S2 " << std::endl; + context ().start_tracking(); + } + +}; + +struct gps_channel_waiting_fsm_S3: public sc::state { +public: + typedef sc::transition reactions; + + gps_channel_waiting_fsm_S3(my_context ctx) : + my_base(ctx) { + //std::cout << "Enter Channel_waiting_S3 " << std::endl; + context ().request_satellite(); + } + ~gps_channel_waiting_fsm_S3(){} +}; + +GpsL1CaChannelFsm::GpsL1CaChannelFsm() { + initiate(); //start the FSM } - - - -GpsL1CaChannelFsm::GpsL1CaChannelFsm(AcquisitionInterface *acquisition) : acq_(acquisition) -{ - initiate(); //start the FSM +GpsL1CaChannelFsm::GpsL1CaChannelFsm(AcquisitionInterface *acquisition) : + acq_(acquisition) { + initiate(); //start the FSM } - - - -void GpsL1CaChannelFsm::Event_gps_start_acquisition() -{ - this->process_event(Ev_gps_channel_start_acquisition()); +void GpsL1CaChannelFsm::Event_gps_start_acquisition() { + this->process_event(Ev_gps_channel_start_acquisition()); } - - -void GpsL1CaChannelFsm::Event_gps_valid_acquisition() -{ - this->process_event(Ev_gps_channel_valid_acquisition()); +void GpsL1CaChannelFsm::Event_gps_valid_acquisition() { + this->process_event(Ev_gps_channel_valid_acquisition()); } -void GpsL1CaChannelFsm::Event_gps_failed_acquisition_repeat() -{ - this->process_event(Ev_gps_channel_failed_acquisition_repeat()); +void GpsL1CaChannelFsm::Event_gps_failed_acquisition_repeat() { + this->process_event(Ev_gps_channel_failed_acquisition_repeat()); } - - -void GpsL1CaChannelFsm::Event_gps_failed_acquisition_no_repeat() -{ - this->process_event(Ev_gps_channel_failed_acquisition_no_repeat()); +void GpsL1CaChannelFsm::Event_gps_failed_acquisition_no_repeat() { + this->process_event(Ev_gps_channel_failed_acquisition_no_repeat()); } - - -void GpsL1CaChannelFsm::Event_gps_failed_tracking() -{ - this->process_event(Ev_gps_channel_failed_tracking()); +void GpsL1CaChannelFsm::Event_gps_failed_tracking_standby() { + this->process_event(Ev_gps_channel_failed_tracking_standby()); } +//void GpsL1CaChannelFsm::Event_gps_failed_tracking_reacq() { +// this->process_event(Ev_gps_channel_failed_tracking_reacq()); +//} -void GpsL1CaChannelFsm::set_acquisition(AcquisitionInterface *acquisition) -{ - acq_ = acquisition; +void GpsL1CaChannelFsm::set_acquisition(AcquisitionInterface *acquisition) { + acq_ = acquisition; } - - -void GpsL1CaChannelFsm::set_tracking(TrackingInterface *tracking) -{ - trk_ = tracking; +void GpsL1CaChannelFsm::set_tracking(TrackingInterface *tracking) { + trk_ = tracking; } - - -void GpsL1CaChannelFsm::set_queue(gr_msg_queue_sptr queue) -{ - queue_ = queue; +void GpsL1CaChannelFsm::set_queue(gr_msg_queue_sptr queue) { + queue_ = queue; } - - -void GpsL1CaChannelFsm::set_channel(unsigned int channel) -{ - channel_ = channel; +void GpsL1CaChannelFsm::set_channel(unsigned int channel) { + channel_ = channel; } - - -void GpsL1CaChannelFsm::start_acquisition() -{ - acq_->reset(); +void GpsL1CaChannelFsm::start_acquisition() { + acq_->reset(); } - - -void GpsL1CaChannelFsm::start_tracking() -{ - //LOG_AT_LEVEL(INFO) << "Channel " << channel_ - //<< " passing prn code phase " << acq_->prn_code_phase(); - //LOG_AT_LEVEL(INFO) << "Channel " << channel_ - //<< " passing doppler freq shift " << acq_->doppler_freq_shift(); - //LOG_AT_LEVEL(INFO) << "Channel " << channel_ - //<< " passing acquisition sample stamp " - //<< acq_->get_sample_stamp(); - //trk_->set_prn_code_phase(acq_->prn_code_phase()); - //trk_->set_doppler_freq_shift(acq_->doppler_freq_shift()); - //trk_->set_acq_sample_stamp(acq_->get_sample_stamp()); - trk_->start_tracking(); +void GpsL1CaChannelFsm::start_tracking() { + //LOG_AT_LEVEL(INFO) << "Channel " << channel_ + //<< " passing prn code phase " << acq_->prn_code_phase(); + //LOG_AT_LEVEL(INFO) << "Channel " << channel_ + //<< " passing doppler freq shift " << acq_->doppler_freq_shift(); + //LOG_AT_LEVEL(INFO) << "Channel " << channel_ + //<< " passing acquisition sample stamp " + //<< acq_->get_sample_stamp(); + //trk_->set_prn_code_phase(acq_->prn_code_phase()); + //trk_->set_doppler_freq_shift(acq_->doppler_freq_shift()); + //trk_->set_acq_sample_stamp(acq_->get_sample_stamp()); + trk_->start_tracking(); + ControlMessageFactory* cmf = new ControlMessageFactory(); + if (queue_ != gr_msg_queue_sptr()) { + queue_->handle(cmf->GetQueueMessage(channel_, 1)); + } + delete cmf; } - - -void GpsL1CaChannelFsm::request_satellite() -{ - ControlMessageFactory* cmf = new ControlMessageFactory(); - if (queue_ != gr_msg_queue_sptr()) - { - queue_->handle(cmf->GetQueueMessage(channel_, 0)); - } - delete cmf; +void GpsL1CaChannelFsm::request_satellite() { + ControlMessageFactory* cmf = new ControlMessageFactory(); + if (queue_ != gr_msg_queue_sptr()) { + queue_->handle(cmf->GetQueueMessage(channel_, 0)); + } + delete cmf; } diff --git a/src/algorithms/channel/libs/gps_l1_ca_channel_fsm.h b/src/algorithms/channel/libs/gps_l1_ca_channel_fsm.h index 26fe70e6d..0cee07d67 100644 --- a/src/algorithms/channel/libs/gps_l1_ca_channel_fsm.h +++ b/src/algorithms/channel/libs/gps_l1_ca_channel_fsm.h @@ -80,7 +80,8 @@ public: void Event_gps_valid_acquisition(); void Event_gps_failed_acquisition_repeat(); void Event_gps_failed_acquisition_no_repeat(); - void Event_gps_failed_tracking(); + //void Event_gps_failed_tracking_reacq(); + void Event_gps_failed_tracking_standby(); private: AcquisitionInterface *acq_; diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_fll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_fll_pll_tracking_cc.cc index 3db7355c9..4327b6b36 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_fll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_fll_pll_tracking_cc.cc @@ -463,7 +463,7 @@ int Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::general_work (int noutput_items, gr_vecto d_CN0_SNV_dB_Hz = gps_l1_ca_CN0_SNV(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in); d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES); // ###### TRACKING UNLOCK NOTIFICATION ##### - int tracking_message; + //int tracking_message; if (d_carrier_lock_test < d_carrier_lock_threshold or d_carrier_lock_test > MINIMUM_VALID_CN0) { d_carrier_lock_fail_counter++; @@ -475,8 +475,13 @@ int Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::general_work (int noutput_items, gr_vecto if (d_carrier_lock_fail_counter > MAXIMUM_LOCK_FAIL_COUNTER) { std::cout << "Channel " << d_channel << " loss of lock!" << std::endl; - tracking_message = 3; //loss of lock - d_channel_internal_queue->push(tracking_message); +// tracking_message = 3; //loss of lock +// d_channel_internal_queue->push(tracking_message); + ControlMessageFactory* cmf = new ControlMessageFactory(); + if (d_queue != gr_msg_queue_sptr()) { + d_queue->handle(cmf->GetQueueMessage(d_channel, 2)); + } + delete cmf; d_carrier_lock_fail_counter = 0; d_enable_tracking = false; // TODO: check if disabling tracking is consistent with the channel state machine } diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc index de4e1e332..437920f99 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc @@ -471,7 +471,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_in d_CN0_SNV_dB_Hz = gps_l1_ca_CN0_SNV(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in); d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES); // ###### TRACKING UNLOCK NOTIFICATION ##### - int tracking_message; + //int tracking_message; if (d_carrier_lock_test < d_carrier_lock_threshold or d_carrier_lock_test > MINIMUM_VALID_CN0) { d_carrier_lock_fail_counter++; @@ -483,8 +483,13 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_in if (d_carrier_lock_fail_counter > MAXIMUM_LOCK_FAIL_COUNTER) { std::cout << "Channel " << d_channel << " loss of lock!" << std::endl ; - tracking_message = 3; //loss of lock - d_channel_internal_queue->push(tracking_message); + //tracking_message = 3; //loss of lock + //d_channel_internal_queue->push(tracking_message); + ControlMessageFactory* cmf = new ControlMessageFactory(); + if (d_queue != gr_msg_queue_sptr()) { + d_queue->handle(cmf->GetQueueMessage(d_channel, 2)); + } + delete cmf; d_carrier_lock_fail_counter = 0; d_enable_tracking = false; // TODO: check if disabling tracking is consistent with the channel state machine diff --git a/src/core/interfaces/channel_interface.h b/src/core/interfaces/channel_interface.h index 00673b510..eb2a12b63 100644 --- a/src/core/interfaces/channel_interface.h +++ b/src/core/interfaces/channel_interface.h @@ -57,6 +57,7 @@ public: virtual void start_acquisition() = 0; virtual void set_signal(Gnss_Signal) = 0; virtual void start() = 0; + virtual void standby() = 0; virtual void stop() = 0; }; diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 3acfe0dd9..717ee5523 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -2,7 +2,7 @@ * \file gnss_flowgraph.cc * \brief Implementation of a GNSS receiver flowgraph * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com - * Luis Esteve, 2011. luis(at)epsilon-formacion.com + * Luis Esteve, 2012. luis(at)epsilon-formacion.com * * Detailed description of the file here if needed. * @@ -90,8 +90,15 @@ void GNSSFlowgraph::start() { void GNSSFlowgraph::stop() { for (unsigned int i = 0; i < channels_count_; i++) { +// if(channels_state_[i]==2) channel(i)-> channel(i)->stop(); } + + for (unsigned int i = 0; i < channels_count_; i++) { + std::cout << "Channel " << i << " in state " << channels_state_[i] + << std::endl; + } + DLOG(INFO) << "Threads finished. Return to main program."; top_block_->stop(); running_ = false; @@ -216,10 +223,15 @@ void GNSSFlowgraph::connect() { << available_GNSS_signals_.front() << std::endl; available_GNSS_signals_.pop_front(); channel(i)->start(); - //channel(i)->start_acquisition(); + if (channels_state_[i] == 1) { + channel(i)->start_acquisition(); + DLOG(INFO) << "Channel " << i + << " connected to observables and ready for acquisition"; + } else { + DLOG(INFO) << "Channel " << i + << " connected to observables in standby mode"; + } - DLOG(INFO) << "Channel " << i - << " connected to observables and ready for acquisition"; } /* * Connect the observables output of each channel to the PVT block @@ -285,6 +297,50 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) { break; // TODO: Tracking messages + case 1: + + LOG_AT_LEVEL(INFO) << "Channel " << who << " ACQ SUCCESS satellite " + << channel(who)->get_signal().get_satellite(); + + 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++) { + std::cout << "Channel " << i << " in state " << channels_state_[i] + << std::endl; + } + break; + + case 2: + + LOG_AT_LEVEL(INFO) << "Channel " << who << " TRK FAILED satellite " + << channel(who)->get_signal().get_satellite(); + + 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++) { + std::cout << "Channel " << i << " in state " << channels_state_[i] + << std::endl; + } + break; + default: break; } @@ -360,6 +416,8 @@ void GNSSFlowgraph::init() { set_signals_list(); + set_channels_state(); + applied_actions_ = 0; DLOG(INFO) << "Blocks instantiated. " << channels_count_ << " channels."; @@ -376,7 +434,7 @@ void GNSSFlowgraph::set_signals_list() { * See http://igscb.jpl.nasa.gov/igscb/data/format/rinex301.pdf (page 5) */ std::set 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, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 32 }; std::set::iterator available_gps_prn_iter; @@ -390,12 +448,12 @@ void GNSSFlowgraph::set_signals_list() { for (available_gps_prn_iter = available_gps_prn.begin(); available_gps_prn_iter != available_gps_prn.end(); available_gps_prn_iter++) { - signal_value = Gnss_Signal(Gnss_Satellite(std::string("GPS"), *available_gps_prn_iter),std::string("1C")); + signal_value = Gnss_Signal(Gnss_Satellite(std::string("GPS"), + *available_gps_prn_iter), std::string("1C")); available_GNSS_signals_.push_back(signal_value); } - std::list::iterator gnss_it = - available_GNSS_signals_.begin(); + std::list::iterator gnss_it = available_GNSS_signals_.begin(); for (unsigned int i = 0; i < channels_count_; i++) { std::string default_system = "GPS"; @@ -410,24 +468,54 @@ void GNSSFlowgraph::set_signals_list() { unsigned int sat = configuration_->property("Channel" + boost::lexical_cast(i) + ".satellite", 0); - if ((sat == 0) || (sat == gnss_it->get_satellite().get_PRN())) // 0 = not PRN in configuration file { gnss_it++; } else { - signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat),gnss_signal); + signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), + gnss_signal); available_GNSS_signals_.remove(signal_value); available_GNSS_signals_.insert(gnss_it, signal_value); } } - std::cout << "Signal queue: " << std::endl; - for (std::list::iterator it = - available_GNSS_signals_.begin(); it - != available_GNSS_signals_.end(); it++) { - std::cout << *it << std::endl; + /* std::cout << "Signal queue: " << std::endl; + for (std::list::iterator it = + available_GNSS_signals_.begin(); it + != available_GNSS_signals_.end(); it++) { + std::cout << *it << std::endl; + }*/ + +} + +void GNSSFlowgraph::set_channels_state() { + + max_acq_channels_ = (configuration_->property("Channels.in_acquisition", + channels_count_)); + + if (max_acq_channels_ > channels_count_) { + max_acq_channels_ = channels_count_; + std::cout + << "Channels_in_acquisition is bigger than number of channels. Variable acq_channels_count_ is set to " + << channels_count_ << std::endl; } + channels_state_.reserve(channels_count_); + + for (unsigned int i = 0; i < channels_count_; i++) { + if (i < max_acq_channels_) { + channels_state_.push_back(1); + } else + channels_state_.push_back(0); + } + acq_channels_count_ = max_acq_channels_; + + DLOG(INFO) << acq_channels_count_ << " channels in acquisition state"; + + for (unsigned int i = 0; i < channels_count_; i++) { + std::cout << "Channel " << i << " in state " << channels_state_[i] + << std::endl; + } } void GNSSFlowgraph::apply_action(unsigned int what) { diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index ac4ce966a..ef768d797 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -118,10 +118,13 @@ private: void init(); void apply_action(unsigned int what); void set_signals_list(); + void set_channels_state(); bool connected_; bool running_; unsigned int channels_count_; + unsigned int acq_channels_count_; + unsigned int max_acq_channels_; unsigned int applied_actions_; std::string config_file_; @@ -135,7 +138,7 @@ private: gr_msg_queue_sptr queue_; std::list available_GNSS_signals_; - + std::vector channels_state_; }; #endif /*GNSS_SDR_GNSS_FLOWGRAPH_H_*/