lte: Refactor DoInitialize methods of LteEnbPhy and LteUePhy

see merge request !29
This commit is contained in:
ZorazeAli
2019-02-26 08:12:32 +01:00
parent b58cac8135
commit 6eae98fbca
2 changed files with 22 additions and 38 deletions

View File

@@ -265,25 +265,17 @@ void
LteEnbPhy::DoInitialize ()
{
NS_LOG_FUNCTION (this);
bool haveNodeId = false;
uint32_t nodeId = 0;
if (m_netDevice != 0)
{
Ptr<Node> node = m_netDevice->GetNode ();
if (node != 0)
{
nodeId = node->GetId ();
haveNodeId = true;
}
}
if (haveNodeId)
{
Simulator::ScheduleWithContext (nodeId, Seconds (0), &LteEnbPhy::StartFrame, this);
}
else
{
Simulator::ScheduleNow (&LteEnbPhy::StartFrame, this);
}
NS_ABORT_MSG_IF (m_netDevice == nullptr, "LteEnbDevice is not available in LteEnbPhy");
Ptr<Node> node = m_netDevice->GetNode ();
NS_ABORT_MSG_IF (node == nullptr, "Node is not available in the LteNetDevice of LteEnbPhy");
uint32_t nodeId = node->GetId ();
//ScheduleWithContext() is needed here to set context for logs,
//because Initialize() is called outside of Node::AddDevice().
Simulator::ScheduleWithContext (nodeId, Seconds (0), &LteEnbPhy::StartFrame, this);
Ptr<SpectrumValue> noisePsd = LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (m_ulEarfcn, m_ulBandwidth, m_noiseFigure);
m_uplinkSpectrumPhy->SetNoisePowerSpectralDensity (noisePsd);
LtePhy::DoInitialize ();

View File

@@ -311,25 +311,17 @@ void
LteUePhy::DoInitialize ()
{
NS_LOG_FUNCTION (this);
bool haveNodeId = false;
uint32_t nodeId = 0;
if (m_netDevice != 0)
{
Ptr<Node> node = m_netDevice->GetNode ();
if (node != 0)
{
nodeId = node->GetId ();
haveNodeId = true;
}
}
if (haveNodeId)
{
Simulator::ScheduleWithContext (nodeId, Seconds (0), &LteUePhy::SubframeIndication, this, 1, 1);
}
else
{
Simulator::ScheduleNow (&LteUePhy::SubframeIndication, this, 1, 1);
}
NS_ABORT_MSG_IF (m_netDevice == nullptr, "LteNetDevice is not available in LteUePhy");
Ptr<Node> node = m_netDevice->GetNode ();
NS_ABORT_MSG_IF (node == nullptr, "Node is not available in the LteNetDevice of LteUePhy");
uint32_t nodeId = node->GetId ();
//ScheduleWithContext() is needed here to set context for logs,
//because Initialize() is called outside of Node::AddDevice().
Simulator::ScheduleWithContext (nodeId, Seconds (0), &LteUePhy::SubframeIndication, this, 1, 1);
LtePhy::DoInitialize ();
}