mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 10:03:58 +02:00
Make examples runable as tests
This commit is contained in:
parent
fccc05f6c2
commit
3f4ba0a8c1
5 changed files with 107 additions and 26 deletions
|
@ -1,6 +1,7 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/config.h"
|
||||
|
@ -10,7 +11,6 @@
|
|||
#include "ns3/integer.h"
|
||||
|
||||
#include "leo-orbit-node-helper.h"
|
||||
#include "../model/leo-orbit.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -33,6 +33,26 @@ LeoOrbitNodeHelper::SetAttribute (string name, const AttributeValue &value)
|
|||
m_nodeFactory.Set (name, value);
|
||||
}
|
||||
|
||||
NodeContainer
|
||||
LeoOrbitNodeHelper::Install (const LeoOrbit &orbit)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << orbit);
|
||||
|
||||
MobilityHelper mobility;
|
||||
mobility.SetPositionAllocator ("ns3::LeoCircularOrbitPostionAllocator",
|
||||
"NumOrbits", IntegerValue (orbit.planes),
|
||||
"NumSatellites", IntegerValue (orbit.sats));
|
||||
mobility.SetMobilityModel ("ns3::LeoCircularOrbitMobilityModel",
|
||||
"Altitude", DoubleValue (orbit.alt),
|
||||
"Inclination", DoubleValue (orbit.inc));
|
||||
|
||||
NodeContainer c;
|
||||
c.Create (orbit.sats*orbit.planes);
|
||||
mobility.Install (c);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
NodeContainer
|
||||
LeoOrbitNodeHelper::Install (const std::string &orbitFile)
|
||||
{
|
||||
|
@ -44,18 +64,7 @@ LeoOrbitNodeHelper::Install (const std::string &orbitFile)
|
|||
LeoOrbit orbit;
|
||||
while ((orbits >> orbit))
|
||||
{
|
||||
MobilityHelper mobility;
|
||||
mobility.SetPositionAllocator ("ns3::LeoCircularOrbitPostionAllocator",
|
||||
"NumOrbits", IntegerValue (orbit.planes),
|
||||
"NumSatellites", IntegerValue (orbit.sats));
|
||||
mobility.SetMobilityModel ("ns3::LeoCircularOrbitMobilityModel",
|
||||
"Altitude", DoubleValue (orbit.alt),
|
||||
"Inclination", DoubleValue (orbit.inc));
|
||||
|
||||
NodeContainer c;
|
||||
c.Create (orbit.sats*orbit.planes);
|
||||
mobility.Install (c);
|
||||
nodes.Add (c);
|
||||
nodes.Add (Install (orbit));
|
||||
NS_LOG_DEBUG ("Added orbit plane");
|
||||
}
|
||||
orbits.close ();
|
||||
|
@ -65,4 +74,21 @@ LeoOrbitNodeHelper::Install (const std::string &orbitFile)
|
|||
return nodes;
|
||||
}
|
||||
|
||||
NodeContainer
|
||||
LeoOrbitNodeHelper::Install (const vector<LeoOrbit> &orbits)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << orbits);
|
||||
|
||||
NodeContainer nodes;
|
||||
for (uint64_t i = 0; i < orbits.size(); i++)
|
||||
{
|
||||
nodes.Add (Install (orbits[i]));
|
||||
NS_LOG_DEBUG ("Added orbit plane");
|
||||
}
|
||||
|
||||
NS_LOG_DEBUG ("Added " << nodes.GetN () << " nodes");
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue