コード例 #1
0
 /// <summary>
 /// Launches the score report in the user's default browser.
 /// </summary>
 /// <param name="sender">Automatically generated by Visual Studio.</param>
 /// <param name="e">Automatically generated by Visual Studio.</param>
 private void reportButton_Click(object sender, EventArgs e)
 {
     ReportLauncher.GenerateMPAiSoundScoreHTML(UserManagement.CurrentUser.SoundScoreboard);
     if (File.Exists(ReportLauncher.MPAiSoundScoreReportHTMLAddress))
     {
         ReportLauncher.ShowMPAiSoundScoreReport();
     }
 }
コード例 #2
0
        public void ConnectAndRecieve()
        {
            pipeServerIsClosed = false;

            while (!pipeServerIsClosed)
            {
                if (!shutdown)
                {
                    Console.WriteLine("PythonPipe.connectAndRecieve is running in its own thread");

                    using (NamedPipeServerStream pipeServer = new NamedPipeServerStream("NPSSVowelPlot", PipeDirection.InOut, 254))
                    {
                        Console.WriteLine("Waiting for connection...");
                        pipeServer.WaitForConnection();

                        Console.WriteLine("Connected.");
                        var binaryReader = new BinaryReader(pipeServer);
                        Console.WriteLine("Messages from VowelPlot.py...");
                        while (true)
                        {
                            try
                            {
                                var    recievedLength = (int)binaryReader.ReadUInt64();         // Read string length
                                string recievedString = new string(binaryReader.ReadChars(recievedLength - 1));

                                if (recievedString.Length == 1)
                                {
                                    break;
                                }
                                String[] recievedStringList = recievedString.Split('\n');
                                int      length             = recievedStringList.Length;
                                Console.WriteLine(length);
                                MPAiSoundScoreBoardSession session = UserManagement.CurrentUser.SoundScoreboard.NewScoreBoardSession();

                                int count = 0;
                                foreach (String str in recievedStringList)
                                {
                                    String[] lineStringList = str.Split(' ');
                                    if (count > 0)
                                    {
                                        //vowels
                                        String vowel = lineStringList[0];
                                        float  correctnessPercentage;
                                        if (!float.TryParse(lineStringList[1], out correctnessPercentage))
                                        {
                                            throw new Exception("Could not parse String to Float");
                                        }

                                        session.AddScoreBoardItem(vowel, correctnessPercentage);
                                    }
                                    else
                                    {
                                        //total
                                        float overallPercentage;

                                        if (!float.TryParse(lineStringList[1], out overallPercentage))
                                        {
                                            throw new Exception("Could not parse String to Float");
                                        }
                                        Console.WriteLine(overallPercentage);
                                        session.OverallCorrectnessPercentage = overallPercentage;
                                    }
                                    count++;
                                }
                                ReportLauncher.GenerateMPAiSoundScoreHTML(UserManagement.CurrentUser.SoundScoreboard);
                            }
                            catch (EndOfStreamException)
                            {
                                break;
                            }
                        }
                        Console.WriteLine("Requesting plotcontrooler to shut down ");
                        PlotController.RequestShutDown();
                    }
                }
                else
                {
                    break;
                }
            }
        }