示例#1
0
 void TrainStartButtonClick(object sender, EventArgs e)
 {
     if (userNameTextBox.TextLength == 0)
     {
         MessageBox.Show("No username entered!!");
         return;
     }
     else
     {
         userNameTextBox.Enabled = false;
         //trainFormExitButton.Enabled = false;
     }
     userName                = userNameTextBox.Text;
     activityType            = "Meditation";
     trainMediButton.Enabled = false;
     storedFile              = "outfile.CSV";
     eeg_loggerObject.record(storedFile);
     try{
         userAuthObj.storeNewFeature(userName, storedFile, activityType);
         MessageBox.Show("Training Completed successfully!!");
         mediTrainedlabel.Text   = "Completed";
         trainMediButton.Visible = false;
         trainMathButton.Visible = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("There was some error while extracting features");
         MessageBox.Show(ex.Message);
         MessageBox.Show(ex.StackTrace);
         trainMediButton.Enabled = true;
     }
 }
        private void signalMatchButton_Click(object sender, EventArgs e)
        {
            //userName = ScreenLock.LoginForm.loginFormStaticObject.userNameString.Text;
            // userName = ScreenLock.LoginForm.userNameString;
            activityType = "Meditation";
            // string path = "profiles\\" + userName;//Environment.CurrentDirectory + "\\profiles\\" + userName;
            string path = userName;

            if (!(Directory.Exists(path)))
            {
                MessageBox.Show("User name \"" + userName + "\" not found!!");
                return;
            }
            //else
            //{
            //    //userNameTextBox.Enabled = false;
            //}
            string temp = activityType + "Activity.txt";
            //  string filePath = Environment.CurrentDirectory + "\\profiles\\" + userName + "\\" + temp;
            string filePath = userName + "\\" + temp;

            if (!(File.Exists(filePath)))
            {
                MessageBox.Show("\"" + activityType + "\" activity not trained!!Train the activity before matching");
                return;
            }
            mediMatchButton.Enabled = false;
            storedFile = "outfile.CSV";
            eeg_loggerObject.record(storedFile);
            try
            {
                res       = userAuthenticateObj.matchFeatures(userName, storedFile, activityType);
                ans       = ((MWNumericArray)res).ToVector(MWArrayComponent.Real);
                authParam = ans.GetValue(0).ToString();
                if (authParam.Equals("1"))
                {
                    mediMatchButton.Visible = false;
                    mathMatchButton.Visible = true;
                    matchMediLabel.Text     = "Authenticated";
                    //formCloseButton.Enabled = true;
                }
                else
                {
                    authParam = null;
                    MessageBox.Show("Authentication Failure!!", "FAILURE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    mediMatchButton.Enabled = true;
                    mathMatchButton.Visible = false;
                    //readingMatchButton.Visible = false;
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was some error while matching the features!!");
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.StackTrace);
                mediMatchButton.Visible = true;
            }
            finally
            {
                mediMatchButton.Visible = true;
                //mathMatchButton.Visible = true;
            }
        }