Exemple #1
0
        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);
        }
Exemple #2
0
        private void ButtonTrainBump_Click(object sender, RoutedEventArgs e)
        {
            string command = "bump";

            _ = TcpConnection.SendMessage(command);
        }
Exemple #3
0
        private void ButtonNetReinitialize_Click(object sender, RoutedEventArgs e)
        {
            string command = "reinitialize";

            _ = TcpConnection.SendMessage(command);
        }
Exemple #4
0
        private void DeleteNet(string name)
        {
            char quote = '"';

            TcpConnection.SendMessage("deletenet " + quote + name + quote);
        }
Exemple #5
0
 private void MenuItemTestSQLStatement_Click(object sender, RoutedEventArgs e)
 {
     _ = TcpConnection.SendMessage("runsql");
     //MessageBox.Show("Server response: " + response);
 }
Exemple #6
0
        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);
        }
Exemple #7
0
 private void MenuClearLog_Click(object sender, RoutedEventArgs e)
 {
     _ = TcpConnection.SendMessage("clearlog");
 }
Exemple #8
0
 private void MenuItemWriteToLog_Click(object sender, RoutedEventArgs e)
 {
     _ = TcpConnection.SendMessage("writetolog");
 }
Exemple #9
0
        private void MenuItemTestTcpMessage_Click(object sender, RoutedEventArgs e)
        {
            string response = TcpConnection.SendMessage("test message");

            MessageBox.Show("Server response: " + response);
        }
Exemple #10
0
 private void MenuItemFileOpenKB_Click(object sender, RoutedEventArgs e)
 {
     _ = TcpConnection.SendMessage("openkb");
     //MessageBox.Show("Server response: " + response);
 }
Exemple #11
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);
                }
            }
        }