satellite-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) 2013 Magister Solutions Ltd
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: Sami Rantanen <sami.rantanen@magister.fi>
19  */
20 
22 
23 #include <ns3/boolean.h>
24 #include <ns3/log.h>
25 #include <ns3/trace-source-accessor.h>
26 
27 #include <cmath>
28 
29 namespace ns3
30 {
31 
32 NS_OBJECT_ENSURE_REGISTERED(SatMobilityModel);
33 
34 TypeId
36 {
37  static TypeId tid =
38  TypeId("ns3::SatMobilityModel")
39  .SetParent<MobilityModel>()
40  .AddAttribute("SatPosition",
41  "The current position of the mobility model.",
42  TypeId::ATTR_SET | TypeId::ATTR_GET,
43  GeoCoordinateValue(GeoCoordinate(0.0, 0.0, 0.0)),
44  MakeGeoCoordinateAccessor(&SatMobilityModel::SetGeoPosition,
47  .AddAttribute("AsGeoCoordinates",
48  "SetPosition method takes Geodetic coordinates in given Vector, "
49  "x=longitude, y=latitude, z=altitude",
50  BooleanValue(true),
51  MakeBooleanAccessor(&SatMobilityModel::m_GetAsGeoCoordinates),
52  MakeBooleanChecker())
53  .AddTraceSource("SatCourseChange",
54  "The value of the position and/or velocity coordinate changed",
55  MakeTraceSourceAccessor(&SatMobilityModel::m_satCourseChangeTrace),
56  "ns3::SatMobilityModel::CourseChangeCallback");
57  return tid;
58 }
59 
60 TypeId
62 {
63  return GetTypeId();
64 }
65 
67  : m_cartesianPositionOutdated(false),
68  m_GetAsGeoCoordinates(true)
69 {
70 }
71 
73 {
74 }
75 
78 {
79  return DoGetGeoPosition();
80 }
81 
82 void
84 {
86  DoSetGeoPosition(position);
87 }
88 
89 void
91 {
93  NotifyCourseChange();
94 }
95 
96 Vector
98 {
100  {
101  Vector position = DoGetGeoPosition().ToVector();
102  DoSetCartesianPosition(position);
103  }
104 
105  return m_cartesianPosition;
106 }
107 
108 void
109 SatMobilityModel::DoSetPosition(const Vector& position)
110 {
112  {
114  DoSetGeoPosition(GeoCoordinate(position.x, position.y, position.z));
115  }
116  else
117  {
119  m_cartesianPosition = position;
120  DoSetGeoPosition(GeoCoordinate(position));
121  }
122 }
123 
124 void
125 SatMobilityModel::DoSetCartesianPosition(const Vector& position) const
126 {
128  m_cartesianPosition = position;
129 }
130 
131 } // namespace ns3
GeoCoordinate class is used to store and operate with geodetic coordinates.
Vector ToVector() const
Converts Geodetic coordinates to Cartesian coordinates.
hold objects of type ns3::GeoCoordinate
virtual ~SatMobilityModel()=0
Destructor for SatMobilityModel.
TypeId GetInstanceTypeId(void) const
virtual GeoCoordinate DoGetGeoPosition(void) const =0
static TypeId GetTypeId(void)
Get the type ID.
virtual void DoSetGeoPosition(const GeoCoordinate &position)=0
void DoSetCartesianPosition(const Vector &position) const
This method is used to force update of cartesian position.
virtual Vector DoGetPosition(void) const
SatMobilityModel()
Default constructor.
GeoCoordinate GetGeoPosition(void) const
virtual void DoSetPosition(const Vector &position)
ns3::TracedCallback< Ptr< const SatMobilityModel > > m_satCourseChangeTrace
Used to alert subscribers that a change in direction, velocity, or position has occurred.
void SetGeoPosition(const GeoCoordinate &position)
void NotifyGeoCourseChange(void) const
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Ptr< const AttributeChecker > MakeGeoCoordinateChecker(void)