예제 #1
0
        /// <summary>
        /// --------------------------- CONSTRUCTORS ---------------------------
        /// </summary>
        public LoadProfileGUI()
        {
            this.authorizer     = new Authorizer();
            this.sessionCreator = new SessionCreator();
            this.profileHandler = new ProfileHandler();
            this.headsetFinder  = new HeadsetFinder();


            this.licenseId       = "";
            this.cortexToken     = "";
            this.sessionId       = "";
            this.isActiveSession = false;
            Array.Clear(previousTriggerTime, 0, previousTriggerTime.Length);

            this.streams = new List <string>();

            this.applicationConnection = ApplicationConnection.Instance;

            stopwatch.Start();

            this.cortexClient = CortexClient.Instance;
            SubscribeToEvents();
            this.authorizer.Start(licenseId);
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("RECORD DATA DEMO");
            Console.WriteLine("Please wear Headset with good signal!!!");


            _ctxClient = CortexClient.Instance;
            _ctxClient.OnCreateRecord     += RecordCreatedOK;
            _ctxClient.OnStopRecord       += RecordStoppedOK;
            _ctxClient.OnErrorMsgReceived += MessageErrorRecieved;
            _ctxClient.OnQueryRecords     += QueryRecordsOK;
            _ctxClient.OnDeleteRecords    += DeleteRecordOK;
            _ctxClient.OnUpdateRecord     += RecordUpdatedOK;

            _authorizer.OnAuthorized          += AuthorizedOK;
            _headsetFinder.OnHeadsetConnected += HeadsetConnectedOK;
            _sessionCreator.OnSessionCreated  += SessionCreatedOk;
            _sessionCreator.OnSessionClosed   += SessionClosedOK;


            Console.WriteLine("Prepare to record Data");
            // Start
            _authorizer.Start();

            if (_readyForRecordDataEvent.WaitOne(50000))
            {
                Console.WriteLine("Press certain key to inject marker");
                Console.WriteLine("Press C to create record");
                Console.WriteLine("Press S to stop record");
                Console.WriteLine("Press Q to query record");
                Console.WriteLine("Press D to delete record");
                Console.WriteLine("Press U to update record");
                Console.WriteLine("Press H to show all commands");
                Console.WriteLine("Press Esc to quit");
                Console.WriteLine("Ignore Tab, Enter, Spacebar and Backspace key");

                ConsoleKeyInfo keyInfo;
                while (true)
                {
                    keyInfo = Console.ReadKey(true);
                    Console.WriteLine(keyInfo.KeyChar.ToString() + " has pressed");
                    if (keyInfo.Key == ConsoleKey.S)
                    {
                        // Stop Record
                        Console.WriteLine("Stop Record");
                        _ctxClient.StopRecord(_cortexToken, _sessionId);
                    }
                    else if (keyInfo.Key == ConsoleKey.C)
                    {
                        // Create Record
                        string title = "RecDemo-" + _recordNo;
                        Console.WriteLine("Create Record" + title);
                        _ctxClient.CreateRecord(_cortexToken, _sessionId, title);
                        _recordNo++;
                    }
                    else if (keyInfo.Key == ConsoleKey.U)
                    {
                        // Update Record
                        string        description = "description for RecDemo";
                        List <string> tags        = new List <string>()
                        {
                            "demo1", "demo2"
                        };
                        Console.WriteLine("Update Record: " + _currRecordId);
                        _ctxClient.UpdateRecord(_cortexToken, _currRecordId, description, tags);
                    }
                    else if (keyInfo.Key == ConsoleKey.Q)
                    {
                        // Query Record
                        // query param
                        JObject query = new JObject();
                        query.Add("applicationId", _sessionCreator.ApplicationId);

                        //order
                        JArray  orderBy  = new JArray();
                        JObject eleOrder = new JObject();
                        eleOrder.Add("startDatetime", "DESC");
                        orderBy.Add(eleOrder);
                        // limit
                        int limit  = 5; // number of maximum record return
                        int offset = 0;
                        _ctxClient.QueryRecord(_cortexToken, query, orderBy, offset, limit);
                    }
                    else if (keyInfo.Key == ConsoleKey.D)
                    {
                        // Delete first Record
                        if (_recordLists.Count > 0)
                        {
                            Record lastRecord = _recordLists[0];
                            string recordId   = lastRecord.Uuid;
                            Console.WriteLine("Delete Record" + recordId);
                            _ctxClient.DeleteRecord(_cortexToken, new List <string>()
                            {
                                recordId
                            });
                        }
                        else
                        {
                            Console.WriteLine("Please queryRecords first before call deleteRecord which delete first record in Lists");
                        }
                    }
                    else if (keyInfo.Key == ConsoleKey.H)
                    {
                        Console.WriteLine("Press certain key to inject marker");
                        Console.WriteLine("Press C to create record");
                        Console.WriteLine("Press S to stop record");
                        Console.WriteLine("Press Q to query record");
                        Console.WriteLine("Press D to delete record");
                        Console.WriteLine("Press U to update record");
                        Console.WriteLine("Press H to show all commands");
                        Console.WriteLine("Press Esc to quit");
                    }
                    else if (keyInfo.Key == ConsoleKey.Tab)
                    {
                        continue;
                    }
                    else if (keyInfo.Key == ConsoleKey.Backspace)
                    {
                        continue;
                    }
                    else if (keyInfo.Key == ConsoleKey.Enter)
                    {
                        continue;
                    }
                    else if (keyInfo.Key == ConsoleKey.Spacebar)
                    {
                        continue;
                    }
                    else if (keyInfo.Key == ConsoleKey.Escape)
                    {
                        _sessionCreator.CloseSession();
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Unsupported key");
                    }
                }

                Thread.Sleep(10000);
            }
            else
            {
                Console.WriteLine("The preparation for injecting marker is unsuccessful. Please try again");
            }
        }
예제 #3
0
 // Use this for initialization
 void Start()
 {
     cc = new CortexClient("localhost", 1337);
 }
예제 #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("INJECT MARKER DEMO");
            Console.WriteLine("Please wear Headset with good signal!!!");


            _ctxClient = CortexClient.Instance;
            _ctxClient.OnCreateRecord     += RecordCreatedOK;
            _ctxClient.OnStopRecord       += RecordStoppedOK;
            _ctxClient.OnInjectMarker     += MarkerInjectedOk;
            _ctxClient.OnErrorMsgReceived += MessageErrorRecieved;

            _authorizer.OnAuthorized          += AuthorizedOK;
            _headsetFinder.OnHeadsetConnected += HeadsetConnectedOK;
            _sessionCreator.OnSessionCreated  += SessionCreatedOk;
            _sessionCreator.OnSessionClosed   += SessionClosedOK;

            Console.WriteLine("Prepare to inject marker");
            // Start
            _authorizer.Start();

            if (_readyForInjectMarkerEvent.WaitOne(50000))
            {
                Console.WriteLine("Press certain key except below keys to inject marker");
                Console.WriteLine("Press S to stop record and quit");
                Console.WriteLine("Press Esc to quit");
                Console.WriteLine("Press H to show all commands");
                Console.WriteLine("Ignore Tab, Enter, Spacebar and Backspace key");

                int            valueMaker = 1;
                ConsoleKeyInfo keyInfo;
                while (true)
                {
                    keyInfo = Console.ReadKey(true);
                    Console.WriteLine(keyInfo.KeyChar.ToString() + " has pressed");
                    if (keyInfo.Key == ConsoleKey.S)
                    {
                        // Querry Sessions before quit
                        _ctxClient.StopRecord(_cortexToken, _sessionId);
                        Thread.Sleep(10000);
                        break;
                    }
                    if (keyInfo.Key == ConsoleKey.H)
                    {
                        Console.WriteLine("Press certain key except below keys to inject marker");
                        Console.WriteLine("Press S to stop record and quit");
                        Console.WriteLine("Press Esc to quit");
                        Console.WriteLine("Press H to show all commands");
                        Console.WriteLine("Ignore Tab, Enter, Spacebar and Backspace key");
                    }
                    else if (keyInfo.Key == ConsoleKey.Tab)
                    {
                        continue;
                    }
                    else if (keyInfo.Key == ConsoleKey.Backspace)
                    {
                        continue;
                    }
                    else if (keyInfo.Key == ConsoleKey.Enter)
                    {
                        continue;
                    }
                    else if (keyInfo.Key == ConsoleKey.Spacebar)
                    {
                        continue;
                    }
                    else if (keyInfo.Key == ConsoleKey.Escape)
                    {
                        break;
                    }
                    else
                    {
                        // Inject marker
                        if (_isRecording)
                        {
                            _ctxClient.InjectMarker(_cortexToken, _sessionId, keyInfo.Key.ToString(), valueMaker, Utils.GetEpochTimeNow());
                            Thread.Sleep(2000);
                            valueMaker++;
                        }
                    }
                }

                Thread.Sleep(10000);
            }
            else
            {
                Console.WriteLine("The preparation for injecting marker is unsuccessful. Please try again");
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("TRAINING MENTAL COMMAND DEMO");
            Console.WriteLine("Please wear Headset with good signal!!!");
            _ctxClient = CortexClient.Instance;
            _trainer.OnReadyForTraning   += ReadyForTraining;
            _trainer.OnTrainingSucceeded += TrainingSucceededOK;
            _trainer.OnProfileLoaded     += ProfileLoadedOK;
            _trainer.OnUnProfileLoaded   += ProfileUnloadedOK;

            Console.WriteLine("Prepare to training");
            // Start
            _trainer.Start("mentalCommand");

            if (_readyForTrainingEvent.WaitOne(50000))
            {
                Console.WriteLine("Press C to create a Profile.");
                Console.WriteLine("Press L to load a Profile.");
                Console.WriteLine("Press U to unload a Profile.");
                Console.WriteLine("Press 0 to start Neutral training.");
                Console.WriteLine("Press 1 to start Push training.");
                Console.WriteLine("Press 2 to start Pull training.");
                Console.WriteLine("Press A to accept training.");
                Console.WriteLine("Press R to reject training.");
                Console.WriteLine("Press H to show all commands.");
                Console.WriteLine("Press Esc to quit");
                Console.WriteLine("Ignore Tab, Enter, Spacebar and Backspace key");

                ConsoleKeyInfo keyInfo;
                while (true)
                {
                    keyInfo = Console.ReadKey(true);
                    Console.WriteLine(keyInfo.KeyChar.ToString() + " has pressed");

                    if (keyInfo.Key == ConsoleKey.C)
                    {
                        if (string.IsNullOrEmpty(Program._profileName))
                        {
                            _profileName = Utils.GenerateUuidProfileName("McDemo");
                        }

                        Console.WriteLine("Create profile: " + _profileName);
                        _trainer.CreateProfile(_profileName);
                        Thread.Sleep(1000);
                    }
                    else if (keyInfo.Key == ConsoleKey.L)
                    {
                        //Load profile
                        Console.WriteLine("Load profile: " + _profileName);
                        _trainer.LoadProfile(_profileName);
                        Thread.Sleep(1000);
                    }
                    else if (keyInfo.Key == ConsoleKey.U)
                    {
                        //Load profile
                        Console.WriteLine("UnLoad profile: " + _profileName);
                        _trainer.UnLoadProfile(_profileName);
                        Thread.Sleep(1000);
                    }
                    else if (keyInfo.Key == ConsoleKey.D0)
                    {
                        if (_isProfileLoaded)
                        {
                            _currentAction = "neutral";
                            //Start neutral training
                            _trainer.DoTraining(_currentAction, "start");
                            Thread.Sleep(2000);
                        }
                    }
                    else if (keyInfo.Key == ConsoleKey.D1)
                    {
                        if (_isProfileLoaded)
                        {
                            //Start push training
                            _currentAction = "push";
                            _trainer.DoTraining(_currentAction, "start");
                            Thread.Sleep(2000);
                        }
                    }
                    else if (keyInfo.Key == ConsoleKey.D2)
                    {
                        if (_isProfileLoaded)
                        {
                            //Start pull training
                            _currentAction = "pull";
                            _trainer.DoTraining(_currentAction, "start");
                            Thread.Sleep(2000);
                        }
                    }
                    else if (keyInfo.Key == ConsoleKey.A)
                    {
                        //Accept training
                        if (_isSucceeded)
                        {
                            _trainer.DoTraining(_currentAction, "accept");
                            Thread.Sleep(1000);
                            _isSucceeded = false; // reset
                        }
                    }
                    else if (keyInfo.Key == ConsoleKey.R)
                    {
                        //Reject training
                        if (_isSucceeded)
                        {
                            _trainer.DoTraining(_currentAction, "reject");
                            Thread.Sleep(1000);
                            _isSucceeded = false; // reset
                        }
                    }
                    else if (keyInfo.Key == ConsoleKey.H)
                    {
                        Console.WriteLine("Press C to create a Profile.");
                        Console.WriteLine("Press L to load a Profile.");
                        Console.WriteLine("Press U to unload a Profile.");
                        Console.WriteLine("Press 0 to start Neutral training.");
                        Console.WriteLine("Press 1 to start Push training.");
                        Console.WriteLine("Press 2 to start Pull training.");
                        Console.WriteLine("Press A to accept training.");
                        Console.WriteLine("Press R to reject training.");
                        Console.WriteLine("Press H to show all commands");
                        Console.WriteLine("Press Esc to quit");
                    }
                    else if (keyInfo.Key == ConsoleKey.Tab)
                    {
                        continue;
                    }
                    else if (keyInfo.Key == ConsoleKey.Backspace)
                    {
                        continue;
                    }
                    else if (keyInfo.Key == ConsoleKey.Enter)
                    {
                        continue;
                    }
                    else if (keyInfo.Key == ConsoleKey.Spacebar)
                    {
                        continue;
                    }
                    else if (keyInfo.Key == ConsoleKey.Escape)
                    {
                        _trainer.CloseSession();
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Unsupported key");
                    }
                }

                Thread.Sleep(10000);
            }
            else
            {
                Console.WriteLine("The preparation for training is unsuccessful. Please try again");
            }
        }
예제 #6
0
 // Use this for initialization
 void Start()
 {
     cc = new CortexClient("localhost", 1337);
 }