Exemplo n.º 1
0
        private void stopCollectingDataButton_Click(object sender, EventArgs e)
        {
            startCollectingDataButton.Enabled = true;
            stopCollectingDataButton.Enabled = false;
            selectedRaceComboBox.Enabled = true;
            this.eventComboBox.Enabled = true;
#if V15
            networkFeed.Quit();
            server.End();
#else
            networkListener.End();
            passDetector.Exit();
#endif
            if(binaryLogger != null)
                binaryLogger.Dispose();
            binaryLogger = null;
        }
Exemplo n.º 2
0
        private void CreateBinLogger()
        {
            String binLogFileName = (currentRace != null) ? GetCleanedRaceName(currentRace.name) + "_out.bin" : "_out.bin";
            string appPath = Path.GetDirectoryName(Config.Instance.DataDirectory);
            Directory.SetCurrentDirectory(appPath);
            if (!Directory.Exists("runs"))
                Directory.CreateDirectory("runs");
            Directory.SetCurrentDirectory(appPath + "\\runs");

            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker)delegate
                {
                    if (eventComboBox.SelectedIndex != -1)
                        binLogFileName = DataManager.Instance.Events[eventComboBox.SelectedIndex].name + "_" + binLogFileName;
                });
            }
            else
            {
                if (eventComboBox.SelectedIndex != -1)
                    binLogFileName = DataManager.Instance.Events[eventComboBox.SelectedIndex].name + "_" + binLogFileName;
            }

            //if file exists, append some counter to it
            int fileNameCounter = 1;
            if (File.Exists(binLogFileName))
            {
                String currentFileName = binLogFileName;
                while (File.Exists(currentFileName))
                {
                    int strIndex = currentFileName.IndexOf(".bin");
                    if (strIndex > 0)
                    {
                        currentFileName = currentFileName.Remove(strIndex - 1, 1);
                        currentFileName = currentFileName.Insert(strIndex - 1, "" + fileNameCounter);
                    }
                    fileNameCounter++;
                    if (fileNameCounter > 10)
                        break;
                }
                binLogFileName = currentFileName;
            }
            binaryLogger = new LoggerBinary(binLogFileName);
#if V15
            binaryLogger.AddPublisher(server.IndividualReadingPublisher);
#else
            binaryLogger.AddPublisher(networkListener);
#endif
        }