Loading...
Searching...
No Matches
satellite-traced-mobility-model.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2018 CNES
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Mathias Ettinger <mettinger@toulouse.viveris.com>
19 */
20
22
24
25#include "ns3/enum.h"
26#include "ns3/log.h"
27#include "ns3/simulator.h"
28#include "ns3/singleton.h"
29
30#include <string>
31
32NS_LOG_COMPONENT_DEFINE("SatTracedMobilityModel");
33
34namespace ns3
35{
36
37NS_OBJECT_ENSURE_REGISTERED(SatTracedMobilityModel);
38
39TypeId
41{
42 static TypeId tid =
43 TypeId("ns3::SatTracedMobilityModel")
44 .SetParent<SatMobilityModel>()
45 .AddConstructor<SatTracedMobilityModel>()
46 .AddAttribute("ReferenceEllipsoid",
47 "Reference Ellipsoid model to use when reading coordinates",
48 EnumValue(GeoCoordinate::SPHERE),
49 MakeEnumAccessor<GeoCoordinate::ReferenceEllipsoid_t>(
51 MakeEnumChecker(GeoCoordinate::SPHERE,
52 "Sphere",
54 "WGS84",
56 "GRS80"))
57 .AddAttribute("UpdateInterval",
58 "Interval at which the position should update",
59 TimeValue(MilliSeconds(1)),
61 MakeTimeChecker(FemtoSeconds(1)));
62
63 return tid;
64}
65
66void
68{
69 m_antennaGainPatterns = nullptr;
70
71 Object::DoDispose();
72}
73
75{
76 NS_FATAL_ERROR("SatTracedMobilityModel default constructor should not be used");
77}
78
80 const std::string& filename,
81 Ptr<SatAntennaGainPatternContainer> agp)
82 : m_satId(satId),
83 m_traceFilename(filename),
84 m_updateInterval(MilliSeconds(1)),
86 m_geoPosition(0.0, 0.0, 0.0),
87 m_velocity(0.0, 0.0, 0.0),
89{
90 NS_LOG_FUNCTION(this);
91
93}
94
96{
97 NS_LOG_FUNCTION(this);
98}
99
102{
103 NS_LOG_FUNCTION(this);
104
105 return m_geoPosition;
106}
107
108void
110{
111 NS_LOG_FUNCTION(this << position);
112
113 double time = m_updateInterval.GetSeconds();
114 Vector distance = position.ToVector() - m_geoPosition.ToVector();
115 m_velocity = Vector(distance.x / time, distance.y / time, distance.z / time);
116
117 NS_LOG_INFO("Changing position from " << m_geoPosition << " to " << position << ". Velocity is "
118 << m_velocity << " (" << m_velocity.GetLength() << ")");
119
120 m_geoPosition = position;
122}
123
124Vector
126{
127 NS_LOG_FUNCTION(this);
128
129 return DoGetGeoPosition().ToVector();
130}
131
132void
134{
135 NS_LOG_FUNCTION(this << position);
136
138}
139
140Vector
142{
143 NS_LOG_FUNCTION(this);
144
145 return m_velocity;
146}
147
148void
150{
151 NS_LOG_FUNCTION(this);
152
153 GeoCoordinate newPosition =
154 Singleton<SatPositionInputTraceContainer>::Get()->GetPosition(m_traceFilename,
156 DoSetGeoPosition(newPosition);
157
159}
160
161void
163{
164 m_satId = satId;
165}
166
167uint32_t
169{
170 return m_satId;
171}
172
173uint32_t
175{
176 return m_antennaGainPatterns->GetBestBeamId(m_satId, m_geoPosition, ignoreNan);
177}
178
179} // namespace ns3
GeoCoordinate class is used to store and operate with geodetic coordinates.
Vector ToVector() const
Converts Geodetic coordinates to Cartesian coordinates.
SatMobilityModel()
Default constructor.
Satellite mobility model for which the current position change based on values read from a file.
void SetSatId(uint32_t satId)
Set the satellite ID linked to this node.
static TypeId GetTypeId(void)
Get the type ID.
virtual void DoSetPosition(const Vector &position)
uint32_t GetBestBeamId(bool ignoreNan=false) const
Return the best beam ID based on the current position.
Ptr< SatAntennaGainPatternContainer > m_antennaGainPatterns
virtual ~SatTracedMobilityModel()
Destructor for SatMobilityModel.
uint32_t GetSatId(void) const
Return the satellite ID linked to this node.
virtual void DoDispose()
Dispose of this class instance.
virtual GeoCoordinate DoGetGeoPosition(void) const
virtual void DoSetGeoPosition(const GeoCoordinate &position)
GeoCoordinate::ReferenceEllipsoid_t m_refEllipsoid
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.