@@ -487,6 +487,44 @@ <h3>Read sensor data</h3>
487
487
} ) ;
488
488
}
489
489
490
+ } else if ( sensorTypes [ sensor ] . scheme == "BSEC2GasClassifierOutput" ) {
491
+ //Parse BSEC values
492
+ const BSECValues = parsedStringValue . split ( " " ) ;
493
+ console . log ( "Split: " , BSECValues ) ;
494
+
495
+ var val0 = BSECValues [ 1 ] ; //gas 0 probability (%)
496
+ var val1 = BSECValues [ 5 ] ; //gas 1 probability (%)
497
+ var val2 = BSECValues [ 9 ] ; //gas 2 probability (%)
498
+ var val3 = BSECValues [ 13 ] ; //gas 3 probability (%)
499
+ //var status = BSECValues[17]; //status
500
+ //var total = (val0+val1+val2+val3);
501
+
502
+ if ( sensorTypes [ sensor ] . value == 0 ) { //Plot doesn't exist yet because no valid data have been received
503
+ Plotly . newPlot ( chartIdx ,
504
+ [
505
+ { y :[ val0 ] , name :'Gas0 probability(%)' , type :'line' } , { y :[ val1 ] , name :'Gas1 probability(%)' , type :'line' } ,
506
+ { y :[ val2 ] , name :'Gas2 probability(%)' , type :'line' } , { y :[ val3 ] , name :'Gas3 probability(%)' , type :'line' }
507
+ ] ) ;
508
+ //Update json to signal that the reception started
509
+ cnt = sensorTypes [ sensor ] . value + 1 ;
510
+ sensorTypes [ sensor ] . value = cnt ;
511
+ } else { //Plot already exists
512
+ Plotly . extendTraces ( chartIdx , { y :[ [ val0 ] ] } , [ 0 ] ) ;
513
+ Plotly . extendTraces ( chartIdx , { y :[ [ val1 ] ] } , [ 1 ] ) ;
514
+ Plotly . extendTraces ( chartIdx , { y :[ [ val2 ] ] } , [ 2 ] ) ;
515
+ Plotly . extendTraces ( chartIdx , { y :[ [ val3 ] ] } , [ 3 ] ) ;
516
+ cnt = sensorTypes [ sensor ] . value ;
517
+ sensorTypes [ sensor ] . value = cnt + 1 ;
518
+ }
519
+
520
+ if ( cnt > 150 ) {
521
+ Plotly . relayout ( chartIdx , {
522
+ xaxis : {
523
+ range : [ cnt - 150 , cnt ]
524
+ }
525
+ } ) ;
526
+ }
527
+
490
528
}
491
529
}
492
530
}
@@ -524,6 +562,10 @@ <h3>Read sensor data</h3>
524
562
} else {
525
563
parse_scheme = parseScheme [ "types" ] [ 7 ] [ "parse-scheme" ] ;
526
564
}
565
+ } else if ( scheme == "BSEC2DataCollectorOutput" ) {
566
+ parse_scheme = parseScheme [ "types" ] [ 8 ] [ "parse-scheme" ] ;
567
+ } else if ( scheme == "BSEC2GasClassifierOutput" ) {
568
+ parse_scheme = parseScheme [ "types" ] [ 9 ] [ "parse-scheme" ] ;
527
569
}
528
570
529
571
parse_scheme . forEach ( element => {
@@ -547,13 +589,22 @@ <h3>Read sensor data</h3>
547
589
size = 2 ;
548
590
} else if ( valueType == "uint24" ) {
549
591
value = data . getUint16 ( dataIndex , true ) + ( data . getUint8 ( dataIndex + 2 , true ) << 16 ) ;
592
+ value = value * scale ;
550
593
size = 3 ;
551
594
} else if ( valueType == "uint32" ) {
552
595
value = data . getUint16 ( dataIndex , true ) + ( data . getUint16 ( dataIndex + 2 , true ) << 16 ) ;
596
+ value = value * scale ;
553
597
size = 4 ;
554
598
} else if ( valueType == "float" ) {
555
599
value = data . getFloat32 ( dataIndex , true ) * scale ;
556
600
size = 4 ;
601
+ } else if ( valueType == "uint64" ) {
602
+ valLow = data . getUint32 ( dataIndex , true )
603
+ valHigh = data . getUint32 ( dataIndex + 4 , true )
604
+ value = ( valLow + ( valHigh * 2 ** 32 ) ) * scale
605
+ //value = (valLow) * scale
606
+ //console.log('value:' + value + 'scale:' + scale)
607
+ size = 8 ;
557
608
} else if ( valueType == "none" ) {
558
609
value = eventcount + 1 ;
559
610
sensorTypes [ sensor ] . eventcount = value ;
0 commit comments