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 NS_LOG_COMPONENT_DEFINE("SatTracedMobilityModel");
31 
32 namespace ns3
33 {
34 
35 NS_OBJECT_ENSURE_REGISTERED(SatTracedMobilityModel);
36 
37 TypeId
39 {
40  static TypeId tid =
41  TypeId("ns3::SatTracedMobilityModel")
42  .SetParent<SatMobilityModel>()
43  .AddConstructor<SatTracedMobilityModel>()
44  .AddAttribute("ReferenceEllipsoid",
45  "Reference Ellipsoid model to use when reading coordinates",
46  EnumValue(GeoCoordinate::SPHERE),
47  MakeEnumAccessor(&SatTracedMobilityModel::m_refEllipsoid),
48  MakeEnumChecker(GeoCoordinate::SPHERE,
49  "Sphere",
51  "WGS84",
53  "GRS80"))
54  .AddAttribute("UpdateInterval",
55  "Interval at which the position should update",
56  TimeValue(MilliSeconds(1)),
58  MakeTimeChecker(FemtoSeconds(1)));
59 
60  return tid;
61 }
62 
63 TypeId
65 {
66  return GetTypeId();
67 }
68 
69 void
71 {
72  m_antennaGainPatterns = NULL;
73 
74  Object::DoDispose();
75 }
76 
78 {
79  NS_FATAL_ERROR("SatTracedMobilityModel default constructor should not be used");
80 }
81 
83  const std::string& filename,
84  Ptr<SatAntennaGainPatternContainer> agp)
85  : m_satId(satId),
86  m_traceFilename(filename),
87  m_updateInterval(MilliSeconds(1)),
88  m_refEllipsoid(GeoCoordinate::SPHERE),
89  m_geoPosition(0.0, 0.0, 0.0),
90  m_velocity(0.0, 0.0, 0.0),
91  m_antennaGainPatterns(agp)
92 {
93  NS_LOG_FUNCTION(this);
94 
96 }
97 
99 {
100  NS_LOG_FUNCTION(this);
101 }
102 
105 {
106  NS_LOG_FUNCTION(this);
107 
108  return m_geoPosition;
109 }
110 
111 void
113 {
114  NS_LOG_FUNCTION(this << position);
115 
116  double time = m_updateInterval.GetSeconds();
117  Vector distance = position.ToVector() - m_geoPosition.ToVector();
118  m_velocity = Vector(distance.x / time, distance.y / time, distance.z / time);
119 
120  NS_LOG_INFO("Changing position from " << m_geoPosition << " to " << position << ". Velocity is "
121  << m_velocity << " (" << m_velocity.GetLength() << ")");
122 
123  m_geoPosition = position;
125 }
126 
127 Vector
129 {
130  NS_LOG_FUNCTION(this);
131 
132  return m_velocity;
133 }
134 
135 void
137 {
138  NS_LOG_FUNCTION(this);
139 
140  GeoCoordinate newPosition =
141  Singleton<SatPositionInputTraceContainer>::Get()->GetPosition(m_traceFilename,
143  DoSetGeoPosition(newPosition);
144 
146 }
147 
148 uint32_t
150 {
151  return m_antennaGainPatterns->GetBestBeamId(m_satId, m_geoPosition, false);
152 }
153 
154 } // namespace ns3
GeoCoordinate class is used to store and operate with geodetic coordinates.
Vector ToVector() const
Converts Geodetic coordinates to Cartesian coordinates.
Keep track of the current position and velocity of an object in satellite network.
void NotifyGeoCourseChange(void) const
uint32_t GetBestBeamId(void) const
Return the best beam ID based on the current position.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< SatAntennaGainPatternContainer > m_antennaGainPatterns
virtual ~SatTracedMobilityModel()
Destructor for SatMobilityModel.
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.