mirror of https://github.com/PentHertz/srsLTE.git
- Ported fsm.h to srslog.
- Adapted and removed old loggers in tests and code that used fsm.h
This commit is contained in:
parent
c8a4bf2613
commit
79eca0980d
|
@ -22,11 +22,11 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
#define otherfsmDebug(f, fmt, ...) f->get_log()->debug("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__)
|
#define otherfsmDebug(f, fmt, ...) f->get_logger().debug("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__)
|
||||||
#define otherfsmInfo(f, fmt, ...) f->get_log()->info("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__)
|
#define otherfsmInfo(f, fmt, ...) f->get_logger().info("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__)
|
||||||
#define otherfsmWarning(f, fmt, ...) \
|
#define otherfsmWarning(f, fmt, ...) \
|
||||||
f->get_log()->warning("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__)
|
f->get_logger().warning("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__)
|
||||||
#define otherfsmError(f, fmt, ...) f->get_log()->error("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__)
|
#define otherfsmError(f, fmt, ...) f->get_logger().error("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__)
|
||||||
|
|
||||||
#define fsmDebug(fmt, ...) otherfsmDebug(this, fmt, ##__VA_ARGS__)
|
#define fsmDebug(fmt, ...) otherfsmDebug(this, fmt, ##__VA_ARGS__)
|
||||||
#define fsmInfo(fmt, ...) otherfsmInfo(this, fmt, ##__VA_ARGS__)
|
#define fsmInfo(fmt, ...) otherfsmInfo(this, fmt, ##__VA_ARGS__)
|
||||||
|
@ -159,7 +159,7 @@ static auto get_state_recursive(FSM* f) -> disable_if_fsm_state<FSM, State, Stat
|
||||||
//! Helper type for FSM state-related operations
|
//! Helper type for FSM state-related operations
|
||||||
template <typename FSM, typename State>
|
template <typename FSM, typename State>
|
||||||
struct state_traits {
|
struct state_traits {
|
||||||
static_assert(FSM::template can_hold_state<State>(), "FSM type does not hold provided State\n");
|
static_assert(FSM::template can_hold_state<State>(), "FSM type does not hold provided State");
|
||||||
using state_t = State;
|
using state_t = State;
|
||||||
using is_subfsm = std::integral_constant<bool, ::srslte::is_composite_fsm<State>::value>;
|
using is_subfsm = std::integral_constant<bool, ::srslte::is_composite_fsm<State>::value>;
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ struct apply_first_guard_pass<FSM, type_list<First, Rows...> > {
|
||||||
// Log Transition
|
// Log Transition
|
||||||
if (std::is_same<src_state, dest_state>::value) {
|
if (std::is_same<src_state, dest_state>::value) {
|
||||||
otherfsmInfo(static_cast<typename FSM::derived_t*>(f),
|
otherfsmInfo(static_cast<typename FSM::derived_t*>(f),
|
||||||
"Event \"%s\" triggered state \"%s\" update\n",
|
"Event \"%s\" triggered state \"%s\" update",
|
||||||
get_type_name<event_type>().c_str(),
|
get_type_name<event_type>().c_str(),
|
||||||
get_type_name<src_state>().c_str());
|
get_type_name<src_state>().c_str());
|
||||||
} else {
|
} else {
|
||||||
|
@ -250,7 +250,7 @@ struct apply_first_guard_pass<FSM, type_list<> > {
|
||||||
{
|
{
|
||||||
if (should_log_unhandled_event(&ev)) {
|
if (should_log_unhandled_event(&ev)) {
|
||||||
otherfsmDebug(static_cast<typename FSM::derived_t*>(f),
|
otherfsmDebug(static_cast<typename FSM::derived_t*>(f),
|
||||||
"unhandled event caught in state \"%s\": \"%s\"\n",
|
"unhandled event caught in state \"%s\": \"%s\"",
|
||||||
get_type_name<SrcState>().c_str(),
|
get_type_name<SrcState>().c_str(),
|
||||||
get_type_name<Event>().c_str());
|
get_type_name<Event>().c_str());
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ public:
|
||||||
struct state_list : public std::tuple<States...> {
|
struct state_list : public std::tuple<States...> {
|
||||||
using tuple_base_t = std::tuple<States...>;
|
using tuple_base_t = std::tuple<States...>;
|
||||||
using init_state_t = typename std::decay<decltype(std::get<0>(std::declval<tuple_base_t>()))>::type;
|
using init_state_t = typename std::decay<decltype(std::get<0>(std::declval<tuple_base_t>()))>::type;
|
||||||
static_assert(not type_list_contains<Derived, States...>(), "An FSM cannot contain itself as state\n");
|
static_assert(not type_list_contains<Derived, States...>(), "An FSM cannot contain itself as state");
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
state_list(base_fsm_t<Derived>* f, Args&&... args) : tuple_base_t(std::forward<Args>(args)...)
|
state_list(base_fsm_t<Derived>* f, Args&&... args) : tuple_base_t(std::forward<Args>(args)...)
|
||||||
|
@ -507,7 +507,7 @@ protected:
|
||||||
public:
|
public:
|
||||||
static const bool is_nested = false;
|
static const bool is_nested = false;
|
||||||
|
|
||||||
explicit fsm_t(srslte::log_ref log_) : log_h(log_) {}
|
explicit fsm_t(srslog::basic_logger& logger) : logger(logger) {}
|
||||||
|
|
||||||
// Push Events to FSM
|
// Push Events to FSM
|
||||||
template <typename Ev>
|
template <typename Ev>
|
||||||
|
@ -527,9 +527,9 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_fsm_event_log_level(srslte::LOG_LEVEL_ENUM e) { fsm_event_log_level = e; }
|
void set_fsm_event_log_level(srslog::basic_levels lvl) { log_level = lvl; }
|
||||||
|
|
||||||
srslte::log_ref get_log() const { return log_h; }
|
srslog::basic_logger& get_logger() const { return logger; }
|
||||||
|
|
||||||
bool is_trigger_locked() const { return trigger_locked; }
|
bool is_trigger_locked() const { return trigger_locked; }
|
||||||
|
|
||||||
|
@ -537,18 +537,18 @@ public:
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void log_fsm_activity(const char* format, Args&&... args)
|
void log_fsm_activity(const char* format, Args&&... args)
|
||||||
{
|
{
|
||||||
switch (fsm_event_log_level) {
|
switch (log_level) {
|
||||||
case LOG_LEVEL_DEBUG:
|
case srslog::basic_levels::debug:
|
||||||
log_h->debug(format, std::forward<Args>(args)...);
|
logger.debug(format, std::forward<Args>(args)...);
|
||||||
break;
|
break;
|
||||||
case LOG_LEVEL_INFO:
|
case srslog::basic_levels::info:
|
||||||
log_h->info(format, std::forward<Args>(args)...);
|
logger.info(format, std::forward<Args>(args)...);
|
||||||
break;
|
break;
|
||||||
case LOG_LEVEL_WARNING:
|
case srslog::basic_levels::warning:
|
||||||
log_h->warning(format, std::forward<Args>(args)...);
|
logger.warning(format, std::forward<Args>(args)...);
|
||||||
break;
|
break;
|
||||||
case LOG_LEVEL_ERROR:
|
case srslog::basic_levels::error:
|
||||||
log_h->error(format, std::forward<Args>(args)...);
|
logger.error(format, std::forward<Args>(args)...);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -570,9 +570,9 @@ protected:
|
||||||
pending_events.emplace_back(std::bind([this](Ev& e) { process_event(std::move(e)); }, std::move(e)));
|
pending_events.emplace_back(std::bind([this](Ev& e) { process_event(std::move(e)); }, std::move(e)));
|
||||||
}
|
}
|
||||||
|
|
||||||
srslte::log_ref log_h;
|
srslog::basic_logger& logger;
|
||||||
srslte::LOG_LEVEL_ENUM fsm_event_log_level = LOG_LEVEL_INFO;
|
srslog::basic_levels log_level = srslog::basic_levels::info;
|
||||||
bool trigger_locked = false;
|
bool trigger_locked = false;
|
||||||
std::deque<srslte::move_callback<void()> > pending_events;
|
std::deque<srslte::move_callback<void()> > pending_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ public:
|
||||||
|
|
||||||
parent_t* parent_fsm() { return fsm_ptr; }
|
parent_t* parent_fsm() { return fsm_ptr; }
|
||||||
|
|
||||||
srslte::log_ref get_log() const { return parent_fsm()->get_log(); }
|
srslog::basic_logger& get_logger() const { return parent_fsm()->get_logger(); }
|
||||||
|
|
||||||
// Push Events to root FSM
|
// Push Events to root FSM
|
||||||
template <typename Ev>
|
template <typename Ev>
|
||||||
|
@ -634,7 +634,7 @@ class proc_fsm_t : public fsm_t<Derived>
|
||||||
using fsm_t<Derived>::derived;
|
using fsm_t<Derived>::derived;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using fsm_t<Derived>::log_h;
|
using fsm_t<Derived>::logger;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using base_t = proc_fsm_t<Derived, Result>;
|
using base_t = proc_fsm_t<Derived, Result>;
|
||||||
|
@ -650,14 +650,14 @@ public:
|
||||||
void enter(Derived* f)
|
void enter(Derived* f)
|
||||||
{
|
{
|
||||||
if (f->launch_counter > 0) {
|
if (f->launch_counter > 0) {
|
||||||
f->log_h->warning(
|
f->logger.warning(
|
||||||
"FSM \"%s\": No result was set for run no. %d\n", get_type_name<Derived>().c_str(), f->launch_counter);
|
"FSM \"%s\": No result was set for run no. %d", get_type_name<Derived>().c_str(), f->launch_counter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enter(Derived* f, const complete_ev& ev)
|
void enter(Derived* f, const complete_ev& ev)
|
||||||
{
|
{
|
||||||
f->log_h->info("FSM \"%s\": Finished run no. %d\n", get_type_name<Derived>().c_str(), f->launch_counter);
|
f->logger.info("FSM \"%s\": Finished run no. %d", get_type_name<Derived>().c_str(), f->launch_counter);
|
||||||
f->last_result = ev.result;
|
f->last_result = ev.result;
|
||||||
for (auto& func : f->listening_fsms) {
|
for (auto& func : f->listening_fsms) {
|
||||||
func(ev);
|
func(ev);
|
||||||
|
@ -668,11 +668,11 @@ public:
|
||||||
void exit(Derived* f)
|
void exit(Derived* f)
|
||||||
{
|
{
|
||||||
f->launch_counter++;
|
f->launch_counter++;
|
||||||
f->log_h->info("FSM \"%s\": Starting run no. %d\n", get_type_name<Derived>().c_str(), f->launch_counter);
|
f->logger.info("FSM \"%s\": Starting run no. %d", get_type_name<Derived>().c_str(), f->launch_counter);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit proc_fsm_t(srslte::log_ref log_) : fsm_t<Derived>(log_) {}
|
explicit proc_fsm_t(srslog::basic_logger& logger) : fsm_t<Derived>(logger) {}
|
||||||
|
|
||||||
bool is_running() const { return not base_t::template is_in_state<idle_st>(); }
|
bool is_running() const { return not base_t::template is_in_state<idle_st>(); }
|
||||||
|
|
||||||
|
@ -711,7 +711,7 @@ public:
|
||||||
void enter(FSM* f, const Ev& ev)
|
void enter(FSM* f, const Ev& ev)
|
||||||
{
|
{
|
||||||
if (proc_ptr->is_running()) {
|
if (proc_ptr->is_running()) {
|
||||||
f->get_log()->error("Unable to launch proc1\n");
|
f->get_logger().error("Unable to launch proc1");
|
||||||
f->trigger(typename ProcFSM::complete_ev{false});
|
f->trigger(typename ProcFSM::complete_ev{false});
|
||||||
}
|
}
|
||||||
proc_ptr->trigger(srslte::proc_launch_ev<Ev>{ev});
|
proc_ptr->trigger(srslte::proc_launch_ev<Ev>{ev});
|
||||||
|
|
|
@ -20,11 +20,12 @@ struct ev1 {};
|
||||||
struct ev2 {};
|
struct ev2 {};
|
||||||
|
|
||||||
std::vector<std::string> calls;
|
std::vector<std::string> calls;
|
||||||
|
|
||||||
template <typename State>
|
template <typename State>
|
||||||
void call_log_helper(State* state, srslte::log_ref log_h, const char* type)
|
void call_log_helper(State* state, srslog::basic_logger& logger, const char* type)
|
||||||
{
|
{
|
||||||
std::string callname = srslte::get_type_name<State>() + "::" + type;
|
std::string callname = srslte::get_type_name<State>() + "::" + type;
|
||||||
log_h->info("%s custom called\n", callname.c_str());
|
logger.info("%s custom called", callname.c_str());
|
||||||
calls.push_back(callname);
|
calls.push_back(callname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ public:
|
||||||
void exit(fsm1* f);
|
void exit(fsm1* f);
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit fsm1(srslte::log_ref log_) : srslte::fsm_t<fsm1>(log_) {}
|
explicit fsm1(srslog::basic_logger& logger) : srslte::fsm_t<fsm1>(logger) {}
|
||||||
|
|
||||||
// this state is another FSM
|
// this state is another FSM
|
||||||
class fsm2 : public subfsm_t<fsm2>
|
class fsm2 : public subfsm_t<fsm2>
|
||||||
|
@ -55,22 +56,22 @@ public:
|
||||||
struct state_inner {
|
struct state_inner {
|
||||||
void enter(fsm2* f)
|
void enter(fsm2* f)
|
||||||
{
|
{
|
||||||
call_log_helper(this, f->get_log(), "enter");
|
call_log_helper(this, f->get_logger(), "enter");
|
||||||
f->parent_fsm()->inner_enter_counter++;
|
f->parent_fsm()->inner_enter_counter++;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct state_inner2 {
|
struct state_inner2 {
|
||||||
void enter(fsm2* f) { call_log_helper(this, f->get_log(), "enter"); }
|
void enter(fsm2* f) { call_log_helper(this, f->get_logger(), "enter"); }
|
||||||
void exit(fsm2* f) { call_log_helper(this, f->get_log(), "exit"); }
|
void exit(fsm2* f) { call_log_helper(this, f->get_logger(), "exit"); }
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit fsm2(fsm1* f_) : composite_fsm_t(f_) {}
|
explicit fsm2(fsm1* f_) : composite_fsm_t(f_) {}
|
||||||
fsm2(fsm2&&) = default;
|
fsm2(fsm2&&) = default;
|
||||||
fsm2& operator=(fsm2&&) = default;
|
fsm2& operator=(fsm2&&) = default;
|
||||||
~fsm2() { get_log()->info("%s being destroyed!", get_type_name(*this).c_str()); }
|
~fsm2() { get_logger().info("%s being destroyed!", get_type_name(*this).c_str()); }
|
||||||
|
|
||||||
void enter(fsm1* f) { call_log_helper(this, get_log(), "enter"); }
|
void enter(fsm1* f) { call_log_helper(this, get_logger(), "enter"); }
|
||||||
void exit(fsm1* f) { call_log_helper(this, get_log(), "exit"); }
|
void exit(fsm1* f) { call_log_helper(this, get_logger(), "exit"); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void inner_action1(state_inner& s, const ev1& e);
|
void inner_action1(state_inner& s, const ev1& e);
|
||||||
|
@ -117,54 +118,54 @@ protected:
|
||||||
|
|
||||||
void fsm1::idle_st::enter(fsm1* f)
|
void fsm1::idle_st::enter(fsm1* f)
|
||||||
{
|
{
|
||||||
call_log_helper(this, f->log_h, "enter");
|
call_log_helper(this, f->logger, "enter");
|
||||||
f->idle_enter_counter++;
|
f->idle_enter_counter++;
|
||||||
}
|
}
|
||||||
void fsm1::state1::enter(fsm1* f, const ev1& ev)
|
void fsm1::state1::enter(fsm1* f, const ev1& ev)
|
||||||
{
|
{
|
||||||
call_log_helper(this, f->log_h, "enter");
|
call_log_helper(this, f->logger, "enter");
|
||||||
f->state1_enter_counter++;
|
f->state1_enter_counter++;
|
||||||
}
|
}
|
||||||
void fsm1::state1::enter(fsm1* f, const ev2& ev)
|
void fsm1::state1::enter(fsm1* f, const ev2& ev)
|
||||||
{
|
{
|
||||||
call_log_helper(this, f->log_h, "enter2");
|
call_log_helper(this, f->logger, "enter2");
|
||||||
f->state1_enter_counter++;
|
f->state1_enter_counter++;
|
||||||
}
|
}
|
||||||
void fsm1::state1::exit(fsm1* f)
|
void fsm1::state1::exit(fsm1* f)
|
||||||
{
|
{
|
||||||
call_log_helper(this, f->log_h, "exit");
|
call_log_helper(this, f->logger, "exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
// FSM event handlers
|
// FSM event handlers
|
||||||
void fsm1::fsm2::inner_action1(state_inner& s, const ev1& e)
|
void fsm1::fsm2::inner_action1(state_inner& s, const ev1& e)
|
||||||
{
|
{
|
||||||
call_log_helper(this, get_log(), "inner_action1");
|
call_log_helper(this, get_logger(), "inner_action1");
|
||||||
}
|
}
|
||||||
|
|
||||||
void fsm1::fsm2::inner_action2(state_inner& s, const ev2& e)
|
void fsm1::fsm2::inner_action2(state_inner& s, const ev2& e)
|
||||||
{
|
{
|
||||||
call_log_helper(this, get_log(), "inner_action2");
|
call_log_helper(this, get_logger(), "inner_action2");
|
||||||
}
|
}
|
||||||
|
|
||||||
void fsm1::fsm2::inner_action3(state_inner2& s, const ev2& e)
|
void fsm1::fsm2::inner_action3(state_inner2& s, const ev2& e)
|
||||||
{
|
{
|
||||||
get_log()->info("fsm2::state_inner2::react called\n");
|
get_logger().info("fsm2::state_inner2::react called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void fsm1::action1(idle_st& s, const ev1& e)
|
void fsm1::action1(idle_st& s, const ev1& e)
|
||||||
{
|
{
|
||||||
call_log_helper(this, log_h, "action1");
|
call_log_helper(this, logger, "action1");
|
||||||
foo(e);
|
foo(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fsm1::action2(state1& s, const ev1& ev)
|
void fsm1::action2(state1& s, const ev1& ev)
|
||||||
{
|
{
|
||||||
call_log_helper(this, log_h, "action2");
|
call_log_helper(this, logger, "action2");
|
||||||
}
|
}
|
||||||
|
|
||||||
void fsm1::action3(state1& s, const ev2& ev)
|
void fsm1::action3(state1& s, const ev2& ev)
|
||||||
{
|
{
|
||||||
call_log_helper(this, log_h, "action3");
|
call_log_helper(this, logger, "action3");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static Checks
|
// Static Checks
|
||||||
|
@ -172,17 +173,16 @@ void fsm1::action3(state1& s, const ev2& ev)
|
||||||
namespace srslte {
|
namespace srslte {
|
||||||
namespace fsm_details {
|
namespace fsm_details {
|
||||||
|
|
||||||
static_assert(is_fsm<fsm1>::value, "invalid metafunction\n");
|
static_assert(is_fsm<fsm1>::value, "invalid metafunction");
|
||||||
static_assert(is_composite_fsm<fsm1::fsm2>::value, "invalid metafunction\n");
|
static_assert(is_composite_fsm<fsm1::fsm2>::value, "invalid metafunction");
|
||||||
static_assert(type_list_size(typename filter_transition_type<ev1, fsm1::idle_st, fsm_transitions<fsm1> >::type{}) > 0,
|
static_assert(type_list_size(typename filter_transition_type<ev1, fsm1::idle_st, fsm_transitions<fsm1> >::type{}) > 0,
|
||||||
"invalid filter metafunction\n");
|
"invalid filter metafunction");
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<fsm_state_list_type<fsm1>, fsm1::state_list<fsm1::idle_st, fsm1::state1, fsm1::fsm2> >::value,
|
std::is_same<fsm_state_list_type<fsm1>, fsm1::state_list<fsm1::idle_st, fsm1::state1, fsm1::fsm2> >::value,
|
||||||
"get state list failed\n");
|
"get state list failed");
|
||||||
static_assert(fsm1::can_hold_state<fsm1::state1>(), "failed can_hold_state check\n");
|
static_assert(fsm1::can_hold_state<fsm1::state1>(), "failed can_hold_state check");
|
||||||
static_assert(std::is_same<enable_if_fsm_state<fsm1, fsm1::idle_st>, void>::value, "get state list failed\n");
|
static_assert(std::is_same<enable_if_fsm_state<fsm1, fsm1::idle_st>, void>::value, "get state list failed");
|
||||||
static_assert(std::is_same<disable_if_fsm_state<fsm1, fsm1::fsm2::state_inner>, void>::value,
|
static_assert(std::is_same<disable_if_fsm_state<fsm1, fsm1::fsm2::state_inner>, void>::value, "get state list failed");
|
||||||
"get state list failed\n");
|
|
||||||
|
|
||||||
} // namespace fsm_details
|
} // namespace fsm_details
|
||||||
} // namespace srslte
|
} // namespace srslte
|
||||||
|
@ -191,10 +191,10 @@ static_assert(std::is_same<disable_if_fsm_state<fsm1, fsm1::fsm2::state_inner>,
|
||||||
|
|
||||||
int test_hsm()
|
int test_hsm()
|
||||||
{
|
{
|
||||||
srslte::log_ref log_h{"HSM"};
|
srslog::basic_logger& logger = srslog::fetch_basic_logger("HSM", false);
|
||||||
log_h->set_level(srslte::LOG_LEVEL_INFO);
|
logger.set_level(srslog::basic_levels::info);
|
||||||
|
|
||||||
fsm1 f{log_h};
|
fsm1 f{logger};
|
||||||
TESTASSERT(f.idle_enter_counter == 1);
|
TESTASSERT(f.idle_enter_counter == 1);
|
||||||
TESTASSERT(get_type_name(f) == "fsm1");
|
TESTASSERT(get_type_name(f) == "fsm1");
|
||||||
TESTASSERT(f.current_state_name() == "idle_st");
|
TESTASSERT(f.current_state_name() == "idle_st");
|
||||||
|
@ -280,7 +280,7 @@ public:
|
||||||
void enter(proc1* f, const srslte::proc_launch_ev<int>& ev);
|
void enter(proc1* f, const srslte::proc_launch_ev<int>& ev);
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit proc1(srslte::log_ref log_) : base_t(log_) {}
|
explicit proc1(srslog::basic_logger& logger) : base_t(logger) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Transitions
|
// Transitions
|
||||||
|
@ -307,18 +307,18 @@ protected:
|
||||||
|
|
||||||
void proc1::procstate1::enter(proc1* f, const launch_ev<int>& ev)
|
void proc1::procstate1::enter(proc1* f, const launch_ev<int>& ev)
|
||||||
{
|
{
|
||||||
f->log_h->info("started!\n");
|
f->logger.info("started!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void proc1::handle_success(procstate1& s, const procevent1& ev)
|
void proc1::handle_success(procstate1& s, const procevent1& ev)
|
||||||
{
|
{
|
||||||
log_h->info("success!\n");
|
logger.info("success!");
|
||||||
trigger(complete_ev{5});
|
trigger(complete_ev{5});
|
||||||
}
|
}
|
||||||
|
|
||||||
void proc1::handle_failure(procstate1& s, const procevent1& ev)
|
void proc1::handle_failure(procstate1& s, const procevent1& ev)
|
||||||
{
|
{
|
||||||
log_h->info("failure!\n");
|
logger.info("failure!");
|
||||||
trigger(complete_ev{3});
|
trigger(complete_ev{3});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,9 +328,8 @@ public:
|
||||||
struct st2 {};
|
struct st2 {};
|
||||||
using proc1_st = srslte::proc_wait_st<proc1>;
|
using proc1_st = srslte::proc_wait_st<proc1>;
|
||||||
|
|
||||||
explicit proc_listener_fsm(srslte::log_ref log_, proc1* proc_ptr_) :
|
proc_listener_fsm(srslog::basic_logger& logger, proc1* proc_ptr_) :
|
||||||
base_t(log_),
|
base_t(logger), states(this, st1{}, st2{}, proc1_st{proc_ptr_})
|
||||||
states(this, st1{}, st2{}, proc1_st{proc_ptr_})
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -352,9 +351,9 @@ protected:
|
||||||
|
|
||||||
int test_fsm_proc()
|
int test_fsm_proc()
|
||||||
{
|
{
|
||||||
proc1 proc{srslte::logmap::get("PROC")};
|
proc1 proc{srslog::fetch_basic_logger("PROC", false)};
|
||||||
proc.get_log()->set_level(srslte::LOG_LEVEL_INFO);
|
proc.get_logger().set_level(srslog::basic_levels::info);
|
||||||
proc.set_fsm_event_log_level(srslte::LOG_LEVEL_INFO);
|
proc.set_fsm_event_log_level(srslog::basic_levels::info);
|
||||||
|
|
||||||
int v = 2;
|
int v = 2;
|
||||||
TESTASSERT(proc.current_state_name() == "idle_st");
|
TESTASSERT(proc.current_state_name() == "idle_st");
|
||||||
|
@ -374,7 +373,7 @@ int test_fsm_proc()
|
||||||
TESTASSERT(proc.get_result() == 3);
|
TESTASSERT(proc.get_result() == 3);
|
||||||
|
|
||||||
{
|
{
|
||||||
proc_listener_fsm outer_fsm{srslte::logmap::get("TEST"), &proc};
|
proc_listener_fsm outer_fsm{srslog::fetch_basic_logger("TEST"), &proc};
|
||||||
TESTASSERT(outer_fsm.is_in_state<proc_listener_fsm::st1>());
|
TESTASSERT(outer_fsm.is_in_state<proc_listener_fsm::st1>());
|
||||||
outer_fsm.trigger(6);
|
outer_fsm.trigger(6);
|
||||||
TESTASSERT(outer_fsm.is_in_state<proc_listener_fsm::proc1_st>());
|
TESTASSERT(outer_fsm.is_in_state<proc_listener_fsm::proc1_st>());
|
||||||
|
@ -385,7 +384,7 @@ int test_fsm_proc()
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
proc_listener_fsm outer_fsm{srslte::logmap::get("TEST"), &proc};
|
proc_listener_fsm outer_fsm{srslog::fetch_basic_logger("TEST"), &proc};
|
||||||
TESTASSERT(outer_fsm.is_in_state<proc_listener_fsm::st1>());
|
TESTASSERT(outer_fsm.is_in_state<proc_listener_fsm::st1>());
|
||||||
proc.trigger(srslte::proc_launch_ev<int>{v});
|
proc.trigger(srslte::proc_launch_ev<int>{v});
|
||||||
TESTASSERT(proc.is_running());
|
TESTASSERT(proc.is_running());
|
||||||
|
@ -426,7 +425,7 @@ public:
|
||||||
struct detach_request_ev {};
|
struct detach_request_ev {};
|
||||||
struct detach_accept_ev {};
|
struct detach_accept_ev {};
|
||||||
|
|
||||||
nas_fsm(srslte::log_ref log_) : fsm_t<nas_fsm>(log_) {}
|
explicit nas_fsm(srslog::basic_logger& logger) : fsm_t<nas_fsm>(logger) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
state_list<emm_null_st,
|
state_list<emm_null_st,
|
||||||
|
@ -461,9 +460,11 @@ protected:
|
||||||
|
|
||||||
int test_nas_fsm()
|
int test_nas_fsm()
|
||||||
{
|
{
|
||||||
srslte::log_ref log_h{"NAS"};
|
auto& logger = srslog::fetch_basic_logger("NAS", false);
|
||||||
log_h->set_level(srslte::LOG_LEVEL_INFO);
|
logger.set_level(srslog::basic_levels::info);
|
||||||
nas_fsm fsm{log_h};
|
|
||||||
|
nas_fsm fsm{logger};
|
||||||
|
|
||||||
TESTASSERT(fsm.is_in_state<nas_fsm::emm_null_st>());
|
TESTASSERT(fsm.is_in_state<nas_fsm::emm_null_st>());
|
||||||
|
|
||||||
// NULL -> EMM-DEREGISTERED
|
// NULL -> EMM-DEREGISTERED
|
||||||
|
@ -539,7 +540,7 @@ struct fsm3 : public srslte::fsm_t<fsm3> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fsm3() : base_t(srslte::log_ref{"TEST"}) {}
|
fsm3() : base_t(srslog::fetch_basic_logger("TEST")) {}
|
||||||
|
|
||||||
std::vector<std::string> events;
|
std::vector<std::string> events;
|
||||||
|
|
||||||
|
@ -591,16 +592,18 @@ int test_fsm_self_trigger()
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
srslte::log_ref testlog{"TEST"};
|
srslog::basic_logger& logger = srslog::fetch_basic_logger("TEST", false);
|
||||||
testlog->set_level(srslte::LOG_LEVEL_INFO);
|
logger.set_level(srslog::basic_levels::info);
|
||||||
|
srslog::init();
|
||||||
|
|
||||||
TESTASSERT(test_hsm() == SRSLTE_SUCCESS);
|
TESTASSERT(test_hsm() == SRSLTE_SUCCESS);
|
||||||
testlog->info("TEST \"hsm\" finished successfully\n\n");
|
logger.info("TEST \"hsm\" finished successfully\n");
|
||||||
TESTASSERT(test_fsm_proc() == SRSLTE_SUCCESS);
|
TESTASSERT(test_fsm_proc() == SRSLTE_SUCCESS);
|
||||||
testlog->info("TEST \"proc\" finished successfully\n\n");
|
logger.info("TEST \"proc\" finished successfully\n");
|
||||||
TESTASSERT(test_nas_fsm() == SRSLTE_SUCCESS);
|
TESTASSERT(test_nas_fsm() == SRSLTE_SUCCESS);
|
||||||
testlog->info("TEST \"nas fsm\" finished successfully\n\n");
|
logger.info("TEST \"nas fsm\" finished successfully\n");
|
||||||
TESTASSERT(test_fsm_self_trigger() == SRSLTE_SUCCESS);
|
TESTASSERT(test_fsm_self_trigger() == SRSLTE_SUCCESS);
|
||||||
testlog->info("TEST \"fsm self trigger\" finished successfully\n\n");
|
logger.info("TEST \"fsm self trigger\" finished successfully\n");
|
||||||
|
|
||||||
return SRSLTE_SUCCESS;
|
return SRSLTE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,6 @@ private:
|
||||||
pdcp_interface_rrc* pdcp = nullptr;
|
pdcp_interface_rrc* pdcp = nullptr;
|
||||||
gtpu_interface_rrc* gtpu = nullptr;
|
gtpu_interface_rrc* gtpu = nullptr;
|
||||||
s1ap_interface_rrc* s1ap = nullptr;
|
s1ap_interface_rrc* s1ap = nullptr;
|
||||||
srslte::log_ref rrc_log;
|
|
||||||
srslog::basic_logger& logger;
|
srslog::basic_logger& logger;
|
||||||
|
|
||||||
// derived params
|
// derived params
|
||||||
|
|
|
@ -28,8 +28,7 @@ using namespace asn1::rrc;
|
||||||
|
|
||||||
namespace srsenb {
|
namespace srsenb {
|
||||||
|
|
||||||
rrc::rrc(srslte::task_sched_handle task_sched_) :
|
rrc::rrc(srslte::task_sched_handle task_sched_) : logger(srslog::fetch_basic_logger("RRC")), task_sched(task_sched_)
|
||||||
rrc_log("RRC"), logger(srslog::fetch_basic_logger("RRC")), task_sched(task_sched_)
|
|
||||||
{
|
{
|
||||||
pending_paging.clear();
|
pending_paging.clear();
|
||||||
ue_pool.reserve(16);
|
ue_pool.reserve(16);
|
||||||
|
@ -865,7 +864,6 @@ void rrc::configure_mbsfn_sibs()
|
||||||
|
|
||||||
int rrc::pack_mcch()
|
int rrc::pack_mcch()
|
||||||
{
|
{
|
||||||
|
|
||||||
mcch.msg.set_c1();
|
mcch.msg.set_c1();
|
||||||
mbsfn_area_cfg_r9_s& area_cfg_r9 = mcch.msg.c1().mbsfn_area_cfg_r9();
|
mbsfn_area_cfg_r9_s& area_cfg_r9 = mcch.msg.c1().mbsfn_area_cfg_r9();
|
||||||
area_cfg_r9.common_sf_alloc_period_r9 = mbsfn_area_cfg_r9_s::common_sf_alloc_period_r9_e_::rf64;
|
area_cfg_r9.common_sf_alloc_period_r9 = mbsfn_area_cfg_r9_s::common_sf_alloc_period_r9_e_::rf64;
|
||||||
|
|
|
@ -183,7 +183,7 @@ uint16_t rrc::start_ho_ue_resource_alloc(const asn1::s1ap::ho_request_s&
|
||||||
************************************************************************************************/
|
************************************************************************************************/
|
||||||
|
|
||||||
rrc::ue::rrc_mobility::rrc_mobility(rrc::ue* outer_ue) :
|
rrc::ue::rrc_mobility::rrc_mobility(rrc::ue* outer_ue) :
|
||||||
base_t(outer_ue->parent->rrc_log),
|
base_t(outer_ue->parent->logger),
|
||||||
rrc_ue(outer_ue),
|
rrc_ue(outer_ue),
|
||||||
rrc_enb(outer_ue->parent),
|
rrc_enb(outer_ue->parent),
|
||||||
pool(outer_ue->pool),
|
pool(outer_ue->pool),
|
||||||
|
@ -385,7 +385,7 @@ void rrc::ue::rrc_mobility::handle_ho_preparation_complete(bool
|
||||||
srslte::unique_byte_buffer_t container)
|
srslte::unique_byte_buffer_t container)
|
||||||
{
|
{
|
||||||
if (not is_success) {
|
if (not is_success) {
|
||||||
log_h->info("Received S1AP HandoverFailure. Aborting Handover...");
|
logger.info("Received S1AP HandoverFailure. Aborting Handover...");
|
||||||
trigger(srslte::failure_ev{});
|
trigger(srslte::failure_ev{});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -394,15 +394,15 @@ void rrc::ue::rrc_mobility::handle_ho_preparation_complete(bool
|
||||||
{
|
{
|
||||||
asn1::cbit_ref bref(container->msg, container->N_bytes);
|
asn1::cbit_ref bref(container->msg, container->N_bytes);
|
||||||
if (rrchocmd.unpack(bref) != asn1::SRSASN_SUCCESS) {
|
if (rrchocmd.unpack(bref) != asn1::SRSASN_SUCCESS) {
|
||||||
get_log()->warning("Unpacking of RRC HOCommand was unsuccessful");
|
get_logger().warning("Unpacking of RRC HOCommand was unsuccessful");
|
||||||
get_log()->warning_hex(container->msg, container->N_bytes, "Received container:");
|
get_logger().warning(container->msg, container->N_bytes, "Received container:");
|
||||||
trigger(ho_cancel_ev{});
|
trigger(ho_cancel_ev{});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rrchocmd.crit_exts.type().value != c1_or_crit_ext_opts::c1 or
|
if (rrchocmd.crit_exts.type().value != c1_or_crit_ext_opts::c1 or
|
||||||
rrchocmd.crit_exts.c1().type().value != ho_cmd_s::crit_exts_c_::c1_c_::types_opts::ho_cmd_r8) {
|
rrchocmd.crit_exts.c1().type().value != ho_cmd_s::crit_exts_c_::c1_c_::types_opts::ho_cmd_r8) {
|
||||||
get_log()->warning("Only handling r8 Handover Commands");
|
get_logger().warning("Only handling r8 Handover Commands");
|
||||||
trigger(ho_cancel_ev{});
|
trigger(ho_cancel_ev{});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -573,7 +573,7 @@ bool rrc::ue::rrc_mobility::s1_source_ho_st::start_enb_status_transfer(const asn
|
||||||
void rrc::ue::rrc_mobility::s1_source_ho_st::wait_ho_cmd::enter(s1_source_ho_st* f, const ho_meas_report_ev& ev)
|
void rrc::ue::rrc_mobility::s1_source_ho_st::wait_ho_cmd::enter(s1_source_ho_st* f, const ho_meas_report_ev& ev)
|
||||||
{
|
{
|
||||||
srslte::console("Starting S1 Handover of rnti=0x%x to cellid=0x%x.\n", f->rrc_ue->rnti, ev.target_eci);
|
srslte::console("Starting S1 Handover of rnti=0x%x to cellid=0x%x.\n", f->rrc_ue->rnti, ev.target_eci);
|
||||||
f->get_log()->info("Starting S1 Handover of rnti=0x%x to cellid=0x%x.", f->rrc_ue->rnti, ev.target_eci);
|
f->get_logger().info("Starting S1 Handover of rnti=0x%x to cellid=0x%x.", f->rrc_ue->rnti, ev.target_eci);
|
||||||
f->report = ev;
|
f->report = ev;
|
||||||
|
|
||||||
bool success = f->parent_fsm()->start_ho_preparation(f->report.target_eci, f->report.meas_obj->meas_obj_id, false);
|
bool success = f->parent_fsm()->start_ho_preparation(f->report.target_eci, f->report.meas_obj->meas_obj_id, false);
|
||||||
|
@ -781,10 +781,10 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho
|
||||||
for (const auto& erab_item : ho_req_msg.protocol_ies.erab_to_be_setup_list_ho_req.value) {
|
for (const auto& erab_item : ho_req_msg.protocol_ies.erab_to_be_setup_list_ho_req.value) {
|
||||||
auto& erab = erab_item.value.erab_to_be_setup_item_ho_req();
|
auto& erab = erab_item.value.erab_to_be_setup_item_ho_req();
|
||||||
if (erab.ext) {
|
if (erab.ext) {
|
||||||
get_log()->warning("Not handling E-RABToBeSetupList extensions");
|
get_logger().warning("Not handling E-RABToBeSetupList extensions");
|
||||||
}
|
}
|
||||||
if (erab.transport_layer_address.length() > 32) {
|
if (erab.transport_layer_address.length() > 32) {
|
||||||
get_log()->error("IPv6 addresses not currently supported");
|
get_logger().error("IPv6 addresses not currently supported");
|
||||||
trigger(srslte::failure_ev{});
|
trigger(srslte::failure_ev{});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -792,7 +792,7 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho
|
||||||
if (not erab.ie_exts_present or not erab.ie_exts.data_forwarding_not_possible_present or
|
if (not erab.ie_exts_present or not erab.ie_exts.data_forwarding_not_possible_present or
|
||||||
erab.ie_exts.data_forwarding_not_possible.ext.value !=
|
erab.ie_exts.data_forwarding_not_possible.ext.value !=
|
||||||
asn1::s1ap::data_forwarding_not_possible_opts::data_forwarding_not_possible) {
|
asn1::s1ap::data_forwarding_not_possible_opts::data_forwarding_not_possible) {
|
||||||
get_log()->warning("Data Forwarding of E-RABs not supported");
|
get_logger().warning("Data Forwarding of E-RABs not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create E-RAB and associated main GTPU tunnel
|
// Create E-RAB and associated main GTPU tunnel
|
||||||
|
@ -910,12 +910,12 @@ void rrc::ue::rrc_mobility::intraenb_ho_st::enter(rrc_mobility* f, const ho_meas
|
||||||
target_cell = f->rrc_enb->cell_common_list->get_cell_id(cell_id);
|
target_cell = f->rrc_enb->cell_common_list->get_cell_id(cell_id);
|
||||||
source_cell = f->rrc_ue->ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX)->cell_common;
|
source_cell = f->rrc_ue->ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX)->cell_common;
|
||||||
if (target_cell == nullptr) {
|
if (target_cell == nullptr) {
|
||||||
f->log_h->error("The target cell_id=0x%x was not found in the list of eNB cells", cell_id);
|
f->logger.error("The target cell_id=0x%x was not found in the list of eNB cells", cell_id);
|
||||||
f->trigger(srslte::failure_ev{});
|
f->trigger(srslte::failure_ev{});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
f->log_h->info("Starting intraeNB Handover of rnti=0x%x to 0x%x.", f->rrc_ue->rnti, meas_report.target_eci);
|
f->logger.info("Starting intraeNB Handover of rnti=0x%x to 0x%x.", f->rrc_ue->rnti, meas_report.target_eci);
|
||||||
|
|
||||||
if (target_cell == nullptr) {
|
if (target_cell == nullptr) {
|
||||||
f->trigger(srslte::failure_ev{});
|
f->trigger(srslte::failure_ev{});
|
||||||
|
|
|
@ -516,6 +516,8 @@ int main(int argc, char** argv)
|
||||||
logger.set_level(srslog::basic_levels::info);
|
logger.set_level(srslog::basic_levels::info);
|
||||||
logger.set_hex_dump_max_size(1024);
|
logger.set_hex_dump_max_size(1024);
|
||||||
|
|
||||||
|
srslog::init();
|
||||||
|
|
||||||
using event = mobility_test_params::test_event;
|
using event = mobility_test_params::test_event;
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ std::string to_string(const phy_cell_t& cell)
|
||||||
phy_controller::phy_controller(srsue::phy_interface_rrc_lte* phy_,
|
phy_controller::phy_controller(srsue::phy_interface_rrc_lte* phy_,
|
||||||
srslte::task_sched_handle task_sched_,
|
srslte::task_sched_handle task_sched_,
|
||||||
std::function<void(uint32_t, uint32_t, bool)> on_cell_selection) :
|
std::function<void(uint32_t, uint32_t, bool)> on_cell_selection) :
|
||||||
base_t(srslte::log_ref{"RRC"}),
|
base_t(srslog::fetch_basic_logger("RRC")),
|
||||||
phy(phy_),
|
phy(phy_),
|
||||||
task_sched(task_sched_),
|
task_sched(task_sched_),
|
||||||
cell_selection_always_observer(std::move(on_cell_selection))
|
cell_selection_always_observer(std::move(on_cell_selection))
|
||||||
|
@ -37,13 +37,13 @@ void phy_controller::in_sync()
|
||||||
|
|
||||||
bool phy_controller::set_cell_config(const srslte::phy_cfg_t& config, uint32_t cc_idx)
|
bool phy_controller::set_cell_config(const srslte::phy_cfg_t& config, uint32_t cc_idx)
|
||||||
{
|
{
|
||||||
log_h->info("Setting PHY config for cc_idx=%d", cc_idx);
|
logger.info("Setting PHY config for cc_idx=%d", cc_idx);
|
||||||
return set_cell_config(config, cc_idx, true);
|
return set_cell_config(config, cc_idx, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void phy_controller::set_phy_to_default()
|
void phy_controller::set_phy_to_default()
|
||||||
{
|
{
|
||||||
log_h->info("Setting default PHY config (common and dedicated)");
|
logger.info("Setting default PHY config (common and dedicated)");
|
||||||
|
|
||||||
srslte::phy_cfg_t& default_cfg = current_cells_cfg[0];
|
srslte::phy_cfg_t& default_cfg = current_cells_cfg[0];
|
||||||
default_cfg.set_defaults();
|
default_cfg.set_defaults();
|
||||||
|
@ -55,7 +55,7 @@ void phy_controller::set_phy_to_default()
|
||||||
/// Apply default PHY config for all SCells as specified in TS 36.331 9.2.4
|
/// Apply default PHY config for all SCells as specified in TS 36.331 9.2.4
|
||||||
void phy_controller::set_phy_to_default_dedicated()
|
void phy_controller::set_phy_to_default_dedicated()
|
||||||
{
|
{
|
||||||
log_h->info("Setting default dedicated PHY config");
|
logger.info("Setting default dedicated PHY config");
|
||||||
|
|
||||||
srslte::phy_cfg_t& default_cfg = current_cells_cfg[0];
|
srslte::phy_cfg_t& default_cfg = current_cells_cfg[0];
|
||||||
default_cfg.set_defaults_dedicated();
|
default_cfg.set_defaults_dedicated();
|
||||||
|
@ -66,7 +66,7 @@ void phy_controller::set_phy_to_default_dedicated()
|
||||||
|
|
||||||
void phy_controller::set_phy_to_default_pucch_srs()
|
void phy_controller::set_phy_to_default_pucch_srs()
|
||||||
{
|
{
|
||||||
log_h->info("Setting default PHY config dedicated");
|
logger.info("Setting default PHY config dedicated");
|
||||||
|
|
||||||
srslte::phy_cfg_t& default_cfg_ded = current_cells_cfg[0];
|
srslte::phy_cfg_t& default_cfg_ded = current_cells_cfg[0];
|
||||||
default_cfg_ded.set_defaults_pucch_sr();
|
default_cfg_ded.set_defaults_pucch_sr();
|
||||||
|
@ -91,7 +91,7 @@ bool phy_controller::set_cell_config(const srslte::phy_cfg_t& cfg, uint32_t cc_i
|
||||||
void phy_controller::set_config_complete()
|
void phy_controller::set_config_complete()
|
||||||
{
|
{
|
||||||
if (nof_pending_configs == 0) {
|
if (nof_pending_configs == 0) {
|
||||||
log_h->warning("Received more phy config complete signals than the ones scheduled");
|
logger.warning("Received more phy config complete signals than the ones scheduled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nof_pending_configs--;
|
nof_pending_configs--;
|
||||||
|
@ -104,12 +104,12 @@ void phy_controller::set_config_complete()
|
||||||
bool phy_controller::start_cell_select(const phy_cell_t& phy_cell, srslte::event_observer<bool> observer)
|
bool phy_controller::start_cell_select(const phy_cell_t& phy_cell, srslte::event_observer<bool> observer)
|
||||||
{
|
{
|
||||||
if (is_in_state<selecting_cell>()) {
|
if (is_in_state<selecting_cell>()) {
|
||||||
log_h->warning("Failed to launch cell selection as it is already running");
|
logger.warning("Failed to launch cell selection as it is already running");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
trigger(cell_sel_cmd{phy_cell});
|
trigger(cell_sel_cmd{phy_cell});
|
||||||
if (not is_in_state<selecting_cell>()) {
|
if (not is_in_state<selecting_cell>()) {
|
||||||
log_h->warning("Failed to launch cell selection. Current state: %s", current_state_name().c_str());
|
logger.warning("Failed to launch cell selection. Current state: %s", current_state_name().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cell_selection_notifier = std::move(observer);
|
cell_selection_notifier = std::move(observer);
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
namespace srsue {
|
namespace srsue {
|
||||||
|
|
||||||
srslte::log_ref test_log{"TEST"};
|
|
||||||
|
|
||||||
struct cell_search_result_test {
|
struct cell_search_result_test {
|
||||||
cell_search_result_test(phy_controller* phy_ctrl_) : phy_ctrl(phy_ctrl_) {}
|
cell_search_result_test(phy_controller* phy_ctrl_) : phy_ctrl(phy_ctrl_) {}
|
||||||
|
|
||||||
|
@ -27,8 +25,8 @@ struct cell_search_result_test {
|
||||||
result = result_;
|
result = result_;
|
||||||
|
|
||||||
if (phy_ctrl->current_state_name() == "searching_cell" or phy_ctrl->is_trigger_locked()) {
|
if (phy_ctrl->current_state_name() == "searching_cell" or phy_ctrl->is_trigger_locked()) {
|
||||||
phy_ctrl->get_log()->error(
|
phy_ctrl->get_logger().error(
|
||||||
"When caller is signalled with cell search result, cell search state cannot be active\n");
|
"When caller is signalled with cell search result, cell search state cannot be active");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,16 +43,16 @@ struct cell_select_result_test {
|
||||||
{
|
{
|
||||||
result = result_ ? 1 : 0;
|
result = result_ ? 1 : 0;
|
||||||
if (phy_ctrl->current_state_name() == "selecting_cell" or phy_ctrl->is_trigger_locked()) {
|
if (phy_ctrl->current_state_name() == "selecting_cell" or phy_ctrl->is_trigger_locked()) {
|
||||||
phy_ctrl->get_log()->error(
|
phy_ctrl->get_logger().error(
|
||||||
"When caller is signalled with cell select result, cell select state cannot be active\n");
|
"When caller is signalled with cell select result, cell select state cannot be active");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// start a new cell selection right away
|
// start a new cell selection right away
|
||||||
if (counter++ < 1) {
|
if (counter++ < 1) {
|
||||||
phy_cell_t new_cell = {};
|
phy_cell_t new_cell = {};
|
||||||
new_cell.pci = 3;
|
new_cell.pci = 3;
|
||||||
new_cell.earfcn = 3400;
|
new_cell.earfcn = 3400;
|
||||||
phy_ctrl->start_cell_select(new_cell, *this);
|
phy_ctrl->start_cell_select(new_cell, *this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,9 +191,15 @@ int test_phy_cell_select_init_error_handling()
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_INFO);
|
auto& test_logger = srslog::fetch_basic_logger("TEST", false);
|
||||||
|
test_logger.set_level(srslog::basic_levels::info);
|
||||||
|
test_logger.set_hex_dump_max_size(-1);
|
||||||
|
auto& RRC_logger = srslog::fetch_basic_logger("RRC", false);
|
||||||
|
RRC_logger.set_level(srslog::basic_levels::info);
|
||||||
|
RRC_logger.set_hex_dump_max_size(-1);
|
||||||
|
srslog::init();
|
||||||
|
|
||||||
TESTASSERT(srsue::test_phy_ctrl_fsm() == SRSLTE_SUCCESS);
|
TESTASSERT(srsue::test_phy_ctrl_fsm() == SRSLTE_SUCCESS);
|
||||||
TESTASSERT(srsue::test_phy_cell_select_init_error_handling() == SRSLTE_SUCCESS);
|
TESTASSERT(srsue::test_phy_cell_select_init_error_handling() == SRSLTE_SUCCESS);
|
||||||
srsue::test_log->info("Finished RRC PHY controller test successfully\n");
|
test_logger.info("Finished RRC PHY controller test successfully");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue