Example #1
0
 public String getDriverInfo(String script, String method, StandingsItem standing, SessionInfo session, Int32 rounding)
 {
     try
     {
         string result = scripts[script].DriverInfo(method, standing, session, rounding);
         logger.Debug("Calling getDriverInfo('{0}') in {1} Result: {2}", method, script, result);
         return(result);
     }
     catch (Exception ex)
     {
         logger.Error("Error in {0}.DriverInfo('{2}'): {1}", script, ex.ToString(), method);
     }
     return("[Error]");
 }
Example #2
0
 void standingsGridDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (standingsGrid.SelectedItem != null)
     {
         StandingsItem driver = (StandingsItem)standingsGrid.SelectedItem;
         if (iRTVOConnection.isConnected && !iRTVOConnection.isServer)
         {
             iRTVOConnection.BroadcastMessage("SWITCH", padCarNum(driver.Driver.NumberPlate), -1);
         }
         if (!iRTVOConnection.isConnected || iRTVOConnection.isServer)
         {
             API.sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.CamSwitchNum, padCarNum(driver.Driver.NumberPlate), -1);
         }
         SharedData.updateControls = true;
     }
 }
Example #3
0
            public SessionInfo()
            {
                id = 0;
                lapsTotal = 0;
                lapsComplete = 0;
                leadChanges = 0;
                cautions = 0;
                cautionLaps = 0;

                fastestlap = 0;
                fastestdriver = new DriverInfo();
                fastestlapnum = 0;

                time = 0;
                sessiontimeremaining = 0;
                sessionlength = 0;
                sessionstarttime = -1;
                sessionstartpos = 0;
                finishline = Int32.MaxValue;

                type = sessionType.invalid;
                state = sessionState.invalid;
                flag = sessionFlag.invalid;
                startlight = sessionStartLight.off;

                standings = new List<StandingsItem>();
                followedDriver = new StandingsItem();
            }
Example #4
0
 public void setFollowedDriver(Int32 carIdx)
 {
     followedDriver = FindDriver(carIdx);
 }
Example #5
0
            public webtimingDriver(StandingsItem driver, SessionInfo session)
            {
                position = driver.PositionLive.ToString();
                name     = driver.Driver.Name;

                // KJ: for multi-car/multi-class races and pitting status
                car     = "";
                pitting = false;

                // KJ: set name for team events
                if (driver.Driver.TeamId > 0)
                {
                    name = driver.Driver.TeamName + " (" + driver.Driver.Shortname + ")";
                }
                number      = driver.Driver.NumberPlate;
                car         = SharedData.theme.getCar(driver.Driver.CarId); // KJ: set car
                lap         = driver.CurrentLap.LapNum.ToString();
                fastestlap  = Utils.floatTime2String(driver.FastestLap, 3, false);
                previouslap = Utils.floatTime2String(driver.PreviousLap.LapTime, 3, false);
                pit         = driver.PitStops.ToString();
                lapsled     = driver.LapsLed.ToString();
                sectors     = new string[0];

                classid       = driver.Driver.CarClass.ToString();
                classname     = driver.Driver.CarClassName;
                classposition = session.getClassPosition(driver.Driver).ToString();
                classgap      = driver.ClassGapLive_HR;
                classinterval = driver.ClassIntervalLive_HR;

                StandingsItem leader = SharedData.Sessions.CurrentSession.FindPosition(1, DataOrders.liveposition);
                StandingsItem infront;

                if (driver.PositionLive <= 1)
                {
                    infront = new StandingsItem();
                }
                else
                {
                    infront = SharedData.Sessions.CurrentSession.FindPosition(driver.Position - 1, DataOrders.liveposition);
                }

                if (SharedData.Sessions.CurrentSession.Type == SessionTypes.race
                    /* && (driver.Finished == true || driver.Sector == 0) */)
                {
                    if (infront.PreviousLap.GapLaps > driver.PreviousLap.GapLaps)
                    {
                        interval = (infront.FindLap(driver.PreviousLap.LapNum).LapNum - driver.PreviousLap.LapNum) + " L";
                    }
                    else
                    {
                        interval = Utils.floatTime2String((driver.PreviousLap.Gap - infront.FindLap(driver.PreviousLap.LapNum).Gap), 3, false);
                    }

                    if (driver.PreviousLap.GapLaps > 0)
                    {
                        gap = driver.PreviousLap.GapLaps + " L";
                    }
                    else
                    {
                        gap = Utils.floatTime2String(driver.PreviousLap.Gap, 3, false);
                    }
                }
                else
                {
                    interval = Utils.floatTime2String((driver.FastestLap - infront.FastestLap), 3, false);
                    gap      = Utils.floatTime2String((driver.FastestLap - leader.FastestLap), 3, false);
                }

                if (SharedData.SelectedSectors.Count > 0)
                {
                    sectors = new string[SharedData.SelectedSectors.Count];

                    for (int i = 0; i < SharedData.SelectedSectors.Count; i++)
                    {
                        if (driver.Sector <= 0) // first sector, show previous lap times
                        {
                            if (i < driver.PreviousLap.SectorTimes.Count)
                            {
                                Sector sector = driver.PreviousLap.SectorTimes.Find(s => s.Num.Equals(i));
                                if (sector != null)
                                {
                                    sectors[i] = Utils.floatTime2String(sector.Time, 1, false);
                                }
                                else
                                {
                                    sectors[i] = "-.--";
                                }
                            }
                            else
                            {
                                sectors[i] = "-.--";
                            }
                        }
                        else
                        {
                            if (i < driver.CurrentLap.SectorTimes.Count)
                            {
                                Sector sector = driver.CurrentLap.SectorTimes.Find(s => s.Num.Equals(i));
                                if (sector != null)
                                {
                                    sectors[i] = Utils.floatTime2String(sector.Time, 1, false);
                                }
                                else
                                {
                                    sectors[i] = "-.--";
                                }
                            }
                            else
                            {
                                sectors[i] = "-.--";
                            }
                        }
                    }
                }

                if (SharedData.Sessions.CurrentSession.Type == SessionTypes.race &&
                    driver.TrackSurface == SurfaceTypes.NotInWorld &&
                    SharedData.allowRetire &&
                    (SharedData.Sessions.CurrentSession.Time - driver.OffTrackSince) > 1)
                {
                    retired = true;

                    if (infront.CurrentLap.LapNum > driver.CurrentLap.LapNum)
                    {
                        interval = (infront.CurrentLap.LapNum - driver.CurrentLap.LapNum) + " L";
                    }
                    else
                    {
                        interval = Utils.floatTime2String((driver.PreviousLap.Gap - infront.PreviousLap.Gap), 3, false);
                    }
                    if ((leader.CurrentLap.LapNum - driver.CurrentLap.LapNum) > 0)
                    {
                        gap = leader.CurrentLap.LapNum - driver.CurrentLap.LapNum + " L";
                    }
                    else
                    {
                        gap = Utils.floatTime2String(driver.PreviousLap.Gap, 3, false);
                    }
                }
                else
                {
                    retired = false;
                }
                // KJ: set pitting status
                if (driver.TrackSurface == SurfaceTypes.InPitStall)
                {
                    pitting = true;
                }
                else
                {
                    pitting = false;
                }
            }
Example #6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Add additional Columns to Standings
            StandingsItem tmpItem = new StandingsItem();
            Type          tmpType = tmpItem.GetType();

            IEnumerable <string> props = ExtractHelper.IterateProps(tmpType);
            string validProps          = String.Join(" , ", props).Replace("StandingsItem.", "");

            foreach (Settings.ColumnSetting col in SharedData.settings.DriversColumns)
            {
                if (!props.Contains("StandingsItem." + col.Name))
                {
                    logger.Warn("Unkown column in optins.ini standingsgrid::columns '{0}'", col);
                    logger.Warn("Valid Columns are: {0}", validProps);
                    // continue;
                }

                DataGridTextColumn textColumn = new DataGridTextColumn();
                textColumn.Header  = col.Header;
                textColumn.Binding = new Binding(col.Name);
                standingsGrid.Columns.Add(textColumn);
                logger.Trace("Added column '{0}'", col);
            }

            // We subscribe to Session change, to prevent staningsGrid show old data
            SharedData.Sessions.PropertyChanged += CurrentSession_PropertyChanged;

            BindingOperations.CollectionRegistering += BindingOperations_CollectionRegistering;

            UpdateDataContext();
            BookmarksGrid.DataContext = SharedData.Bookmarks.List;
            Cameras = SharedData.Camera.Groups;

            API = new iRTVO.iRacingAPI();
            API.sdk.Startup();

            updateTimer.Interval = new TimeSpan(0, 0, 0, 0, 500);
            updateTimer.Tick    += new EventHandler(updateGrids);
            updateTimer.Start();
            updateGrids(new object(), new EventArgs());

            int i = 0;

            foreach (Single sector in SharedData.Sectors)
            {
                CheckBox cb = new CheckBox();
                cb.Content = "Sector " + i + ": " + sector.ToString("0.000");
                cb.Name    = "s" + i;
                cb.Click  += new RoutedEventHandler(sectorClick);
                sectorsStackPanel.Children.Add(cb);

                int found = SharedData.SelectedSectors.FindIndex(s => s.Equals(sector));
                if (found >= 0)
                {
                    cb.IsChecked = true;
                }

                i++;
            }
        }