mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 04:30:33 +00:00
New Channel FSM
This commit is contained in:
parent
6dd3abfdea
commit
540221e227
@ -103,10 +103,7 @@ Channel::Channel(ConfigurationInterface *configuration, unsigned int channel,
|
||||
|
||||
|
||||
// Destructor
|
||||
Channel::~Channel()
|
||||
{
|
||||
channel_fsm_.terminate();
|
||||
}
|
||||
Channel::~Channel(){}
|
||||
|
||||
|
||||
void Channel::connect(gr::top_block_sptr top_block)
|
||||
@ -139,7 +136,6 @@ void Channel::connect(gr::top_block_sptr top_block)
|
||||
top_block->msg_connect(nav_->get_left_block(), pmt::mp("preamble_timestamp_s"), trk_->get_right_block(), pmt::mp("preamble_timestamp_s"));
|
||||
DLOG(INFO) << "MSG FEEDBACK CHANNEL telemetry_decoder -> tracking";
|
||||
|
||||
//std::cout<<"has port: "<<trk_->get_right_block()->has_msg_port(pmt::mp("events"))<<std::endl;
|
||||
top_block->msg_connect(acq_->get_right_block(), pmt::mp("events"), channel_msg_rx, pmt::mp("events"));
|
||||
top_block->msg_connect(trk_->get_right_block(), pmt::mp("events"), channel_msg_rx, pmt::mp("events"));
|
||||
|
||||
|
@ -30,15 +30,10 @@
|
||||
|
||||
#include "channel_fsm.h"
|
||||
#include <memory>
|
||||
#include <boost/statechart/simple_state.hpp>
|
||||
#include <boost/statechart/state.hpp>
|
||||
#include <boost/statechart/transition.hpp>
|
||||
#include <boost/statechart/custom_reaction.hpp>
|
||||
#include <boost/mpl/list.hpp>
|
||||
#include <glog/logging.h>
|
||||
#include "control_message_factory.h"
|
||||
|
||||
|
||||
/*
|
||||
struct Ev_channel_start_acquisition: sc::event<Ev_channel_start_acquisition>
|
||||
{};
|
||||
|
||||
@ -53,10 +48,9 @@ struct Ev_channel_failed_acquisition_no_repeat: sc::event<Ev_channel_failed_acqu
|
||||
|
||||
struct Ev_channel_failed_tracking_standby: sc::event<Ev_channel_failed_tracking_standby>
|
||||
{};
|
||||
*/
|
||||
|
||||
//struct Ev_channel_failed_tracking_reacq: sc::event<Ev_channel_failed_tracking_reacq>
|
||||
//{};
|
||||
|
||||
/*
|
||||
struct channel_idle_fsm_S0: public sc::state<channel_idle_fsm_S0, ChannelFsm>
|
||||
{
|
||||
public:
|
||||
@ -114,7 +108,7 @@ public:
|
||||
}
|
||||
~channel_waiting_fsm_S3(){}
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
|
||||
ChannelFsm::ChannelFsm()
|
||||
@ -122,7 +116,7 @@ ChannelFsm::ChannelFsm()
|
||||
acq_ = nullptr;
|
||||
trk_ = nullptr;
|
||||
channel_ = 0;
|
||||
initiate(); //start the FSM
|
||||
d_state = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -132,51 +126,60 @@ ChannelFsm::ChannelFsm(std::shared_ptr<AcquisitionInterface> acquisition) :
|
||||
{
|
||||
trk_ = nullptr;
|
||||
channel_ = 0;
|
||||
initiate(); //start the FSM
|
||||
d_state = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ChannelFsm::Event_start_acquisition()
|
||||
{
|
||||
initiate();
|
||||
this->process_event(Ev_channel_start_acquisition());
|
||||
mx.lock();
|
||||
d_state = 1;
|
||||
start_acquisition();
|
||||
LOG(INFO) << "FSM Event_start_acquisition";
|
||||
DLOG(INFO) << "CH = " << channel_ << ". Ev start acquisition";
|
||||
mx.unlock();
|
||||
}
|
||||
|
||||
|
||||
void ChannelFsm::Event_valid_acquisition()
|
||||
{
|
||||
this->process_event(Ev_channel_valid_acquisition());
|
||||
mx.lock();
|
||||
d_state = 2;
|
||||
start_tracking();
|
||||
DLOG(INFO) << "CH = " << channel_ << ". Ev valid acquisition";
|
||||
mx.unlock();
|
||||
}
|
||||
|
||||
|
||||
void ChannelFsm::Event_failed_acquisition_repeat()
|
||||
{
|
||||
this->process_event(Ev_channel_failed_acquisition_repeat());
|
||||
mx.lock();
|
||||
d_state = 1;
|
||||
start_acquisition();
|
||||
DLOG(INFO) << "CH = " << channel_ << ". Ev failed acquisition repeat";
|
||||
mx.unlock();
|
||||
}
|
||||
|
||||
void ChannelFsm::Event_failed_acquisition_no_repeat()
|
||||
{
|
||||
this->process_event(Ev_channel_failed_acquisition_no_repeat());
|
||||
mx.lock();
|
||||
d_state = 3;
|
||||
request_satellite();
|
||||
DLOG(INFO) << "CH = " << channel_ << ". Ev failed acquisition no repeat";
|
||||
mx.unlock();
|
||||
}
|
||||
|
||||
|
||||
// Something is wrong here, we are using a memory after it ts freed
|
||||
void ChannelFsm::Event_failed_tracking_standby()
|
||||
{
|
||||
this->process_event(Ev_channel_failed_tracking_standby());
|
||||
mx.lock();
|
||||
d_state = 0;
|
||||
notify_stop_tracking();
|
||||
DLOG(INFO) << "CH = " << channel_ << ". Ev failed tracking standby";
|
||||
mx.unlock();
|
||||
}
|
||||
|
||||
//void ChannelFsm::Event_failed_tracking_reacq() {
|
||||
// this->process_event(Ev_channel_failed_tracking_reacq());
|
||||
//}
|
||||
|
||||
void ChannelFsm::set_acquisition(std::shared_ptr<AcquisitionInterface> acquisition)
|
||||
{
|
||||
acq_ = acquisition;
|
||||
|
@ -1,12 +1,12 @@
|
||||
/*!
|
||||
* \file channel_fsm.h
|
||||
* \brief Interface of the State Machine for channel using boost::statechart
|
||||
* \author Luis Esteve, 2011. luis(at)epsilon-formacion.com
|
||||
* \brief Interface of the State Machine for channel
|
||||
* \author Antonio Ramos, 2017. antonio.ramos(at)cttc.es
|
||||
*
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
@ -32,26 +32,23 @@
|
||||
#ifndef GNSS_SDR_CHANNEL_FSM_H
|
||||
#define GNSS_SDR_CHANNEL_FSM_H
|
||||
|
||||
|
||||
#include <boost/statechart/state_machine.hpp>
|
||||
#include <mutex>
|
||||
#include <gnuradio/msg_queue.h>
|
||||
#include "acquisition_interface.h"
|
||||
#include "tracking_interface.h"
|
||||
#include "telemetry_decoder_interface.h"
|
||||
|
||||
|
||||
namespace sc = boost::statechart;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
/*
|
||||
struct channel_idle_fsm_S0;
|
||||
struct channel_acquiring_fsm_S1;
|
||||
struct channel_tracking_fsm_S2;
|
||||
struct channel_waiting_fsm_S3;
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief This class implements a State Machine for channel using boost::statechart
|
||||
*/
|
||||
class ChannelFsm: public sc::state_machine<ChannelFsm, channel_idle_fsm_S0>
|
||||
class ChannelFsm
|
||||
{
|
||||
public:
|
||||
ChannelFsm();
|
||||
@ -61,24 +58,27 @@ public:
|
||||
void set_tracking(std::shared_ptr<TrackingInterface> tracking);
|
||||
void set_queue(gr::msg_queue::sptr queue);
|
||||
void set_channel(unsigned int channel);
|
||||
void start_acquisition();
|
||||
void start_tracking();
|
||||
void request_satellite();
|
||||
void notify_stop_tracking();
|
||||
|
||||
//FSM EVENTS
|
||||
void Event_start_acquisition();
|
||||
void Event_valid_acquisition();
|
||||
void Event_failed_acquisition_repeat();
|
||||
void Event_failed_acquisition_no_repeat();
|
||||
//void Event_gps_failed_tracking_reacq();
|
||||
void Event_failed_tracking_standby();
|
||||
|
||||
private:
|
||||
|
||||
void start_acquisition();
|
||||
void start_tracking();
|
||||
void request_satellite();
|
||||
void notify_stop_tracking();
|
||||
|
||||
std::shared_ptr<AcquisitionInterface> acq_;
|
||||
std::shared_ptr<TrackingInterface> trk_;
|
||||
gr::msg_queue::sptr queue_;
|
||||
unsigned int channel_;
|
||||
unsigned int d_state;
|
||||
std::mutex mx;
|
||||
};
|
||||
|
||||
#endif /*GNSS_SDR_CHANNEL_FSM_H*/
|
||||
|
Loading…
Reference in New Issue
Block a user