vlcSim 0.2.3__tar.gz → 0.2.4__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.
- {vlcSim-0.2.3 → vlcSim-0.2.4}/PKG-INFO +63 -13
- vlcSim-0.2.4/README.md +133 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/setup.py +1 -1
- {vlcSim-0.2.3 → vlcSim-0.2.4}/vlcSim.egg-info/PKG-INFO +63 -13
- vlcSim-0.2.3/README.md +0 -83
- {vlcSim-0.2.3 → vlcSim-0.2.4}/LICENSE.md +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/setup.cfg +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/test/test_receiver.py +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/test/test_scenario.py +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/test/test_vled.py +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/vlcSim.egg-info/SOURCES.txt +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/vlcSim.egg-info/dependency_links.txt +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/vlcSim.egg-info/not-zip-safe +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/vlcSim.egg-info/requires.txt +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/vlcSim.egg-info/top_level.txt +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/vlcsim/__init__.py +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/vlcsim/controller.py +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/vlcsim/scene.py +0 -0
- {vlcSim-0.2.3 → vlcSim-0.2.4}/vlcsim/simulator.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vlcSim
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
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
|
|
@@ -36,18 +36,53 @@ Next example could be used to start coding with the package:
|
|
|
36
36
|
|
|
37
37
|
```python
|
|
38
38
|
from vlcsim import *
|
|
39
|
+
import math
|
|
39
40
|
|
|
40
41
|
|
|
41
|
-
def alloc(receiver, connection, scenario: Scenario, controller: Controller):
|
|
42
|
+
def alloc(receiver, connection: Connection, scenario: Scenario, controller: Controller):
|
|
42
43
|
vleds = scenario.vleds
|
|
43
|
-
|
|
44
|
+
capacities = []
|
|
44
45
|
for vled in vleds:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if controller.numberOfActiveConnections(
|
|
48
|
-
|
|
46
|
+
capacities.append(scenario.capacityVled(receiver, vled))
|
|
47
|
+
posBestCapacity = capacities.index(max(capacities))
|
|
48
|
+
if controller.numberOfActiveConnections(posBestCapacity) > 5:
|
|
49
|
+
connection.AP = scenario.rfs[0]
|
|
49
50
|
else:
|
|
50
|
-
connection.AP = vleds[
|
|
51
|
+
connection.AP = vleds[posBestCapacity]
|
|
52
|
+
|
|
53
|
+
numberOfSlices = connection.numberOfSlicesNeeded(
|
|
54
|
+
connection.capacityRequired, capacities[posBestCapacity]
|
|
55
|
+
)
|
|
56
|
+
connection.receiver.capacityFromAP = capacities[posBestCapacity]
|
|
57
|
+
actualSlice = connection.nextSliceInAPWhenArriving(connection.AP)
|
|
58
|
+
aux = 0
|
|
59
|
+
|
|
60
|
+
# Actual frame
|
|
61
|
+
for slice in range(actualSlice, connection.AP.slicesInFrame):
|
|
62
|
+
if (
|
|
63
|
+
len(controller.framesState(connection.AP)) == 0
|
|
64
|
+
or controller.framesState(connection.AP)[0][slice] == False
|
|
65
|
+
):
|
|
66
|
+
connection.assignFrameSlice(0, slice)
|
|
67
|
+
aux += 1
|
|
68
|
+
break
|
|
69
|
+
|
|
70
|
+
# next frames
|
|
71
|
+
for frameIndex in range(1, len(controller.framesState(connection.AP))):
|
|
72
|
+
for slice in range(connection.AP.slicesInFrame):
|
|
73
|
+
if controller.framesState(connection.AP)[frameIndex][slice] == False:
|
|
74
|
+
connection.assignFrameSlice(frameIndex, slice)
|
|
75
|
+
aux += 1
|
|
76
|
+
break
|
|
77
|
+
|
|
78
|
+
if aux == numberOfSlices:
|
|
79
|
+
break
|
|
80
|
+
|
|
81
|
+
frameIndex = len(controller.framesState(connection.AP))
|
|
82
|
+
while aux < numberOfSlices:
|
|
83
|
+
connection.assignFrameSlice(frameIndex, 0)
|
|
84
|
+
frameIndex += 1
|
|
85
|
+
aux += 1
|
|
51
86
|
return Controller.status.ALLOCATED, connection
|
|
52
87
|
|
|
53
88
|
|
|
@@ -58,21 +93,31 @@ if __name__ == "__main__":
|
|
|
58
93
|
|
|
59
94
|
# Adding Vleds to the room
|
|
60
95
|
vled = VLed(-1.25, -1.25, 2.15, 60, 60, 20, 70)
|
|
61
|
-
vled.sliceTime = 2
|
|
96
|
+
vled.sliceTime = 0.2
|
|
97
|
+
vled.slicesInFrame = 10
|
|
98
|
+
vled.B = 0.5e5
|
|
62
99
|
sim.scenario.addVLed(vled)
|
|
63
100
|
vled = VLed(-1.25, 1.25, 2.15, 60, 60, 20, 70)
|
|
64
|
-
vled.sliceTime = 2
|
|
101
|
+
vled.sliceTime = 0.2
|
|
102
|
+
vled.slicesInFrame = 10
|
|
103
|
+
vled.B = 0.5e5
|
|
65
104
|
sim.scenario.addVLed(vled)
|
|
66
105
|
vled = VLed(1.25, -1.25, 2.15, 60, 60, 20, 70)
|
|
67
|
-
vled.sliceTime = 2
|
|
106
|
+
vled.sliceTime = 0.2
|
|
107
|
+
vled.slicesInFrame = 10
|
|
108
|
+
vled.B = 0.5e5
|
|
68
109
|
sim.scenario.addVLed(vled)
|
|
69
110
|
vled = VLed(1.25, 1.25, 2.15, 60, 60, 20, 70)
|
|
70
|
-
vled.sliceTime = 2
|
|
111
|
+
vled.sliceTime = 0.2
|
|
112
|
+
vled.slicesInFrame = 10
|
|
113
|
+
vled.B = 0.5e5
|
|
71
114
|
sim.scenario.addVLed(vled)
|
|
72
115
|
|
|
73
116
|
# Adding rf
|
|
74
117
|
rf = RF(0, 0, 0.85)
|
|
75
|
-
rf.sliceTime = 2
|
|
118
|
+
rf.sliceTime = 0.2
|
|
119
|
+
rf.slicesInFrame = 10
|
|
120
|
+
rf.B = 0.5e5
|
|
76
121
|
sim.scenario.addRF(rf)
|
|
77
122
|
|
|
78
123
|
# setting algorithm and number of connections
|
|
@@ -84,14 +129,19 @@ if __name__ == "__main__":
|
|
|
84
129
|
sim.mu = 10
|
|
85
130
|
|
|
86
131
|
# changing random wait limits
|
|
132
|
+
|
|
87
133
|
sim.upper_random_wait = 20
|
|
88
134
|
sim.lower_random_wait = 2
|
|
89
135
|
|
|
136
|
+
sim.lower_capacity_required = 1e5
|
|
137
|
+
sim.upper_capacity_required = 5e5
|
|
138
|
+
|
|
90
139
|
# initialize and run
|
|
91
140
|
sim.init()
|
|
92
141
|
sim.run()
|
|
93
142
|
|
|
94
143
|
|
|
144
|
+
|
|
95
145
|
```
|
|
96
146
|
|
|
97
147
|
|
vlcSim-0.2.4/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
VLCSim is an Event-Oriented simulator package for Visible Light Communication.
|
|
2
|
+
|
|
3
|
+
# Features
|
|
4
|
+
|
|
5
|
+
- Dynamic Environment with in/out connections
|
|
6
|
+
- Flexible resource allocation algorithm
|
|
7
|
+
- Flexible VLC/room parameters
|
|
8
|
+
|
|
9
|
+
# Events
|
|
10
|
+
|
|
11
|
+
The simulator has 5 Type of events:
|
|
12
|
+
|
|
13
|
+
* **ARRIVE**: Every time when a connection arrives to the system
|
|
14
|
+
* **RESUME**: When a connection begin the transmission
|
|
15
|
+
* **PAUSE**: When a Connection PAUSES the transmission
|
|
16
|
+
* **DEPARTURE**: When a connectin ends its transmission
|
|
17
|
+
* **RETRYING**: WHen a connection is not allocated, and uses a WAIT status, it makes a new attepmt to connect.
|
|
18
|
+
|
|
19
|
+
# Code example
|
|
20
|
+
|
|
21
|
+
Next example could be used to start coding with the package:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from vlcsim import *
|
|
25
|
+
import math
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def alloc(receiver, connection: Connection, scenario: Scenario, controller: Controller):
|
|
29
|
+
vleds = scenario.vleds
|
|
30
|
+
capacities = []
|
|
31
|
+
for vled in vleds:
|
|
32
|
+
capacities.append(scenario.capacityVled(receiver, vled))
|
|
33
|
+
posBestCapacity = capacities.index(max(capacities))
|
|
34
|
+
if controller.numberOfActiveConnections(posBestCapacity) > 5:
|
|
35
|
+
connection.AP = scenario.rfs[0]
|
|
36
|
+
else:
|
|
37
|
+
connection.AP = vleds[posBestCapacity]
|
|
38
|
+
|
|
39
|
+
numberOfSlices = connection.numberOfSlicesNeeded(
|
|
40
|
+
connection.capacityRequired, capacities[posBestCapacity]
|
|
41
|
+
)
|
|
42
|
+
connection.receiver.capacityFromAP = capacities[posBestCapacity]
|
|
43
|
+
actualSlice = connection.nextSliceInAPWhenArriving(connection.AP)
|
|
44
|
+
aux = 0
|
|
45
|
+
|
|
46
|
+
# Actual frame
|
|
47
|
+
for slice in range(actualSlice, connection.AP.slicesInFrame):
|
|
48
|
+
if (
|
|
49
|
+
len(controller.framesState(connection.AP)) == 0
|
|
50
|
+
or controller.framesState(connection.AP)[0][slice] == False
|
|
51
|
+
):
|
|
52
|
+
connection.assignFrameSlice(0, slice)
|
|
53
|
+
aux += 1
|
|
54
|
+
break
|
|
55
|
+
|
|
56
|
+
# next frames
|
|
57
|
+
for frameIndex in range(1, len(controller.framesState(connection.AP))):
|
|
58
|
+
for slice in range(connection.AP.slicesInFrame):
|
|
59
|
+
if controller.framesState(connection.AP)[frameIndex][slice] == False:
|
|
60
|
+
connection.assignFrameSlice(frameIndex, slice)
|
|
61
|
+
aux += 1
|
|
62
|
+
break
|
|
63
|
+
|
|
64
|
+
if aux == numberOfSlices:
|
|
65
|
+
break
|
|
66
|
+
|
|
67
|
+
frameIndex = len(controller.framesState(connection.AP))
|
|
68
|
+
while aux < numberOfSlices:
|
|
69
|
+
connection.assignFrameSlice(frameIndex, 0)
|
|
70
|
+
frameIndex += 1
|
|
71
|
+
aux += 1
|
|
72
|
+
return Controller.status.ALLOCATED, connection
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if __name__ == "__main__":
|
|
76
|
+
# Simulator Constructor: size of the room, with the numbrer of grids and the rho parameter
|
|
77
|
+
|
|
78
|
+
sim = Simulator(5.0, 5.0, 2.15, 10, 0.8)
|
|
79
|
+
|
|
80
|
+
# Adding Vleds to the room
|
|
81
|
+
vled = VLed(-1.25, -1.25, 2.15, 60, 60, 20, 70)
|
|
82
|
+
vled.sliceTime = 0.2
|
|
83
|
+
vled.slicesInFrame = 10
|
|
84
|
+
vled.B = 0.5e5
|
|
85
|
+
sim.scenario.addVLed(vled)
|
|
86
|
+
vled = VLed(-1.25, 1.25, 2.15, 60, 60, 20, 70)
|
|
87
|
+
vled.sliceTime = 0.2
|
|
88
|
+
vled.slicesInFrame = 10
|
|
89
|
+
vled.B = 0.5e5
|
|
90
|
+
sim.scenario.addVLed(vled)
|
|
91
|
+
vled = VLed(1.25, -1.25, 2.15, 60, 60, 20, 70)
|
|
92
|
+
vled.sliceTime = 0.2
|
|
93
|
+
vled.slicesInFrame = 10
|
|
94
|
+
vled.B = 0.5e5
|
|
95
|
+
sim.scenario.addVLed(vled)
|
|
96
|
+
vled = VLed(1.25, 1.25, 2.15, 60, 60, 20, 70)
|
|
97
|
+
vled.sliceTime = 0.2
|
|
98
|
+
vled.slicesInFrame = 10
|
|
99
|
+
vled.B = 0.5e5
|
|
100
|
+
sim.scenario.addVLed(vled)
|
|
101
|
+
|
|
102
|
+
# Adding rf
|
|
103
|
+
rf = RF(0, 0, 0.85)
|
|
104
|
+
rf.sliceTime = 0.2
|
|
105
|
+
rf.slicesInFrame = 10
|
|
106
|
+
rf.B = 0.5e5
|
|
107
|
+
sim.scenario.addRF(rf)
|
|
108
|
+
|
|
109
|
+
# setting algorithm and number of connections
|
|
110
|
+
sim.set_allocation_algorithm(alloc)
|
|
111
|
+
sim.goalConnections = 100
|
|
112
|
+
|
|
113
|
+
# changing Dynamic
|
|
114
|
+
sim.lambdaS = 1
|
|
115
|
+
sim.mu = 10
|
|
116
|
+
|
|
117
|
+
# changing random wait limits
|
|
118
|
+
|
|
119
|
+
sim.upper_random_wait = 20
|
|
120
|
+
sim.lower_random_wait = 2
|
|
121
|
+
|
|
122
|
+
sim.lower_capacity_required = 1e5
|
|
123
|
+
sim.upper_capacity_required = 5e5
|
|
124
|
+
|
|
125
|
+
# initialize and run
|
|
126
|
+
sim.init()
|
|
127
|
+
sim.run()
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
|
|
@@ -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.
|
|
13
|
+
version="0.2.4",
|
|
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.
|
|
3
|
+
Version: 0.2.4
|
|
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
|
|
@@ -36,18 +36,53 @@ Next example could be used to start coding with the package:
|
|
|
36
36
|
|
|
37
37
|
```python
|
|
38
38
|
from vlcsim import *
|
|
39
|
+
import math
|
|
39
40
|
|
|
40
41
|
|
|
41
|
-
def alloc(receiver, connection, scenario: Scenario, controller: Controller):
|
|
42
|
+
def alloc(receiver, connection: Connection, scenario: Scenario, controller: Controller):
|
|
42
43
|
vleds = scenario.vleds
|
|
43
|
-
|
|
44
|
+
capacities = []
|
|
44
45
|
for vled in vleds:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if controller.numberOfActiveConnections(
|
|
48
|
-
|
|
46
|
+
capacities.append(scenario.capacityVled(receiver, vled))
|
|
47
|
+
posBestCapacity = capacities.index(max(capacities))
|
|
48
|
+
if controller.numberOfActiveConnections(posBestCapacity) > 5:
|
|
49
|
+
connection.AP = scenario.rfs[0]
|
|
49
50
|
else:
|
|
50
|
-
connection.AP = vleds[
|
|
51
|
+
connection.AP = vleds[posBestCapacity]
|
|
52
|
+
|
|
53
|
+
numberOfSlices = connection.numberOfSlicesNeeded(
|
|
54
|
+
connection.capacityRequired, capacities[posBestCapacity]
|
|
55
|
+
)
|
|
56
|
+
connection.receiver.capacityFromAP = capacities[posBestCapacity]
|
|
57
|
+
actualSlice = connection.nextSliceInAPWhenArriving(connection.AP)
|
|
58
|
+
aux = 0
|
|
59
|
+
|
|
60
|
+
# Actual frame
|
|
61
|
+
for slice in range(actualSlice, connection.AP.slicesInFrame):
|
|
62
|
+
if (
|
|
63
|
+
len(controller.framesState(connection.AP)) == 0
|
|
64
|
+
or controller.framesState(connection.AP)[0][slice] == False
|
|
65
|
+
):
|
|
66
|
+
connection.assignFrameSlice(0, slice)
|
|
67
|
+
aux += 1
|
|
68
|
+
break
|
|
69
|
+
|
|
70
|
+
# next frames
|
|
71
|
+
for frameIndex in range(1, len(controller.framesState(connection.AP))):
|
|
72
|
+
for slice in range(connection.AP.slicesInFrame):
|
|
73
|
+
if controller.framesState(connection.AP)[frameIndex][slice] == False:
|
|
74
|
+
connection.assignFrameSlice(frameIndex, slice)
|
|
75
|
+
aux += 1
|
|
76
|
+
break
|
|
77
|
+
|
|
78
|
+
if aux == numberOfSlices:
|
|
79
|
+
break
|
|
80
|
+
|
|
81
|
+
frameIndex = len(controller.framesState(connection.AP))
|
|
82
|
+
while aux < numberOfSlices:
|
|
83
|
+
connection.assignFrameSlice(frameIndex, 0)
|
|
84
|
+
frameIndex += 1
|
|
85
|
+
aux += 1
|
|
51
86
|
return Controller.status.ALLOCATED, connection
|
|
52
87
|
|
|
53
88
|
|
|
@@ -58,21 +93,31 @@ if __name__ == "__main__":
|
|
|
58
93
|
|
|
59
94
|
# Adding Vleds to the room
|
|
60
95
|
vled = VLed(-1.25, -1.25, 2.15, 60, 60, 20, 70)
|
|
61
|
-
vled.sliceTime = 2
|
|
96
|
+
vled.sliceTime = 0.2
|
|
97
|
+
vled.slicesInFrame = 10
|
|
98
|
+
vled.B = 0.5e5
|
|
62
99
|
sim.scenario.addVLed(vled)
|
|
63
100
|
vled = VLed(-1.25, 1.25, 2.15, 60, 60, 20, 70)
|
|
64
|
-
vled.sliceTime = 2
|
|
101
|
+
vled.sliceTime = 0.2
|
|
102
|
+
vled.slicesInFrame = 10
|
|
103
|
+
vled.B = 0.5e5
|
|
65
104
|
sim.scenario.addVLed(vled)
|
|
66
105
|
vled = VLed(1.25, -1.25, 2.15, 60, 60, 20, 70)
|
|
67
|
-
vled.sliceTime = 2
|
|
106
|
+
vled.sliceTime = 0.2
|
|
107
|
+
vled.slicesInFrame = 10
|
|
108
|
+
vled.B = 0.5e5
|
|
68
109
|
sim.scenario.addVLed(vled)
|
|
69
110
|
vled = VLed(1.25, 1.25, 2.15, 60, 60, 20, 70)
|
|
70
|
-
vled.sliceTime = 2
|
|
111
|
+
vled.sliceTime = 0.2
|
|
112
|
+
vled.slicesInFrame = 10
|
|
113
|
+
vled.B = 0.5e5
|
|
71
114
|
sim.scenario.addVLed(vled)
|
|
72
115
|
|
|
73
116
|
# Adding rf
|
|
74
117
|
rf = RF(0, 0, 0.85)
|
|
75
|
-
rf.sliceTime = 2
|
|
118
|
+
rf.sliceTime = 0.2
|
|
119
|
+
rf.slicesInFrame = 10
|
|
120
|
+
rf.B = 0.5e5
|
|
76
121
|
sim.scenario.addRF(rf)
|
|
77
122
|
|
|
78
123
|
# setting algorithm and number of connections
|
|
@@ -84,14 +129,19 @@ if __name__ == "__main__":
|
|
|
84
129
|
sim.mu = 10
|
|
85
130
|
|
|
86
131
|
# changing random wait limits
|
|
132
|
+
|
|
87
133
|
sim.upper_random_wait = 20
|
|
88
134
|
sim.lower_random_wait = 2
|
|
89
135
|
|
|
136
|
+
sim.lower_capacity_required = 1e5
|
|
137
|
+
sim.upper_capacity_required = 5e5
|
|
138
|
+
|
|
90
139
|
# initialize and run
|
|
91
140
|
sim.init()
|
|
92
141
|
sim.run()
|
|
93
142
|
|
|
94
143
|
|
|
144
|
+
|
|
95
145
|
```
|
|
96
146
|
|
|
97
147
|
|
vlcSim-0.2.3/README.md
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
VLCSim is an Event-Oriented simulator package for Visible Light Communication.
|
|
2
|
-
|
|
3
|
-
# Features
|
|
4
|
-
|
|
5
|
-
- Dynamic Environment with in/out connections
|
|
6
|
-
- Flexible resource allocation algorithm
|
|
7
|
-
- Flexible VLC/room parameters
|
|
8
|
-
|
|
9
|
-
# Events
|
|
10
|
-
|
|
11
|
-
The simulator has 5 Type of events:
|
|
12
|
-
|
|
13
|
-
* **ARRIVE**: Every time when a connection arrives to the system
|
|
14
|
-
* **RESUME**: When a connection begin the transmission
|
|
15
|
-
* **PAUSE**: When a Connection PAUSES the transmission
|
|
16
|
-
* **DEPARTURE**: When a connectin ends its transmission
|
|
17
|
-
* **RETRYING**: WHen a connection is not allocated, and uses a WAIT status, it makes a new attepmt to connect.
|
|
18
|
-
|
|
19
|
-
# Code example
|
|
20
|
-
|
|
21
|
-
Next example could be used to start coding with the package:
|
|
22
|
-
|
|
23
|
-
```python
|
|
24
|
-
from vlcsim import *
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def alloc(receiver, connection, scenario: Scenario, controller: Controller):
|
|
28
|
-
vleds = scenario.vleds
|
|
29
|
-
snrFromVleds = []
|
|
30
|
-
for vled in vleds:
|
|
31
|
-
snrFromVleds.append(scenario.snrVled(receiver, vled))
|
|
32
|
-
posBestSNR = snrFromVleds.index(max(snrFromVleds))
|
|
33
|
-
if controller.numberOfActiveConnections(posBestSNR) > 2:
|
|
34
|
-
return Controller.status.WAIT, connection
|
|
35
|
-
else:
|
|
36
|
-
connection.AP = vleds[posBestSNR]
|
|
37
|
-
return Controller.status.ALLOCATED, connection
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if __name__ == "__main__":
|
|
41
|
-
# Simulator Constructor: size of the room, with the numbrer of grids and the rho parameter
|
|
42
|
-
|
|
43
|
-
sim = Simulator(5.0, 5.0, 2.15, 10, 0.8)
|
|
44
|
-
|
|
45
|
-
# Adding Vleds to the room
|
|
46
|
-
vled = VLed(-1.25, -1.25, 2.15, 60, 60, 20, 70)
|
|
47
|
-
vled.sliceTime = 2
|
|
48
|
-
sim.scenario.addVLed(vled)
|
|
49
|
-
vled = VLed(-1.25, 1.25, 2.15, 60, 60, 20, 70)
|
|
50
|
-
vled.sliceTime = 2
|
|
51
|
-
sim.scenario.addVLed(vled)
|
|
52
|
-
vled = VLed(1.25, -1.25, 2.15, 60, 60, 20, 70)
|
|
53
|
-
vled.sliceTime = 2
|
|
54
|
-
sim.scenario.addVLed(vled)
|
|
55
|
-
vled = VLed(1.25, 1.25, 2.15, 60, 60, 20, 70)
|
|
56
|
-
vled.sliceTime = 2
|
|
57
|
-
sim.scenario.addVLed(vled)
|
|
58
|
-
|
|
59
|
-
# Adding rf
|
|
60
|
-
rf = RF(0, 0, 0.85)
|
|
61
|
-
rf.sliceTime = 2
|
|
62
|
-
sim.scenario.addRF(rf)
|
|
63
|
-
|
|
64
|
-
# setting algorithm and number of connections
|
|
65
|
-
sim.set_allocation_algorithm(alloc)
|
|
66
|
-
sim.goalConnections = 100
|
|
67
|
-
|
|
68
|
-
# changing Dynamic
|
|
69
|
-
sim.lambdaS = 1
|
|
70
|
-
sim.mu = 10
|
|
71
|
-
|
|
72
|
-
# changing random wait limits
|
|
73
|
-
sim.upper_random_wait = 20
|
|
74
|
-
sim.lower_random_wait = 2
|
|
75
|
-
|
|
76
|
-
# initialize and run
|
|
77
|
-
sim.init()
|
|
78
|
-
sim.run()
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|