Commit be27bb59 authored by aligungr's avatar aligungr

UE/gNB executable refactor

parent 23d60da7
...@@ -23,42 +23,42 @@ ...@@ -23,42 +23,42 @@
namespace nr::gnb namespace nr::gnb
{ {
void GnbCmdHandler::PauseTasks(TaskBase &base) void GnbCmdHandler::pauseTasks()
{ {
base.gtpTask->requestPause(); m_base->gtpTask->requestPause();
base.mrTask->requestPause(); m_base->mrTask->requestPause();
base.ngapTask->requestPause(); m_base->ngapTask->requestPause();
base.rrcTask->requestPause(); m_base->rrcTask->requestPause();
base.sctpTask->requestPause(); m_base->sctpTask->requestPause();
} }
void GnbCmdHandler::UnpauseTasks(TaskBase &base) void GnbCmdHandler::unpauseTasks()
{ {
base.gtpTask->requestUnpause(); m_base->gtpTask->requestUnpause();
base.mrTask->requestUnpause(); m_base->mrTask->requestUnpause();
base.ngapTask->requestUnpause(); m_base->ngapTask->requestUnpause();
base.rrcTask->requestUnpause(); m_base->rrcTask->requestUnpause();
base.sctpTask->requestUnpause(); m_base->sctpTask->requestUnpause();
} }
bool GnbCmdHandler::IsAllPaused(TaskBase &base) bool GnbCmdHandler::isAllPaused()
{ {
if (!base.gtpTask->isPauseConfirmed()) if (!m_base->gtpTask->isPauseConfirmed())
return false; return false;
if (!base.mrTask->isPauseConfirmed()) if (!m_base->mrTask->isPauseConfirmed())
return false; return false;
if (!base.ngapTask->isPauseConfirmed()) if (!m_base->ngapTask->isPauseConfirmed())
return false; return false;
if (!base.rrcTask->isPauseConfirmed()) if (!m_base->rrcTask->isPauseConfirmed())
return false; return false;
if (!base.sctpTask->isPauseConfirmed()) if (!m_base->sctpTask->isPauseConfirmed())
return false; return false;
return true; return true;
} }
void GnbCmdHandler::HandleCmd(TaskBase &base, NwGnbCliCommand &msg) void GnbCmdHandler::handleCmd(NwGnbCliCommand &msg)
{ {
PauseTasks(base); pauseTasks();
uint64_t currentTime = utils::CurrentTimeMillis(); uint64_t currentTime = utils::CurrentTimeMillis();
uint64_t endTime = currentTime + PAUSE_CONFIRM_TIMEOUT; uint64_t endTime = currentTime + PAUSE_CONFIRM_TIMEOUT;
...@@ -67,7 +67,7 @@ void GnbCmdHandler::HandleCmd(TaskBase &base, NwGnbCliCommand &msg) ...@@ -67,7 +67,7 @@ void GnbCmdHandler::HandleCmd(TaskBase &base, NwGnbCliCommand &msg)
while (currentTime < endTime) while (currentTime < endTime)
{ {
currentTime = utils::CurrentTimeMillis(); currentTime = utils::CurrentTimeMillis();
if (IsAllPaused(base)) if (isAllPaused())
{ {
isPaused = true; isPaused = true;
break; break;
...@@ -81,47 +81,47 @@ void GnbCmdHandler::HandleCmd(TaskBase &base, NwGnbCliCommand &msg) ...@@ -81,47 +81,47 @@ void GnbCmdHandler::HandleCmd(TaskBase &base, NwGnbCliCommand &msg)
} }
else 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) switch (msg.cmd->present)
{ {
case app::GnbCliCommand::STATUS: { case app::GnbCliCommand::STATUS: {
msg.sendResult(ToJson(base.appTask->m_statusInfo).dumpYaml()); msg.sendResult(ToJson(m_base->appTask->m_statusInfo).dumpYaml());
break; break;
} }
case app::GnbCliCommand::INFO: { case app::GnbCliCommand::INFO: {
msg.sendResult(ToJson(*base.config).dumpYaml()); msg.sendResult(ToJson(*m_base->config).dumpYaml());
break; break;
} }
case app::GnbCliCommand::AMF_LIST: { case app::GnbCliCommand::AMF_LIST: {
Json json = Json::Arr({}); 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}})); json.push(Json::Obj({{"id", amf.first}}));
msg.sendResult(json.dumpYaml()); msg.sendResult(json.dumpYaml());
break; break;
} }
case app::GnbCliCommand::AMF_INFO: { 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"); msg.sendError("AMF not found with given ID");
else 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()); msg.sendResult(ToJson(*amf).dumpYaml());
} }
break; break;
} }
case app::GnbCliCommand::UE_LIST: { case app::GnbCliCommand::UE_LIST: {
Json json = Json::Arr({}); Json json = Json::Arr({});
for (auto &ue : base.ngapTask->m_ueCtx) for (auto &ue : m_base->ngapTask->m_ueCtx)
{ {
json.push(Json::Obj({ 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}, {"ran-ngap-id", ue.second->ranUeNgapId},
{"amf-ngap-id", ue.second->amfUeNgapId}, {"amf-ngap-id", ue.second->amfUeNgapId},
})); }));
...@@ -130,7 +130,7 @@ void GnbCmdHandler::HandleCmdImpl(TaskBase &base, NwGnbCliCommand &msg) ...@@ -130,7 +130,7 @@ void GnbCmdHandler::HandleCmdImpl(TaskBase &base, NwGnbCliCommand &msg)
break; break;
} }
case app::GnbCliCommand::UE_COUNT: { 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; break;
} }
} }
......
...@@ -17,15 +17,23 @@ namespace nr::gnb ...@@ -17,15 +17,23 @@ namespace nr::gnb
class GnbCmdHandler class GnbCmdHandler
{ {
private: private:
static void PauseTasks(TaskBase &base); TaskBase *m_base;
static void UnpauseTasks(TaskBase &base);
static bool IsAllPaused(TaskBase &base);
public: public:
static void HandleCmd(TaskBase &base, NwGnbCliCommand &msg); explicit GnbCmdHandler(TaskBase *base) : m_base(base)
{
}
private: 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 } // namespace nr::gnb
...@@ -42,7 +42,8 @@ void GnbAppTask::onLoop() ...@@ -42,7 +42,8 @@ void GnbAppTask::onLoop()
} }
case NtsMessageType::GNB_CLI_COMMAND: { case NtsMessageType::GNB_CLI_COMMAND: {
auto *w = dynamic_cast<NwGnbCliCommand *>(msg); auto *w = dynamic_cast<NwGnbCliCommand *>(msg);
GnbCmdHandler::HandleCmd(*m_base, *w); GnbCmdHandler handler{m_base};
handler.handleCmd(*w);
break; break;
} }
default: 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