mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 12:40:35 +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
|
// Destructor
|
||||||
Channel::~Channel()
|
Channel::~Channel(){}
|
||||||
{
|
|
||||||
channel_fsm_.terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Channel::connect(gr::top_block_sptr top_block)
|
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"));
|
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";
|
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(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"));
|
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 "channel_fsm.h"
|
||||||
#include <memory>
|
#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 <glog/logging.h>
|
||||||
#include "control_message_factory.h"
|
#include "control_message_factory.h"
|
||||||
|
|
||||||
|
/*
|
||||||
struct Ev_channel_start_acquisition: sc::event<Ev_channel_start_acquisition>
|
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_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>
|
struct channel_idle_fsm_S0: public sc::state<channel_idle_fsm_S0, ChannelFsm>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -114,7 +108,7 @@ public:
|
|||||||
}
|
}
|
||||||
~channel_waiting_fsm_S3(){}
|
~channel_waiting_fsm_S3(){}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
ChannelFsm::ChannelFsm()
|
ChannelFsm::ChannelFsm()
|
||||||
@ -122,7 +116,7 @@ ChannelFsm::ChannelFsm()
|
|||||||
acq_ = nullptr;
|
acq_ = nullptr;
|
||||||
trk_ = nullptr;
|
trk_ = nullptr;
|
||||||
channel_ = 0;
|
channel_ = 0;
|
||||||
initiate(); //start the FSM
|
d_state = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -132,51 +126,60 @@ ChannelFsm::ChannelFsm(std::shared_ptr<AcquisitionInterface> acquisition) :
|
|||||||
{
|
{
|
||||||
trk_ = nullptr;
|
trk_ = nullptr;
|
||||||
channel_ = 0;
|
channel_ = 0;
|
||||||
initiate(); //start the FSM
|
d_state = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ChannelFsm::Event_start_acquisition()
|
void ChannelFsm::Event_start_acquisition()
|
||||||
{
|
{
|
||||||
initiate();
|
mx.lock();
|
||||||
this->process_event(Ev_channel_start_acquisition());
|
d_state = 1;
|
||||||
|
start_acquisition();
|
||||||
LOG(INFO) << "FSM Event_start_acquisition";
|
LOG(INFO) << "FSM Event_start_acquisition";
|
||||||
DLOG(INFO) << "CH = " << channel_ << ". Ev start acquisition";
|
DLOG(INFO) << "CH = " << channel_ << ". Ev start acquisition";
|
||||||
|
mx.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChannelFsm::Event_valid_acquisition()
|
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";
|
DLOG(INFO) << "CH = " << channel_ << ". Ev valid acquisition";
|
||||||
|
mx.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChannelFsm::Event_failed_acquisition_repeat()
|
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";
|
DLOG(INFO) << "CH = " << channel_ << ". Ev failed acquisition repeat";
|
||||||
|
mx.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelFsm::Event_failed_acquisition_no_repeat()
|
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";
|
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()
|
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";
|
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)
|
void ChannelFsm::set_acquisition(std::shared_ptr<AcquisitionInterface> acquisition)
|
||||||
{
|
{
|
||||||
acq_ = acquisition;
|
acq_ = acquisition;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
/*!
|
/*!
|
||||||
* \file channel_fsm.h
|
* \file channel_fsm.h
|
||||||
* \brief Interface of the State Machine for channel using boost::statechart
|
* \brief Interface of the State Machine for channel
|
||||||
* \author Luis Esteve, 2011. luis(at)epsilon-formacion.com
|
* \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
|
* GNSS-SDR is a software defined Global Navigation
|
||||||
* Satellite Systems receiver
|
* Satellite Systems receiver
|
||||||
@ -32,26 +32,23 @@
|
|||||||
#ifndef GNSS_SDR_CHANNEL_FSM_H
|
#ifndef GNSS_SDR_CHANNEL_FSM_H
|
||||||
#define GNSS_SDR_CHANNEL_FSM_H
|
#define GNSS_SDR_CHANNEL_FSM_H
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
#include <boost/statechart/state_machine.hpp>
|
|
||||||
#include <gnuradio/msg_queue.h>
|
#include <gnuradio/msg_queue.h>
|
||||||
#include "acquisition_interface.h"
|
#include "acquisition_interface.h"
|
||||||
#include "tracking_interface.h"
|
#include "tracking_interface.h"
|
||||||
#include "telemetry_decoder_interface.h"
|
#include "telemetry_decoder_interface.h"
|
||||||
|
|
||||||
|
/*
|
||||||
namespace sc = boost::statechart;
|
|
||||||
namespace mpl = boost::mpl;
|
|
||||||
|
|
||||||
struct channel_idle_fsm_S0;
|
struct channel_idle_fsm_S0;
|
||||||
struct channel_acquiring_fsm_S1;
|
struct channel_acquiring_fsm_S1;
|
||||||
struct channel_tracking_fsm_S2;
|
struct channel_tracking_fsm_S2;
|
||||||
struct channel_waiting_fsm_S3;
|
struct channel_waiting_fsm_S3;
|
||||||
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief This class implements a State Machine for channel using boost::statechart
|
* \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:
|
public:
|
||||||
ChannelFsm();
|
ChannelFsm();
|
||||||
@ -61,24 +58,27 @@ public:
|
|||||||
void set_tracking(std::shared_ptr<TrackingInterface> tracking);
|
void set_tracking(std::shared_ptr<TrackingInterface> tracking);
|
||||||
void set_queue(gr::msg_queue::sptr queue);
|
void set_queue(gr::msg_queue::sptr queue);
|
||||||
void set_channel(unsigned int channel);
|
void set_channel(unsigned int channel);
|
||||||
void start_acquisition();
|
|
||||||
void start_tracking();
|
|
||||||
void request_satellite();
|
|
||||||
void notify_stop_tracking();
|
|
||||||
|
|
||||||
//FSM EVENTS
|
//FSM EVENTS
|
||||||
void Event_start_acquisition();
|
void Event_start_acquisition();
|
||||||
void Event_valid_acquisition();
|
void Event_valid_acquisition();
|
||||||
void Event_failed_acquisition_repeat();
|
void Event_failed_acquisition_repeat();
|
||||||
void Event_failed_acquisition_no_repeat();
|
void Event_failed_acquisition_no_repeat();
|
||||||
//void Event_gps_failed_tracking_reacq();
|
|
||||||
void Event_failed_tracking_standby();
|
void Event_failed_tracking_standby();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void start_acquisition();
|
||||||
|
void start_tracking();
|
||||||
|
void request_satellite();
|
||||||
|
void notify_stop_tracking();
|
||||||
|
|
||||||
std::shared_ptr<AcquisitionInterface> acq_;
|
std::shared_ptr<AcquisitionInterface> acq_;
|
||||||
std::shared_ptr<TrackingInterface> trk_;
|
std::shared_ptr<TrackingInterface> trk_;
|
||||||
gr::msg_queue::sptr queue_;
|
gr::msg_queue::sptr queue_;
|
||||||
unsigned int channel_;
|
unsigned int channel_;
|
||||||
|
unsigned int d_state;
|
||||||
|
std::mutex mx;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*GNSS_SDR_CHANNEL_FSM_H*/
|
#endif /*GNSS_SDR_CHANNEL_FSM_H*/
|
||||||
|
Loading…
Reference in New Issue
Block a user