示例#1
0
 public bool CloudConnected()
 {
     if (EmotivCloudClient.EC_Connect() == EdkDll.EDK_OK)
     {
         message_box.text = "Connection to server OK";
         if (EmotivCloudClient.EC_Login(userName.text, password.text) == EdkDll.EDK_OK)
         {
             message_box.text = "Login as " + userName.text;
             if (EmotivCloudClient.EC_GetUserDetail(ref userCloudID) == EdkDll.EDK_OK)
             {
                 message_box.text = "CloudID: " + userCloudID;
                 return(true);
             }
         }
         else
         {
             message_box.text = "Cant login as " + userName.text + ", check password is correct";
         }
     }
     else
     {
         message_box.text = "Cant connect to server";
     }
     return(false);
 }
示例#2
0
 public void SaveProfile()
 {
     if (CloudConnected())
     {
         int profileId = -1;
         EmotivCloudClient.EC_GetProfileId(userCloudID, profileName.text, ref profileId);
         if (profileId >= 0)
         {
             if (EmotivCloudClient.EC_UpdateUserProfile(userCloudID, (int)engineUserID, profileId) == EdkDll.EDK_OK)
             {
                 message_box.text = "Profile updated";
             }
             else
             {
                 message_box.text = "Error saving profile, aborting";
             }
         }
         else
         {
             if (EmotivCloudClient.EC_SaveUserProfile(
                     userCloudID, engineUserID, profileName.text,
                     EmotivCloudClient.profileFileType.TRAINING) == EdkDll.EDK_OK)
             {
                 message_box.text = "Profiled saved successfully";
             }
             else
             {
                 message_box.text = "Error saving profile, aborting";
             }
         }
     }
 }
 //- Load - Save profile buttons // connect to the cloud // check for profile existence
 public bool CloudConnected()
 {
     if (EmotivCloudClient.EC_Connect() == Emotiv.EdkDll.EDK_OK)
     {
         Debug.Log("Connection to server OK");
         if (EmotivCloudClient.EC_Login(userName.text, password.text) == Emotiv.EdkDll.EDK_OK)
         {
             successOrNot.text = "Login as " + userName.text;
             if (EmotivCloudClient.EC_GetUserDetail(ref userCloudID) == Emotiv.EdkDll.EDK_OK)
             {
                 Debug.Log("CloudID: " + userCloudID.ToString());
                 return(true);
             }
         }
         else
         {
             successOrNot.text = "Cant login as " + userName.text + ", check password is correct";
         }
     }
     else
     {
         successOrNot.text = "Cant connect to server";
     }
     return(false);
 }
示例#4
0
    /*
     * These are the functions themselves that handle the connections, the message_box.text are text fields in the GUI where the user writes down his EMOTIV credentials
     */

    public bool CloudConnected()
    {
        if (EmotivCloudClient.EC_Connect() == EdkDll.EDK_OK)
        {
            textOutputFunction("Status: Connection to server OK");
            Debug.Log("Status: Connection to server OK");
            if (EmotivCloudClient.EC_Login(userName.text, password.text) == EdkDll.EDK_OK)
            {
                textOutputFunction("Status: Login as " + userName.text);
                Debug.Log("Status: Login as " + userName.text);
                if (EmotivCloudClient.EC_GetUserDetail(ref userCloudID) == EdkDll.EDK_OK)
                {
                    textOutputFunction("Status: CloudID: " + userCloudID);
                    Debug.Log("Status: CloudID: " + userCloudID);
                    return(true);
                }
            }
            else
            {
                textOutputFunction("Status: Cant login as " + userName.text + ", check password is correct");
                Debug.Log("Status: Cant login as " + userName.text + ", check password is correct");
            }
        }
        else
        {
            textOutputFunction("Status: Cant connect to server");
            Debug.Log("Status: Cant connect to server");
        }
        return(false);
    }
示例#5
0
    void loginWindow(int id)
    {
        GUI.Label(new Rect(10, 20, 100, 30), "User Name");
        username = GUI.TextField(new Rect(10, 40, 180, 30), username);
        GUI.Label(new Rect(10, 90, 100, 30), "Password");
        password = GUI.PasswordField(new Rect(10, 110, 180, 30), password, '*');
        if (GUI.Button(new Rect(10, 150, 80, 30), "Cancel"))
        {
            isLogin = false;
        }
        if (GUI.Button(new Rect(100, 150, 80, 30), "Login"))
        {
            int connect_result = EmotivCloudClient.EC_Connect();
            if (connect_result == EmotivCloudClient.EC_OK)
            {
                var login_result = EmotivCloudClient.EC_Login(username, password);
                if (login_result == EmotivCloudClient.EC_OK)
                {
                    Debug.Log("login success");
                    EmotivCloudClient.EC_GetUserDetail(ref userCloudId);
                    Debug.Log("user cloud id: " + userCloudId.ToString());
                    nProfile = EmotivCloudClient.EC_GetAllProfileName(userCloudId);
                    Debug.Log("number profiles: " + nProfile.ToString());
                    profiles = new List <PROFILE>();
                    for (var i = 0; i < nProfile; i++)
                    {
                        //Debug.Log("delete profile: ");
                        //var _id = EmotivCloudClient.EC_ProfileIDAtIndex(userCloudId, i);
                        //EmotivCloudClient.EC_DeleteUserProfile(userCloudId, _id);

                        int ii = EmotivCloudClient.EC_ProfileIDAtIndex(userCloudId, i);
                        EmotivCloudClient.Plugin_EC_ProfileNameAtIndex(userCloudId, 0);
                        PROFILE t = new PROFILE();
                        t.id   = EmotivCloudClient.EC_ProfileIDAtIndex(userCloudId, i);
                        t.name = EmotivCloudClient.Plugin_EC_ProfileNameAtIndex(userCloudId, i);
                        profiles.Add(t);
                        Debug.Log("profile name: " + profiles[i].name + " profile id: " + profiles[i].id.ToString());
                    }
                    isLogin = false;
                }

                else
                {
                    Debug.Log("cannot login, error: " + login_result.ToString());
                }
            }
            else
            {
                Debug.Log("cannot connect to emotiv cloud, error: " + connect_result.ToString());
            }
        }
        if (userCloudId != -1) //logged in
        {
            if (GUI.Button(new Rect(10, 150, 80, 30), "Load Profile"))
            {
            }
        }
    }
示例#6
0
        static void SavingLoadingFunction(int mode)
        {
            int getNumberProfile = EmotivCloudClient.EC_GetAllProfileName(userCloudID);

            if (mode == 0)
            {
                int profileID = EmotivCloudClient.EC_GetProfileId(userCloudID, profileName);

                if (profileID >= 0)
                {
                    Console.WriteLine("Profile with " + profileName + " is existed");
                    Console.WriteLine("Updating....");
                    if (EmotivCloudClient.EC_UpdateUserProfile(userCloudID, 0, profileID) == EmotivCloudClient.EC_OK)
                    {
                        Console.WriteLine("Updating finished");
                    }
                    else
                    {
                        Console.WriteLine("Updating failed");
                    }
                }
                else
                {
                    Console.WriteLine("Saving...");

                    if (EmotivCloudClient.EC_SaveUserProfile(userCloudID, (int)0, profileName,
                                                             EmotivCloudClient.profileFileType.TRAINING) == EmotivCloudClient.EC_OK)
                    {
                        Console.WriteLine("Saving finished");
                    }
                    else
                    {
                        Console.WriteLine("Saving failed");
                    }
                }

                return;
            }
            if (mode == 1)
            {
                if (getNumberProfile > 0)
                {
                    Console.WriteLine("Loading...");

                    if (EmotivCloudClient.EC_LoadUserProfile(userCloudID, 0,
                                                             EmotivCloudClient.EC_GetProfileId(userCloudID, profileName), version) == EmotivCloudClient.EC_OK)
                    {
                        Console.WriteLine("Loading finished");
                    }
                    else
                    {
                        Console.WriteLine("Loading failed");
                    }
                }

                return;
            }
        }
示例#7
0
        static void SavingLoadingFunction(int mode)
        {
            int getNumberProfile = EmotivCloudClient.EC_GetAllProfileName(userCloudID);

            if (mode == 0)
            {
                int profileID = EmotivCloudClient.EC_GetProfileId(userCloudID, profileName);

                if (profileID >= 0)
                {
                    Console.WriteLine("Profile with " + profileName + " is existed");
                    if (EmotivCloudClient.EC_UpdateUserProfile(userCloudID, engineUserID, profileID, profileName))
                    {
                        Console.WriteLine("Updating finished");
                    }
                    else
                    {
                        Console.WriteLine("Updating failed");
                    }
                }
                else if (EmotivCloudClient.EC_SaveUserProfile(userCloudID, (int)engineUserID, profileName, EmotivCloudClient.profileFileType.TRAINING))
                {
                    Console.WriteLine("Saving finished");
                }
                else
                {
                    Console.WriteLine("Saving failed");
                }

                Thread.Sleep(5000);
                return;
            }
            if (mode == 1)
            {
                if (getNumberProfile > 0)
                {
                    if (EmotivCloudClient.EC_LoadUserProfile(userCloudID, engineUserID, EmotivCloudClient.EC_ProfileIDAtIndex(userCloudID, 0), version))
                    {
                        Console.WriteLine("Loading finished");
                    }
                    else
                    {
                        Console.WriteLine("Loading failed");
                    }
                }

                Thread.Sleep(5000);
                return;
            }
        }
示例#8
0
 public void LoadProfile()
 {
     if (CloudConnected())
     {
         if (EmotivCloudClient.EC_LoadUserProfile(userCloudID, (int)engineUserID, EmotivCloudClient.EC_GetProfileId(userCloudID, profileName.text), (int)version))
         {
             message_box.text = "Load finished";
         }
         else
         {
             message_box.text = "Problem loading";
         }
     }
 }
 public void LoadProfile()
 {
     if (CloudConnected())
     {
         int profileId = -1;
         EmotivCloudClient.EC_GetProfileId(userCloudID, profileName.text, ref profileId);
         if (EmotivCloudClient.EC_LoadUserProfile(userCloudID, (int)engineUserID, profileId, (int)version) == Emotiv.EdkDll.EDK_OK)
         {
             successOrNot.text = "Load finished successfully";
             isRegestered      = true;
         }
         else
         {
             successOrNot.text = "Problem loading";
         }
     }
 }
示例#10
0
        public static void activateLicense()
        {
            string licenseKey = "d8a7953c-e088-40a9-b9cc-a41bb7cfbb2b";
            int    debitNum   = 1000000;
            string userName   = "******";
            string password   = "******";

            //Authorize

            if (EmotivCloudClient.EC_Connect() != EdkDll.EDK_OK)
            {
                My_Program.myForm.textBox1.Text = "Cannot connect to Emotiv.";
                Thread.Sleep(2000);
                return;
            }


            if (EmotivCloudClient.EC_Login(userName, password) != EdkDll.EDK_OK)
            {
                My_Program.myForm.textBox1.Text = "Your login failed.";
                Thread.Sleep(2000);
                return;
            }

            My_Program.myForm.textBox1.Text = "Logged in as " + userName;

            int userCloudID = 0;

            if (EmotivCloudClient.EC_GetUserDetail(ref userCloudID) != EdkDll.EDK_OK)
            {
                return;
            }


            int result = EdkDll.IEE_AuthorizeLicense(licenseKey, debitNum);

            if (result == EdkDll.EDK_OK || result == EdkDll.EDK_LICENSE_REGISTERED)
            {
                My_Program.myForm.textBox1.Text = "License activated.";
            }
            else
            {
                My_Program.myForm.textBox1.Text = "License Error:" + result;
            }
        }
示例#11
0
        static void Main(string[] args)
        {
            Console.WriteLine("===========================================");
            Console.WriteLine("The example to activate a license key.");
            Console.WriteLine("===========================================");

            EmoEngine engine = EmoEngine.Instance;

            engine.Connect();

            //Authorize
            if (EmotivCloudClient.EC_Connect() != EdkDll.EDK_OK)
            {
                Console.WriteLine("Cannot connect to Emotiv Cloud.");
                Thread.Sleep(2000);
                return;
            }

            if (EmotivCloudClient.EC_Login(userName, password) != EdkDll.EDK_OK)
            {
                Console.WriteLine("Your login attempt has failed. The username or password may be incorrect");
                Thread.Sleep(2000);
                return;
            }

            Console.WriteLine("Logged in as " + userName);

            if (EmotivCloudClient.EC_GetUserDetail(ref userCloudID) != EdkDll.EDK_OK)
            {
                return;
            }

            //Active license
            activateLicense();

            //We can call this API any time to check current License information
            licenseInformation();

            //GetDebitInfo
            getDebitInformation();

            Thread.Sleep(5000);
        }
示例#12
0
    void UploadProfileWindow(int wId)
    {
        GUI.Label(new Rect(10, 20, 200, 30), "Create new profile");
        newProfileName = GUI.TextField(new Rect(10, 40, 180, 30), newProfileName);
        if (GUI.Button(new Rect(10, 80, 90, 30), "Cancel"))
        {
            isUploadProfile = false;
        }
        if (GUI.Button(new Rect(120, 80, 80, 30), "Upload"))
        {
            int pid = EmotivCloudClient.EC_GetProfileId(userCloudId, newProfileName);
            if (pid >= 0)
            {
                EmotivCloudClient.EC_UpdateUserProfile(userCloudId, EmoUserManagement.currentUser, pid);
                //close upload window
                isUploadProfile = false;
            }
            else
            {
                EmotivCloudClient.EC_SaveUserProfile(userCloudId, EmoUserManagement.currentUser, newProfileName, EmotivCloudClient.profileFileType.TRAINING);
                int     id = EmotivCloudClient.EC_GetProfileId(userCloudId, newProfileName);
                PROFILE t  = new PROFILE();
                t.id   = id;
                t.name = newProfileName;
                profiles.Add(t);
                //close upload window
                isUploadProfile = false;
            }
        }
        GUI.Label(new Rect(10, 110, 200, 30), "or select from your profiles");
        vec2_Scoll = GUI.BeginScrollView(new Rect(10, 130, 200, 300), vec2_Scoll, new Rect(0, 0, 200, 300));
        int _i = 0;

        foreach (PROFILE p in profiles)
        {
            if (GUI.Button(new Rect(0, 10 + _i * 35, 200, 30), p.name))
            {
                newProfileName = p.name;
            }
            _i++;
        }
        GUI.EndScrollView();
    }
示例#13
0
 public void LoadProfile()
 {
     if (CloudConnected())
     {
         int profileId = -1;
         if (EmotivCloudClient.EC_LoadUserProfile(
                 userCloudID, (int)engineUserID,
                 EmotivCloudClient.EC_GetProfileId(userCloudID, profileName.text, ref profileId),
                 (int)version) == EdkDll.EDK_OK)
         {
             textOutputFunction("Status: Load finished");
             Debug.Log("Status: Load finished");
         }
         else
         {
             textOutputFunction("Status: Problem loading");
             Debug.Log("Status: Problem loading");
         }
     }
 }
示例#14
0
        static void ProfileLoading()
        {
            Console.WriteLine("Loading...");

            int profileID = -1;

            EmotivCloudClient.EC_GetProfileId(cloudUserID, profileName, ref profileID);

            if (EmotivCloudClient.EC_LoadUserProfile(cloudUserID, 0, profileID, version) == EdkDll.EDK_OK)
            {
                Console.WriteLine("Loading finished");
            }
            else
            {
                Console.WriteLine("Loading failed");
            }

            Thread.Sleep(5000);
            return;
        }
示例#15
0
    public void LoadProfile()
    {
        if (CloudConnected())
        {
            int profileId = -1;
            EmotivCloudClient.EC_GetProfileId(userCloudID, profileName.text, ref profileId);

            if (EmotivCloudClient.EC_LoadUserProfile(
                    userCloudID, (int)engineUserID,
                    profileId,
                    (int)version) == EdkDll.EDK_OK)
            {
                message_box.text = "Load finished";
            }
            else
            {
                message_box.text = "Problem loading";
            }
        }
    }
示例#16
0
    void LoadProfileWindow(int wid)
    {
        GUI.Label(new Rect(10, 20, 200, 30), "Select profile");
        vec2_Scoll = GUI.BeginScrollView(new Rect(10, 50, 200, 300), vec2_Scoll, new Rect(0, 0, 200, 300));
        int i = 0;

        foreach (PROFILE p in profiles)
        {
            if (GUI.Button(new Rect(0, 10 + i * 35, 200, 30), p.name))
            {
                EmotivCloudClient.EC_LoadUserProfile(userCloudId, EmoUserManagement.currentUser, p.id, -1);
                str_Profile   = p.name;
                isLoadProfile = false;
            }
            i++;
        }
        GUI.EndScrollView();
        if (GUI.Button(new Rect(10, 350, 200, 30), "Close"))
        {
            isLoadProfile = false;
        }
    }
示例#17
0
        static void ProfileSaving()
        {
            int profileID = -1;

            EmotivCloudClient.EC_GetProfileId(cloudUserID, profileName, ref profileID);

            if (profileID >= 0)
            {
                Console.WriteLine("Updating...");

                Console.WriteLine("Profile with " + profileName + " is existed");
                if (EmotivCloudClient.EC_UpdateUserProfile(cloudUserID, engineUserID, profileID) == EdkDll.EDK_OK)
                {
                    Console.WriteLine("Updating finished");
                }
                else
                {
                    Console.WriteLine("Updating failed");
                }
            }
            else
            {
                Console.WriteLine("Saving...");

                if (EmotivCloudClient.EC_SaveUserProfile(cloudUserID, 0, profileName,
                                                         EmotivCloudClient.profileFileType.TRAINING) == EdkDll.EDK_OK)
                {
                    Console.WriteLine("Saving finished");
                }
                else
                {
                    Console.WriteLine("Saving failed");
                }
            }

            Thread.Sleep(5000);
            return;
        }
示例#18
0
 public void SaveProfile()
 {
     if (CloudConnected())
     {
         int profileId = -1;
         profileId = EmotivCloudClient.EC_GetProfileId(userCloudID, profileName.text, ref profileId);
         if (profileId >= 0)
         {
             if (EmotivCloudClient.EC_UpdateUserProfile(userCloudID, (int)engineUserID, profileId) == EdkDll.EDK_OK)
             {
                 textOutputFunction("Status: Profile updated");
                 Debug.Log("Status: Profile updated");
             }
             else
             {
                 textOutputFunction("Status: Error saving profile, aborting");
                 Debug.Log("Status: Error saving profile, aborting");
             }
         }
         else
         {
             if (EmotivCloudClient.EC_SaveUserProfile(
                     userCloudID, engineUserID, profileName.text,
                     EmotivCloudClient.profileFileType.TRAINING) == EdkDll.EDK_OK)
             {
                 textOutputFunction("Status: Profiled saved successfully");
                 Debug.Log("Status: Profiled saved successfully");
             }
             else
             {
                 textOutputFunction("Status: Error saving profile, aborting");
                 Debug.Log("Status: Error saving profile, aborting");
             }
         }
     }
 }
示例#19
0
        static void Main(string[] args)
        {
            EmoEngine engine = EmoEngine.Instance;

            engine.EmoEngineConnected +=
                new EmoEngine.EmoEngineConnectedEventHandler(engine_EmoEngineConnected);
            engine.EmoEngineDisconnected +=
                new EmoEngine.EmoEngineDisconnectedEventHandler(engine_EmoEngineDisconnected);

            engine.UserAdded +=
                new EmoEngine.UserAddedEventHandler(engine_UserAdded);
            engine.UserRemoved +=
                new EmoEngine.UserRemovedEventHandler(engine_UserRemoved);

            engine.EmoStateUpdated +=
                new EmoEngine.EmoStateUpdatedEventHandler(engine_EmoStateUpdated);
            engine.EmoEngineEmoStateUpdated +=
                new EmoEngine.EmoEngineEmoStateUpdatedEventHandler(engine_EmoEngineEmoStateUpdated);

            engine.MentalCommandEmoStateUpdated +=
                new EmoEngine.MentalCommandEmoStateUpdatedEventHandler(engine_MentalCommandEmoStateUpdated);
            engine.MentalCommandTrainingStarted +=
                new EmoEngine.MentalCommandTrainingStartedEventEventHandler(engine_MentalCommandTrainingStarted);
            engine.MentalCommandTrainingSucceeded +=
                new EmoEngine.MentalCommandTrainingSucceededEventHandler(engine_MentalCommandTrainingSucceeded);
            engine.MentalCommandTrainingCompleted +=
                new EmoEngine.MentalCommandTrainingCompletedEventHandler(engine_MentalCommandTrainingCompleted);
            engine.MentalCommandTrainingRejected +=
                new EmoEngine.MentalCommandTrainingRejectedEventHandler(engine_MentalCommandTrainingRejected);

            engine.Connect();

            Console.WriteLine("===========================================================================");
            Console.WriteLine("Example to show how to detect mental command detection with a profile.");
            Console.WriteLine("===========================================================================");

            ConsoleKeyInfo cki = new ConsoleKeyInfo();

            if (EmotivCloudClient.EC_Connect() != EmotivCloudClient.EC_OK)
            {
                Console.WriteLine("Cannot connect to Emotiv Cloud.");
                Thread.Sleep(2000);
                return;
            }

            if (EmotivCloudClient.EC_Login(userName, password) != EmotivCloudClient.EC_OK)
            {
                Console.WriteLine("Your login attempt has failed. The username or password may be incorrect");
                Thread.Sleep(2000);
                return;
            }

            Console.WriteLine("Logged in as " + userName);

            if (EmotivCloudClient.EC_GetUserDetail(ref userCloudID) != EmotivCloudClient.EC_OK)
            {
                return;
            }

            while (true)
            {
                try
                {
                    if (Console.KeyAvailable)
                    {
                        cki = Console.ReadKey(true);
                        keyHandler(cki.Key);

                        if (cki.Key == ConsoleKey.X)
                        {
                            break;
                        }
                    }
                    engine.ProcessEvents(5);
                }
                catch (EmoEngineException e)
                {
                    Console.WriteLine("{0}", e.ToString());
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0}", e.ToString());
                }
            }
            engine.Disconnect();
        }
示例#20
0
        static void Main(string[] args)
        {
            Console.WriteLine("===========================================================================");
            Console.WriteLine("Example to saving and loading profile from Emotiv Cloud.");
            Console.WriteLine("===========================================================================");
            Console.WriteLine("Press 'F1' to saving profile to Emotiv Cloud.");
            Console.WriteLine("Press 'F2' to loading profile from Emotiv Cloud.");

            SavingAndLoadingProfileCloud p = new SavingAndLoadingProfileCloud();

            // create the engine
            EmoEngine engine = EmoEngine.Instance;

            engine.UserAdded += new EmoEngine.UserAddedEventHandler(engine_UserAdded_Event);
            engine.Connect();

            ConsoleKeyInfo cki = new ConsoleKeyInfo();

            if (EmotivCloudClient.EC_Connect() != EdkDll.EDK_OK)
            {
                Console.WriteLine("Cannot connect to Emotiv Cloud.");
                Thread.Sleep(2000);
                return;
            }

            if (EmotivCloudClient.EC_Login(userName, password) != EdkDll.EDK_OK)
            {
                Console.WriteLine("Your login attempt has failed. The username or password may be incorrect");
                Thread.Sleep(2000);
                return;
            }

            Console.WriteLine("Logged in as " + userName);

            if (EmotivCloudClient.EC_GetUserDetail(ref cloudUserID) != EdkDll.EDK_OK)
            {
                return;
            }

            // Loading information of all profiles from Cloud to buffer.
            // and return number of profile in the list.
            int getNumberProfile = EmotivCloudClient.EC_GetAllProfileName(cloudUserID);

            while (true)
            {
                engine.ProcessEvents(10);

                if (!Console.KeyAvailable)
                {
                    continue;
                }
                cki = Console.ReadKey(true);

                if (cki.Key == ConsoleKey.F1)
                {
                    if (engineUserID < 0)
                    {
                        Console.WriteLine("No headset is connected.");
                        continue;
                    }

                    // If your profile is new profile. You need call this function
                    // before want to train Mental Command detections.
                    ProfileSaving();
                    break;
                }
                if (cki.Key == ConsoleKey.F2)
                {
                    if (engineUserID < 0)
                    {
                        Console.WriteLine("No headset is connected.");
                        continue;
                    }

                    if (getNumberProfile > 0)
                    {
                        ProfileLoading();
                        break;
                    }
                }
            }

            engine.Disconnect();
        }
示例#21
0
        protected override bool ConnectionSetUp(out string errorMessage)
        {
            string userName    = this.username;
            string password    = this.password;
            string profileName = this.profileName;

            int state = 0;

            uint engineUserID;
            int  userCloudID;

            engineUserID = 0;
            userCloudID  = -1;

            if (EdkDll.IEE_EngineConnect("Emotiv Systems-5") != EdkDll.EDK_OK)
            {
                errorMessage = "Emotiv Engine start up failed.";
                return(false);
            }

            eEvent = EdkDll.IEE_EmoEngineEventCreate();
            eState = EdkDll.IEE_EmoStateCreate();

            UpdateBatteryLevel();
            UpdateWirelessSigmalStrength();

            if (EmotivCloudClient.EC_Connect() != EmotivCloudClient.EC_OK)
            {
                errorMessage = ("Cannot connect to Emotiv Cloud");
                return(false);
            }

            if (EmotivCloudClient.EC_Login(userName, password) != EmotivCloudClient.EC_OK)
            {
                errorMessage = ("Your login attempt has failed. The username or password may be incorrect");
                return(false);
            }

            //Debug.WriteLine("Logged in as " + userName);

            if (EmotivCloudClient.EC_GetUserDetail(ref userCloudID) != EmotivCloudClient.EC_OK)
            {
                errorMessage = "Unable to get user details";
                return(false);
            }

            state = EdkDll.IEE_EngineGetNextEvent(eEvent);

            if (state == EdkDll.EDK_OK)
            {
                var eventType = EdkDll.IEE_EmoEngineEventGetType(eEvent);
                EdkDll.IEE_EmoEngineEventGetUserId(eEvent, out engineUserID);

                // Log the EmoState if it has been updated
                if (eventType == EdkDll.IEE_Event_t.IEE_UserAdded)
                {
                    //Debug.WriteLine("User added");
                }
            }
            else if (state != EdkDll.EDK_NO_EVENT)
            {
                errorMessage = ("Internal error in Emotiv Engine!");
                return(false);
            }

            //Debug.WriteLine("userCloudID: " + userCloudID);
            //Debug.WriteLine("userEngineID: " + engineUserID);

            int version          = -1; // Lastest version
            int getNumberProfile = EmotivCloudClient.EC_GetAllProfileName(userCloudID);

            //Debug.WriteLine(getNumberProfile);

            if (getNumberProfile > 0)
            {
                int profileID = EmotivCloudClient.EC_GetProfileId(userCloudID, profileName);
                //Debug.WriteLine(profileID);
                if (EmotivCloudClient.EC_LoadUserProfile(userCloudID, (int)engineUserID, profileID, version) == EmotivCloudClient.EC_OK)
                {
                    // Debug.WriteLine("Loading finished" + EmotivCloudClient.EC_GetAllProfileName(userCloudID));
                }
                else
                {
                    errorMessage = ("Loading failed: either USB not connected or profile  \'" + profileName + "\' doesn't exist");
                    EmotivCloudClient.EC_Logout(userCloudID);
                    return(false);
                }
            }

            uint pTrainedActionsOut = 0;

            EdkDll.IEE_MentalCommandGetTrainedSignatureActions(engineUserID, out pTrainedActionsOut);
            //Debug.WriteLine("Current overall trained actions: " + pTrainedActionsOut);

            float skill = -1;

            EdkDll.IEE_MentalCommandGetOverallSkillRating(engineUserID, out skill);
            //Debug.WriteLine("Current overall skill rating: " + skill);

            errorMessage = "Profile " + profileName + " was loaded and device connected!";

            return(true);
        }
示例#22
0
        static void Main(string[] args)
        {
            EmoEngine engine = EmoEngine.Instance;

            engine.EmoEngineConnected +=
                new EmoEngine.EmoEngineConnectedEventHandler(engine_EmoEngineConnected);
            engine.EmoEngineDisconnected +=
                new EmoEngine.EmoEngineDisconnectedEventHandler(engine_EmoEngineDisconnected);

            engine.UserAdded +=
                new EmoEngine.UserAddedEventHandler(engine_UserAdded);
            engine.UserRemoved +=
                new EmoEngine.UserRemovedEventHandler(engine_UserRemoved);

            engine.EmoStateUpdated +=
                new EmoEngine.EmoStateUpdatedEventHandler(engine_EmoStateUpdated);
            engine.EmoEngineEmoStateUpdated +=
                new EmoEngine.EmoEngineEmoStateUpdatedEventHandler(engine_EmoEngineEmoStateUpdated);

            engine.MentalCommandEmoStateUpdated +=
                new EmoEngine.MentalCommandEmoStateUpdatedEventHandler(engine_MentalCommandEmoStateUpdated);
            engine.MentalCommandTrainingStarted +=
                new EmoEngine.MentalCommandTrainingStartedEventEventHandler(engine_MentalCommandTrainingStarted);
            engine.MentalCommandTrainingSucceeded +=
                new EmoEngine.MentalCommandTrainingSucceededEventHandler(engine_MentalCommandTrainingSucceeded);
            engine.MentalCommandTrainingCompleted +=
                new EmoEngine.MentalCommandTrainingCompletedEventHandler(engine_MentalCommandTrainingCompleted);
            engine.MentalCommandTrainingRejected +=
                new EmoEngine.MentalCommandTrainingRejectedEventHandler(engine_MentalCommandTrainingRejected);

            engine.Connect();

            Console.WriteLine("===========================================================================");
            Console.WriteLine("Example to show how to detect mental command detection with a profile.");
            Console.WriteLine("Please use hotkeys for training.");
            Console.WriteLine("F1: MetalCommand: Set Active Action - LEFT and RIGHT");
            Console.WriteLine("F2: MetalCommand: Training Action   - NEUTRAL");
            Console.WriteLine("F3: MetalCommand: Training Action   - RIGHT");
            Console.WriteLine("F4: MetalCommand: Training Action   - LEFT");
            Console.WriteLine("F5: MetalCommand: Set Active Level  - 2");
            Console.WriteLine("F6: MetalCommand: Get Active Level");
            Console.WriteLine("F7: MetalCommand: Get OverSkills Rating");
            Console.WriteLine("F8: Update profile");
            Console.WriteLine("F9: Load profile");
            Console.WriteLine("F10:Enable Logger");
            Console.WriteLine("===========================================================================");

            ConsoleKeyInfo cki = new ConsoleKeyInfo();

            if (EmotivCloudClient.EC_Connect() != EdkDll.EDK_OK)
            {
                Console.WriteLine("Cannot connect to Emotiv Cloud.");
                Thread.Sleep(2000);
                return;
            }

            if (EmotivCloudClient.EC_Login(userName, password) != EdkDll.EDK_OK)
            {
                Console.WriteLine("Your login attempt has failed. The username or password may be incorrect");
                Thread.Sleep(2000);
                return;
            }

            Console.WriteLine("Logged in as " + userName);

            if (EmotivCloudClient.EC_GetUserDetail(ref userCloudID) != EdkDll.EDK_OK)
            {
                return;
            }

            while (true)
            {
                try
                {
                    if (Console.KeyAvailable)
                    {
                        cki = Console.ReadKey(true);
                        keyHandler(cki.Key);

                        if (cki.Key == ConsoleKey.X)
                        {
                            break;
                        }
                    }
                    engine.ProcessEvents(5);
                }
                catch (EmoEngineException e)
                {
                    Console.WriteLine("{0}", e.ToString());
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0}", e.ToString());
                }
            }
            engine.Disconnect();
        }
示例#23
0
        static void Main(string[] args)
        {
            Console.WriteLine("===========================================================================");
            Console.WriteLine("Example to saving and loading profile from Emotiv Cloud.");
            Console.WriteLine("===========================================================================");
            Console.WriteLine("Press 'F1' to saving profile to Emotiv Cloud.");
            Console.WriteLine("Press 'F2' to loading profile from Emotiv Cloud.");

            SavingAndLoadingProfileCloud p = new SavingAndLoadingProfileCloud();

            // create the engine
            EmoEngine engine = EmoEngine.Instance;

            engine.UserAdded += new EmoEngine.UserAddedEventHandler(engine_UserAdded_Event);
            engine.Connect();

            ConsoleKeyInfo cki = new ConsoleKeyInfo();

            if (EmotivCloudClient.EC_Connect() != EmotivCloudClient.EC_OK)
            {
                Console.WriteLine("Cannot connect to Emotiv Cloud.");
                Thread.Sleep(2000);
                return;
            }

            if (EmotivCloudClient.EC_Login(userName, password) != EmotivCloudClient.EC_OK)
            {
                Console.WriteLine("Your login attempt has failed. The username or password may be incorrect");
                Thread.Sleep(2000);
                return;
            }

            Console.WriteLine("Logged in as " + userName);

            if (EmotivCloudClient.EC_GetUserDetail(ref userCloudID) != EmotivCloudClient.EC_OK)
            {
                return;
            }

            while (true)
            {
                engine.ProcessEvents(10);

                if (!Console.KeyAvailable)
                {
                    continue;
                }
                cki = Console.ReadKey(true);

                if (cki.Key == ConsoleKey.F1)
                {
                    if (engineUserID < 0)
                    {
                        Console.WriteLine("No headset is connected.");
                        continue;
                    }
                    SavingLoadingFunction(0);
                    break;
                }
                if (cki.Key == ConsoleKey.F2)
                {
                    if (engineUserID < 0)
                    {
                        Console.WriteLine("No headset is connected.");
                        continue;
                    }
                    SavingLoadingFunction(1);
                    break;
                }
            }

            engine.Disconnect();
        }