@@ -117,6 +117,7 @@ public sealed class CortexClient
117
117
public event EventHandler < Record > OnUpdateRecord ;
118
118
public event EventHandler < List < Record > > OnQueryRecords ;
119
119
public event EventHandler < MultipleResultEventArgs > OnDeleteRecords ;
120
+ public event EventHandler < MultipleResultEventArgs > ExportRecordsFinished ;
120
121
public event EventHandler < JObject > OnInjectMarker ;
121
122
public event EventHandler < JObject > OnUpdateMarker ;
122
123
public event EventHandler < JObject > OnGetDetectionInfo ;
@@ -133,6 +134,7 @@ public sealed class CortexClient
133
134
public event EventHandler < string > SessionClosedNotify ;
134
135
public event EventHandler < HeadsetConnectEventArgs > HeadsetConnectNotify ;
135
136
public event EventHandler < string > HeadsetScanFinished ;
137
+ public event EventHandler < string > DataPostProcessingFinished ;
136
138
137
139
// Constructor
138
140
static CortexClient ( )
@@ -425,72 +427,72 @@ private void HandleResponse(string method, JToken data)
425
427
{
426
428
OnGetTrainingTime ( this , ( double ) data [ "time" ] ) ;
427
429
}
430
+ // export record
431
+ else if ( method == "exportRecord" )
432
+ {
433
+ JArray successList = ( JArray ) data [ "success" ] ;
434
+ JArray failList = ( JArray ) data [ "failure" ] ;
435
+ ExportRecordsFinished ( this , new MultipleResultEventArgs ( successList , failList ) ) ;
436
+ }
428
437
429
438
}
430
439
431
440
// handle warning response
432
441
private void HandleWarning ( int code , JToken messageData )
433
442
{
434
443
Console . WriteLine ( "handleWarning: " + code ) ;
435
- if ( code == WarningCode . AccessRightGranted )
444
+ switch ( code )
436
445
{
437
- // granted access right
446
+ case WarningCode . AccessRightGranted :
438
447
OnAccessRightGranted ( this , true ) ;
439
- }
440
- else if ( code == WarningCode . AccessRightRejected )
441
- {
448
+ break ;
449
+ case WarningCode . AccessRightRejected :
442
450
OnAccessRightGranted ( this , false ) ;
443
- }
444
- else if ( code == WarningCode . EULAAccepted )
445
- {
451
+ break ;
452
+ case WarningCode . EULAAccepted :
446
453
OnEULAAccepted ( this , true ) ;
447
- }
448
- else if ( code == WarningCode . UserLogin )
449
- {
450
- string message = messageData . ToString ( ) ;
451
- OnUserLogin ( this , message ) ;
452
- }
453
- else if ( code == WarningCode . UserLogout )
454
- {
455
- string message = messageData . ToString ( ) ;
456
- OnUserLogout ( this , message ) ;
457
- }
458
- else if ( code == WarningCode . HeadsetScanFinished )
459
- {
460
- string message = messageData [ "behavior" ] . ToString ( ) ;
461
- HeadsetScanFinished ( this , message ) ;
462
- }
463
- else if ( code == WarningCode . StreamStop )
464
- {
465
- string sessionId = messageData [ "sessionId" ] . ToString ( ) ;
466
- SessionClosedNotify ( this , sessionId ) ;
467
- }
468
- else if ( code == WarningCode . SessionAutoClosed )
469
- {
470
- string sessionId = messageData [ "sessionId" ] . ToString ( ) ;
471
- SessionClosedNotify ( this , sessionId ) ;
472
- }
473
- else if ( code == WarningCode . HeadsetConnected )
474
- {
454
+ break ;
455
+ case WarningCode . UserLogin :
456
+ OnUserLogin ( this , messageData . ToString ( ) ) ;
457
+ break ;
458
+ case WarningCode . UserLogout :
459
+ OnUserLogout ( this , messageData . ToString ( ) ) ;
460
+ break ;
461
+ case WarningCode . HeadsetScanFinished :
462
+ HeadsetScanFinished ( this , messageData [ "behavior" ] . ToString ( ) ) ;
463
+ break ;
464
+ case WarningCode . StreamStop :
465
+ case WarningCode . SessionAutoClosed :
466
+ SessionClosedNotify ( this , messageData [ "sessionId" ] . ToString ( ) ) ;
467
+ break ;
468
+ case WarningCode . HeadsetConnected :
469
+ {
475
470
string headsetId = messageData [ "headsetId" ] . ToString ( ) ;
476
471
string message = messageData [ "behavior" ] . ToString ( ) ;
477
472
Console . WriteLine ( "handleWarning:" + message ) ;
478
473
HeadsetConnectNotify ( this , new HeadsetConnectEventArgs ( true , message , headsetId ) ) ;
479
- }
480
- else if ( code == WarningCode . HeadsetWrongInformation ||
481
- code == WarningCode . HeadsetCannotConnected ||
482
- code == WarningCode . HeadsetConnectingTimeout )
483
- {
474
+ break ;
475
+ }
476
+ case WarningCode . HeadsetWrongInformation :
477
+ case WarningCode . HeadsetCannotConnected :
478
+ case WarningCode . HeadsetConnectingTimeout :
479
+ {
484
480
string headsetId = messageData [ "headsetId" ] . ToString ( ) ;
485
481
string message = messageData [ "behavior" ] . ToString ( ) ;
486
482
HeadsetConnectNotify ( this , new HeadsetConnectEventArgs ( false , message , headsetId ) ) ;
487
- }
488
- else if ( code == WarningCode . CortexAutoUnloadProfile )
489
- {
490
- // the current profile is unloaded automatically
483
+ break ;
484
+ }
485
+ case WarningCode . CortexAutoUnloadProfile :
491
486
OnUnloadProfile ( this , true ) ;
487
+ break ;
488
+ case WarningCode . DataPostProcessingFinished :
489
+ Console . WriteLine ( "Data post processing finished" ) ;
490
+ DataPostProcessingFinished ( this , messageData [ "recordId" ] . ToString ( ) ) ;
491
+ break ;
492
+ default :
493
+ Console . WriteLine ( "Warning code: " + code + ", message: " + messageData . ToString ( ) ) ;
494
+ break ;
492
495
}
493
-
494
496
}
495
497
private void WebSocketClient_Closed ( object sender , EventArgs e )
496
498
{
@@ -726,6 +728,52 @@ public void DeleteRecord(string cortexToken, List<string> records)
726
728
SendTextMessage ( param , "deleteRecord" , true ) ;
727
729
}
728
730
731
+ // Export Records
732
+ // Required params: cortexToken, records, folderPath, streamTypes, format
733
+ public void ExportRecord ( string cortexToken , List < string > records , string folderPath ,
734
+ List < string > streamTypes , string format , string version = null ,
735
+ List < string > licenseIds = null , bool includeDemographics = false ,
736
+ bool includeMarkerExtraInfos = false , bool includeSurvey = false ,
737
+ bool includeDeprecatedPM = false )
738
+ {
739
+ JObject param = new JObject ( ) ;
740
+ param . Add ( "recordIds" , JArray . FromObject ( records ) ) ;
741
+ param . Add ( "cortexToken" , cortexToken ) ;
742
+ param . Add ( "folder" , folderPath ) ;
743
+ param . Add ( "streamTypes" , JArray . FromObject ( streamTypes ) ) ;
744
+ param . Add ( "format" , format ) ; // EDF, CSV, EDFPLUS, BDFPLUS
745
+
746
+ // If the format is "EDF", then you must omit version parameter.
747
+ // If the format is "CSV", then version parameter must be "V1" or "V2".
748
+ if ( version != null )
749
+ {
750
+ param . Add ( "version" , version ) ;
751
+ }
752
+ if ( licenseIds != null )
753
+ {
754
+ param . Add ( "licenseIds" , JArray . FromObject ( licenseIds ) ) ;
755
+ }
756
+
757
+ if ( includeDemographics )
758
+ {
759
+ param . Add ( "includeDemographics" , includeDemographics ) ;
760
+ }
761
+ if ( includeMarkerExtraInfos )
762
+ {
763
+ param . Add ( "includeMarkerExtraInfos" , includeMarkerExtraInfos ) ;
764
+ }
765
+ if ( includeSurvey )
766
+ {
767
+ param . Add ( "includeSurvey" , includeSurvey ) ;
768
+ }
769
+ if ( includeDeprecatedPM )
770
+ {
771
+ param . Add ( "includeDeprecatedPM" , includeDeprecatedPM ) ;
772
+ }
773
+
774
+ SendTextMessage ( param , "exportRecord" , true ) ;
775
+ }
776
+
729
777
// InjectMarker
730
778
// Required params: session, cortexToken, label, value, time
731
779
public void InjectMarker ( string cortexToken , string sessionId , string label , JToken value , double time , string port = null )
0 commit comments