-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.node.html
More file actions
670 lines (573 loc) · 36.4 KB
/
Copy pathnode.node.html
File metadata and controls
670 lines (573 loc) · 36.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>node.node module — PyMoSim v0.8 Manual</title>
<link href="_static/css/theme.css" rel="stylesheet" />
<link href="_static/css/index.c5995385ac14fb8791e8eb36b4908be2.css" rel="stylesheet" />
<link rel="stylesheet"
href="_static/vendor/fontawesome/5.13.0/css/all.min.css">
<link rel="preload" as="font" type="font/woff2" crossorigin
href="_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2">
<link rel="preload" as="font" type="font/woff2" crossorigin
href="_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2">
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/basic.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css" />
<link rel="preload" as="script" href="_static/js/index.1c5a1a01449ed65a7b51.js">
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="node.obstacle module" href="node.obstacle.html" />
<link rel="prev" title="node.mobility3 module" href="node.mobility3.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="en" />
</head>
<body data-spy="scroll" data-target="#bd-toc-nav" data-offset="80">
<div class="container-fluid" id="banner"></div>
<nav class="navbar navbar-light navbar-expand-lg bg-light fixed-top bd-navbar" id="navbar-main"><div class="container-xl">
<div id="navbar-start">
<a class="navbar-brand" href="index.html">
<img src="_static/icon.png" class="logo" alt="logo">
</a>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-collapsible" aria-controls="navbar-collapsible" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar-collapsible" class="col-lg-9 collapse navbar-collapse">
<div id="navbar-center" class="mr-auto">
<div class="navbar-center-item">
<ul id="navbar-main-elements" class="navbar-nav">
<li class="toctree-l1 nav-item">
<a class="reference internal nav-link" href="comm.html">
comm package
</a>
</li>
<li class="toctree-l1 current active nav-item">
<a class="reference internal nav-link" href="node.html">
node package
</a>
</li>
<li class="toctree-l1 nav-item">
<a class="reference internal nav-link" href="sim.html">
sim package
</a>
</li>
<li class="toctree-l1 nav-item">
<a class="reference internal nav-link" href="map.html">
map package
</a>
</li>
</ul>
</div>
</div>
<div id="navbar-end">
<div class="navbar-end-item">
<form class="bd-search d-flex align-items-center" action="search.html" method="get">
<i class="icon fas fa-search"></i>
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search the docs ..." aria-label="Search the docs ..." autocomplete="off" >
</form>
</div>
<div class="navbar-end-item">
<ul id="navbar-icon-links" class="navbar-nav" aria-label="Icon Links">
<li class="nav-item">
<a class="nav-link" href="https://github.com/cfoh/pymosim" rel="noopener" target="_blank" title="GitHub">
<span><i class="fab fa-github-square"></i></span>
<label class="sr-only">GitHub</label>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</nav>
<div class="container-xl">
<div class="row">
<!-- Only show if we have sidebars configured, else just a small margin -->
<div class="col-12 col-md-3 bd-sidebar"><form class="bd-search d-flex align-items-center" action="search.html" method="get">
<i class="icon fas fa-search"></i>
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search the docs ..." aria-label="Search the docs ..." autocomplete="off" >
</form><nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
<div class="bd-toc-item active">
<ul class="current nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="node.draw.html">
node.draw module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="node.mobility.html">
node.mobility module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="node.mobility2.html">
node.mobility2 module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="node.mobility2b.html">
node.mobility2b module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="node.mobility3.html">
node.mobility3 module
</a>
</li>
<li class="toctree-l1 current active">
<a class="current reference internal" href="#">
node.node module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="node.obstacle.html">
node.obstacle module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="node.routemobi.html">
node.routemobi module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="node.timer.html">
node.timer module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="node.type.html">
node.type module
</a>
</li>
</ul>
</div>
</nav>
</div>
<div class="d-none d-xl-block col-xl-2 bd-toc">
<div class="toc-item">
<nav id="bd-toc-nav">
</nav>
</div>
<div class="toc-item">
</div>
</div>
<main class="col-12 col-md-9 col-xl-7 py-md-5 pl-md-5 pr-md-4 bd-content" role="main">
<div>
<div class="section" id="module-node.node">
<span id="node-node-module"></span><h1>node.node module<a class="headerlink" href="#module-node.node" title="Permalink to this headline">¶</a></h1>
<p>Module <cite>node</cite> contains an abstract <cite>BaseNode</cite> class which is the base class for
all communication node entities in the simulation.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<ul class="simple">
<li><p>Created by: CH Foh (2021)</p></li>
</ul>
</div>
<dl class="py class">
<dt id="node.node.BaseNode">
<em class="property">class </em><code class="sig-prename descclassname">node.node.</code><code class="sig-name descname">BaseNode</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">simworld</span></em>, <em class="sig-param"><span class="n">id</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">node_type</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">abc.ABC</span></code>, <a class="reference internal" href="node.draw.html#node.draw.Drawing" title="node.draw.Drawing"><code class="xref py py-class docutils literal notranslate"><span class="pre">node.draw.Drawing</span></code></a></p>
<p>This is an abstract base class for all communication node entities to
extend.</p>
<p>The subclass can access to several convenient functions
via the base class. Each node instance should have a unique <cite>id</cite>
to be identified easily. Currently, the recommended data type for
the <cite>id</cite> is string.</p>
<dl class="field-list">
<dt class="field-odd">Attributes</dt>
<dd class="field-odd"><dl>
<dt><strong>id</strong><span class="classifier"><a class="reference internal" href="#node.node.BaseNode.ID" title="node.node.BaseNode.ID"><code class="xref py py-class docutils literal notranslate"><span class="pre">node.node.BaseNode.ID</span></code></a></span></dt><dd><p>The <cite>id</cite> of this node. Ideally, this should be unique for each node
so that a lookup can always find the appropriate node instance based on the <cite>id</cite>.
However, the code will not check for uniqueness.</p>
</dd>
<dt><strong>type</strong><span class="classifier"><a class="reference internal" href="#node.node.BaseNode.Type" title="node.node.BaseNode.Type"><code class="xref py py-class docutils literal notranslate"><span class="pre">node.node.BaseNode.Type</span></code></a></span></dt><dd><p>The <cite>type</cite> of this node. The type is used in the simulation to draw the node
on the screen. Different types will be drawn differently.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Methods</p>
<table class="longtable table autosummary">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#node.node.BaseNode.ID" title="node.node.BaseNode.ID"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ID</span></code></a>(id_str)</p></td>
<td><p>The data structure for the node id.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#node.node.BaseNode.Type" title="node.node.BaseNode.Type"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Type</span></code></a>(node_type)</p></td>
<td><p>The definition of a node type.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">clear_drawing</span></code>()</p></td>
<td><p>Clear the drawing for this node by removing all drawables associated with this node.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">del_circle</span></code>(radius)</p></td>
<td><p>(Deprecated) Remove an earlier added circle for this node.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">del_drawable</span></code>(drawable)</p></td>
<td><p>Remove a specific drawable from the drawing list.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">del_line</span></code>(other_node)</p></td>
<td><p>(Deprecated) Remove an earlier added line for this node.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">del_sector</span></code>(radius, pointing_angle, width_angle)</p></td>
<td><p>(Deprecated) Remove an earlier added sector drawing.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">del_text</span></code>(dx, dy, text)</p></td>
<td><p>(Deprecated) Remove an earlier added text message.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">draw_circle</span></code>(radius[, pen, brush])</p></td>
<td><p>Put a circle around this node where the node is the center of the circle.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">draw_line</span></code>(other_node[, pen, brush])</p></td>
<td><p>Draw a line from this node to <cite>other_node</cite>.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">draw_line_segments</span></code>(points[, pen, brush])</p></td>
<td><p>Draw line segments around this node where (0,0) is the center of the node.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">draw_sector</span></code>(radius, pointing_angle, width_angle)</p></td>
<td><p>Draw a sector where its center is at this node, its radius is <cite>radius</cite> its pointing angle is <cite>pointing_angle</cite>, its width (in degree) is specified in <cite>width_angle</cite>.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">draw_text</span></code>(dx, dy, text, font[, foreground, …])</p></td>
<td><p>Draw a text at around this node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#node.node.BaseNode.get" title="node.node.BaseNode.get"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get</span></code></a>(query_str)</p></td>
<td><p>Query the node to retrieve corresponding information.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#node.node.BaseNode.get_color" title="node.node.BaseNode.get_color"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_color</span></code></a>()</p></td>
<td><p>Get the color that is used to draw this node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#node.node.BaseNode.get_node_list" title="node.node.BaseNode.get_node_list"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_node_list</span></code></a>()</p></td>
<td><p>Provide the list of all nodes.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#node.node.BaseNode.is_disabled" title="node.node.BaseNode.is_disabled"><code class="xref py py-obj docutils literal notranslate"><span class="pre">is_disabled</span></code></a>()</p></td>
<td><p>Use this method to check if a node is disabled.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#node.node.BaseNode.is_visible" title="node.node.BaseNode.is_visible"><code class="xref py py-obj docutils literal notranslate"><span class="pre">is_visible</span></code></a>()</p></td>
<td><p>Use this method to check if a node is visible.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#node.node.BaseNode.lookup" title="node.node.BaseNode.lookup"><code class="xref py py-obj docutils literal notranslate"><span class="pre">lookup</span></code></a>(id)</p></td>
<td><p>This is a static method for performing a lookup for the node with <cite>id</cite>.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#node.node.BaseNode.remove_from_simulation" title="node.node.BaseNode.remove_from_simulation"><code class="xref py py-obj docutils literal notranslate"><span class="pre">remove_from_simulation</span></code></a>()</p></td>
<td><p>This method is used to remove this node from the simulation.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#node.node.BaseNode.reset" title="node.node.BaseNode.reset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">reset</span></code></a>()</p></td>
<td><p>Reset the global node list.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#node.node.BaseNode.reset_color" title="node.node.BaseNode.reset_color"><code class="xref py py-obj docutils literal notranslate"><span class="pre">reset_color</span></code></a>()</p></td>
<td><p>Reset the color for the node to the default color of <cite>wx.BLACK</cite>.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#node.node.BaseNode.set_color" title="node.node.BaseNode.set_color"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_color</span></code></a>(color)</p></td>
<td><p>Set the color to draw for this node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#node.node.BaseNode.set_mobility" title="node.node.BaseNode.set_mobility"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_mobility</span></code></a>(mobility[, direction])</p></td>
<td><p>Set the <cite>mobility</cite> for this instance.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#node.node.BaseNode.set_transceiver" title="node.node.BaseNode.set_transceiver"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_transceiver</span></code></a>(transceiver)</p></td>
<td><p>Use this method to set a transceiver for the node.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#node.node.BaseNode.set_visible" title="node.node.BaseNode.set_visible"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_visible</span></code></a>([flag])</p></td>
<td><p>Use this method to set the visibility of a node.</p></td>
</tr>
</tbody>
</table>
<dl class="py class">
<dt id="node.node.BaseNode.ID">
<em class="property">class </em><code class="sig-name descname">ID</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">id_str</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.ID" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>The data structure for the node id. The current implementation
uses string for the id.</p>
<dl class="py method">
<dt id="node.node.BaseNode.ID.__init__">
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">id_str</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.ID.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt id="node.node.BaseNode.Type">
<em class="property">class </em><code class="sig-name descname">Type</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">node_type</span></em><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.Type" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>The definition of a node type. The animation process will use the
type to decide how to draw the node on the screen. Besides, this
can be used for user simulation to check the belonging of a node and
also conveniently retrieve all nodes of the same type.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This is now an obsolete feature and will be removed soon. Please use
any <a class="reference internal" href="node.type.html#node.type.BaseType" title="node.type.BaseType"><code class="xref py py-class docutils literal notranslate"><span class="pre">node.type.BaseType</span></code></a> subclass for node type instead.</p>
</div>
<dl class="py attribute">
<dt id="node.node.BaseNode.Type.BS">
<code class="sig-name descname">BS</code><em class="property"> = 0</em><a class="headerlink" href="#node.node.BaseNode.Type.BS" title="Permalink to this definition">¶</a></dt>
<dd><p>Use it to describe a base station. A small circle will be drawn to
to represent a base station.</p>
</dd></dl>
<dl class="py attribute">
<dt id="node.node.BaseNode.Type.Vehicle">
<code class="sig-name descname">Vehicle</code><em class="property"> = 1</em><a class="headerlink" href="#node.node.BaseNode.Type.Vehicle" title="Permalink to this definition">¶</a></dt>
<dd><p>Use it to describe a vehicle. A triangle will be drawn to represent
a vehicle.</p>
</dd></dl>
<dl class="py attribute">
<dt id="node.node.BaseNode.Type.Drone">
<code class="sig-name descname">Drone</code><em class="property"> = 2</em><a class="headerlink" href="#node.node.BaseNode.Type.Drone" title="Permalink to this definition">¶</a></dt>
<dd><p>Use it to describe a drone. It is not implemented at the moment.</p>
</dd></dl>
<dl class="py attribute">
<dt id="node.node.BaseNode.Type.UserDefined">
<code class="sig-name descname">UserDefined</code><em class="property"> = 1000</em><a class="headerlink" href="#node.node.BaseNode.Type.UserDefined" title="Permalink to this definition">¶</a></dt>
<dd><p>Set a node to this type for user defined type. If the simulation needs
more than one user defined types, use <cite>UserDefined+1</cite>, <cite>UserDefined+2</cite>, and
so on to extend user defined types. Any number that is larger or equal to
<cite>UserDefined</cite> is considered a user defined type. The animation will not draw
user defined types on the screen, the user simulation must manually draw a
shape or show a bitmap image to indicate the presence of the node.</p>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.Type.__init__">
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">node_type</span></em><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.Type.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.__init__">
<em class="property">abstract </em><code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">simworld</span></em>, <em class="sig-param"><span class="n">id</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">node_type</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>This is the constructor. It must be reimplemented and
super() must be called.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>simworld</strong><span class="classifier"><a class="reference internal" href="sim.simulation.html#sim.simulation.World" title="sim.simulation.World"><code class="xref py py-class docutils literal notranslate"><span class="pre">sim.simulation.World</span></code></a></span></dt><dd><p>To provide the container of the node to be initiated.</p>
</dd>
<dt><strong>id</strong><span class="classifier"><a class="reference internal" href="#node.node.BaseNode.ID" title="node.node.BaseNode.ID"><code class="xref py py-class docutils literal notranslate"><span class="pre">node.node.BaseNode.ID</span></code></a>, default=None</span></dt><dd><p>To provide the <cite>id</cite> of this node.</p>
</dd>
<dt><strong>type</strong><span class="classifier"><a class="reference internal" href="#node.node.BaseNode.Type" title="node.node.BaseNode.Type"><code class="xref py py-class docutils literal notranslate"><span class="pre">node.node.BaseNode.Type</span></code></a>, default=None</span></dt><dd><p>To specify the <cite>type</cite> of this node.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.get_node_list">
<em class="property">static </em><code class="sig-name descname">get_node_list</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.get_node_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Provide the list of all nodes.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>There is no reason why user simulation needs to use this method
to obtain all nodes, since user simulation creates all nodes in
own scenario class and should keep a record of all nodes within
the scenario class.</p>
</div>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.reset">
<em class="property">static </em><code class="sig-name descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Reset the global node list.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>User simulation should not call this method. This method is used
for simulation engine to start a new simulation with proper
initialization.</p>
</div>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.remove_from_simulation">
<code class="sig-name descname">remove_from_simulation</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.remove_from_simulation" title="Permalink to this definition">¶</a></dt>
<dd><p>This method is used to remove this node from the simulation.</p>
<p>In the user simulation, if nodes are allocated dynamically, this method
must be used to remove any unwanted node. Removing a node will inform
the simulation engine to disable it so that it will not interact with other
nodes in the simulation world and will not be shown on the animation.</p>
<p>The method does not immediately delete the node, it marks the node
as disabled. The simulation will ignore the disabled nodes during
the processing. In the simulation loop, when there is a substantial number
of disabled nodes, the simulation will trigger garbage collector to
remove the disabled nodes from the global list.</p>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.is_disabled">
<code class="sig-name descname">is_disabled</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.is_disabled" title="Permalink to this definition">¶</a></dt>
<dd><p>Use this method to check if a node is disabled.</p>
<p>This method is used in the simulation engine. There is no reason to use it
in the user simulation.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><dl class="simple">
<dt>bool</dt><dd><p>Whether the node is disabled. Disabled nodes will not appear on the
simulation world.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.is_visible">
<code class="sig-name descname">is_visible</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.is_visible" title="Permalink to this definition">¶</a></dt>
<dd><p>Use this method to check if a node is visible. Note that the drawing
of user defined types is not managed by the simulation engine, thus the
simulation engine simply ignores the flag. However, the user may use
this flag for own indication to manually control the visibility of this
node.</p>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.set_visible">
<code class="sig-name descname">set_visible</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">flag</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.set_visible" title="Permalink to this definition">¶</a></dt>
<dd><p>Use this method to set the visibility of a node. Note that the drawing
of user defined types is not managed by the simulation engine, thus the
simulation engine simply ignores the flag. However, the user may use
this flag for own indication to manually control the visibility of this
node.</p>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.set_color">
<code class="sig-name descname">set_color</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">color</span></em><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.set_color" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the color to draw for this node.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>color</strong><span class="classifier">color constant defined in wx</span></dt><dd><p>The color to draw.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.get_color">
<code class="sig-name descname">get_color</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.get_color" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the color that is used to draw this node.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><dl class="simple">
<dt>Color constant defined in wx</dt><dd><p>The color for this node.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.reset_color">
<code class="sig-name descname">reset_color</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.reset_color" title="Permalink to this definition">¶</a></dt>
<dd><p>Reset the color for the node to the default color of <cite>wx.BLACK</cite>.</p>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.get">
<code class="sig-name descname">get</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">query_str</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Query the node to retrieve corresponding information.</p>
<p>The information can be queried includes:</p>
<ul class="simple">
<li><p>“location”: the current location of the node, return an instance of
<a class="reference internal" href="sim.loc.html#sim.loc.LOC" title="sim.loc.LOC"><code class="xref py py-class docutils literal notranslate"><span class="pre">sim.loc.LOC</span></code></a> subclass.</p></li>
<li><p>“direction”: the current moving direction of the node, return an instance
of <a class="reference internal" href="sim.direction.html#sim.direction.DIR" title="sim.direction.DIR"><code class="xref py py-class docutils literal notranslate"><span class="pre">sim.direction.DIR</span></code></a> subclass.</p></li>
<li><p>“speed”: the targeted moving speed of the node, return a float. The actual speed
can be lower due to other slow moving vehicles in front.</p></li>
<li><p>“displacement”: the distance travelled in the last simulation step, return a float.
Displacement can be useful to calculate the actual speed.
(Note: currently not supported, throws system error if called)</p></li>
<li><p>“mobility”: the mobility instance of the node, return an instance of
<a class="reference internal" href="node.mobility.html#node.mobility.BaseMobility" title="node.mobility.BaseMobility"><code class="xref py py-class docutils literal notranslate"><span class="pre">node.mobility.BaseMobility</span></code></a> subclass.</p></li>
<li><p>“transceiver”: the transceiver instance of the node.</p></li>
<li><p>“simworld”: the simulation world instance, user simulation is
already given this instance during the creation event, so it is unnecessary
to use this method to get the instance again.</p></li>
</ul>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>query_str</strong><span class="classifier">str</span></dt><dd><p>The query string. See also above.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.set_mobility">
<code class="sig-name descname">set_mobility</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">mobility</span></em>, <em class="sig-param"><span class="n">direction</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.set_mobility" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the <cite>mobility</cite> for this instance. It is important to set a mobility
to a node even it is stationary, as mobility contains location and direction
information used in the simulation.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>mobility</strong><span class="classifier"><a class="reference internal" href="node.mobility.html#node.mobility.BaseMobility" title="node.mobility.BaseMobility"><code class="xref py py-class docutils literal notranslate"><span class="pre">node.mobility.BaseMobility</span></code></a> subclass</span></dt><dd><p>The <cite>mobility</cite> model for this node.</p>
</dd>
<dt><strong>direction</strong><span class="classifier"><a class="reference internal" href="sim.direction.html#sim.direction.DIR" title="sim.direction.DIR"><code class="xref py py-class docutils literal notranslate"><span class="pre">sim.direction.DIR</span></code></a> subclass, optional, default=None</span></dt><dd><p>The <cite>direction</cite> of the node. If None is given, the default setting will
be a constant north pointing direction.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.set_transceiver">
<code class="sig-name descname">set_transceiver</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">transceiver</span></em><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.set_transceiver" title="Permalink to this definition">¶</a></dt>
<dd><p>Use this method to set a transceiver for the node. A transceiver is
needed for communications.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>transceiver</strong><span class="classifier"><a class="reference internal" href="comm.transceiver.html#comm.transceiver.Transceiver" title="comm.transceiver.Transceiver"><code class="xref py py-class docutils literal notranslate"><span class="pre">comm.transceiver.Transceiver</span></code></a></span></dt><dd><p>The transceiver for this node. The transceiver provides a collection
of functions for communications.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="node.node.BaseNode.lookup">
<em class="property">static </em><code class="sig-name descname">lookup</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">id</span><span class="p">:</span> <span class="n"><a class="reference internal" href="#node.node.BaseNode.ID" title="node.node.BaseNode.ID">node.node.BaseNode.ID</a></span></em><span class="sig-paren">)</span><a class="headerlink" href="#node.node.BaseNode.lookup" title="Permalink to this definition">¶</a></dt>
<dd><p>This is a static method for performing a lookup for the node with <cite>id</cite>.</p>
<p>This method acts like a local DNS, but we use <cite>id</cite> instead of a DNS
name, and we retrieve from the global lookup table instead of via
network DNS query. Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">node.node</span> <span class="kn">import</span> <span class="n">BaseNode</span>
<span class="n">my_node</span> <span class="o">=</span> <span class="n">BaseNode</span><span class="o">.</span><span class="n">lookup</span><span class="p">(</span><span class="s2">"vehicle1"</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>id</strong><span class="classifier"><a class="reference internal" href="#node.node.BaseNode.ID" title="node.node.BaseNode.ID"><code class="xref py py-class docutils literal notranslate"><span class="pre">node.node.BaseNode.ID</span></code></a></span></dt><dd><p>The <cite>id</cite> to lookup.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><a class="reference internal" href="#node.node.BaseNode" title="node.node.BaseNode"><code class="xref py py-class docutils literal notranslate"><span class="pre">node.node.BaseNode</span></code></a> subclass</dt><dd><p>The node instance that carries the <cite>id</cite>, or <cite>None</cite> if not found.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>
</div>
</main>
</div>
</div>
<script src="_static/js/index.1c5a1a01449ed65a7b51.js"></script>
<footer class="footer mt-5 mt-md-0">
<div class="container">
<div class="footer-item">
<p class="copyright">
© Copyright 2021, cfoh.<br/>
</p>
</div>
<div class="footer-item">
<p class="sphinx-version">
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 3.4.3.<br/>
</p>
</div>
</div>
</footer>
</body>
</html>