コード例 #1
0
        public override void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            try
            {
                maxFuelOfCar = float.Parse(e.SessionInfo["DriverInfo"]["DriverCarFuelMaxLtr"].Value);
                trackLength  = float.Parse(e.SessionInfo["WeekendInfo"]["TrackLength"].Value.Substring(0, 4)) * 1000;

                var isMaxRpmValid = float.TryParse(e.SessionInfo["DriverInfo"]["DriverCarRedLine"].Value,
                                                   out sessionDash.maxRpm);

                if (isMaxRpmValid)
                {
                    sessionDash.maxRpm = float.Parse(e.SessionInfo["DriverInfo"]["DriverCarRedLine"].Value);
                }

                sessionType = e.SessionInfo["SessionInfo"]["Sessions"]["SessionNum", sessionNumber]["SessionType"].Value;
                raceWeek    = e.SessionInfo["WeekendInfo"]["RaceWeek"].Value;
                eventType   = e.SessionInfo["WeekendInfo"]["EventType"].Value;
                eventType   = eventType.Replace(' ', '_');
                trackName   = e.SessionInfo["WeekendInfo"]["TrackName"].Value;
                trackName   = trackName.Replace(' ', '_');
            }
            catch (Exception ex)
            {
                if (errorLogger == null)
                {
                    errorLogger = new Logger(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\iRacingDash\\logs\\iRacingDash\\" + dateInString + "_W" + raceWeek + "_" + eventType + "_" + trackName + "\\errorLog.txt");
                }
                errorLogger.Log("OnSessionInfoUpdated Error", ex.Message);
            }
        }
コード例 #2
0
 protected virtual void OnSessionInfoUpdated(SdkWrapper.SessionInfoUpdatedEventArgs e)
 {
     if (this.SessionInfoUpdated != null)
     {
         this.SessionInfoUpdated(this, e);
     }
 }
コード例 #3
0
        //private void UpdateOfftrackHistory(List<Offtrack> offtracks)
        //{
        //    if (SyncManager.Instance.Status == SyncManager.ConnectionStatus.Connected &&
        //        SyncManager.Instance.User != null)
        //    {
        //         Only host sends offtracks
        //        if (SyncManager.Instance.User.IsHost)
        //        {
        //            SyncManager.Instance.State.SetOfftrackHistory(this.Drivers);

        //             Send to server
        //            SyncManager.Instance.SendStateUpdate(SyncCommandHelper.UpdateOfftracks(offtracks));
        //        }
        //    }
        //}

        #endregion

        #endregion

        #region Events

        private void SdkOnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            _sessionInfo = e.SessionInfo;

            try
            {
                if (_mustUpdateSessionData)
                {
                    _sessionData.Update(e.SessionInfo);
                    _timeDelta             = new TimeDelta((float)_sessionData.Track.Length * 1000f, 20, 64);
                    _mustUpdateSessionData = false;

                    this.OnStaticInfoChanged();
                }

                App.Instance.Dispatcher.Invoke(() =>
                {
                    // Handle session info update
                    this.UpdateDriverlist(e.SessionInfo);

                    // Broadcast to windows
                    if (this.SessionInfoUpdated != null)
                    {
                        this.SessionInfoUpdated(sender, e);
                    }
                });
            }
            catch (Exception ex)
            {
                App.Instance.LogError("Updating session info.", ex);
            }
        }
コード例 #4
0
        // Event handler called when the session info is updated
        // This typically happens when a car crosses the finish line for example
        private void wrapper_SessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            sessionInfoLabel.Text = string.Format("Session info (last update time: {0})", e.UpdateTime);

            // Let's just dump the session info:
            sessionInfoTextBox.Text = e.SessionInfo;
        }
コード例 #5
0
        private void UpdateIncidents(SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            var type = Sim.Instance.SessionData.SessionType[0].ToString();
            var time = e.UpdateTime;

            var oldDict = _drivers.ToDictionary(driver => driver.Id);
            var newDict = Sim.Instance.Drivers.ToDictionary(driver => driver.Id);

            _drivers.Clear();

            foreach (var kvp in newDict)
            {
                var id     = kvp.Key;
                var driver = kvp.Value;

                var prevInc = 0;
                if (oldDict.ContainsKey(id))
                {
                    prevInc = oldDict[id].CurrentResults.Incidents;
                }

                var delta = driver.CurrentResults.Incidents - prevInc;
                if (delta > 0)
                {
                    _incidents.Add(new Incident(driver, type, time, delta));
                }

                _drivers.Add(driver);
            }
        }
コード例 #6
0
        private void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            YamlQuery query        = query = e.SessionInfo["DriverInfo"]["DriverCarIdx"];
            int       DriverCarIdx = int.Parse(query.GetValue(), NumberStyles.Any, CultureInfo.InvariantCulture);

            query = e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", DriverCarIdx]["CarPath"];
            string carTag = query.GetValue();

            query = e.SessionInfo["DriverInfo"]["DriverCarSLFirstRPM"];
            int firstRPM = int.Parse(query.GetValue(), NumberStyles.Any, CultureInfo.InvariantCulture);

            int shiftPoint = hostWindow.GetCustomShift(carTag);

            if (shiftPoint > 0)
            {
                dataParser.SetRPMRange(firstRPM, shiftPoint);
            }
            else
            {
                query = e.SessionInfo["DriverInfo"]["DriverCarSLBlinkRPM"];
                int lastRPM = int.Parse(query.GetValue(), NumberStyles.Any, CultureInfo.InvariantCulture);
                hostWindow.SetCustomShift(carTag, lastRPM);
                dataParser.SetRPMRange(firstRPM, lastRPM);
            }
        }
コード例 #7
0
        /// <summary>
        /// Called when [session information updated].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="SdkWrapper.SessionInfoUpdatedEventArgs"/> instance containing the event data.</param>
        private void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            // We have no session so wait a bit
            if (_currentSessionNumber == null)
            {
                return;
            }

            // Cache the Session Info
            _si = e.SessionInfo;

            // Grab the Session Type
            _timingData.RaceInfo.SessionType = GetSessionType(_si["SessionInfo"]["Sessions"]["SessionNum", _currentSessionNumber]["SessionType"].GetValue());

            /*
             * If the current session data is empty then do an initial parse of the session data. Since this
             * data never changes between praccy / qualy / race there is no point parsing it more than once.
             */
            if (_timingData.RaceInfo.TrackName == null)
            {
                InitialSessionParse(_si);
                _forceSessionUpdate = false;
            }

            /*
             * If the session type has changed then force an update of the track conditions etc
             */
            if (_forceSessionUpdate)
            {
                ParseTrackStatus(_si);
            }

            UpdateDrivers(_si);
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: gearysw/IrFuelCalc
        private void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            if (Math.Abs(m_maxFuel) > 0.01)
            {
                return;
            }

            var rawMaxFuel = e.SessionInfo["DriverInfo"]["DriverCarFuelMaxLtr"].Value;

            if (!double.TryParse(rawMaxFuel, out double maxFuel))
            {
                m_logger.Error("Error parsing max fuel: {0}", rawMaxFuel);
                return;
            }

            var rawMaxFuelPerc = e.SessionInfo["DriverInfo"]["DriverCarMaxFuelPct"].Value;

            if (!double.TryParse(rawMaxFuelPerc, out double maxFuelPerc))
            {
                m_logger.Error("Error parsing max fuel percent: {0}", rawMaxFuelPerc);
                return;
            }

            m_logger.Debug("Max Fuel tank found to be: {0}", maxFuel);
            m_logger.Debug("Max Fuel percent found to be: {0}", maxFuelPerc);
            m_maxFuel = maxFuel * maxFuelPerc;
            m_logger.Debug("Max Fule is: {0}", m_maxFuel);


            UpdateLabels();
        }
コード例 #9
0
        private void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            // The session info has updated
            bool shouldUpdateGrid = false;

            // Let's check every driver for a new lap
            foreach (var driver in Sim.Instance.Drivers)
            {
                // Ignore if there are no results yet
                if (driver.CurrentResults == null)
                {
                    continue;
                }

                // Get the number of laps this driver has completed
                var currentLap = driver.CurrentResults.LapsComplete;

                // Check what lap this driver was on the last update
                int?previousLap = null;
                if (previousLaps.ContainsKey(driver.Id))
                {
                    // We already stored their previous lap
                    previousLap = previousLaps[driver.Id];

                    // Then update the lap number to the current lap
                    previousLaps[driver.Id] = currentLap;
                }
                else
                {
                    // We didn't store their lap yet, so add it
                    previousLaps.Add(driver.Id, currentLap);
                }

                // Check if their lap number has changed
                if (previousLap == null || previousLap.Value < currentLap)
                {
                    // Lap has changed, grab their laptime and add to the list of lap entries
                    var lastTime = driver.CurrentResults.LastTime;

                    var entry = new LapEntry();
                    entry.CustomerId = driver.CustId;
                    entry.Name       = driver.Name;
                    entry.CarNumber  = driver.CarNumber;

                    entry.Lap            = lastTime.LapNumber;
                    entry.Laptime        = lastTime.Value;
                    entry.LaptimeDisplay = lastTime.Display;

                    laps.Add(entry);

                    // After we checked every driver we need to update the grid to reflect the changes
                    shouldUpdateGrid = true;
                }
            }

            if (shouldUpdateGrid)
            {
                bindingSource.ResetBindings(false);
            }
        }
コード例 #10
0
        private void SdkOnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            Debug.WriteLine($"SdkOnSessionInfoUpdated: {e.UpdateTime}");

            // Cache info
            _sessionInfo = e.SessionInfo;

            // Stop if we don't have a session number yet
            if (_currentSessionNumber == null)
            {
                return;
            }

            if (_mustUpdateSessionData)
            {
                _sessionData.Update(e.SessionInfo);
                _timeDelta             = new TimeDelta((float)_sessionData.Track.Length * 1000f, 20, 64);
                _mustUpdateSessionData = false;

                this.OnStaticInfoChanged();
            }

            // Update drivers
            this.UpdateDriverList(e.SessionInfo);

            this.OnSessionInfoUpdated(e);
        }
コード例 #11
0
        private void SdkOnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            var ssid = e.SessionInfo["WeekendInfo"]["SubSessionID"].GetValue();

            if (!string.IsNullOrWhiteSpace(ssid))
            {
                this.SubSessionId = long.Parse(ssid);
            }
            else
            {
                this.SubSessionId = null;
            }

            var query = e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", Sdk.DriverId];

            this.Driver          = new DriverInfo();
            this.Driver.Id       = int.Parse(query["UserID"].GetValue("0"));
            this.Driver.Username = query["UserName"].GetValue();
            this.Driver.Initials = query["Initials"].GetValue();

            if (this.SessionInfoUpdated != null)
            {
                this.SessionInfoUpdated(this, e);
            }
        }
コード例 #12
0
ファイル: IRacingConnector.cs プロジェクト: Romulus968/iDash
        private void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            try
            {
                YamlQuery yLastRPM  = e.SessionInfo["DriverInfo"]["DriverCarSLLastRPM"];
                YamlQuery yShiftRPM = e.SessionInfo["DriverInfo"]["DriverCarSLShiftRPM"];
                //YamlQuery yIsOnPit = e.SessionInfo["DriverInfo"]["OnPitRoad"];

                if (yShiftRPM != null)
                {
                    lastRpm = float.Parse(yShiftRPM.Value, CultureInfo.InvariantCulture.NumberFormat);
                    //Logger.LogMessageToFile("Shift:" + maxRpm + "\n");
                }
                else
                {
                    if (yLastRPM != null)
                    {
                        //calibrate shift gear light rpm
                        lastRpm = float.Parse(yLastRPM.Value, CultureInfo.InvariantCulture.NumberFormat) * MainForm.maxRPM;
                        //Logger.LogMessageToFile("Shift:" + maxRpm + "\n");
                    }
                }

                firstRpm = FIRST_RPM * lastRpm;
            }
            catch (Exception ex)
            {
                logger.LogExceptionToFile(ex);
            }
        }
コード例 #13
0
        // Event handler called when the session info is updated
        // This typically happens when a car crosses the finish line for example
        private void wrapper_SessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            sessionInfoLabel.Text = string.Format("Session info (last update time: {0})", e.UpdateTime);

            // Let's just dump the session info:
            sessionInfoTextBox.Text = e.SessionInfo.Yaml;

            // Read some values using a YAML query
            string trackName = e.SessionInfo.GetValue("WeekendInfo:TrackName:");
            int    sessionId = int.Parse(e.SessionInfo.GetValue("WeekendInfo:SessionId:"));
            string windSpeed = e.SessionInfo.GetValue("WeekendInfo:WeekendOptions:WindSpeed:");

            // Read some values with the easier notation (no need to write the YAML query)
            var trackLength = e.SessionInfo["WeekendInfo"]["TrackLength"].GetValue();
            var driver1Name = e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", 1]["UserName"].GetValue();

            // Attempt to read the username of a random driver safely
            var random = new Random();
            var id     = random.Next(0, 60);

            string driverName;

            if (e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", id]["UserName"].TryGetValue(out driverName))
            {
                // Success
                MessageBox.Show(driverName);
            }
            else
            {
                // not found
                MessageBox.Show("Error retrieving name of driver " + id);
            }
        }
コード例 #14
0
        private void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            var rawMaxFuel = e.SessionInfo["DriverInfo"]["DriverCarFuelMaxLtr"].Value;

            if (!double.TryParse(rawMaxFuel, out double maxFuel))
            {
                m_logger.Error("Error parsing max fuel: {0}", rawMaxFuel);
                return;
            }

            var rawMaxFuelPerc = e.SessionInfo["DriverInfo"]["DriverCarMaxFuelPct"].Value;

            if (!double.TryParse(rawMaxFuelPerc, out double maxFuelPerc))
            {
                m_logger.Error("Error parsing max fuel percent: {0}", rawMaxFuelPerc);
                return;
            }

            if (Math.Abs(m_maxFuel - maxFuel * maxFuelPerc) > 0.1)
            {
                m_maxFuel = maxFuel * maxFuelPerc;
                m_logger.Debug("Max Fuel tank found to be: {0}", maxFuel);
                m_logger.Debug("Max Fuel percent found to be: {0}%", maxFuelPerc * 100);
                m_logger.Debug("Max Fuel is: {0}", m_maxFuel);
            }

            var trackId          = e.SessionInfo["WeekendInfo"]["TrackID"].Value;
            var trackDisplayName = e.SessionInfo["WeekendInfo"]["TrackDisplayName"].Value;

            var carIdx        = int.Parse(e.SessionInfo["DriverInfo"]["DriverCarIdx"].Value);
            var carScreenName = e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", carIdx]["CarScreenName"].Value;
            var carId         = e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", carIdx]["CarID"].Value;

            if (m_lastTrackId != trackId || m_lastCarId != carId)
            {
                // Track and/or car has changed, so reset everything.
                m_logger.Debug("Track: {0} - {1}", trackId, trackDisplayName);
                m_logger.Debug("Car: {0} - {1}", carId, carScreenName);

                m_lastCarId   = carId;
                m_lastTrackId = trackId;

                m_lastFuelLevel        = 0.0;
                m_averageLapTime       = 0.0;
                m_lastLapCompleted     = 0;
                m_sessionRemainingTime = 0.0;
                m_fuelToAdd            = 0;
                m_totalFuelRequired    = 0.0;
                m_fuelLastLap          = 0.0;
                m_fuelPerLap           = 0.0;
                m_estimatedStops       = 0;
                m_estimatedLaps        = 0;
                m_telemLaps            = 0;
                m_lapTimes.Clear();
                m_fuelUsages.Clear();
            }

            UpdateLabels();
        }
コード例 #15
0
        public SessionData(SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            YamlQuery query = e.SessionInfo["DriverInfo"]["DriverCarIdx"];

            query   = e.SessionInfo["WeekendInfo"]["TrackSkies"];
            weather = query.GetValue();

            //query = e.SessionInfo["WeekendInfo"]["TrackSurfaceTemp"];
            //trackTemp = double.Parse(query.GetValue().Split(' ')[0], CultureInfo.InvariantCulture);
        }
コード例 #16
0
 // Event handler called when the session info is updated
 private void wrapper_SessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
 {
     if (!hasInit)
     {
         hasInit  = true;
         track    = e.SessionInfo["WeekendInfo"]["TrackName"].Value;
         driverID = Convert.ToInt16(e.SessionInfo["DriverInfo"]["DriverCarIdx"].Value);
         car      = e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", driverID]["CarPath"].Value;
         fuelEst  = Convert.ToDouble(cfg.readSetting(track + "-" + car, "0"));
         fuelLaps = Convert.ToInt32(cfg.readSetting(track + "-" + car + "-l", "0"));
     }
 }
コード例 #17
0
        private void SaveSessionInfo(SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            var dir = "output";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            var path = Path.Combine(dir, $"sessioninfo_{e.UpdateTime.ToString("0")}.txt");

            File.WriteAllText(path, e.SessionInfo.Yaml);
        }
コード例 #18
0
        private SdkWrapper.SessionInfoUpdatedEventArgs DoSessionInfoUpdate(bool sendEvents)
        {
            var timestamp = reader.ReadDouble();
            var yaml      = ReadUTF8(reader);
            var args      = new SdkWrapper.SessionInfoUpdatedEventArgs(yaml, timestamp);

            if (sendEvents)
            {
                sessionInfoUpdateHandlers.ForEach(h => h.Invoke(this, args));
            }

            return(args);
        }
コード例 #19
0
ファイル: Form1.cs プロジェクト: nervTeh/iRacingSdkWrapper
        private void wrapper_SessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            // Indicate that we are updating the drivers list
            isUpdatingDrivers = true;

            // Parse the Drivers section of the session info into a list of drivers
            this.ParseDrivers(e.SessionInfo);

            // Parse the ResultsPositions section of the session info to get the positions and times of drivers
            this.ParseTimes(e.SessionInfo);

            // Indicate we are finished updating drivers
            isUpdatingDrivers = false;
        }
コード例 #20
0
        private void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            _drivers.Clear();
            foreach (Driver driver in Sim.Instance.Drivers)
            {
                _drivers.Add(driver);
            }
            if (Sim.Instance.SessionData.Track != null)
            {
                double trackLength = Sim.Instance.SessionData.Track.Length;

                _trackDistPctFromKM = warnDistance / trackLength;
            }
            // Use session info...
        }
コード例 #21
0
 // Event handler called when the session info is updated
 private void wrapper_SessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
 {
     if (!hasInit)
     {
         try
         {
             hasInit  = true;
             track    = e.SessionInfo["WeekendInfo"]["TrackName"].Value;
             driverID = Convert.ToInt16(e.SessionInfo["DriverInfo"]["DriverCarIdx"].Value);
             car      = e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", driverID]["CarPath"].Value;
             fuelEst  = Convert.ToDouble(cfg.readSetting(track + "-" + car, "0"));
             fuelLaps = Convert.ToInt32(cfg.readSetting(track + "-" + car + "-l", "0"));
             console("Load data for " + car + " at " + track);
         }
         catch (Exception exe)
         {
             ExceptionHelper.writeToLogFile(exe.Message, exe.ToString(), "Update Session Data", exe.LineNumber(), this.FindForm().Name);
         }
     }
 }
コード例 #22
0
        public void OnSessionInfoUpdate(Object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            if (record)
            {
                if (sessionLogPath == null)
                {
                    YamlQuery q         = e.SessionInfo["WeekendInfo"]["SessionID"];
                    string    sessionId = q.GetValue("default");
                    sessionLogPath = MakeSessionLogPath(sessionId);
                }
                using (BinaryWriter w = AppendBinary(sessionLogPath))
                {
                    w.Write(1); // session info update record identifer
                    w.Write(e.UpdateTime);
                    WriteUTF8(w, e.SessionInfo.Yaml);
                }
            }

            sessionInfoUpdateHandlers.ForEach(h => h.Invoke(sender, e));
        }
コード例 #23
0
        private void wrapper_SessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            // Create a Deserializer
            // Tell it to ignore unmatched properties unless you have mapped every single property
            var deserializer = new Deserializer(ignoreUnmatched: true);

            // Read the session info yaml
            using (var reader = new StringReader(e.SessionInfo.Yaml))
            {
                var customSessionInfo = deserializer.Deserialize <CustomSessionInfo>(reader);

                // Write it to a label for example
                label1.Text = "WeekendInfo:TrackName: " + customSessionInfo.WeekendInfo.TrackName
                              + "\n"
                              + "WeekendInfo:WeekendOptions:StartingGrid: " +
                              customSessionInfo.WeekendInfo.WeekendOptions.StartingGrid
                              + "\n"
                              + "DriverInfo:Drivers[0]:UserName: " + customSessionInfo.DriverInfo.Drivers[0].UserName;
            }
        }
コード例 #24
0
ファイル: DataParser.cs プロジェクト: Zuppi/Zuppidash
        public void ParseSession(SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            YamlQuery query = e.SessionInfo["DriverInfo"]["DriverCarIdx"];

            driverID = int.Parse(query.GetValue(), NumberStyles.Any, CultureInfo.InvariantCulture);
            query    = e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", driverID]["CarPath"];
            carTag   = query.GetValue();

            sessionData = new SessionData(e);

            if (!ReadXML())
            {
                query    = e.SessionInfo["DriverInfo"]["DriverCarSLFirstRPM"];
                startRPM = int.Parse(query.GetValue(), NumberStyles.Any, CultureInfo.InvariantCulture);
                query    = e.SessionInfo["DriverInfo"]["DriverCarSLBlinkRPM"];
                endRPM   = int.Parse(query.GetValue(), NumberStyles.Any, CultureInfo.InvariantCulture);
                WriteXML();
            }

            RPMInterval = (endRPM - startRPM) / 9;
        }
コード例 #25
0
        private void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            driversGridView.Rows.Clear();

            var deserializer = new Deserializer();
            var sr           = new StringReader(e.SessionInfo.RawYaml);
            var o            = deserializer.Deserialize <dynamic>(sr);
            var drivers      = o["DriverInfo"]["Drivers"];

            foreach (var driver in drivers)
            {
                if (driver["CarIsPaceCar"] == "1" || driver["IsSpectator"] == "1")
                {
                    continue;
                }

                string   userIdStr        = driver["UserID"];
                int      userIdInt        = Convert.ToInt32(userIdStr);
                string   comment          = _commentDirectory[userIdInt];
                var      commentFirstLine = GetFirstLine(comment);
                object[] row = { userIdStr, driver["UserName"], driver["IRating"], driver["LicString"], commentFirstLine };
                driversGridView.Rows.Add(row);
            }
        }
コード例 #26
0
        private void _wrapper_Connected(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            sessionType = e.SessionInfo["SessionInfo"]["Sessions"]["SessionNum", sessionNumber]["SessionType"].Value;
            var sessionTypeEnum = GetEnumValueFromDescription <SessionTypeEnum>(sessionType);


            switch (sessionTypeEnum)
            {
            case SessionTypeEnum.OfflineTesting:
                var offlineTestingSession = new OfflineTestingSession(NonRTCalculationFPS, this, _wrapper, dash);
                _wrapper.TelemetryUpdated   += offlineTestingSession.OnTelemetryUpdated;
                _wrapper.SessionInfoUpdated += offlineTestingSession.OnSessionInfoUpdated;
                break;

            case SessionTypeEnum.Practice:
                var practiceSession = new PracticeSession(NonRTCalculationFPS, this, _wrapper, dash);
                _wrapper.TelemetryUpdated   += practiceSession.OnTelemetryUpdated;
                _wrapper.SessionInfoUpdated += practiceSession.OnSessionInfoUpdated;
                break;

            case SessionTypeEnum.Qualify:
                var qualifySession = new QualifySession(NonRTCalculationFPS, this, _wrapper, dash);
                _wrapper.TelemetryUpdated   += qualifySession.OnTelemetryUpdated;
                _wrapper.SessionInfoUpdated += qualifySession.OnSessionInfoUpdated;
                break;

            case SessionTypeEnum.WarmUp:
                break;

            case SessionTypeEnum.Race:
                break;

            default:
                break;
            }
        }
コード例 #27
0
 public abstract void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e);
コード例 #28
0
        private void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            try
            {
                subSessionNumber = Int32.Parse(e.SessionInfo["WeekendInfo"]["SubSessionID"].Value);

                #region Init subSessionNumberTemp
                if (subSessionNumberTemp == -1)
                {
                    //init SubSessionIdTemp
                    subSessionNumberTemp = subSessionNumber;
                }
                #endregion

                #region On Session Change
                if (sessionNumberTemp != sessionNumber || subSessionNumber != subSessionNumberTemp)
                {
                    sessionChanged = true;

                    subSessionNumberTemp = subSessionNumber;
                }
                #endregion

                #region On Track Change
                if (trackId != trackIdTemp)
                {
                    if (Turns != null)
                    {
                        Turns.Clear();
                    }
                    trackSet = false;
                }
                #endregion


                trackId      = Int32.Parse(e.SessionInfo["WeekendInfo"]["TrackID"].Value);
                driverCarIdx = Int32.Parse(e.SessionInfo["DriverInfo"]["DriverCarIdx"].Value);
                carNumber    = Int32.Parse(e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", driverCarIdx]["CarNumber"]
                                           .Value);
                teamName      = e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", driverCarIdx]["TeamName"].Value;
                carClassColor = e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", driverCarIdx]["CarClassColor"].Value;
                //var telemetryDiskFile = e.SessionInfo["WeekendInfo"]["TelemetryOptions"]["TelemetryDiskFile"].Value;
                var isMaxRpmValid = float.TryParse(e.SessionInfo["DriverInfo"]["DriverCarRedLine"].Value, out maxRpm);

                if (isMaxRpmValid)
                {
                    maxRpm = float.Parse(e.SessionInfo["DriverInfo"]["DriverCarRedLine"].Value);
                }

                car_number_value.Text = carNumber.ToString();
                team_name_value.Text  = teamName;
            }
            catch (Exception ex)
            {
                if (errorLogger == null)
                {
                    errorLogger = new Logger(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\iRacingDash\\logs\\iWECOverlay\\" + dateInString + "\\errorLog.txt");
                }

                errorLogger.Log("OnSessionInfoUpdated Error", ex.Message);
            }
        }
コード例 #29
0
ファイル: MainWindow.xaml.cs プロジェクト: MADAL1EN/iRduino
        ////////

        // Event handler called when the session info is updated
        // This typically happens when a car crosses the finish line for example
        private void WrapperSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            SdkWrapper.SessionInfoUpdatedEventArgs newSessionInfo = e; //may fix a problem (b u g)??
            DisplayMngr.SessionUpdate(newSessionInfo);
        }
コード例 #30
0
ファイル: Program.cs プロジェクト: bdr27/SimDashProject
 private static void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
 {
     //throw new NotImplementedException();
 }