-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path15_rule_based_avoidance.html
More file actions
435 lines (366 loc) · 15.1 KB
/
Copy path15_rule_based_avoidance.html
File metadata and controls
435 lines (366 loc) · 15.1 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
<!DOCTYPE html>
<!--
To Do: Add timer with Start/Reset button(s); Replace text-based status display
with bar graph including average/cumulative statistics for current or most recent
timed simulation that freezes at end of timed simulation
-->
<html lang="en-US" style="display: flex;">
<head>
<title>HLSI Ex 15</title>
<meta charset="UTF-8"/>
<link rel="stylesheet" type="text/css" media="all" href="hlsi.css">
<link rel=stylesheet type=text/css href=sidebar.css />
<style>
output {font-weight: bold;}
</style>
<script src=d3.v5.min.js></script>
<script src=fft.js></script>
<script src=common.js></script>
<script src=signal.js></script>
<script src=sliders.js></script>
<!-- <script src=powerSpectrumPlot.js></script> -->
<script src=powerSpectrumPlot_2D.js></script>
<script src=powerSpectrumPlot_3D.js></script>
<script src=spectralEfficiencyPlot.js></script>
<script src=sinrPlot_BarChart.js></script>
<script src="averageThroughputPlot_BarChart.js"></script>
<script src="modeController.js"></script>
<script src=label.js></script>
<script src=timer.js></script>
<script src=scriptController.js></script>
<script src=capacityBanner.js></script>
<!-- <script src="capacityRunner.js"></script> -->
<script src=capacityRunner_multisignal.js></script>
<script src=throughputPlotMultiSignals.js></script>
<script src=hoppingInterferer.js></script>
<script src="https://unpkg.com/d3-simple-slider"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.1/chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2.0.0"></script>
<style>
.grid-container {
display: grid;
grid-template-columns: auto auto;
padding: 2px;
}
.grid-item {
padding: 2px;
font-size: 30px;
text-align: center;
}
/* Style the tab */
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: black;
width: fit-content;
border: groove;
border-radius: 8px;
height: 3rem;
}
/* Style the buttons inside the tab */
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
color: white;
/* width: 5vw; */
}
/* Change background color of buttons on hover */
.tab button:hover {
background-color: lightgray;
color: black;
}
/* Create an active/current tablink class */
.tab button.active {
background-color: darkkhaki;
color: black;
}
.timer {
margin-left: 2rem;
display: none;
width: 60vw;
justify-content: start;
}
.PU_controls {
display: flex;
flex-direction: row;
}
@media screen and (max-width: 1000px) {
.grid-container {
width: 25%;
grid-template-columns: none;
}
}
@media screen and (min-width: 1500px) {
.grid-container {
width: 25%;
grid-template-columns: auto auto;
}
}
</style>
</head>
<body style="margin:0;">
<!-- <h2>Exercise 15 Rule Based Interferer Avoidance</h2>
<p><a href="index.html">[exercises]</a></p> -->
<section class="banner" style="position: fixed; z-index: 11; background: rgba(0,0,0,0.85)">
<label for="menu-control" class="hamburger">
<i class="hamburger__icon"></i>
<i class="hamburger__icon"></i>
<i class="hamburger__icon"></i>
</label>
<input type="checkbox" id="menu-control" class="menu-control">
<aside class="sidebar" style="z-index: 10;">
<nav class="sidebar__menu">
<a href="01_bw.html"><b>1</b> Bandwidth</a>
<a href="02_freq.html"><b>2</b> Frequency</a>
<a href="03_gn.html"><b>3</b> Gain</a>
<a href="04_freq_bw_gn.html"><b>4</b> Frequency, Bandwidth, and Gain</a>
<a href="05_capacity.html"><b>5</b> Information Capacity</a>
<a href="06_interference.html"><b>6</b> Interference and Information Capacity</a>
<a href="07_capacity.html"><b>7</b> Information Capacity</a>
<a href="08_capacity.html"><b>8</b> Information Capacity</a>
<a href="09_capacity.html"><b>9</b> Information Capacity</a>
<a href="10_capacity.html"><b>10</b> Information Capacity</a>
<a href="11_pathloss.html"><b>11</b> Path Loss</a>
<a href="12_pathloss_interference.html"><b>12</b> Path Loss with Interference</a>
<a href="13_manual_avoidance.html"><b>13</b> Manual Interferer Avoidance</a>
<a href="" onclick="alert('Exercise 14: reserved for future use')"><b>14</b> SAS (Spectrum Access System)</a>
<a href="15_rule_based_avoidance.html" class="selected"><b>15</b> Rule Based Interferer Avoidance</a>
<a href="16_programmable_avoidance.html"><b>16</b> Programmable Interferer Avoidance</a>
<a href="17_machine_learning_avoidance.html"><b>17</b> Machine Learning Interferer Avoidance</a>
<a href="18_machine_learning_time_based_avoidance.html"><b>18</b> Machine Learning With Periodic Interferer Avoidance</a>
<a href="19_rf_front_end_spectrum_sharing.html"><b>19</b> RF Front End Spectrum Sharing</a>
<a href="20_rf_front_end_spectrum_sharing.html"><b>20</b> Programmable RF Front End Spectrum Sharing</a>
<a href="21_rf_front_end_spectrum_sharing_with_interferer.html"><b>21</b> RF Front End Spectrum Sharing with Interferer</a>
<a href="22_rf_front_end_spectrum_sharing_with_interferer.html"><b>22</b> Programmable Spectrum Sharing with Interferer</a>
<a href="23_rf_front_end_spectrum_sharing_sliders_programmable.html"><b>23</b> RFFE Spectrum Sharing - Manual and Programmable</a>
<a href="25_rf_front_end_spectrum_sharing_menu.html"><b>25</b> RFFE Spectrum Sharing - Calculate SINR options menu</a>
<a href="26_rf_front_end_spectrum_sharing_ programmable.html"><b>26</b> RFFE Spectrum Sharing -- SINR Calculations Programmable</a>
</nav>
<label for="menu-control" class="sidebar__close"></label>
</aside>
<div style="margin-left: 6%; font-size: 1.3rem; margin-top: 0.3%; font-family: sans-serif; order: 1; width: inherit;"><span style="color: #ddd;">Exercise 15</span> Rule Based Interferer Avoidance </div>
<div style="order: 2; margin-left: auto; margin-right: 2%; display: flex;">
<span style="font-size: 250%; font-family: monospace; letter-spacing: 2px; margin-left: auto; margin-right: 5px; color: #e6d9ba;"></span>
<div style="width: 20%;">
<img style="width: 100%;" src="images/wireless-logo.png">
</div>
</div>
</section>
<div class="content-section" style="margin: 0% 2%; margin-top: 5%;">
<div style="display: inline-flex;">
<div class="tab">
<button class="tablinks" onclick="onTabChange(event, 'normal', signalList)">Normal</button>
<button class="tablinks" onclick="onTabChange(event, 'timer', signalList)">Timer</button>
</div>
<div class="timer" id="timer">
<p id=capacityRunner></p>
</div>
</div>
<div class="PU_controls">
<p><label for="pu_mode">Type of co-existing signal:</label>
<select id="pu_mode" onchange="onPUModeChange()">
<option id="interference" value="interference">Interference</option>
<option id="radar_primary_user" value="radar_primary_user">Radar Primary User</option>
<option id="comms_primary_user" value="comms_primary_user">Comms Primary User</option>
</select>
</p>
<div id="sinr_thresholdDiv" style="margin-top: 1rem; margin-left: 1rem; display: none;">
<label for="sinr_threshold">SINR Threshold (dB)</label>
<input style="width: 3.5rem;" id="sinr_threshold" type="text" value="20"
oninput="this.value = this.value
.replace(/[^0-9.-]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/^0[^.]/, '0').replace(/^[-]*[0-9]+[.]*[0-9]*[-]/, '0');" />
</div>
<div id="rate_thresholdDiv" style="margin-top: 1rem; margin-left: 1rem; display: none;">
<label for="rate_threshold">Data Rate Threshold (M bits/sec)</label>
<input style="width: 3.5rem;" id="rate_threshold" type="text" value="2"
oninput="this.value = this.value
.replace(/[^0-9.-]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/^0[^.]/, '0').replace(/^[-]*[0-9]+[.]*[0-9]*[-]/, '0');" />
</div>
<div class="applyDiv" style="margin-top: 1rem; margin-left: 1rem;">
<input id="apply" type="button" value="Apply" onclick="onPUModeChange()">
</div>
</div>
<p>
Press the "Start" button to start the changing of signal parameters
gain and bandwidth as time go on. The interferer has a "frequency
hopping mind" of its' own, which we do not control; we just try to
avoid it by selecting one of the pre-programmed rules.
</p>
<p id=capacityRunner></p>
<p id=hoppingInterferer></p>
<p id=capacityBanner></p>
<p>
<input type="range" id=freq />
</p>
<p>
<input type="range" id=bw />
</p>
<p>
<input type="range" id=gn />
</p>
<p>
<input type="range" id=mcs />
</p>
<div style="display:inline-flex;">
<span style="font-size: 24px; margin-right: 8px;">3D</span>
<label class="switch">
<input id="psd_3d_checkbox" type="checkbox" onclick="power_spectral_density_3d_checkbox_change();">
<span class="slider round"></span>
</label>
</div>
</div>
<div class="grid-container">
<div class="grid-item">
<div id="psd_svg_figure_parent" style="float: left; margin-left: 1%;"></div>
</div>
<div class="grid-item">
<div class="grid-container">
<div class="grid-item" id="sinr_parent" style="width: 360px; height: 320px;">
<canvas id="sinr-bar-chart" style="width: 100%; height: 100%;"></canvas>
</div>
<div class="grid-item">
<div id="avg_throughput" style="width: 360px; height: 320px;">
<!-- <canvas id="avg-throughput-bar-chart" style="width: 100%; height: 100%; margin-top:-25px;"></canvas> -->
</div>
</div>
</div>
</div>
<div class="grid-item">
<div id="throughput-multisignal" style="width: 720px;"></div>
</div>
<div class="grid-item">
<div id="spectral_efficiency_parent" style="width: 720px;"></div>
</div>
</div>
</body>
<script>
'use strict';
var sig = new Signal(conf.sig0, '', {
bw_max: 38.0e6, // Hz
bw_init: 10.0e6, // Hz
bw_min: 2.0e6, // Hz
gn_max: 1.0, // dB
gn_init: -10.0, // dB
gn_min: -40, // dB
mcs_init: 4 // array index int 0 to 11
});
var interferer = new Signal(conf.sig0, 'interferer', {
bw_max: 38.0e6, // Hz
bw_init: 2.5e6, // Hz
gn_max: 0.0, // dB
gn_init: -12, // dB
gn_min: -40, // dB
freq_init: 1785.0e6 // Hz
});
var signalList = [sig, interferer];
var noise = Signal(conf.noise, "Noise", { gn_init: -40});
// How many bits of randomness are there in Math.random()?
//
// Lets say it's 30 bits (due too float round-off of 32 bits) and just
// cycle the value after that. Computing Math.random() is not cheap.
const rbits = 30;
const rsize = (0x01 << rbits) - 1;
// rsize = 2^(rbits)
const randBits = Math.round(Math.random()*rsize);
// randBits is now a big random integer.
var randBit = 1; // one bit gets set in randBit.
//
// Coin() returns +1 or -1 depending on randomness in randBits.
function Coin() {
// pick a bit
let bit = randBits & randBit;
// Go to the next bit.
randBit = randBit << 1;
if(randBit > rsize)
// Reset back to the first bit.
randBit = 1;
return (bit)?(1):(-1);
}
// The list of "Rule Based" functions in the <select> after the "Start"
// button.
var funcs = {
"Select pre-configured Strategy ...":
"This is not an otional function",
"No Adaptation":
function() { },
"Random Frequency":
function(t) {
sig.freq = sig.freq_min + Math.random()*(sig.freq_max - sig.freq_min);
},
"Frequency Adaptation":
function(t) {
let i = interferer;
let s = sig;
// A small standard frequency change size.
let delta = 0.1 * (s.freq_max - s.freq_min);
// The mean frequency.
let favg = (s.freq_max + s.freq_min)/2.0;
let f_lower = s.freq - 0.5*s.bw,
f_upper = s.freq + 0.5*s.bw,
i_lower = i.freq - 0.5*i.bw,
i_upper = i.freq + 0.5*i.bw;
if(!(f_lower > i_upper || f_upper < i_lower)) {
// The interferer and the signal overlap.
let ch1 = f_lower - i_lower;
let ch2 = f_upper - i_upper;
let ch3 = Math.abs(i_upper - f_lower);
let ch4 = Math.abs(i_lower - f_upper);
if((ch2 > 0) && (ch1 > 0)) {
if(f_lower < s.freq_min || f_upper > s.freq_max) s.freq = favg;
s.freq += Coin() * ch3 + delta;
return;
}
if((ch2 > 0) && (ch1 < 0)) {
if(f_lower < s.freq_min || f_upper > s.freq_max) s.freq = favg;
let ch5 = Math.abs(ch3) + Math.abs(ch4);
s.freq += Coin() * ch5 + delta;
return;
}
if((ch2 < 0) && (ch1 < 0)) {
if(f_lower < s.freq_min || f_upper > s.freq_max) s.freq = favg;
s.freq += Coin() * ch4 + delta;
return;
}
s.freq = favg;
return;
}
},
"Frequency and Bandwidth Adaptation":
function(t) {
let i = interferer;
let s = sig;
// A small standard frequency change size.
let delta = 0.1 * (s.freq_max - s.freq_min);
// The mean frequency.
let favg = (s.freq_max + s.freq_min)/2.0;
let f_lower = s.freq - 0.5*s.bw,
f_upper = s.freq + 0.5*s.bw,
i_lower = i.freq - 0.5*i.bw,
i_upper = i.freq + 0.5*i.bw;
if(i.freq < favg) {
s.freq = (i.freq_max + i_upper)/2.0;
s.bw = i.freq_max - i_upper - delta
} else {
s.freq = (i_lower + i.freq_min)/2.0;
s.bw = i_lower - i.freq_min - delta;
}
}
}
Slider(sig, 'freq', '#freq');
Slider(sig, 'bw', '#bw');
Slider(sig, 'gn', '#gn');
Slider(sig, 'mcs', '#mcs');
HoppingInterferer(interferer, '#hoppingInterferer');
CapacityBanner(sig, '#capacityBanner');
PowerSpectrumPlot_2D();
ThroughputPlot([sig]);
SpectralEfficiencyPlot(sig);
SinrPlot_BarChart.init([sig], "sinr-bar-chart", ["User Signal"], null, ["rgb(48, 25, 72)", "rgba(230,97,0)"]);
</script>
</html>