Loading...
Searching...
No Matches
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#include <stdint.h>
29
30namespace ns3
31{
32
33NS_OBJECT_ENSURE_REGISTERED(SatMobilityModel);
34
35TypeId
37{
38 static TypeId tid =
39 TypeId("ns3::SatMobilityModel")
40 .SetParent<MobilityModel>()
41 .AddAttribute("SatPosition",
42 "The current position of the mobility model.",
43 TypeId::ATTR_SET | TypeId::ATTR_GET,
44 GeoCoordinateValue(GeoCoordinate(0.0, 0.0, 0.0)),
45 MakeGeoCoordinateAccessor(&SatMobilityModel::SetGeoPosition,
48 .AddAttribute("AsGeoCoordinates",
49 "SetPosition method takes Geodetic coordinates in given Vector, "
50 "x=longitude, y=latitude, z=altitude",
51 BooleanValue(true),
52 MakeBooleanAccessor(&SatMobilityModel::m_GetAsGeoCoordinates),
53 MakeBooleanChecker())
54 .AddTraceSource("SatCourseChange",
55 "The value of the position and/or velocity coordinate changed",
56 MakeTraceSourceAccessor(&SatMobilityModel::m_satCourseChangeTrace),
57 "ns3::SatMobilityModel::CourseChangeCallback");
58 return tid;
59}
60
66
70
73{
74 return DoGetGeoPosition();
75}
76
77void
83
84double
85SatMobilityModel::GetDistanceFrom(Ptr<const SatMobilityModel> other) const
86{
87 Vector oPosition = other->DoGetGeoPosition().ToVector();
88 Vector position = DoGetGeoPosition().ToVector();
89 return CalculateDistance(position, oPosition);
90}
91
92void
94{
96 NotifyCourseChange();
97}
98
99Vector
101{
103 {
104 Vector position = DoGetGeoPosition().ToVector();
105 DoSetCartesianPosition(position);
106 }
107
108 return m_cartesianPosition;
109}
110
111void
112SatMobilityModel::DoSetPosition(const Vector& position)
113{
115 {
117 DoSetGeoPosition(GeoCoordinate(position.x, position.y, position.z));
118 }
119 else
120 {
122 m_cartesianPosition = position;
124 }
125}
126
127void
128SatMobilityModel::DoSetCartesianPosition(const Vector& position) const
129{
131 m_cartesianPosition = position;
132}
133
134} // 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
Keep track of the current position and velocity of an object in satellite network.
virtual ~SatMobilityModel()=0
Destructor for SatMobilityModel.
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.
double GetDistanceFrom(Ptr< const SatMobilityModel > position) const
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)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Ptr< const AttributeChecker > MakeGeoCoordinateChecker(void)