@@ -193,19 +193,28 @@ def get_cnn_data():
193
193
iq_imag = np .int16 (np .imag (data ) * 2 ** 12 - 1 )
194
194
iq = iq_real + 1j * iq_imag
195
195
196
- sdr1 .tx_destroy_buffer ()
197
- sdr1 ._tx2 .tx_destroy_buffer ()
198
196
sdr .tx_destroy_buffer ()
199
197
sdr ._tx2 .tx_destroy_buffer ()
198
+ sdr .tx (iq )
199
+ sdr ._tx2 .tx (iq )
200
200
201
+ sdr1 .tx_destroy_buffer ()
202
+ sdr1 ._tx2 .tx_destroy_buffer ()
201
203
sdr1 .tx (iq )
202
- sdr1 .tx2 (iq )
203
- sdr .tx (iq )
204
- sdr .tx2 (iq )
204
+ sdr1 ._tx2 .tx (iq )
205
205
206
- if get_timestamp (file_path ):
206
+ sdr2 .tx_destroy_buffer ()
207
+ sdr2 ._tx2 .tx_destroy_buffer ()
208
+ sdr2 .tx (iq )
209
+ sdr2 ._tx2 .tx (iq )
207
210
208
- truth_vector .append (truth )
211
+ sdr3 .tx_destroy_buffer ()
212
+ sdr3 ._tx2 .tx_destroy_buffer ()
213
+ sdr3 .tx (iq )
214
+ sdr3 ._tx2 .tx (iq )
215
+
216
+ time .sleep (0.1 )
217
+ if get_timestamp (file_path ):
209
218
with open (file_path , 'r' ) as file :
210
219
lines = file .readlines ()
211
220
estimated_ch1 = int (lines [1 ].strip ())
@@ -217,6 +226,7 @@ def get_cnn_data():
217
226
probability_ch3 = float (lines [7 ].strip ())
218
227
probability_ch4 = float (lines [8 ].strip ())
219
228
229
+ truth_vector .append (truth )
220
230
estimated_ch1_vector .append (estimated_ch1 )
221
231
estimated_ch2_vector .append (estimated_ch2 )
222
232
estimated_ch3_vector .append (estimated_ch3 )
@@ -228,7 +238,7 @@ def get_cnn_data():
228
238
probability_ch4_vector .append (probability_ch4 )
229
239
230
240
if get_timestamp1 (file_path1 ):
231
- truth_vector1 . append ( truth1 )
241
+
232
242
with open (file_path1 , 'r' ) as file :
233
243
lines = file .readlines ()
234
244
estimated_ch5 = int (lines [1 ].strip ())
@@ -239,7 +249,7 @@ def get_cnn_data():
239
249
probability_ch6 = float (lines [6 ].strip ())
240
250
probability_ch7 = float (lines [7 ].strip ())
241
251
probability_ch8 = float (lines [8 ].strip ())
242
-
252
+ truth_vector1 . append ( truth1 )
243
253
estimated_ch5_vector .append (estimated_ch5 )
244
254
estimated_ch6_vector .append (estimated_ch6 )
245
255
estimated_ch7_vector .append (estimated_ch7 )
@@ -307,7 +317,6 @@ def plot_confusion_matrix():
307
317
colorscale = 'Blues'
308
318
))
309
319
fig .update_layout (
310
- title = dict (text = 'Confusion Matrix' , x = 0.5 ),
311
320
xaxis = dict (title = 'Estimated Modulation' ),
312
321
yaxis = dict (title = 'True Modulation' )
313
322
)
@@ -321,13 +330,14 @@ def plot_confusion_matrix1():
321
330
colorscale = 'Blues'
322
331
))
323
332
fig .update_layout (
324
- title = dict (text = 'Confusion Matrix' , x = 0.5 ),
325
333
xaxis = dict (title = 'Estimated Modulation' ),
326
334
yaxis = dict (title = 'True Modulation' )
327
335
)
328
336
return fig
329
337
330
- table_data = pd .DataFrame (columns = ['column-1' , 'column-2' , 'column-3' , 'column-4' , 'column-5' , 'column-6' ], dtype = 'float64' ).to_dict ('records' )
338
+ table_data = pd .DataFrame (columns = ['column-1' , 'column-2' , 'column-3' , 'column-4' , 'column-5' , 'column-6' ], dtype = np .float64 ).to_dict ('records' )
339
+ truth_table_data = pd .DataFrame (columns = ['column-1' , 'column-2' , 'column-3' ], dtype = pd .StringDtype ()).to_dict ('records' )
340
+ truth_table_data1 = pd .DataFrame (columns = ['column-1' , 'column-2' , 'column-3' ], dtype = pd .StringDtype ()).to_dict ('records' )
331
341
332
342
accuracy = 0
333
343
precision = 0
@@ -367,54 +377,102 @@ def update_table():
367
377
},
368
378
]
369
379
380
+ def update_truth_table ():
381
+ global truth_table_data
382
+ global truth_table_data1
383
+
384
+ truth_table_data = [
385
+ {'column-1' : 'Channel 1' , 'column-2' : f'{ modulation_map [str (truth )]} ' , 'column-3' : f'{ modulation_map [str (estimated_ch1 )]} ' },
386
+ {'column-1' : 'Channel 2' , 'column-2' : f'{ modulation_map [str (truth )]} ' , 'column-3' : f'{ modulation_map [str (estimated_ch2 )]} ' },
387
+ {'column-1' : 'Channel 3' , 'column-2' : f'{ modulation_map [str (truth )]} ' , 'column-3' : f'{ modulation_map [str (estimated_ch3 )]} ' },
388
+ {'column-1' : 'Channel 4' , 'column-2' : f'{ modulation_map [str (truth )]} ' , 'column-3' : f'{ modulation_map [str (estimated_ch4 )]} ' },
389
+ ]
390
+
391
+ truth_table_data1 = [
392
+ {'column-1' : 'Channel 1' , 'column-2' : f'{ modulation_map [str (truth )]} ' , 'column-3' : f'{ modulation_map [str (estimated_ch5 )]} ' },
393
+ {'column-1' : 'Channel 2' , 'column-2' : f'{ modulation_map [str (truth )]} ' , 'column-3' : f'{ modulation_map [str (estimated_ch6 )]} ' },
394
+ {'column-1' : 'Channel 3' , 'column-2' : f'{ modulation_map [str (truth )]} ' , 'column-3' : f'{ modulation_map [str (estimated_ch7 )]} ' },
395
+ {'column-1' : 'Channel 4' , 'column-2' : f'{ modulation_map [str (truth )]} ' , 'column-3' : f'{ modulation_map [str (estimated_ch8 )]} ' },
396
+ ]
397
+
398
+
399
+
400
+
401
+
370
402
app .layout = html .Div ([
371
403
html .Div ([
372
404
html .Img (src = '/assets/ADI_logo.svg' , style = {'height' : '45px' , 'margin-right' : '16px' , 'vertical-align' : 'middle' }),
373
405
html .H1 ('High-Performance Analog Meets AI' , style = {'display' : 'inline-block' , 'vertical-align' : 'middle' , 'fontSize' : '46px' })
374
- ], style = {'width' : '100%' , 'text-align' : 'left' , 'padding' : '5px' , 'border-bottom' : '1px solid #B7BBC3' , 'backgroundColor' : '#FFFFFF' , 'font-family' : 'Barlow' , 'display' : 'flex' , 'align-items' : 'center' }),
375
-
376
-
406
+ ], style = {'width' : '100%' , 'text-align' : 'left' , 'padding' : '5px' , 'border-bottom' : '1px solid #B7BBC3' , 'backgroundColor' : '#FFFFFF' , 'font-family' : 'Barlow' , 'align-items' : 'center' }),
377
407
378
408
html .Div ([
379
- html .H2 ('ADRV9009ZU11EG device 1' , style = {'text-align' : 'center' , 'margin-top' : '20px' , 'font-family' : 'Barlow' }),
380
- html .Div (dcc .Graph (id = 'confusion-matrix' ), style = {'width' : '40%' , 'display' : 'inline-block' , 'margin-left' : '5%' }),
381
- html .Div (dcc .Graph (id = 'modulated-data' ), style = {'width' : '40%' , 'display' : 'inline-block' , 'margin-left' : '10%' })
382
- ], style = {'width' : '90%' ,'height' : '65%' , 'margin-left' : '5%' , 'margin-top' : '1%' , 'backgroundColor' : 'transparent' , 'border-radius' : '20px' , 'box-shadow' : '10px 10px 20px rgba(0, 0, 0, 0.2)' , 'font-family' : 'Barlow' , 'fontSize' : '20px' }),
383
-
409
+ html .H2 ('ADRV9009ZU11EG device 1' , style = {'text-align' : 'center' , 'margin-top' : '2%' , 'font-family' : 'Barlow' ,'height' : '10%' }),
410
+ html .Div ([
411
+ dcc .Graph (id = 'confusion-matrix' , style = {'width' : '40%' ,'height' : '100%' ,'display' : 'inline-block' }),
412
+ dash_table .DataTable (
413
+ id = 'truth-table' ,
414
+ columns = [
415
+ {'name' : 'Channel' , 'id' : 'column-1' },
416
+ {'name' : 'Estimated' , 'id' : 'column-2' },
417
+ {'name' : 'Truth' , 'id' : 'column-3' },
418
+ ],
419
+ data = truth_table_data ,
420
+ style_cell = {'textAlign' : 'center' , 'fontSize' : '20px' , 'font-family' : 'Barlow' },
421
+ style_header = {'backgroundColor' : '#1E4056' , 'color' : 'white' , 'font-family' : 'Barlow' , 'fontSize' : '25px' },
422
+ style_table = {'width' : '25%' ,'height' : '100%' , 'display' : 'inline-block' ,'margin-top' : '50%' ,'vertical-align' : 'middle' }
423
+ ),
424
+ dcc .Graph (id = 'modulated-data' , style = {'width' : '40%' ,'height' : '100%' ,'display' : 'inline-block' })
425
+ ], style = {'display' : 'flex' , 'justify-content' : 'space-between' , 'width' : '100%' ,'height' : '90%' })],
426
+ style = {'width' : '98%' , 'height' : '65%' , 'margin-left' : '1%' , 'backgroundColor' : 'transparent' , 'border-radius' : '20px' , 'box-shadow' : '10px 10px 20px rgba(0, 0, 0, 0.2)' , 'font-family' : 'Barlow' , 'fontSize' : '20px' }),
384
427
html .Div (
385
- dash_table .DataTable (
386
- id = 'example-table' ,
387
- columns = [
388
- {'name' : 'Accuracy' , 'id' : 'column-1' },
389
- {'name' : 'Precision' , 'id' : 'column-2' },
390
- {'name' : 'Recall' , 'id' : 'column-3' },
391
- {'name' : 'F1 rate' , 'id' : 'column-4' },
392
- {'name' : 'MSE rate' , 'id' : 'column-5' },
393
- {'name' : 'R2 rate' , 'id' : 'column-6' }
394
- ],
395
- data = table_data ,
396
- style_table = {'width' : '90%' , 'margin-left' : '5%' ,'margin-top' : '2%' , 'border-radius' : '50px' , 'box-shadow' : '10px 10px 20px rgba(0, 0, 0, 0.2)' , 'font-family' : 'Barlow' },
397
- style_cell = {'textAlign' : 'center' , 'fontSize' : '20px' , 'font-family' : 'Barlow' },
398
- style_header = {'backgroundColor' : '#1E4056' , 'color' : 'white' , 'font-family' : 'Barlow' , 'fontSize' : '20px' }
399
- )
428
+ dash_table .DataTable (
429
+ id = 'example-table' ,
430
+ columns = [
431
+ {'name' : 'Accuracy' , 'id' : 'column-1' },
432
+ {'name' : 'Precision' , 'id' : 'column-2' },
433
+ {'name' : 'Recall' , 'id' : 'column-3' },
434
+ {'name' : 'F1 rate' , 'id' : 'column-4' },
435
+ {'name' : 'MSE rate' , 'id' : 'column-5' },
436
+ {'name' : 'R2 rate' , 'id' : 'column-6' }
437
+ ],
438
+ data = table_data ,
439
+ style_table = {'width' : '90%' , 'margin-left' : '5%' , 'margin-top' : '2%' , 'border-radius' : '50px' , 'box-shadow' : '10px 10px 20px rgba(0, 0, 0, 0.2)' , 'font-family' : 'Barlow' },
440
+ style_cell = {'textAlign' : 'center' , 'fontSize' : '20px' , 'font-family' : 'Barlow' },
441
+ style_header = {'backgroundColor' : '#1E4056' , 'color' : 'white' , 'font-family' : 'Barlow' , 'fontSize' : '20px' }
442
+ )
400
443
),
401
444
html .Div ([
402
- html .H2 ('ADRV9009ZU11EG device 2' , style = {'text-align' : 'center' , 'margin-top' : '20px' , 'font-family' : 'Barlow' }),
403
- html .Div (dcc .Graph (id = 'confusion-matrix1' ), style = {'width' : '40%' , 'display' : 'inline-block' , 'margin-left' : '5%' }),
404
- html .Div (dcc .Graph (id = 'modulated-data1' ), style = {'width' : '40%' , 'display' : 'inline-block' , 'margin-left' : '10%' })
405
- ], style = {'width' : '90%' ,'height' : '65%' , 'margin-left' : '5%' , 'margin-top' : '1%' , 'backgroundColor' : 'transparent' , 'border-radius' : '10px' , 'box-shadow' : '10px 10px 20px rgba(0, 0, 0, 0.2)' , 'font-family' : 'Barlow' , 'fontSize' : '20px' }),
406
-
407
- dcc .Interval (
408
- id = 'interval-component' ,
409
- interval = 1 * 1000 , # in milliseconds
410
- n_intervals = 0
411
- )
445
+ html .H2 ('ADRV9009ZU11EG device 2' , style = {'text-align' : 'center' , 'margin-top' : '2%' , 'font-family' : 'Barlow' ,'height' : '10%' }),
446
+ html .Div ([
447
+ dcc .Graph (id = 'confusion-matrix1' , style = {'width' : '40%' ,'height' : '100%' ,'display' : 'inline-block' }),
448
+ dash_table .DataTable (
449
+ id = 'truth-table1' ,
450
+ columns = [
451
+ {'name' : 'Channel' , 'id' : 'column-1' },
452
+ {'name' : 'Estimated' , 'id' : 'column-2' },
453
+ {'name' : 'Truth' , 'id' : 'column-3' },
454
+ ],
455
+ data = truth_table_data1 ,
456
+ style_cell = {'textAlign' : 'center' , 'fontSize' : '20px' , 'font-family' : 'Barlow' },
457
+ style_header = {'backgroundColor' : '#1E4056' , 'color' : 'white' , 'font-family' : 'Barlow' , 'fontSize' : '25px' },
458
+ style_table = {'width' : '25%' ,'height' : '100%' , 'display' : 'inline-block' ,'margin-top' : '50%' ,'vertical-align' : 'middle' }
459
+ ),
460
+ dcc .Graph (id = 'modulated-data1' , style = {'width' : '40%' ,'height' : '100%' ,'display' : 'inline-block' })
461
+ ], style = {'display' : 'flex' , 'justify-content' : 'space-between' , 'width' : '100%' ,'height' : '90%' })],
462
+ style = {'width' : '98%' , 'height' : '65%' , 'margin-left' : '1%' , 'backgroundColor' : 'transparent' , 'border-radius' : '20px' , 'box-shadow' : '10px 10px 20px rgba(0, 0, 0, 0.2)' , 'font-family' : 'Barlow' , 'fontSize' : '20px' }),
463
+ dcc .Interval (
464
+ id = 'interval-component' ,
465
+ interval = 1 * 1000 , # in milliseconds
466
+ n_intervals = 0
467
+ )
412
468
], style = {'font-family' : 'Barlow' })
413
469
414
470
@app .callback (
415
471
[dash .dependencies .Output ('confusion-matrix' , 'figure' ),
416
472
dash .dependencies .Output ('modulated-data' , 'figure' ),
417
473
dash .dependencies .Output ('example-table' , 'data' ),
474
+ dash .dependencies .Output ('truth-table' , 'data' ),
475
+ dash .dependencies .Output ('truth-table1' , 'data' ),
418
476
dash .dependencies .Output ('confusion-matrix1' , 'figure' ),
419
477
dash .dependencies .Output ('modulated-data1' , 'figure' )],
420
478
[dash .dependencies .Input ('interval-component' , 'n_intervals' )]
@@ -423,12 +481,13 @@ def update_graph_live(n):
423
481
get_cnn_data ()
424
482
update_confusion_matrix ()
425
483
update_table ()
426
- return plot_confusion_matrix (), plot_modulated_data (), table_data , plot_confusion_matrix1 (), plot_modulated_data1 ()
484
+ update_truth_table ()
485
+ return plot_confusion_matrix (), plot_modulated_data (), table_data , truth_table_data , truth_table_data1 , plot_confusion_matrix1 (), plot_modulated_data1 ()
427
486
428
487
if __name__ == '__main__' :
429
488
430
489
# Code to be executed just once
431
- sdr = adi .adrv9002 (uri = "ip:10.48.65.203 " )
490
+ sdr = adi .adrv9002 (uri = "ip:10.48.65.222 " )
432
491
sdr .write_stream_profile ( "lte_40_lvds_api_68_14_10.stream" ,"lte_40_lvds_api_68_14_10.json" )
433
492
434
493
sdr .tx0_port_en = "spi"
@@ -442,7 +501,7 @@ def update_graph_live(n):
442
501
sdr .tx_hardwaregain_chan1 = - 10
443
502
444
503
445
- sdr1 = adi .adrv9002 (uri = "ip:10.48.65.154 " )
504
+ sdr1 = adi .adrv9002 (uri = "ip:10.48.65.187 " )
446
505
sdr1 .write_stream_profile ( "lte_40_lvds_api_68_14_10.stream" ,"lte_40_lvds_api_68_14_10.json" )
447
506
448
507
sdr1 .tx0_port_en = "spi"
@@ -456,4 +515,33 @@ def update_graph_live(n):
456
515
sdr1 .tx_hardwaregain_chan0 = - 10
457
516
sdr1 .tx_hardwaregain_chan1 = - 10
458
517
518
+ sdr2 = adi .adrv9002 (uri = "ip:10.48.65.226" )
519
+ sdr2 .write_stream_profile ( "lte_40_lvds_api_68_14_10.stream" ,"lte_40_lvds_api_68_14_10.json" )
520
+
521
+ sdr2 .tx0_port_en = "spi"
522
+ sdr2 .tx1_port_en = "spi"
523
+ sdr2 .tx_ensm_mode_chan0 = "rf_enabled"
524
+ sdr2 .tx_ensm_mode_chan1 = "rf_enabled"
525
+ sdr2 .tx_cyclic_buffer = True
526
+ sdr2 .tx2_cyclic_buffer = True
527
+ sdr2 .tx0_lo = 2400000000
528
+ sdr2 .tx1_lo = 2400000000
529
+ sdr2 .tx_hardwaregain_chan0 = - 10
530
+ sdr2 .tx_hardwaregain_chan1 = - 10
531
+
532
+
533
+ sdr3 = adi .adrv9002 (uri = "ip:10.48.65.203" )
534
+ sdr3 .write_stream_profile ( "lte_40_lvds_api_68_14_10.stream" ,"lte_40_lvds_api_68_14_10.json" )
535
+
536
+ sdr3 .tx0_port_en = "spi"
537
+ sdr3 .tx1_port_en = "spi"
538
+ sdr3 .tx_ensm_mode_chan0 = "rf_enabled"
539
+ sdr3 .tx_ensm_mode_chan1 = "rf_enabled"
540
+ sdr3 .tx_cyclic_buffer = True
541
+ sdr3 .tx2_cyclic_buffer = True
542
+ sdr3 .tx0_lo = 2400000000
543
+ sdr3 .tx1_lo = 2400000000
544
+ sdr3 .tx_hardwaregain_chan0 = - 10
545
+ sdr3 .tx_hardwaregain_chan1 = - 10
546
+
459
547
app .run_server (debug = True )
0 commit comments