diff --git a/model/leo-circular-orbit-position-allocator.cc b/model/leo-circular-orbit-position-allocator.cc new file mode 100644 index 0000000..04fc183 --- /dev/null +++ b/model/leo-circular-orbit-position-allocator.cc @@ -0,0 +1,52 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ + +#include "ns3/integer.h" +#include "leo-circular-orbit-position-allocator.h" + +namespace ns3 { + +NS_OBJECT_ENSURE_REGISTERED (LeoCircularOrbitAllocator); + +LeoCircularOrbitAllocator::LeoCircularOrbitAllocator () + : m_lastOrbit (0), m_lastSatellite (0) +{} + +LeoCircularOrbitAllocator::~LeoCircularOrbitAllocator () +{} + +TypeId +LeoCircularOrbitAllocator::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::LeoCircularOrbitPostionAllocator") + .SetParent () + .SetGroupName ("Leo") + .AddConstructor () + .AddAttribute ("NumOrbits", + "The number of orbits", + IntegerValue (1), + MakeIntegerAccessor (&LeoCircularOrbitAllocator::m_numOrbits), + MakeIntegerChecker ()) + .AddAttribute ("NumSatellites", + "The number of satellites per orbit", + IntegerValue (1), + MakeIntegerAccessor (&LeoCircularOrbitAllocator::m_numSatellites), + MakeIntegerChecker ()) + ; + return tid; +} + +int64_t +LeoCircularOrbitAllocator::AssignStreams (int64_t stream) +{ + return -1; +} + +Vector +LeoCircularOrbitAllocator::GetNext () const +{ + return Vector (180 * ((double) m_lastOrbit / (double) m_numOrbits), + 360.0 * ((double) m_lastSatellite / (double) m_numSatellites), + 0); +} + +}; diff --git a/model/leo-circular-orbit-position-allocator.h b/model/leo-circular-orbit-position-allocator.h new file mode 100644 index 0000000..194a82b --- /dev/null +++ b/model/leo-circular-orbit-position-allocator.h @@ -0,0 +1,39 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ + +#ifndef LEO_CIRCULAR_ORBIT_HELPER_H +#define LEO_CIRCULAR_ORBIT_HELPER_H + +#include "ns3/position-allocator.h" + +namespace ns3 { + +/** + * \brief Allocate pairs of latitude and longitude (offset within orbit) for + * use in LeoCircularOrbitMobilityModel + */ +class LeoCircularOrbitAllocator : public PositionAllocator +{ +public: + /** + * Register this type with the TypeId system. + * \return the object TypeId + */ + static TypeId GetTypeId (); + + LeoCircularOrbitAllocator (); + virtual ~LeoCircularOrbitAllocator (); + + virtual Vector GetNext (void) const; + virtual int64_t AssignStreams (int64_t stream); + +private: + uint64_t m_numOrbits; + uint64_t m_numSatellites; + + mutable uint64_t m_lastOrbit; + mutable uint64_t m_lastSatellite; +}; + +}; + +#endif