예제 #1
0
파일: NetsTab.cs 프로젝트: jpscanlon/AI-Dev
        private void ButtonNetTrain_Click(object sender, RoutedEventArgs e)
        {
            switch (comboBoxNetDataset.Text)
            {
            case "1 Item":
                getHistoryInterval = 3;
                break;

            case "2 Items":
                getHistoryInterval = 3;
                break;

            case "0.2 Percent":
                getHistoryInterval = 3;
                break;

            case "2.0 Percent":
                getHistoryInterval = 5;
                break;

            case "10.0 Percent":
                getHistoryInterval = 8;
                break;
            }

            string command = "trainnet";
            string args    = '"' + comboBoxNetDataset.Text + "\" \"" + textBoxNetIterationSize.Text + '"';

            command = command + " " + args;

            string response = TcpConnection.SendMessage(command);

            if (response == "training started")
            {
                labelNetTrainingProgress.Visibility = Visibility.Visible;
                ProgressBarTraining.IsIndeterminate = true;  // Start animation.
                buttonNetStop.IsEnabled             = true;

                OpenTraining();
            }
        }
예제 #2
0
파일: NetsTab.cs 프로젝트: jpscanlon/AI-Dev
        private void CreateNet()
        {
            string response = TcpConnection.SendMessage("addnet");

            if (response != "")
            {
                if (IsCommandError(response))
                {
                    MessageBox.Show("Server response: \r\n" + response);
                }
                else
                {
                    LoadNetsView();
                    ViewNet(response);  // Response is new net name.
                }
            }
            else
            {
                MessageBox.Show("Error: could not create net.\r\n");
            }
        }
예제 #3
0
파일: NetsTab.cs 프로젝트: jpscanlon/AI-Dev
        private void ButtonNetSave_Click(object sender, RoutedEventArgs e)
        {
            // Replace this with field validation on text change.
            if (comboBoxNetType.Text == "Convolutional" && Convert.ToInt32(textBoxNetConvLayers.Text) < 1)
            {
                textBoxNetConvLayers.Text = "1";
            }

            string descriptionArguments = "\"" + Nets[currentNet].Name + "\" \"" +
                                          textBoxNetName.Text + "\" \"" + comboBoxNetType.Text + "\" \"" +
                                          comboBoxNetActivationFunction.Text + "\" \"" +
                                          Convert.ToString(checkBoxNetIsGrayscale.IsChecked) + "\"";
            string layerArguments = textBoxNetInputs.Text + " " + textBoxNetOutputs.Text + " " +
                                    textBoxNetFCLayers.Text + " " + textBoxNetConvLayers.Text;
            string command;

            if (comboBoxNetType.Text != Nets[currentNet].Type ||
                textBoxNetInputs.Text != Convert.ToString(Nets[currentNet].NumInputs) ||
                textBoxNetOutputs.Text != Convert.ToString(Nets[currentNet].NumOutputs) ||
                textBoxNetFCLayers.Text != Convert.ToString(Nets[currentNet].NumFCLayers) ||
                textBoxNetConvLayers.Text != Convert.ToString(Nets[currentNet].NumConvLayers))
            {
                // Net structure needs to be changed for the save.
                command = "updatewholenet " + descriptionArguments + " " + layerArguments;
            }
            else
            {
                command = "updatenet " + descriptionArguments;
            }

            string response = TcpConnection.SendMessage(command);

            LoadNetsView();
            ViewNet(textBoxNetName.Text);

            MessageBox.Show("Server response: \r\n" + response);
        }
예제 #4
0
파일: NetsTab.cs 프로젝트: jpscanlon/AI-Dev
        private void ButtonTrainBump_Click(object sender, RoutedEventArgs e)
        {
            string command = "bump";

            _ = TcpConnection.SendMessage(command);
        }
예제 #5
0
파일: NetsTab.cs 프로젝트: jpscanlon/AI-Dev
        private void ButtonNetReinitialize_Click(object sender, RoutedEventArgs e)
        {
            string command = "reinitialize";

            _ = TcpConnection.SendMessage(command);
        }
예제 #6
0
파일: NetsTab.cs 프로젝트: jpscanlon/AI-Dev
        private void DeleteNet(string name)
        {
            char quote = '"';

            TcpConnection.SendMessage("deletenet " + quote + name + quote);
        }
예제 #7
0
 private void MenuItemTestSQLStatement_Click(object sender, RoutedEventArgs e)
 {
     _ = TcpConnection.SendMessage("runsql");
     //MessageBox.Show("Server response: " + response);
 }
예제 #8
0
파일: NetsTab.cs 프로젝트: jpscanlon/AI-Dev
        private int OpenNet(string netName)
        {
            bool   nameFound = false;
            int    netIdx    = 0;
            string command   = "opennet \"" + netName + "\"";
            string response  = TcpConnection.SendMessage(command);

            if (response != "error")
            {
                bool isGrayscale;
                if (response == "True")
                {
                    isGrayscale = true;
                }
                else
                {
                    isGrayscale = false;
                }

                textBoxNetIterationSize.Text     = "1";
                checkBoxNetIsGrayscale.IsChecked = isGrayscale;

                while (!nameFound && netIdx < Nets.Count)
                {
                    if (Nets[netIdx].Name == netName)
                    {
                        nameFound            = true;
                        textBoxNetName.Text  = Nets[netIdx].Name;
                        comboBoxNetType.Text = Nets[netIdx].Type.ToString();
                        comboBoxNetActivationFunction.Text = Nets[netIdx].ActivationFunction;
                        textBoxNetInputs.Text     = Nets[netIdx].NumInputs.ToString();
                        textBoxNetOutputs.Text    = Nets[netIdx].NumOutputs.ToString();
                        textBoxNetFCLayers.Text   = Nets[netIdx].NumFCLayers.ToString();
                        textBoxNetConvLayers.Text = Nets[netIdx].NumConvLayers.ToString();
                    }
                    netIdx++;
                }

                if (!nameFound)
                {
                    netIdx = -1;
                }
                else
                {
                    netIdx -= 1;
                }
            }
            else
            {
                netIdx = -1;
            }

            currentNet = netIdx;

            if (netIdx == -1)
            {
                MessageBox.Show("Error: Could not open net.");
            }

            return(netIdx);
        }
예제 #9
0
 private void MenuClearLog_Click(object sender, RoutedEventArgs e)
 {
     _ = TcpConnection.SendMessage("clearlog");
 }
예제 #10
0
 private void MenuItemWriteToLog_Click(object sender, RoutedEventArgs e)
 {
     _ = TcpConnection.SendMessage("writetolog");
 }
예제 #11
0
        private void MenuItemTestTcpMessage_Click(object sender, RoutedEventArgs e)
        {
            string response = TcpConnection.SendMessage("test message");

            MessageBox.Show("Server response: " + response);
        }
예제 #12
0
 private void MenuItemFileOpenKB_Click(object sender, RoutedEventArgs e)
 {
     _ = TcpConnection.SendMessage("openkb");
     //MessageBox.Show("Server response: " + response);
 }
예제 #13
0
        public void ProcessStatements(string statements)
        {
            statements = statements.Trim();
            if (statements.StartsWith("speak"))
            {
                statements = statements.Substring(6, statements.Length - 6);
                Speech.Speak(Speech.AddPronunciation(statements));

                textBoxCommands.CaretIndex = textBoxCommands.Text.Length;
                textBoxCommands.AppendText("\r\n\r\n" + commandPrompt);
                commandsText = textBoxCommands.Text;
                promptIndex  = textBoxCommands.Text.Length;
                textBoxCommands.CaretIndex = textBoxCommands.Text.Length;
                lastCaretIndex             = textBoxCommands.Text.Length;
            }
            else if (statements.StartsWith("getvoices"))
            {
                string installedVoices = Speech.GetInstalledVoices();

                textBoxCommands.CaretIndex = textBoxCommands.Text.Length;
                textBoxCommands.AppendText("\r\n\r\n" + installedVoices + "\r\n" + commandPrompt);
                commandsText = textBoxCommands.Text;
                promptIndex  = textBoxCommands.Text.Length;
                textBoxCommands.CaretIndex = textBoxCommands.Text.Length;
                lastCaretIndex             = textBoxCommands.Text.Length;
            }
            else if (statements.ToLower() == "python")
            {
                string response = TcpConnection.SendMessage("python");

                commandPrompt = pythonCommandPrompt;
                textBoxCommands.CaretIndex = textBoxCommands.Text.Length;
                textBoxCommands.AppendText("\r\n" + response.TrimEnd() + "\r\n\r\n" +
                                           commandPrompt);
                commandsText = textBoxCommands.Text;
                promptIndex  = textBoxCommands.Text.Length;
                textBoxCommands.CaretIndex = textBoxCommands.Text.Length;
                lastCaretIndex             = textBoxCommands.Text.Length;
            }
            else if (commandPrompt == pythonCommandPrompt)
            {
                string response = TcpConnection.SendMessage("[py]" + statements);

                if (response == "[python closed]")
                {
                    commandPrompt = ">";  // Switch back to normal command prompt.
                    StopOutput();
                }
                else
                {
                    lastPythonOutputTime       = DateTime.UtcNow;
                    timerPythonOutput          = new DispatcherTimer();
                    timerPythonOutput.Tick    += new EventHandler(TimerPythonOutput_Tick);
                    timerPythonOutput.Interval = new TimeSpan(0, 0, 0, 0, 200);
                    timerPythonOutput.Start();
                }
            }
            else
            {
                string response = TcpConnection.SendMessage("processstatements " + statements);

                if (response == "RefreshUDWords")
                {
                    // Maybe split pronunciations out of AddRecRulesFromLexRules, since they are
                    // for spokenSynth and can be added separately just for voice synth.
                    LangBnf.LoadLexRules();
                    LoadUDWords();

                    if (checkBoxVoiceRecogition.IsChecked == true)
                    {
                        Speech.LoadSpeechRecognizer();
                    }

                    if (checkBoxVoiceSynth.IsChecked == true)
                    {
                        Speech.AddSynthRulesFromLexRules();
                    }
                    response = "okay;";
                }

                textBoxCommands.CaretIndex = textBoxCommands.Text.Length;
                textBoxCommands.AppendText("\r\n" + response.TrimEnd() + "\r\n\r\n" + commandPrompt);
                commandsText = textBoxCommands.Text;
                promptIndex  = textBoxCommands.Text.Length;
                textBoxCommands.CaretIndex = textBoxCommands.Text.Length;
                lastCaretIndex             = textBoxCommands.Text.Length;

                if (Speech.Synth != null && checkBoxVoiceSynth.IsChecked == true &&
                    response.Length < 200)
                {
                    Speech.Speak(response);
                }
            }
        }