vlcSim 0.2.6__tar.gz → 0.3.0__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.0
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.0",
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.0
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:
@@ -5,6 +5,7 @@ This module work with the classes belonging to the Scene. It manages the physica
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:
@@ -834,6 +835,9 @@ class Receiver:
834
835
 
835
836
  class Scenario:
836
837
  numberOfAPs = 0
838
+ warnings.filterwarnings(
839
+ "ignore", message="invalid value encountered in double_scalars"
840
+ )
837
841
 
838
842
  def __init__(
839
843
  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