//- 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); }
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); }
/* * 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); }
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")) { } } }
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; } }
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); }
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(); }
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(); }
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(); }
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(); }
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); }