author | Marco Miozzo <marco.miozzo@cttc.es> |
Fri, 14 Jun 2013 16:13:07 +0200 | |
changeset 10086 | 7fa6d3329928 |
parent 9703 | 681f35b212ff |
child 10410 | 4d4eb8097fa3 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
5979 | 2 |
/* |
3 |
* Copyright (c) 2009 IITP RAS |
|
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: Denis Fakhriev <fakhriev@iitp.ru> |
|
19 |
*/ |
|
20 |
#include <cmath> |
|
21 |
#include "ns3/simulator.h" |
|
22 |
#include "ns3/double.h" |
|
23 |
#include "steady-state-random-waypoint-mobility-model.h" |
|
24 |
#include "ns3/test.h" |
|
25 |
||
26 |
namespace ns3 { |
|
27 |
||
28 |
NS_OBJECT_ENSURE_REGISTERED (SteadyStateRandomWaypointMobilityModel); |
|
29 |
||
30 |
TypeId |
|
31 |
SteadyStateRandomWaypointMobilityModel::GetTypeId (void) |
|
32 |
{ |
|
33 |
static TypeId tid = TypeId ("ns3::SteadyStateRandomWaypointMobilityModel") |
|
34 |
.SetParent<MobilityModel> () |
|
35 |
.SetGroupName ("Mobility") |
|
36 |
.AddConstructor<SteadyStateRandomWaypointMobilityModel> () |
|
37 |
.AddAttribute ("MinSpeed", |
|
38 |
"Minimum speed value, [m/s]", |
|
39 |
DoubleValue (0.3), |
|
40 |
MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_minSpeed), |
|
41 |
MakeDoubleChecker<double> ()) |
|
42 |
.AddAttribute ("MaxSpeed", |
|
43 |
"Maximum speed value, [m/s]", |
|
44 |
DoubleValue (0.7), |
|
45 |
MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_maxSpeed), |
|
46 |
MakeDoubleChecker<double> ()) |
|
47 |
.AddAttribute ("MinPause", |
|
48 |
"Minimum pause value, [s]", |
|
49 |
DoubleValue (0.0), |
|
50 |
MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_minPause), |
|
51 |
MakeDoubleChecker<double> ()) |
|
52 |
.AddAttribute ("MaxPause", |
|
53 |
"Maximum pause value, [s]", |
|
54 |
DoubleValue (0.0), |
|
55 |
MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_maxPause), |
|
56 |
MakeDoubleChecker<double> ()) |
|
57 |
.AddAttribute ("MinX", |
|
58 |
"Minimum X value of traveling region, [m]", |
|
59 |
DoubleValue (1), |
|
60 |
MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_minX), |
|
61 |
MakeDoubleChecker<double> ()) |
|
62 |
.AddAttribute ("MaxX", |
|
63 |
"Maximum X value of traveling region, [m]", |
|
64 |
DoubleValue (1), |
|
65 |
MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_maxX), |
|
66 |
MakeDoubleChecker<double> ()) |
|
67 |
.AddAttribute ("MinY", |
|
68 |
"Minimum Y value of traveling region, [m]", |
|
69 |
DoubleValue (1), |
|
70 |
MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_minY), |
|
71 |
MakeDoubleChecker<double> ()) |
|
72 |
.AddAttribute ("MaxY", |
|
73 |
"Maximum Y value of traveling region, [m]", |
|
74 |
DoubleValue (1), |
|
75 |
MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_maxY), |
|
10086
7fa6d3329928
Update SteadyStateRandomWaypointMobilityModel with fixed z axis values
Marco Miozzo <marco.miozzo@cttc.es>
parents:
9703
diff
changeset
|
76 |
MakeDoubleChecker<double> ()) |
7fa6d3329928
Update SteadyStateRandomWaypointMobilityModel with fixed z axis values
Marco Miozzo <marco.miozzo@cttc.es>
parents:
9703
diff
changeset
|
77 |
.AddAttribute ("Z", |
7fa6d3329928
Update SteadyStateRandomWaypointMobilityModel with fixed z axis values
Marco Miozzo <marco.miozzo@cttc.es>
parents:
9703
diff
changeset
|
78 |
"Z value of traveling region (fixed), [m]", |
7fa6d3329928
Update SteadyStateRandomWaypointMobilityModel with fixed z axis values
Marco Miozzo <marco.miozzo@cttc.es>
parents:
9703
diff
changeset
|
79 |
DoubleValue (0.0), |
7fa6d3329928
Update SteadyStateRandomWaypointMobilityModel with fixed z axis values
Marco Miozzo <marco.miozzo@cttc.es>
parents:
9703
diff
changeset
|
80 |
MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_z), |
5979 | 81 |
MakeDoubleChecker<double> ()); |
7179
9d72cc013844
mobility coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6839
diff
changeset
|
82 |
|
5979 | 83 |
return tid; |
84 |
} |
|
85 |
||
7179
9d72cc013844
mobility coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6839
diff
changeset
|
86 |
SteadyStateRandomWaypointMobilityModel::SteadyStateRandomWaypointMobilityModel () : |
5979 | 87 |
alreadyStarted (false) |
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
88 |
{ |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
89 |
m_speed = CreateObject<UniformRandomVariable> (); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
90 |
m_pause = CreateObject<UniformRandomVariable> (); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
91 |
m_x1_r = CreateObject<UniformRandomVariable> (); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
92 |
m_y1_r = CreateObject<UniformRandomVariable> (); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
93 |
m_x2_r = CreateObject<UniformRandomVariable> (); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
94 |
m_y2_r = CreateObject<UniformRandomVariable> (); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
95 |
m_u_r = CreateObject<UniformRandomVariable> (); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
96 |
m_x = CreateObject<UniformRandomVariable> (); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
97 |
m_y = CreateObject<UniformRandomVariable> (); |
5979 | 98 |
} |
99 |
||
100 |
void |
|
9703
681f35b212ff
Rename Start and DoStart methods to Initialize and DoInitialize
Vedran Miletić <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
101 |
SteadyStateRandomWaypointMobilityModel::DoInitialize (void) |
5979 | 102 |
{ |
9703
681f35b212ff
Rename Start and DoStart methods to Initialize and DoInitialize
Vedran Miletić <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
103 |
DoInitializePrivate (); |
681f35b212ff
Rename Start and DoStart methods to Initialize and DoInitialize
Vedran Miletić <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
104 |
MobilityModel::DoInitialize (); |
5979 | 105 |
} |
106 |
||
107 |
void |
|
9703
681f35b212ff
Rename Start and DoStart methods to Initialize and DoInitialize
Vedran Miletić <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
108 |
SteadyStateRandomWaypointMobilityModel::DoInitializePrivate (void) |
5979 | 109 |
{ |
110 |
alreadyStarted = true; |
|
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
111 |
// Configure random variables based on attributes |
5979 | 112 |
NS_ASSERT (m_minSpeed >= 1e-6); |
113 |
NS_ASSERT (m_minSpeed <= m_maxSpeed); |
|
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
114 |
m_speed->SetAttribute ("Min", DoubleValue (m_minSpeed)); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
115 |
m_speed->SetAttribute ("Max", DoubleValue (m_maxSpeed)); |
5979 | 116 |
NS_ASSERT (m_minX < m_maxX); |
117 |
NS_ASSERT (m_minY < m_maxY); |
|
118 |
m_position = CreateObject<RandomRectanglePositionAllocator> (); |
|
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
119 |
m_x->SetAttribute ("Min", DoubleValue (m_minX)); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
120 |
m_x->SetAttribute ("Max", DoubleValue (m_maxX)); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
121 |
m_y->SetAttribute ("Min", DoubleValue (m_minY)); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
122 |
m_y->SetAttribute ("Max", DoubleValue (m_maxY)); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
123 |
m_position->SetX (m_x); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
124 |
m_position->SetY (m_y); |
5979 | 125 |
NS_ASSERT (m_minPause <= m_maxPause); |
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
126 |
m_pause->SetAttribute ("Min", DoubleValue (m_minPause)); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
127 |
m_pause->SetAttribute ("Max", DoubleValue (m_maxPause)); |
7179
9d72cc013844
mobility coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6839
diff
changeset
|
128 |
|
5979 | 129 |
m_helper.Update (); |
130 |
m_helper.Pause (); |
|
7179
9d72cc013844
mobility coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6839
diff
changeset
|
131 |
|
5979 | 132 |
// calculate the steady-state probability that a node is initially paused |
133 |
double expectedPauseTime = (m_minPause + m_maxPause)/2; |
|
134 |
double a = m_maxX - m_minX; |
|
135 |
double b = m_maxY - m_minY; |
|
136 |
double v0 = m_minSpeed; |
|
137 |
double v1 = m_maxSpeed; |
|
138 |
double log1 = b*b / a*std::log (std::sqrt ((a*a)/(b*b) + 1) + a/b); |
|
139 |
double log2 = a*a / b*std::log (std::sqrt ((b*b)/(a*a) + 1) + b/a); |
|
140 |
double expectedTravelTime = 1.0/6.0*(log1 + log2); |
|
141 |
expectedTravelTime += 1.0/15.0*((a*a*a)/(b*b) + (b*b*b)/(a*a)) - |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7179
diff
changeset
|
142 |
1.0/15.0*std::sqrt (a*a + b*b)*((a*a)/(b*b) + (b*b)/(a*a) - 3); |
5979 | 143 |
if (v0 == v1) |
144 |
{ |
|
145 |
expectedTravelTime /= v0; |
|
146 |
} |
|
147 |
else |
|
148 |
{ |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7179
diff
changeset
|
149 |
expectedTravelTime *= std::log (v1/v0)/(v1 - v0); |
5979 | 150 |
} |
151 |
double probabilityPaused = expectedPauseTime/(expectedPauseTime + expectedTravelTime); |
|
152 |
NS_ASSERT (probabilityPaused >= 0 && probabilityPaused <= 1); |
|
7179
9d72cc013844
mobility coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6839
diff
changeset
|
153 |
|
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
154 |
double u = m_u_r->GetValue (0, 1); |
5979 | 155 |
if (u < probabilityPaused) // node initially paused |
156 |
{ |
|
157 |
m_helper.SetPosition (m_position->GetNext ()); |
|
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
158 |
u = m_u_r->GetValue (0, 1); |
7179
9d72cc013844
mobility coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6839
diff
changeset
|
159 |
Time pause; |
5979 | 160 |
if (m_minPause != m_maxPause) |
161 |
{ |
|
162 |
if (u < (2*m_minPause/(m_minPause + m_maxPause))) |
|
163 |
{ |
|
164 |
pause = Seconds (u*(m_minPause + m_maxPause)/2); |
|
165 |
} |
|
166 |
else |
|
167 |
{ |
|
168 |
// there is an error in equation 20 in the Tech. Report MCS-03-04 |
|
169 |
// this error is corrected in the TMC 2004 paper and below |
|
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
8984
diff
changeset
|
170 |
pause = Seconds (m_maxPause - std::sqrt ((1 - u)*(m_maxPause*m_maxPause - m_minPause*m_minPause))); |
5979 | 171 |
} |
172 |
} |
|
173 |
else // if pause is constant |
|
174 |
{ |
|
175 |
pause = Seconds (u*expectedPauseTime); |
|
176 |
} |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7179
diff
changeset
|
177 |
NS_ASSERT (!m_event.IsRunning ()); |
5979 | 178 |
m_event = Simulator::Schedule (pause, &SteadyStateRandomWaypointMobilityModel::BeginWalk, this); |
179 |
} |
|
180 |
else // node initially moving |
|
181 |
{ |
|
182 |
double x1, x2, y1, y2; |
|
183 |
double r = 0; |
|
184 |
double u1 = 1; |
|
185 |
while (u1 >= r) |
|
186 |
{ |
|
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
187 |
x1 = m_x1_r->GetValue (0, a); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
188 |
y1 = m_y1_r->GetValue (0, b); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
189 |
x2 = m_x2_r->GetValue (0, a); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
190 |
y2 = m_y2_r->GetValue (0, b); |
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
191 |
u1 = m_u_r->GetValue (0, 1); |
5979 | 192 |
r = std::sqrt (((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))/(a*a + b*b)); |
193 |
NS_ASSERT (r <= 1); |
|
194 |
} |
|
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
195 |
double u2 = m_u_r->GetValue (0, 1); |
10086
7fa6d3329928
Update SteadyStateRandomWaypointMobilityModel with fixed z axis values
Marco Miozzo <marco.miozzo@cttc.es>
parents:
9703
diff
changeset
|
196 |
m_helper.SetPosition (Vector (m_minX + u2*x1 + (1 - u2)*x2, m_minY + u2*y1 + (1 - u2)*y2, m_z)); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7179
diff
changeset
|
197 |
NS_ASSERT (!m_event.IsRunning ()); |
5979 | 198 |
m_event = Simulator::ScheduleNow (&SteadyStateRandomWaypointMobilityModel::SteadyStateBeginWalk, this, |
10086
7fa6d3329928
Update SteadyStateRandomWaypointMobilityModel with fixed z axis values
Marco Miozzo <marco.miozzo@cttc.es>
parents:
9703
diff
changeset
|
199 |
Vector (m_minX + x2, m_minY + y2, m_z)); |
5979 | 200 |
} |
201 |
NotifyCourseChange (); |
|
202 |
} |
|
203 |
||
204 |
void |
|
205 |
SteadyStateRandomWaypointMobilityModel::SteadyStateBeginWalk (const Vector &destination) |
|
206 |
{ |
|
207 |
m_helper.Update (); |
|
208 |
Vector m_current = m_helper.GetCurrentPosition (); |
|
209 |
NS_ASSERT (m_minX <= m_current.x && m_current.x <= m_maxX); |
|
210 |
NS_ASSERT (m_minY <= m_current.y && m_current.y <= m_maxY); |
|
211 |
NS_ASSERT (m_minX <= destination.x && destination.x <= m_maxX); |
|
212 |
NS_ASSERT (m_minY <= destination.y && destination.y <= m_maxY); |
|
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
213 |
double u = m_u_r->GetValue (0, 1); |
5979 | 214 |
double speed = std::pow (m_maxSpeed, u)/std::pow (m_minSpeed, u - 1); |
215 |
double dx = (destination.x - m_current.x); |
|
216 |
double dy = (destination.y - m_current.y); |
|
217 |
double dz = (destination.z - m_current.z); |
|
218 |
double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz); |
|
219 |
||
220 |
m_helper.SetVelocity (Vector (k*dx, k*dy, k*dz)); |
|
221 |
m_helper.Unpause (); |
|
222 |
Time travelDelay = Seconds (CalculateDistance (destination, m_current) / speed); |
|
223 |
m_event = Simulator::Schedule (travelDelay, |
|
224 |
&SteadyStateRandomWaypointMobilityModel::Start, this); |
|
225 |
NotifyCourseChange (); |
|
226 |
} |
|
227 |
||
228 |
void |
|
229 |
SteadyStateRandomWaypointMobilityModel::BeginWalk (void) |
|
230 |
{ |
|
231 |
m_helper.Update (); |
|
232 |
Vector m_current = m_helper.GetCurrentPosition (); |
|
233 |
NS_ASSERT (m_minX <= m_current.x && m_current.x <= m_maxX); |
|
234 |
NS_ASSERT (m_minY <= m_current.y && m_current.y <= m_maxY); |
|
235 |
Vector destination = m_position->GetNext (); |
|
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
236 |
double speed = m_speed->GetValue (); |
5979 | 237 |
double dx = (destination.x - m_current.x); |
238 |
double dy = (destination.y - m_current.y); |
|
239 |
double dz = (destination.z - m_current.z); |
|
240 |
double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz); |
|
241 |
||
242 |
m_helper.SetVelocity (Vector (k*dx, k*dy, k*dz)); |
|
243 |
m_helper.Unpause (); |
|
244 |
Time travelDelay = Seconds (CalculateDistance (destination, m_current) / speed); |
|
245 |
m_event = Simulator::Schedule (travelDelay, |
|
7179
9d72cc013844
mobility coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6839
diff
changeset
|
246 |
&SteadyStateRandomWaypointMobilityModel::Start, this); |
5979 | 247 |
NotifyCourseChange (); |
248 |
} |
|
249 |
||
250 |
void |
|
251 |
SteadyStateRandomWaypointMobilityModel::Start (void) |
|
252 |
{ |
|
253 |
m_helper.Update (); |
|
254 |
m_helper.Pause (); |
|
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
7385
diff
changeset
|
255 |
Time pause = Seconds (m_pause->GetValue ()); |
5979 | 256 |
m_event = Simulator::Schedule (pause, &SteadyStateRandomWaypointMobilityModel::BeginWalk, this); |
257 |
NotifyCourseChange (); |
|
258 |
} |
|
259 |
||
260 |
Vector |
|
261 |
SteadyStateRandomWaypointMobilityModel::DoGetPosition (void) const |
|
262 |
{ |
|
263 |
m_helper.Update (); |
|
264 |
return m_helper.GetCurrentPosition (); |
|
265 |
} |
|
266 |
void |
|
267 |
SteadyStateRandomWaypointMobilityModel::DoSetPosition (const Vector &position) |
|
268 |
{ |
|
269 |
if (alreadyStarted) |
|
270 |
{ |
|
271 |
m_helper.SetPosition (position); |
|
272 |
Simulator::Remove (m_event); |
|
273 |
m_event = Simulator::ScheduleNow (&SteadyStateRandomWaypointMobilityModel::Start, this); |
|
274 |
} |
|
275 |
} |
|
276 |
Vector |
|
277 |
SteadyStateRandomWaypointMobilityModel::DoGetVelocity (void) const |
|
278 |
{ |
|
279 |
return m_helper.GetVelocity (); |
|
280 |
} |
|
8984
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
281 |
int64_t |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
282 |
SteadyStateRandomWaypointMobilityModel::DoAssignStreams (int64_t stream) |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
283 |
{ |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
284 |
int64_t positionStreamsAllocated = 0; |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
285 |
m_speed->SetStream (stream); |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
286 |
m_pause->SetStream (stream + 1); |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
287 |
m_x1_r->SetStream (stream + 2); |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
288 |
m_y1_r->SetStream (stream + 3); |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
289 |
m_x2_r->SetStream (stream + 4); |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
290 |
m_y2_r->SetStream (stream + 5); |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
291 |
m_u_r->SetStream (stream + 6); |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
292 |
m_x->SetStream (stream + 7); |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
293 |
m_y->SetStream (stream + 8); |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
294 |
positionStreamsAllocated = m_position->AssignStreams (stream + 9); |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
295 |
return (9 + positionStreamsAllocated); |
85eed149a0ea
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 2)
Mitch Watrous
parents:
8983
diff
changeset
|
296 |
} |
5979 | 297 |
|
298 |
} // namespace ns3 |