vlcSim 0.2.6__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vlcSim
3
- Version: 0.2.6
3
+ Version: 0.3.1
4
4
  Summary: Python Package of Event-Oriented Simulation for visible light communication
5
5
  Home-page: https://gitlab.com/DaniloBorquez/simvlc/
6
6
  Author: Danilo Bórquez-Paredes
@@ -10,7 +10,7 @@ long_description = (this_directory / "README.md").read_text()
10
10
 
11
11
  setup(
12
12
  name="vlcSim",
13
- version="0.2.6",
13
+ version="0.3.1",
14
14
  license="MIT",
15
15
  description="Python Package of Event-Oriented Simulation for visible light communication",
16
16
  author="Danilo Bórquez-Paredes",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vlcSim
3
- Version: 0.2.6
3
+ Version: 0.3.1
4
4
  Summary: Python Package of Event-Oriented Simulation for visible light communication
5
5
  Home-page: https://gitlab.com/DaniloBorquez/simvlc/
6
6
  Author: Danilo Bórquez-Paredes
@@ -5,6 +5,7 @@ The :mod:`vlcsim.controller` module is in charge of managing the connections and
5
5
  from .scene import *
6
6
  from enum import Enum
7
7
  import math
8
+ import sys
8
9
 
9
10
 
10
11
  class Connection:
@@ -32,6 +33,15 @@ class Connection:
32
33
  self.__goalTime = None
33
34
  self.__time = time
34
35
  self.__capacityRequired = None
36
+ self.__snr = sys.float_info.min
37
+
38
+ @property
39
+ def snr(self):
40
+ return self.__snr
41
+
42
+ @snr.setter
43
+ def snr(self, value):
44
+ self.__snr = value
35
45
 
36
46
  @property
37
47
  def capacityRequired(self) -> float:
@@ -1,15 +1,22 @@
1
1
  """
2
- This module work with the classes belonging to the Scene. It manages the physical sustrate.
2
+ It manages the physical sustrate.
3
3
  """
4
4
 
5
5
  import numpy as np
6
6
  import math as m
7
7
  from enum import Enum
8
+ import warnings
8
9
 
9
10
 
10
11
  class AccessPoint:
11
12
  """
12
- Class representing a generic access point
13
+ Class representing a generic access point. The :class:`vlcsim.scene.AccessPoint` class is in charge of managing the physical sustrate. It has the following attributes:
14
+
15
+ - **x**: **x** coordinate of the position of this VLed.
16
+ - **y**: **y** coordinate of the position of this VLed.
17
+ - **z**: **z** coordinate of the position of this VLed.
18
+ - **state**: Current state of the access point. Could be IDLE or BUSY.
19
+ - **sliceTime**: Time of the slice in [s]
13
20
  """
14
21
 
15
22
  stateap = Enum("state", "IDLE BUSY")
@@ -531,21 +538,21 @@ class Receiver:
531
538
  :param z: z coordinate of the object's coordinate.
532
539
  :param aDet: aDet value of the object's coordinate.
533
540
  :param ts: time of the object's coordinate. Default is 10 seconds.
534
- :param index
541
+ :param index:
535
542
  :param fov: q of the object. Default is 1. 6e - 19.
536
- :param q
543
+ :param q:
537
544
  :param s: ibg b - parameter of the Ib - Galactic model. Default i 5 seconds.
538
545
  :param b: c b - parameter of the Ib - Galactic model. Default is 5 seconds.
539
- :param ibg
540
- :param cb
541
- :param tk
546
+ :param ibg:
547
+ :param cb:
548
+ :param tk:
542
549
  :param a: n n - prameter of the B - parameter. Default is 10 seconds.
543
- :param gv
544
- :param n
545
- :param fr
546
- :param gm
547
- :param i1
548
- :param i2
550
+ :param gv:
551
+ :param n:
552
+ :param fr:
553
+ :param gm:
554
+ :param i1:
555
+ :param i2:
549
556
  """
550
557
  self.__x = x
551
558
  self.__y = y
@@ -834,6 +841,9 @@ class Receiver:
834
841
 
835
842
  class Scenario:
836
843
  numberOfAPs = 0
844
+ warnings.filterwarnings(
845
+ "ignore", message="invalid value encountered in double_scalars"
846
+ )
837
847
 
838
848
  def __init__(
839
849
  self, width: float, length: float, height: float, nGrids: int, rho: float
@@ -92,6 +92,9 @@ class Simulator:
92
92
  self.__upper_capacity_required = None
93
93
  self.__lower_capacity_required = None
94
94
 
95
+ self.__users_by_vlc = []
96
+ self.__users_by_rf = []
97
+
95
98
  self.default_values()
96
99
 
97
100
  def default_values(self):
@@ -273,7 +276,30 @@ class Simulator:
273
276
  )
274
277
  )
275
278
 
276
- print("=" * 120)
279
+ print(f"Number of VLeds: {self.__controller.scenario.numberOfVLeds}")
280
+ print("Positions:")
281
+ print(" ID | X | Y | Z |")
282
+ print("-" * 47)
283
+ for vled in self.__controller.scenario.vleds:
284
+ print(
285
+ "{:>10} | {:8.4f} | {:8.4f} | {:8.4f} |".format(
286
+ vled.ID, vled.x, vled.y, vled.z
287
+ )
288
+ )
289
+ print()
290
+ print(f"Number of RFs: {self.__controller.scenario.numberOfRFs}")
291
+ print("Positions:")
292
+ print(" ID | X | Y | Z |")
293
+ print("-" * 47)
294
+ for rf in self.__controller.scenario.rfs:
295
+ print(
296
+ "{:>10} | {:8.4f} | {:8.4f} | {:8.4f} |".format(
297
+ rf.ID, rf.x, rf.y, rf.z
298
+ )
299
+ )
300
+ print()
301
+
302
+ print("=" * 146)
277
303
  print("| Time ", end="")
278
304
  print("| Event ", end="")
279
305
  print("| Receiver ", end="")
@@ -282,8 +308,10 @@ class Simulator:
282
308
  print("| Z ", end="")
283
309
  print("| Access Point (A.C.) ", end="")
284
310
  print("| Goal time ", end="")
285
- print("| Elapsed time |")
286
- print("=" * 120)
311
+ print("| Elapsed time ", end="")
312
+ print("| SNR ", end="")
313
+ print("| Req. Cap. |")
314
+ print("=" * 146)
287
315
 
288
316
  def print_row(self, event):
289
317
  text = ""
@@ -339,6 +367,8 @@ class Simulator:
339
367
  # event.type,
340
368
  # event.id_connection,
341
369
  # )
370
+ text += "{:10.2e}".format(event.connection.snr) + " |"
371
+ text += "{:10.2e}".format(event.connection.capacityRequired) + " |"
342
372
  print(text)
343
373
 
344
374
  def event_routine(self):
@@ -395,6 +425,10 @@ class Simulator:
395
425
  next_status == Controller.nextStatus.RESUME
396
426
  or next_status == Controller.nextStatus.PAUSE
397
427
  ):
428
+ if type(connection.AP) == VLed:
429
+ self.__users_by_vlc[connection.AP.ID] += 1
430
+ elif type(connection.AP) == RF:
431
+ self.__users_by_rf[connection.AP.ID] += 1
398
432
  self.__current_event.connection = connection
399
433
  if next_status == Controller.nextStatus.RESUME:
400
434
  for pos in range(len(self.__events) - 1, -1, -1):
@@ -545,6 +579,10 @@ class Simulator:
545
579
  and self.__controller.scenario.numberOfRFs == 0
546
580
  ):
547
581
  raise ("The scenario does not have any Vleds or RFs")
582
+ for _ in range(self.__controller.scenario.numberOfVLeds):
583
+ self.__users_by_vlc.append(0)
584
+ for _ in range(self.__controller.scenario.numberOfRFs):
585
+ self.__users_by_rf.append(0)
548
586
  return
549
587
 
550
588
  def run(self):
@@ -552,6 +590,7 @@ class Simulator:
552
590
  while self.__numberOfConnections <= self.__goalConnections:
553
591
  # for i in range(self.__goalConnections):
554
592
  self.event_routine()
593
+ self.aggregated_metrics()
555
594
 
556
595
  def time_duration(self):
557
596
  return self.__time_duration
@@ -568,3 +607,14 @@ class Simulator:
568
607
  @property
569
608
  def scenario(self):
570
609
  return self.__controller.scenario
610
+
611
+ def aggregated_metrics(self):
612
+ print("Number of users connected to each VLed")
613
+ for i in range(self.__controller.scenario.numberOfVLeds):
614
+ id = self.__controller.scenario.vleds[i].ID
615
+ print(f"VLed {id}: {self.__users_by_vlc[id]}")
616
+
617
+ print("Number of users connected to each RF")
618
+ for i in range(self.__controller.scenario.numberOfRFs):
619
+ id = self.__controller.scenario.rfs[i].ID
620
+ print(f"RF {id}: {self.__users_by_rf[id]}")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes