Ejemplo n.º 1
0
 static void Main()
 {
     SpeachSynthesizer.QueueText("Hi there!");
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new TelemetryForm());
 }
Ejemplo n.º 2
0
        private void SettingsForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            Config.UserConfig.AnnounceApexSpeed      = cbApexSpeed.Checked;
            Config.UserConfig.AnnounceCornerTime     = cbTimeSpent.Checked;
            Config.UserConfig.AnnounceDinstance2Apex = cbDistance2Apex.Checked;
            Config.UserConfig.AnnouceSpeed           = Convert.ToInt32(comboAnnounceSpeed.Items[comboAnnounceSpeed.SelectedIndex]);

            Config.SaveConfig();
            SpeachSynthesizer.QueueText("Configuration is saved");
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Check if apex narration is needed and speak!
 ///     Already in 'locked' state. Prevent deadlocks!
 /// </summary>
 public void CheckMyApex()
 {
     if (CircuitLayoutData?.apexInfo == null)
         return;
     // Check if data is consistent
     if (lastMotionFrame == lastLapFrame && lastMotionFrame == lastTelemetryFrame &&
         lastCarMotionData != null && lastLapData != null && lastCarTelemetryData != null)
     {
         // Are we alre
         if (myNextApex == null)
         {
             // Next apex (first apex in upcoming 200 m)
             myNextApex = CircuitLayoutData.apexInfo.Where(a =>
                                 a.numMeasurements > 3
                                 && a.fastAverage > lastLapData.Value.lapDistance &&
                                 a.fastAverage - lastLapData.Value.lapDistance < 200)
                                 .FirstOrDefault();
             if (myNextApex != null)
             {
                 myNextApex.LaptimeBeforeApex = 0;
                 myNextApex.Breaking = 0;
             }
         }
         if (myNextApex != null)
         {
             // Store lap time at 70m before apex
             if (myNextApex.fastAverage - lastLapData.Value.lapDistance < 70 && myNextApex.LaptimeBeforeApex == 0)
             {
                 myNextApex.LaptimeBeforeApex = lastLapData.Value.currentLapTimeInMS;
             }
             if (myNextApex.Breaking == 0 && lastCarTelemetryData.Value.brake>0)
             {
                 // Hitting the brakes!
                 myNextApex.Breaking = lastLapData.Value.lapDistance;
                 if (Config.UserConfig.AnnounceDinstance2Apex)
                 {
                     SpeachSynthesizer.QueueText((myNextApex.fastAverage - lastLapData.Value.lapDistance).ToString());
                 }
             }
             if (lastLapData.Value.lapDistance > myNextApex.fastAverage)
             {
                 // just after apex
                 myLastApex = myNextApex;
                 if (Config.UserConfig.AnnounceApexSpeed)
                 {
                     SpeachSynthesizer.QueueText(lastCarTelemetryData.Value.speed.ToString());
                 }
                 myNextApex = null;
             }
         }
         if (myLastApex != null && lastLapData.Value.lapDistance > myLastApex.fastAverage + 70)
         {
             // X m after apex
             if (myLastApex.LaptimeBeforeApex > 0)
             {
                 string s = (lastLapData.Value.currentLapTimeInMS - myLastApex.LaptimeBeforeApex).ToString();
                 // Call out ms from 150m before apex to now
                 if (Config.UserConfig.AnnounceCornerTime)
                 {
                     SpeachSynthesizer.QueueNumber(s);
                 }
                 myLastApex = null;
             }
         }
     }
 }
Ejemplo n.º 4
0
        public void Read(ReaderMode readerMode, CancellationToken token)
        {
            _readerMode = readerMode;

            int totalBytes = 0;

            if (ReaderMode != ReaderMode.rmRecord)
            {
                var pktFileName = callBack.SelectedFile;

                Stream fIn = new FileStream(pktFileName, FileMode.Open, FileAccess.Read);
                dataStream = fIn;

                while (fIn.Position < fIn.Length && !token.IsCancellationRequested)
                {
                    packetCount++;
                    HandlePacket(fIn, token);
                }
            }
            else
            {
                using (var socket = new UDPSocket())
                {
                    socket.Client(20777);
                    callBack.LogLine("Waiting for packets (port 20777)...");

                    while (!token.IsCancellationRequested)
                    {
                        byte[] data = socket.NextMessage();
                        if (data != null)
                        {
                            packetCount++;
                            totalBytes = totalBytes + data.Length;

                            MemoryStream s = new MemoryStream(data);
                            HandlePacket(s, token);

                            packetList.Add(data);
                        }
                        else
                        {
                            if (!token.IsCancellationRequested)
                            {
                                //callBack.Log($"Restart");
                            }
                        }
                    }
                }
            }
            callBack.LogLine("");
            SpeachSynthesizer.QueueText("Done");
            if (ReaderMode == ReaderMode.rmRecord)
            {
                SaveData();
                callBack.LogLine("Cancelled");
            }
            if (ReaderMode == ReaderMode.rmAnalyze)
            {
                callBack.LogLine("Data loaded");
            }
            if (ReaderMode == ReaderMode.rmReplay)
            {
                callBack.LogLine("Replay finished");
            }
            _readerMode = ReaderMode.rmIdle;
        }
Ejemplo n.º 5
0
 public static void SaveConfig()
 {
     File.WriteAllText("setting.json", JsonSerializer.Serialize(UserConfig));
     SpeachSynthesizer.UpdateSpeed();
 }