コード例 #1
0
ファイル: Track.cs プロジェクト: activa/iRacingSdkWrapper
        public static Track FromSessionInfo(SessionInfo info)
        {
            var track = new Track();

            var query = info["WeekendInfo"];
            track.Id = Parser.ParseInt(query["TrackID"].GetValue());
            track.Name = query["TrackDisplayName"].GetValue();
            track.CodeName = query["TrackName"].GetValue();
            track.Length = Parser.ParseTrackLength(query["TrackLength"].GetValue());

            return track;
        }
コード例 #2
0
        public static Track FromSessionInfo(SessionInfo info)
        {
            var track = new Track();

            var query = info["WeekendInfo"];
            track.Id = Parser.ParseInt(query["TrackID"].GetValue());
            track.Name = query["TrackDisplayName"].GetValue();
            track.CodeName = query["TrackName"].GetValue();
            track.Length = Parser.ParseTrackLength(query["TrackLength"].GetValue());
            track.NightMode = query["WeekendOptions"]["NightMode"].GetValue() == "1";

            // Parse sectors
            track.Sectors.Clear();
            query = info["SplitTimeInfo"]["Sectors"];

            int nr = 0;
            while (nr >= 0)
            {
                var pctString = query["SectorNum", nr]["SectorStartPct"].GetValue();
                float pct;
                if (string.IsNullOrWhiteSpace(pctString) || !float.TryParse(pctString, NumberStyles.AllowDecimalPoint, 
                    CultureInfo.InvariantCulture, out pct))
                {
                    break;
                }

                var sector = new Sector();
                sector.Number = nr;
                sector.StartPercentage = pct;
                track.Sectors.Add(sector);

                nr++;
            }

            return track;
        }
コード例 #3
0
        public void Update(SessionInfo info)
        {
            this.Track = Track.FromSessionInfo(info);
            this.SubsessionId = Parser.ParseInt(info["WeekendInfo"]["SubSessionID"].GetValue());

            var session = info["SessionInfo"]["Sessions"]["SessionNum", Sim.Instance.CurrentSessionNumber];
            this.EventType = session["SessionType"].GetValue();
            var laps = session["SessionLaps"].GetValue();
            var time = Parser.ParseSec(session["SessionTime"].GetValue());

            this.RaceLaps = laps;
            this.RaceTime = time;
        }