25 #include <ns3/boolean.h>
26 #include <ns3/double.h>
28 #include <ns3/pointer.h>
29 #include <ns3/trace-source-accessor.h>
31 NS_LOG_COMPONENT_DEFINE(
"SatMobilityObserver");
36 NS_OBJECT_ENSURE_REGISTERED(SatMobilityObserver);
42 TypeId(
"ns3::SatMobilityObserver")
44 .AddAttribute(
"OwnMobility",
48 MakePointerChecker<SatMobilityModel>())
49 .AddAttribute(
"SatelliteMobility",
50 "The mobility of the satellite.",
53 MakePointerChecker<SatMobilityModel>())
54 .AddAttribute(
"AnotherMobility",
55 "The mobility of the another end node.",
58 MakePointerChecker<SatMobilityModel>())
59 .AddAttribute(
"OwnPropagation",
60 "Own propagation delay model.",
63 MakePointerChecker<SatMobilityModel>())
64 .AddAttribute(
"AnotherPropagation",
65 "The propagation delay model of the another end node.",
68 MakePointerChecker<SatMobilityModel>())
69 .AddAttribute(
"MinAltitude",
70 "The minimum altitude accepted for own position.",
73 MakeDoubleChecker<double>())
74 .AddAttribute(
"MaxAltitude",
75 "The maximum altitude accepted for own position.",
78 MakeDoubleChecker<double>())
79 .AddTraceSource(
"PropertyChanged",
80 "The value of the some property has changed",
82 "ns3::SatMobilityObserver::PropertyChangedCallback");
89 NS_LOG_FUNCTION(
this);
96 NS_LOG_FUNCTION(
this);
103 Ptr<SatMobilityModel> geoSatMobility,
105 : m_ownMobility(ownMobility),
106 m_anotherMobility(NULL),
107 m_geoSatMobility(geoSatMobility),
108 m_ownProgDelayModel(NULL),
109 m_anotherProgDelayModel(NULL),
110 m_initialized(false),
111 m_isRegenerative(isRegenerative)
113 NS_LOG_FUNCTION(
this << ownMobility << geoSatMobility);
121 double satelliteAltitude = satellitePosition.
GetAltitude();
124 NS_ASSERT(satelliteAltitude > 0.0);
128 CalculateDistance(satellitePosition.
ToVector(), Vector(0, 0, 0)) - satelliteAltitude;
150 NS_LOG_FUNCTION(
this);
161 NS_LOG_FUNCTION(
this);
166 Ptr<PropagationDelayModel> anotherDelayModel,
167 Ptr<SatMobilityModel> anotherMobility)
169 NS_LOG_FUNCTION(
this << ownDelayModel << anotherDelayModel << anotherMobility);
171 NS_ASSERT(ownDelayModel != NULL);
172 NS_ASSERT(anotherDelayModel != NULL);
173 NS_ASSERT(anotherMobility != NULL);
195 NS_LOG_FUNCTION(
this);
213 NS_LOG_FUNCTION(
this);
216 m_velocity = std::sqrt((velocity.x * velocity.x) + (velocity.y * velocity.y) +
217 (velocity.z * velocity.z));
225 NS_LOG_FUNCTION(
this);
251 NS_LOG_FUNCTION(
this);
262 NS_LOG_FUNCTION(
this << context << position);
273 if (context ==
"Satellite")
284 NS_LOG_FUNCTION(
this);
298 double distanceToSatellite =
310 double longitudeDelta = satLongitude - earthLongitude;
317 double centralAngleCos =
318 (std::cos(earthLatitude) * std::cos(satLatitude) * std::cos(longitudeDelta)) +
319 (std::sin(earthLatitude) * std::sin(satLatitude));
323 std::sin(std::acos(centralAngleCos)) /
333 NS_LOG_FUNCTION(
this);
352 NS_LOG_FUNCTION(
this);
354 double satelliteAltitude =
m_geoSatMobility->GetGeoPosition().GetAltitude();
357 NS_ASSERT(satelliteAltitude > 0.0);
GeoCoordinate class is used to store and operate with geodetic coordinates.
void SetAltitude(double altitude)
Sets altitude value of coordinate.
double GetAltitude() const
Gets altitude value of coordinate.
double GetLatitude() const
Gets latitude value of coordinate.
ReferenceEllipsoid_t GetRefEllipsoid()
Gets reference ellipsoid used by GeoCoordinate object.
double GetLongitude() const
Gets longitude value of coordinate.
Vector ToVector() const
Converts Geodetic coordinates to Cartesian coordinates.
Ptr< SatMobilityModel > m_geoSatMobility
virtual ~SatMobilityObserver()
Destructor of the mobility observer.
virtual void DoDispose(void)
Dispose of this class instance.
void UpdateElevationAngle()
Update elevation angle.
SatMobilityObserver()
Default constructor of the mobility observer (should not be called)
void ObserveTimingAdvance(Ptr< PropagationDelayModel > ownDelayModel, Ptr< PropagationDelayModel > anotherDelayModel, Ptr< SatMobilityModel > anotherMobility)
Enable observing of the timing advance.
Time GetTimingAdvance(void)
Get timing advance.
void PositionChanged(std::string context, Ptr< const SatMobilityModel > position)
Listener (callback) for mobility position changes.
void SatelliteStatusChanged()
Do actions needed when satellite position is changed.
void UpdateTimingAdvance()
Update timing advance.
double m_maxDistanceToSatellite
double GetVelocity(void)
Get velocity of own movement (speed).
static TypeId GetTypeId(void)
Get the type ID.
Ptr< SatMobilityModel > m_anotherMobility
bool m_updateTimingAdvance
void NotifyPropertyChange(void) const
Notify listeners about some property is changed.
double GetElevationAngle(void)
Get elevation angle.
TracedCallback< Ptr< const SatMobilityObserver > > m_propertyChangeTrace
Used to alert subscribers that a change in some observed property has occurred.
Ptr< PropagationDelayModel > m_anotherProgDelayModel
Ptr< PropagationDelayModel > m_ownProgDelayModel
Ptr< SatMobilityModel > m_ownMobility
bool m_updateElevationAngle
TypeId GetInstanceTypeId(void) const
static T RadiansToDegrees(T radian)
Converts radians to degrees.
static T DegreesToRadians(T degree)
Converts degrees to radians.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.