00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <math.h>
00022
00023 #include "mobility-model.h"
00024 #include "ns3/trace-source-accessor.h"
00025
00026 namespace ns3 {
00027
00028 TypeId
00029 MobilityModel::GetTypeId (void)
00030 {
00031 static TypeId tid = TypeId ("ns3::MobilityModel")
00032 .SetParent<Object> ()
00033 .AddAttribute ("Position", "The current position of the mobility model.",
00034 TypeId::ATTR_SET | TypeId::ATTR_GET,
00035 VectorValue (Vector (0.0, 0.0, 0.0)),
00036 MakeVectorAccessor (&MobilityModel::SetPosition,
00037 &MobilityModel::GetPosition),
00038 MakeVectorChecker ())
00039 .AddAttribute ("Velocity", "The current velocity of the mobility model.",
00040 TypeId::ATTR_GET,
00041 VectorValue (Vector (0.0, 0.0, 0.0)),
00042 MakeVectorAccessor (&MobilityModel::GetVelocity),
00043 MakeVectorChecker ())
00044 .AddTraceSource ("CourseChange",
00045 "The value of the position and/or velocity vector changed",
00046 MakeTraceSourceAccessor (&MobilityModel::m_courseChangeTrace))
00047 ;
00048 return tid;
00049 }
00050
00051 MobilityModel::MobilityModel ()
00052 {}
00053
00054 MobilityModel::~MobilityModel ()
00055 {}
00056
00057 Vector
00058 MobilityModel::GetPosition (void) const
00059 {
00060 return DoGetPosition ();
00061 }
00062 Vector
00063 MobilityModel::GetVelocity (void) const
00064 {
00065 return DoGetVelocity ();
00066 }
00067
00068 void
00069 MobilityModel::SetPosition (const Vector &position)
00070 {
00071 DoSetPosition (position);
00072 }
00073
00074 double
00075 MobilityModel::GetDistanceFrom (Ptr<const MobilityModel> other) const
00076 {
00077 Vector oPosition = other->DoGetPosition ();
00078 Vector position = DoGetPosition ();
00079 return CalculateDistance (position, oPosition);
00080 }
00081
00082 void
00083 MobilityModel::NotifyCourseChange (void) const
00084 {
00085 m_courseChangeTrace(this);
00086 }
00087
00088 }