Commit be27bb59 authored by aligungr's avatar aligungr

UE/gNB executable refactor

parent 23d60da7
......@@ -23,42 +23,42 @@
namespace nr::gnb
{
void GnbCmdHandler::PauseTasks(TaskBase &base)
void GnbCmdHandler::pauseTasks()
{
base.gtpTask->requestPause();
base.mrTask->requestPause();
base.ngapTask->requestPause();
base.rrcTask->requestPause();
base.sctpTask->requestPause();
m_base->gtpTask->requestPause();
m_base->mrTask->requestPause();
m_base->ngapTask->requestPause();
m_base->rrcTask->requestPause();
m_base->sctpTask->requestPause();
}
void GnbCmdHandler::UnpauseTasks(TaskBase &base)
void GnbCmdHandler::unpauseTasks()
{
base.gtpTask->requestUnpause();
base.mrTask->requestUnpause();
base.ngapTask->requestUnpause();
base.rrcTask->requestUnpause();
base.sctpTask->requestUnpause();
m_base->gtpTask->requestUnpause();
m_base->mrTask->requestUnpause();
m_base->ngapTask->requestUnpause();
m_base->rrcTask->requestUnpause();
m_base->sctpTask->requestUnpause();
}
bool GnbCmdHandler::IsAllPaused(TaskBase &base)
bool GnbCmdHandler::isAllPaused()
{
if (!base.gtpTask->isPauseConfirmed())
if (!m_base->gtpTask->isPauseConfirmed())
return false;
if (!base.mrTask->isPauseConfirmed())
if (!m_base->mrTask->isPauseConfirmed())
return false;
if (!base.ngapTask->isPauseConfirmed())
if (!m_base->ngapTask->isPauseConfirmed())
return false;
if (!base.rrcTask->isPauseConfirmed())
if (!m_base->rrcTask->isPauseConfirmed())
return false;
if (!base.sctpTask->isPauseConfirmed())
if (!m_base->sctpTask->isPauseConfirmed())
return false;
return true;
}
void GnbCmdHandler::HandleCmd(TaskBase &base, NwGnbCliCommand &msg)
void GnbCmdHandler::handleCmd(NwGnbCliCommand &msg)
{
PauseTasks(base);
pauseTasks();
uint64_t currentTime = utils::CurrentTimeMillis();
uint64_t endTime = currentTime + PAUSE_CONFIRM_TIMEOUT;
......@@ -67,7 +67,7 @@ void GnbCmdHandler::HandleCmd(TaskBase &base, NwGnbCliCommand &msg)
while (currentTime < endTime)
{
currentTime = utils::CurrentTimeMillis();
if (IsAllPaused(base))
if (isAllPaused())
{
isPaused = true;
break;
......@@ -81,47 +81,47 @@ void GnbCmdHandler::HandleCmd(TaskBase &base, NwGnbCliCommand &msg)
}
else
{
HandleCmdImpl(base, msg);
handleCmdImpl(msg);
}
UnpauseTasks(base);
unpauseTasks();
}
void GnbCmdHandler::HandleCmdImpl(TaskBase &base, NwGnbCliCommand &msg)
void GnbCmdHandler::handleCmdImpl(NwGnbCliCommand &msg)
{
switch (msg.cmd->present)
{
case app::GnbCliCommand::STATUS: {
msg.sendResult(ToJson(base.appTask->m_statusInfo).dumpYaml());
msg.sendResult(ToJson(m_base->appTask->m_statusInfo).dumpYaml());
break;
}
case app::GnbCliCommand::INFO: {
msg.sendResult(ToJson(*base.config).dumpYaml());
msg.sendResult(ToJson(*m_base->config).dumpYaml());
break;
}
case app::GnbCliCommand::AMF_LIST: {
Json json = Json::Arr({});
for (auto &amf : base.ngapTask->m_amfCtx)
for (auto &amf : m_base->ngapTask->m_amfCtx)
json.push(Json::Obj({{"id", amf.first}}));
msg.sendResult(json.dumpYaml());
break;
}
case app::GnbCliCommand::AMF_INFO: {
if (base.ngapTask->m_amfCtx.count(msg.cmd->amfId) == 0)
if (m_base->ngapTask->m_amfCtx.count(msg.cmd->amfId) == 0)
msg.sendError("AMF not found with given ID");
else
{
auto amf = base.ngapTask->m_amfCtx[msg.cmd->amfId];
auto amf = m_base->ngapTask->m_amfCtx[msg.cmd->amfId];
msg.sendResult(ToJson(*amf).dumpYaml());
}
break;
}
case app::GnbCliCommand::UE_LIST: {
Json json = Json::Arr({});
for (auto &ue : base.ngapTask->m_ueCtx)
for (auto &ue : m_base->ngapTask->m_ueCtx)
{
json.push(Json::Obj({
{"ue-name", base.mrTask->m_ueMap[ue.first].name},
{"ue-name", m_base->mrTask->m_ueMap[ue.first].name},
{"ran-ngap-id", ue.second->ranUeNgapId},
{"amf-ngap-id", ue.second->amfUeNgapId},
}));
......@@ -130,7 +130,7 @@ void GnbCmdHandler::HandleCmdImpl(TaskBase &base, NwGnbCliCommand &msg)
break;
}
case app::GnbCliCommand::UE_COUNT: {
msg.sendResult(std::to_string(base.ngapTask->m_ueCtx.size()));
msg.sendResult(std::to_string(m_base->ngapTask->m_ueCtx.size()));
break;
}
}
......
......@@ -17,15 +17,23 @@ namespace nr::gnb
class GnbCmdHandler
{
private:
static void PauseTasks(TaskBase &base);
static void UnpauseTasks(TaskBase &base);
static bool IsAllPaused(TaskBase &base);
TaskBase *m_base;
public:
static void HandleCmd(TaskBase &base, NwGnbCliCommand &msg);
explicit GnbCmdHandler(TaskBase *base) : m_base(base)
{
}
private:
static void HandleCmdImpl(TaskBase &base, NwGnbCliCommand &msg);
void pauseTasks();
void unpauseTasks();
bool isAllPaused();
public:
void handleCmd(NwGnbCliCommand &msg);
private:
void handleCmdImpl(NwGnbCliCommand &msg);
};
} // namespace nr::gnb
......@@ -42,7 +42,8 @@ void GnbAppTask::onLoop()
}
case NtsMessageType::GNB_CLI_COMMAND: {
auto *w = dynamic_cast<NwGnbCliCommand *>(msg);
GnbCmdHandler::HandleCmd(*m_base, *w);
GnbCmdHandler handler{m_base};
handler.handleCmd(*w);
break;
}
default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment