public void FillWheelIdealQuantities(SimulatorDataSet dataSet)
        {
            DriverInfo driver = dataSet.PlayerInfo;

            if (driver == null || string.IsNullOrEmpty(driver.CarName))
            {
                return;
            }

            CheckAndRetrieveIdealQuantities(driver);

            if (_optimalPressureFront == null && _optimalTemperatureFront == null)
            {
                return;
            }

            dataSet.SimulatorSourceInfo.TelemetryInfo.ContainsOptimalTemperatures = true;
            Wheels wheels = driver.CarInfo.WheelsInfo;

            FillWheelIdealQuantities(wheels.FrontLeft, _optimalPressureFront, _optimalTemperatureFront);
            FillWheelIdealQuantities(wheels.FrontRight, _optimalPressureFront, _optimalTemperatureFront);

            FillWheelIdealQuantities(wheels.RearLeft, _optimalPressureRear, _optimalTemperatureRear);
            FillWheelIdealQuantities(wheels.RearRight, _optimalPressureRear, _optimalTemperatureRear);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Fname,Lname,CarModel,MilesDriven,GallonsFilled,FillupDate")] DriverInfo driverInfo)
        {
            if (id != driverInfo.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(driverInfo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DriverInfoExists(driverInfo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(driverInfo));
        }
示例#3
0
        public IList <DriverInfo> SelectDriverDetail(int id)
        {
            DriverInfo driverDetailsDto = null;
            Employee   employeeAlias    = null;
            Driver     driverAlias      = null;
            TaxiCar    taxiCarAlias     = null;

            using (ITransaction transaction = _session.BeginTransaction())
            {
                var driverData = _session.QueryOver(() => driverAlias).
                                 Full.JoinAlias(() => driverAlias.Employee, () => employeeAlias)
                                 .Full.JoinAlias(() => driverAlias.TaxiCar, () => taxiCarAlias).Where(x => employeeAlias.Id == id)
                                 .SelectList(
                    list => list.Select(() => employeeAlias.FirstName)
                    .WithAlias(() => driverDetailsDto.FirstName)
                    .Select(() => employeeAlias.LastName)
                    .WithAlias(() => driverDetailsDto.LastName)
                    .Select(() => taxiCarAlias.UniquieId)
                    .WithAlias(() => driverDetailsDto.UniqueId)
                    .Select(() => taxiCarAlias.Plate)
                    .WithAlias(() => driverDetailsDto.Plate)
                    .Select(() => taxiCarAlias.Brand)
                    .WithAlias(() => driverDetailsDto.Brand)
                    .Select(() => taxiCarAlias.GeoLong)
                    .WithAlias(() => driverDetailsDto.GeoLong)
                    .Select(() => taxiCarAlias.GeoLat)
                    .WithAlias(() => driverDetailsDto.GeoLat)
                    .Select(() => driverAlias.OnDuty)
                    .WithAlias(() => driverDetailsDto.Onduty)
                    ).TransformUsing(Transformers.AliasToBean <DriverInfo>()).List <DriverInfo>();
                return(driverData);
            }
        }
示例#4
0
        /// <summary>
        /// Logs in driver by his name and password.
        /// </summary>
        /// <param name="name">Driver name.</param>
        /// <param name="password">Driver password.</param>
        /// <returns>
        /// True if driver was logged in, else - false.
        /// </returns>
        /// <exception cref="System.Data.DataException">
        /// Thrown when database with <see cref="DriverInfo"/> wasn`t found.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown when database configuration is null.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown when <see cref="DBConfiguration.UnitOfWork"/> is null.
        /// </exception>
        public bool LogIn(string name, string password)
        {
            CheckDatabaseConfiguration();

            SetNullToDriverAndMessage();

            name     = name.Trim();
            password = password.Trim();

            var drivers = dbConfiguration.UnitOfWork.DriverInfoRepository
                          .Get(filter: driverInfo => driverInfo.Name == name);

            if (drivers.Count() == 0)
            {
                message = "The name is incorrect.";
                return(false);
            }

            DriverInfo currentDriver = drivers.First();

            if (currentDriver.Password != password)
            {
                message = "The password is incorrect.";
                return(false);
            }
            driver = new Driver(currentDriver);

            return(true);
        }
示例#5
0
 public TelemetrySnapshot(DriverInfo playerInfo, WeatherInfo weatherInfo, InputInfo inputInfo, SimulatorSourceInfo simulatorSourceInfo)
 {
     PlayerData          = playerInfo;
     WeatherInfo         = weatherInfo;
     InputInfo           = inputInfo;
     SimulatorSourceInfo = simulatorSourceInfo;
 }
示例#6
0
        public DriverPickupsPage(DriverInfo d)
        {
            InitializeComponent();

            driver         = d;
            lblDriver.Text = "Welcome, " + driver.First_Name + " " + driver.Last_Name;
        }
        public Dictionary <string, DriversRating> CreateFieldRating(DriverInfo[] fieldDrivers, int difficulty)
        {
            InitializeReferenceRating(difficulty);
            fieldDrivers = fieldDrivers.OrderBy(x => x.Position).ToArray();
            Dictionary <string, DriversRating> ratings = new Dictionary <string, DriversRating>();
            int middleDriverIndex   = _referenceRatingProviderFactory.CreateReferenceRatingProvider().GetReferenceDriverIndex(fieldDrivers.Length);
            int ratingBetweenPlaces = _simulatorRatingController.QuickRaceAiRatingForPlace;

            for (int i = 0; i < fieldDrivers.Length; i++)
            {
                DriverInfo driver = fieldDrivers[i];
                if (driver.IsPlayer)
                {
                    ratings[driver.DriverName] = _simulatorRatingController.GetPlayerRating(driver.CarClassName).simRating;
                    continue;
                }

                DriverWithoutRating aiDriver = _simulatorRatingController.GetAiRating(driver.DriverName);
                int rating = AddNoise(_referenceRating + (middleDriverIndex - i) * ratingBetweenPlaces);
                ratings[driver.DriverName] = new DriversRating()
                {
                    Deviation  = aiDriver.Deviation,
                    Volatility = aiDriver.Volatility,
                    Rating     = rating
                };
            }

            return(ratings);
        }
示例#8
0
        public void Put(int id, [FromBody] DriverInfo driver)
        {
            var identity = (ClaimsIdentity)User.Identity;

            IEnumerable <Claim> claims = identity.Claims;

            var userIdClaim = claims.Where(claim => claim.Type == "user_id")?.FirstOrDefault();

            if (userIdClaim == null)
            {
                throw new Exception("user_id claim not found");
            }

            if (!int.TryParse(userIdClaim?.Value, out int userId))
            {
                throw new Exception("Invalid value for user_id in users claims");
            }

            if (id != userId || userId != driver?.Id)
            {
                return;
            }

            this.usersDataAccessLayer.UpdateDriverInfo(driver);
        }
        private async Task InsertTodoItem(DriverInfo taxidept)
        {
            // This code inserts a new TodoItem into the database. When the operation completes
            // and Mobile App backend has assigned an Id, the item is added to the CollectionView.
            try
            {
                await itemsTable.InsertAsync(taxidept);

                //MessageBox("You are now Registered.", "Congratulations!!!");
                //await new MessageDialog("You are now Registered").ShowAsync();

                var messagedialog = new MessageDialog("Driver Information Updated!", "Registration Successful!");
                drivername.Text = "";
                phone.Text      = "";
                tid.Text        = "";
                //First command starts
                // Second command starts here
                await messagedialog.ShowAsync();
                await RefreshTodoItems();
            }
            catch (Exception ex)
            {
                var messagedialog = new MessageDialog("Please check your internet connection.", "Something is wrong!");
                //First command starts

                await messagedialog.ShowAsync();
            }
        }
示例#10
0
        public Status Post([FromBody] DriverInfo driver)
        {
            var emailValidator = new EmailValidation();

            if (!emailValidator.IsValidEmail(driver.Email))
            {
                return new Status
                       {
                           StatusCode = 2002,
                           IsOk       = false,
                           Message    = "Email is not valid"
                       }
            }
            ;

            if (!this.usersDataAccessLayer.IsValidUserName(driver.UserName))
            {
                return new Status
                       {
                           StatusCode = 2001,
                           IsOk       = false,
                           Message    = "UserName is not valid"
                       }
            }
            ;

            this.usersDataAccessLayer.AddDriver(driver);

            return(new Status
            {
                StatusCode = 1000,
                IsOk = true,
                Message = "Your account is crated."
            });
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                switch (this.btnSave.Text)
                {
                case "&Save":
                    if (this.CheckRequiredFields())
                    {
                        DriverController driverController = new DriverController();
                        DriverInfo       driverInfo       = new DriverInfo();
                        driverInfo.DriverID      = this.recordID;
                        driverInfo.DriverCode    = this.txtDriverCode.Text.Trim();
                        driverInfo.DriverName    = this.txtDriverName.Text.Trim();
                        driverInfo.DriverLicence = this.txtDriverLicence.Text.Trim();
                        driverInfo.NRCNo         = this.txtNRCNo.Text.Trim();
                        driverInfo.PhoneNo       = this.txtPhoneNo.Text.Trim();
                        driverInfo.Address       = this.txtAddress.Text.Trim();

                        driverController.Insert(driverInfo);

                        string log = "Form-Driver;Item-DriverCode:" + this.txtDriverCode.Text + ";action-Save";
                        userAction.Log(log);

                        this.InitializeControls();
                        this.BindDataGridView();
                        Globalizer.ShowMessage(MessageType.Information, "Saved Successfully");
                    }
                    break;

                case "&Update":
                    if (this.CheckRequiredFields())
                    {
                        DriverController driverController = new DriverController();
                        DriverInfo       driverInfo       = new DriverInfo();

                        driverInfo.DriverID      = this.recordID;
                        driverInfo.DriverCode    = this.txtDriverCode.Text.Trim();
                        driverInfo.DriverName    = this.txtDriverName.Text.Trim();
                        driverInfo.DriverLicence = this.txtDriverLicence.Text.Trim();
                        driverInfo.NRCNo         = this.txtNRCNo.Text.Trim();
                        driverInfo.PhoneNo       = this.txtPhoneNo.Text.Trim();
                        driverInfo.Address       = this.txtAddress.Text.Trim();

                        driverController.UpdateByDriverID(driverInfo);

                        string log = "Form-Driver;Item-DriverCode:" + this.txtDriverCode.Text + ";action-Update";
                        userAction.Log(log);
                        this.InitializeControls();
                        this.BindDataGridView();
                        Globalizer.ShowMessage(MessageType.Information, "Updated Successfully");
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Globalizer.ShowMessage(MessageType.Critical, ex.Message);
            }
        }
示例#12
0
        internal static void ComputeDistanceToPlayer(DriverInfo player, DriverInfo driverInfo, Rf2FullData rf2FullData)
        {
            if (player == null)
            {
                return;
            }

            if (driverInfo.FinishStatus == DriverFinishStatus.Dq || driverInfo.FinishStatus == DriverFinishStatus.Dnf ||
                driverInfo.FinishStatus == DriverFinishStatus.Dnq || driverInfo.FinishStatus == DriverFinishStatus.Dns)
            {
                driverInfo.DistanceToPlayer = double.MaxValue;
                return;
            }

            double trackLength       = rf2FullData.scoring.mScoringInfo.mLapDist;
            double playerLapDistance = player.LapDistance;

            double distanceToPlayer = playerLapDistance - driverInfo.LapDistance;

            if (distanceToPlayer < -(trackLength / 2))
            {
                distanceToPlayer = distanceToPlayer + trackLength;
            }

            if (distanceToPlayer > (trackLength / 2))
            {
                distanceToPlayer = distanceToPlayer - trackLength;
            }

            driverInfo.DistanceToPlayer = distanceToPlayer;
        }
示例#13
0
        protected static void ComputeDistanceToPlayer(DriverInfo player, DriverInfo driverInfo, double trackLength)
        {
            if (player == null)
            {
                return;
            }

            if (driverInfo.FinishStatus == DriverFinishStatus.Dq || driverInfo.FinishStatus == DriverFinishStatus.Dnf ||
                driverInfo.FinishStatus == DriverFinishStatus.Dnq || driverInfo.FinishStatus == DriverFinishStatus.Dns)
            {
                driverInfo.DistanceToPlayer = double.MaxValue;
                return;
            }

            double playerLapDistance = player.LapDistance;

            double distanceToPlayer = playerLapDistance - driverInfo.LapDistance;

            if (distanceToPlayer < -(trackLength / 2))
            {
                distanceToPlayer = distanceToPlayer + trackLength;
            }

            if (distanceToPlayer > (trackLength / 2))
            {
                distanceToPlayer = distanceToPlayer - trackLength;
            }

            driverInfo.DistanceToPlayer = distanceToPlayer;
        }
示例#14
0
 public LapTelemetryInfo(DriverInfo driverInfo, SimulatorDataSet dataSet, LapInfo lapInfo, TimeSpan snapshotInterval, SimulatorSourceInfo simulatorSourceInfo)
 {
     LapStarSnapshot         = new TelemetrySnapshot(driverInfo, dataSet.SessionInfo.WeatherInfo, dataSet.InputInfo, simulatorSourceInfo);
     LapInfo                 = lapInfo;
     PortionTimes            = new LapPortionTimes(10, dataSet.SessionInfo.TrackInfo.LayoutLength.InMeters, lapInfo);
     TimedTelemetrySnapshots = new TimedTelemetrySnapshots(snapshotInterval);
 }
示例#15
0
        protected override void OnLapCompleted(LapInfo lap)
        {
            DriverInfo driver = PluginManager.GetDriverByConnectionId(lap.ConnectionId);

            driver.LapCount = lap.LapNo;
            if (lap.Cuts == 0 && (lap.Laptime < driver.BestLap || driver.BestLap == 0))
            {
                driver.BestLap = lap.Laptime;
            }

            if (this.BroadcastFastestLap > 0)
            {
                // check if this is a new fastest lap for this session
                if (lap.Cuts == 0 && this.PluginManager.CurrentSession.Laps.FirstOrDefault(l => l.Cuts == 0 && l.Laptime < lap.Laptime) == null)
                {
                    this.PluginManager.BroadcastChatMessage(
                        string.Format("{0} has set a new fastest lap: {1}", driver.DriverName, AcServerPluginManager.FormatTimespan((int)lap.Laptime)));
                }
                else if (this.BroadcastFastestLap > 1)
                {
                    if (lap.Cuts == 0)
                    {
                        this.PluginManager.BroadcastChatMessage(
                            string.Format("{0} completed a lap: {1}", driver.DriverName, AcServerPluginManager.FormatTimespan((int)lap.Laptime)));
                    }
                    else
                    {
                        this.PluginManager.BroadcastChatMessage(
                            string.Format("{0} did a lap with {1} cut(s): {2}", driver.DriverName, lap.Cuts, AcServerPluginManager.FormatTimespan((int)lap.Laptime)));
                    }
                }
            }
        }
示例#16
0
        internal void FillTimingInfo(DriverInfo driverInfo, AcsVehicleInfo acVehicleInfo)
        {
            driverInfo.Timing.LastLapTime    = CreateTimeSpan(acVehicleInfo.lastLapTimeMS);
            driverInfo.Timing.CurrentLapTime = CreateTimeSpan(acVehicleInfo.currentLapTimeMS);
            driverInfo.Timing.CurrentSector  = -1;

            if (_sectorLength == null)
            {
                return;
            }

            int currentSector = (int)driverInfo.LapDistance / _sectorLength.Value;

            TimeSpan[] splits = GetCurrentSplitTimes(driverInfo.DriverName);
            if (splits == null || splits.Length <= currentSector)
            {
                return;
            }

            splits[currentSector]               = driverInfo.Timing.CurrentLapTime;
            driverInfo.Timing.CurrentSector     = currentSector + 1;
            driverInfo.Timing.LastSector1Time   = splits[0];
            driverInfo.Timing.LastSector2Time   = splits[1] - splits[0];
            driverInfo.Timing.LastSector3Time   = splits[2] - splits[1];
            driverInfo.Timing.CurrentSectorTime = splits[currentSector];
        }
示例#17
0
        public static DriverTiming FromModel(DriverInfo modelDriverInfo, SessionTiming session, bool invalidateFirstLap)
        {
            var driver = new DriverTiming(modelDriverInfo, session);

            driver.InvalidateFirstLap = invalidateFirstLap;
            return(driver);
        }
示例#18
0
 internal void ValidateLapBasedOnSurface(DriverInfo driverInfo, RfVehicleInfo rfVehicleInfo)
 {
     if (!driverInfo.CurrentLapValid)
     {
         return;
     }
 }
示例#19
0
        private void UpdateDriver(DriverInfo driverInfo)
        {
            driverInfo.LapDistance   += _playerLocationStep;
            driverInfo.TotalDistance += _playerLocationStep;

            if (driverInfo.LapDistance >= _layoutLength)
            {
                driverInfo.LapDistance = 0;
                driverInfo.CompletedLaps++;
            }

            if (!driverInfo.IsPlayer)
            {
                return;
            }

            driverInfo.CarInfo.FuelSystemInfo.FuelCapacity             = Volume.FromLiters(_totalFuel);
            driverInfo.CarInfo.FuelSystemInfo.FuelRemaining            = Volume.FromLiters(_fuel);
            driverInfo.CarInfo.WaterSystemInfo.OptimalWaterTemperature = new OptimalQuantity <Temperature>()
            {
                IdealQuantity       = driverInfo.CarInfo.WaterSystemInfo.OptimalWaterTemperature.IdealQuantity,
                IdealQuantityWindow = driverInfo.CarInfo.WaterSystemInfo.OptimalWaterTemperature.IdealQuantityWindow,
                ActualQuantity      = Temperature.FromCelsius(_engineWaterTemp),
            };
            driverInfo.CarInfo.OilSystemInfo.OptimalOilTemperature = new OptimalQuantity <Temperature>()
            {
                ActualQuantity      = Temperature.FromCelsius(_oilTemp),
                IdealQuantity       = driverInfo.CarInfo.OilSystemInfo.OptimalOilTemperature.IdealQuantity,
                IdealQuantityWindow = driverInfo.CarInfo.OilSystemInfo.OptimalOilTemperature.IdealQuantityWindow,
            };
        }
示例#20
0
        /// <summary>
        /// Добавляет данные нового игрока
        /// </summary>
        public void Add(Account account)
        {
            var playerInfo = new gta_mp_data.Entity.PlayerInfo {
                AccountId = account.Id, Health = 100, Satiety = 100
            };
            var additionalInfo = new PlayerAdditionalInfo {
                AccountId = account.Id
            };
            var driverInfo = new DriverInfo {
                AccountId = account.Id
            };
            var wantedInfo = new Wanted {
                AccountId = account.Id
            };
            var settings = new Settings {
                AccountId = account.Id
            };
            var inventory = new InventoryItem {
                OwnerId = account.Id, Name = "Деньги", Type = InventoryType.Money, Count = 100, CountInHouse = 0
            };

            using (var db = new Database()) {
                db.Insert(playerInfo);
                db.Insert(additionalInfo);
                db.Insert(driverInfo);
                db.Insert(wantedInfo);
                db.Insert(settings);
                db.Insert(inventory);
            }
        }
示例#21
0
        private bool AddPitsUsingTrackDistance(SimulatorDataSet dataSet, DriverInfo driverInfo, bool includeSpeedCheck)
        {
            bool isSpeedZero = !includeSpeedCheck || driverInfo.Speed.InMs < 0.01;

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if ((driverInfo.LapDistance != 0 || isSpeedZero) && _pitTriggerTimes.ContainsKey(driverInfo.DriverName))
            {
                _pitTriggerTimes.Remove(driverInfo.DriverName);
            }

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (driverInfo.LapDistance != 0)
            {
                if (_driversInPits.Contains(driverInfo.DriverName))
                {
                    _driversInPits.Remove(driverInfo.DriverName);
                }
                return(false);
            }

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (driverInfo.LapDistance == 0 && isSpeedZero)
            {
                if (!_pitTriggerTimes.ContainsKey(driverInfo.DriverName))
                {
                    _pitTriggerTimes[driverInfo.DriverName] = dataSet.SessionInfo.SessionTime.Add(_pitTimeDelay);
                    return(false);
                }

                return(dataSet.SessionInfo.SessionTime > _pitTriggerTimes[driverInfo.DriverName]);
            }

            return(false);
        }
        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);
            string path = this.Context.Parameters["targetdir"];

            long   retVal = 0;
            bool   result = false;
            IntPtr hwnd   = new IntPtr(1);

            // install the driver using "gemfirexdodbc" as driver name
            result = ConfigDriver(hwnd, ODBC_INSTALL_DRIVER, DriverInfo.Name, path, "", 0, ref retVal);
            if (!result)
            {
                //MessageBox.Show("Driver installation failed");
                Rollback(stateSaver);
            }

            // These are default values associated with this driver
            result = ConfigDriver(hwnd, ODBC_CONFIG_DRIVER, DriverInfo.Name, DriverInfo.GetDefaultDriverInfo(), "", 0, ref retVal);
            if (!result)
            {
                //MessageBox.Show("Driver configuration failed");
                Rollback(stateSaver);
            }
        }
示例#23
0
        public ActionResult Authenticate(IPersonInfo info)
        {
            DriverInfo driverInfo = info as DriverInfo;

            if (driverInfo != null)
            {
                ActionResult addResult = _extender.Storage.AddDriver(driverInfo);
                if (!addResult.IsValid)
                {
                    return(addResult);
                }
                _drivers.ModifyCollection(col => col.Add(driverInfo));
                return(ActionResult.ValidResult);
            }
            PedestrianInfo pedestrianInfo = info as PedestrianInfo;

            if (pedestrianInfo != null)
            {
                ActionResult addResult = _extender.Storage.AddPedestrian(pedestrianInfo);
                if (!addResult.IsValid)
                {
                    return(addResult);
                }
                _pedestrians.ModifyCollection(col => col.Add(pedestrianInfo));
                return(ActionResult.ValidResult);
            }
            return(ActionResult.GetErrorResult(new NotSupportedException()));
        }
示例#24
0
        private void AddSpeedInfo(SimulatorDataSet data, bool computeNewSpeed, DriverInfo driverInfo)
        {
            if (!computeNewSpeed && _pcarsConnector.PreviousTickInfo.ContainsKey(driverInfo.DriverName))
            {
                driverInfo.Speed = _pcarsConnector.PreviousTickInfo[driverInfo.DriverName].Speed;
            }

            if (_pcarsConnector.PreviousTickInfo.ContainsKey(driverInfo.DriverName) && computeNewSpeed && _lastSpeedComputationSet != null)
            {
                Point3D currentWorldPosition  = driverInfo.WorldPosition;
                Point3D previousWorldPosition = _pcarsConnector.PreviousTickInfo[driverInfo.DriverName].WorldPosition;
                double  duration = data.SessionInfo.SessionTime
                                   .Subtract(_lastSpeedComputationSet.SessionInfo.SessionTime).TotalSeconds;

                // double speed = lastTickDuration.TotalMilliseconds;
                double speed = Point3D.GetDistance(currentWorldPosition, previousWorldPosition).DistanceInM / duration;

                // if (speed < 200)
                driverInfo.Speed = Velocity.FromMs(speed);
            }

            if (computeNewSpeed)
            {
                _pcarsConnector.PreviousTickInfo[driverInfo.DriverName] = driverInfo;
            }
        }
        public async Task <Image> GetOvalSignature(DriverInfo driver)
        {
            string signatureTemplate = driver.OvalLicense.GetSignatureTemplate();
            var    signature         = await GetImageOrDefault(signatureTemplate, 575, 40);

            using (var g = Graphics.FromImage((Image)signature))
            {
                string fontName = "Verdana";

                var font = new Font(fontName, 15, FontStyle.Bold);

                g.SmoothingMode     = SmoothingMode.AntiAlias;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.PixelOffsetMode   = PixelOffsetMode.HighQuality;

                // Draw License Colour & Name
                var greenBrush = new SolidBrush(ColorTranslator.FromHtml($"#00A900"));
                g.FillRectangle(greenBrush, 0, 0, 588, 1);
                g.FillRectangle(greenBrush, 0, 49, 588, 1);
                g.FillRectangle(greenBrush, 0, 0, 1, 50);
                g.DrawString(driver.displayName, font, Brushes.Black, new RectangleF(8, 15, 185, 20));

                var fontBoxHeading = new Font(fontName, 10);
                g.DrawString("iRating", fontBoxHeading, Brushes.White, new RectangleF(205, 6, 45, 12));

                font = new Font(fontName, 13);
                g.DrawString(driver.OvalLicense.iRating, font, Brushes.Black, new RectangleF(205, 22, 60, 25));
                g.DrawString($"{driver.OvalLicense.srPrime}.{driver.OvalLicense.srSub}", font, Brushes.Black, new RectangleF(270, 22, 80, 25));

                g.Flush();
            }

            return(signature);
        }
        private void ExtractLastData(DatagramPayload datagramPayload)
        {
            if (datagramPayload.ContainsOtherDriversTiming)
            {
                _lastDriversInfo = datagramPayload.DriversInfo;
                _lastLeaderInfo  = datagramPayload.LeaderInfo;
                _lastPlayerInfo  = datagramPayload.DriversInfo.Any(x => x.IsPlayer) ? datagramPayload.DriversInfo.FirstOrDefault(x => x.IsPlayer) : _lastPlayerInfo;
            }

            if (datagramPayload.ContainsPlayersTiming)
            {
                _lastPlayerInfo = datagramPayload.PlayerInfo;
                if (_lastDriversInfo != null)
                {
                    int index = Array.IndexOf(_lastDriversInfo, _lastDriversInfo.FirstOrDefault(x => x.IsPlayer));
                    if (index != -1)
                    {
                        _lastDriversInfo[index] = _lastPlayerInfo;
                    }
                }
            }

            if (datagramPayload.ContainsSimulatorSourceInfo)
            {
                _lastSimulatorSourceInfo = datagramPayload.SimulatorSourceInfo;
            }
        }
 public DatagramPayloadUnPacker()
 {
     _lastDriversInfo         = new DriverInfo[0];
     _lastPlayerInfo          = new DriverInfo();
     _lastLeaderInfo          = new DriverInfo();
     _lastSimulatorSourceInfo = new SimulatorSourceInfo();
 }
示例#28
0
        internal static void ComputeDistanceToPlayer(DriverInfo player, DriverInfo driverInfo, AssettoCorsaShared assettoCorsaShared)
        {
            if (player == null)
            {
                return;
            }

            if (driverInfo.FinishStatus == DriverInfo.DriverFinishStatus.Dq || driverInfo.FinishStatus == DriverInfo.DriverFinishStatus.Dnf ||
                driverInfo.FinishStatus == DriverInfo.DriverFinishStatus.Dnq || driverInfo.FinishStatus == DriverInfo.DriverFinishStatus.Dns)
            {
                driverInfo.DistanceToPlayer = double.MaxValue;
                return;
            }

            double trackLength       = assettoCorsaShared.AcsStatic.trackSPlineLength;
            double playerLapDistance = player.LapDistance;

            double distanceToPlayer = playerLapDistance - driverInfo.LapDistance;

            if (distanceToPlayer < -(trackLength / 2))
            {
                distanceToPlayer = distanceToPlayer + trackLength;
            }

            if (distanceToPlayer > (trackLength / 2))
            {
                distanceToPlayer = distanceToPlayer - trackLength;
            }

            driverInfo.DistanceToPlayer = distanceToPlayer;
        }
示例#29
0
        private void ConnectDriver(string name, bool isPlayer)
        {
            if (_players.ContainsKey(name))
            {
                return;
            }
            DriverInfo driver = new DriverInfo();

            _players[name]          = driver;
            driver.CarName          = "Mazda 626";
            driver.CompletedLaps    = 0;
            driver.CurrentLapValid  = true;
            driver.DistanceToPlayer = 0;
            driver.DriverName       = name;
            driver.InPits           = false;
            driver.IsPlayer         = isPlayer;
            driver.LapDistance      = 0;
            driver.Position         = _players.Values.Count;
            if (!isPlayer)
            {
                return;
            }

            driver.CarInfo.FuelSystemInfo.FuelCapacity  = Volume.FromLiters(_totalFuel);
            driver.CarInfo.FuelSystemInfo.FuelRemaining = Volume.FromLiters(_fuel);
            driver.CarInfo.WaterSystemInfo.OptimalWaterTemperature.ActualQuantity = Temperature.FromCelsius(_engineWaterTemp);
            driver.CarInfo.OilSystemInfo.OptimalOilTemperature.ActualQuantity     = Temperature.FromCelsius(_oilTemp);
            return;
        }
示例#30
0
        Stream(ArrayList data, DriverInfo driverInfo)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(DriverInfo)));

            data.Add(new Snoop.Data.String("Driver", driverInfo.Driver));
            data.Add(new Snoop.Data.Bool("Hardware Accelerated", driverInfo.HardwareAccelerated));
            data.Add(new Snoop.Data.String("Path", driverInfo.Path));
        }
示例#31
0
        //硬盘监控
        public void threadDisk(bool is_first, int exec)
        {
            string db_dir = System.Windows.Forms.Application.StartupPath + "\\db.accdb";
            bool begin = tool.execute_or_not("disk_size", db_dir, disk, is_first, exec);
            if (begin == true)
            {
                monitor mtt = new monitor();
                List<string> driverList = mtt.getFixDisk();//获取硬盘列表
                string cd = "";
                foreach (string driver in driverList)
                {
                    float per = mtt.getDiskFreePercent(driver);
                    string drive = driver.Substring(0, 1);

                    DriverInfo driverInfo = new DriverInfo();
                    driverInfo.WarningDrivers = driver;
                    driverInfo.WarningValue = per;
                    driverInfo.WarningDateTime = DateTime.Now;

                    cd += driverInfo.WarningDrivers.Substring(0, 1) + ": " + driverInfo.WarningValue.ToString("0") + "G;\r\n";
                    int csizewarn = int.Parse(tool.readconfig("jb", "Cwarn"));
                    int dsizewarn = int.Parse(tool.readconfig("jb", "Dwarn"));
                    int esizewarn = int.Parse(tool.readconfig("jb", "Ewarn"));
                    int fsizewarn = int.Parse(tool.readconfig("jb", "Fwarn"));
                    int csizeerror = int.Parse(tool.readconfig("bj", "Cerror"));
                    int dsizeerror = int.Parse(tool.readconfig("bj", "Derror"));
                    int esizeerror = int.Parse(tool.readconfig("bj", "Eerror"));
                    int fsizeerror = int.Parse(tool.readconfig("bj", "Ferror"));
                    ////textBox2.Text = csizewarn;
                    if ((drive == "C" && per < csizeerror) || (drive == "D" && per < dsizeerror) || (drive == "E" && per < esizeerror) || (drive == "F" && per < fsizeerror))
                    {
                        WarningListErrorOfDisk.Add(driverInfo);//达到报错条件硬盘

                    }
                    if ((drive == "C" && per < csizewarn) || (drive == "D" && per < dsizewarn) || (drive == "E" && per < esizewarn) || (drive == "F" && per < fsizewarn))
                    {
                        WarningListWarnOfDisk.Add(driverInfo);//达到警告条件硬盘

                    }

                }
                string str5 = System.Windows.Forms.Application.StartupPath;
                string a = str5 + "\\db.accdb";
                Tool_Class.AccessDbClass1 db = new Tool_Class.AccessDbClass1();
                db.AccessDbClass2(a);
                ////textBox1.Text = c;

                string sql3 = "update Status_Now set details ='" + cd + "\n\r" + "参数设置值:" + "\n\r" + diskrecomond + "',create_date = '" + DateTime.Now + "' where para_name = 'disk_size'";

                bool dd = db.ExecuteSQLNonquery(sql3);

                string fgg = "";
                if (WarningListWarnOfDisk.Count == 0 && WarningListErrorOfDisk.Count == 0) //正常
                {
                    fgg = "N";
                    string sql4 = "update Status_Now set para_value='正常',flag ='N' where para_name = 'disk_size'";
                    bool cc = db.ExecuteSQLNonquery(sql4);
                    //////textBox3.Text = cc.ToString();
                }
                if (WarningListWarnOfDisk.Count > 0) //大于设置警告值
                {
                    fgg = "W";
                    string sql4 = "update Status_Now set para_value='警告',flag ='W' where para_name = 'disk_size'";
                    bool cc = db.ExecuteSQLNonquery(sql4);
                    //////textBox3.Text = cc.ToString();
                }
                if (WarningListErrorOfDisk.Count > 0) //大于设置错误值
                {
                    fgg = "E";
                    string sql4 = "update Status_Now set para_value='错误',flag ='E' where para_name = 'disk_size'";
                    bool cc = db.ExecuteSQLNonquery(sql4);
                    //////textBox3.Text = cc.ToString();
                }
                if (WarningListWarnOfDisk.Count > 0 || WarningListErrorOfDisk.Count > 0)
                {
                    string sql11 = "insert into Status_Histroy (para_name,details,flag,create_date) values ('disk_size','" + cd + "','" + fgg + "','" + DateTime.Now + "')";
                    bool ee = db.ExecuteSQLNonquery(sql11);
                    ////textBox3.Text = ee.ToString();
                }
            }
        }
示例#32
0
        private void parser(string yaml)
        {
            int start = 0;
            int end = 0;
            int length = 0;

            length = yaml.Length;
            start = yaml.IndexOf("WeekendInfo:\n", 0, length);
            end = yaml.IndexOf("\n\n", start, length - start);

            string WeekendInfo = yaml.Substring(start, end - start);
            SharedData.Track.Length = (Single)parseDoubleValue(WeekendInfo, "TrackLength", "km") * 1000;
            SharedData.Track.Id = parseIntValue(WeekendInfo, "TrackID");
            SharedData.Track.Turns = parseIntValue(WeekendInfo, "TrackNumTurns");
            SharedData.Track.City = parseStringValue(WeekendInfo, "TrackCity");
            SharedData.Track.Country = parseStringValue(WeekendInfo, "TrackCountry");

            SharedData.Track.Altitude = (Single)parseDoubleValue(WeekendInfo, "TrackAltitude", "m");
            SharedData.Track.Sky = parseStringValue(WeekendInfo, "TrackSkies");
            SharedData.Track.TrackTemperature = (Single)parseDoubleValue(WeekendInfo, "TrackSurfaceTemp", "C");
            SharedData.Track.AirTemperature = (Single)parseDoubleValue(WeekendInfo, "TrackAirTemp", "C");
            SharedData.Track.AirPressure = (Single)parseDoubleValue(WeekendInfo, "TrackAirPressure", "Hg");
            SharedData.Track.WindSpeed = (Single)parseDoubleValue(WeekendInfo, "TrackWindVel", "m/s");
            SharedData.Track.WindDirection = (Single)parseDoubleValue(WeekendInfo, "TrackWindDir", "rad");
            SharedData.Track.Humidity = parseIntValue(WeekendInfo, "TrackRelativeHumidity", "%");
            SharedData.Track.Fog = parseIntValue(WeekendInfo, "TrackFogLevel", "%");

            if (parseIntValue(WeekendInfo, "Official") == 0 &&
                parseIntValue(WeekendInfo, "SeasonID") == 0 &&
                parseIntValue(WeekendInfo, "SeriesID") == 0)
                SharedData.Sessions.Hosted = true;
            else
                SharedData.Sessions.Hosted = false;




            if ( SharedData.theme != null )
                SharedData.Track.Name = SharedData.theme.TrackNames.getValue("Tracks", SharedData.Track.Id.ToString(),false,"Unknown Track",false);

            SharedData.Sessions.SessionId = parseIntValue(WeekendInfo, "SessionID");
            SharedData.Sessions.SubSessionId = parseIntValue(WeekendInfo, "SubSessionID");

            length = yaml.Length;
            start = yaml.IndexOf("DriverInfo:\n", 0, length);
            end = yaml.IndexOf("\n\n", start, length - start);

            string DriverInfo = yaml.Substring(start, end - start);

            length = DriverInfo.Length;
            start = DriverInfo.IndexOf(" Drivers:\n", 0, length);
            end = length;

            string Drivers = DriverInfo.Substring(start, end - start - 1);
            string[] driverList = Drivers.Split(new string[] { "\n - " }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string driver in driverList)
            {
                // KJ: fix
                // let's see if car is already in list ...
                int carIdx = parseIntValue(driver, "CarIdx");
                var driverCarIdx = SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx));
                if (driverCarIdx != null)
                {
                    // car already in list, check if driver changed
                    var newUserId = parseIntValue(driver, "UserID");
                    if (driverCarIdx.UserId != newUserId)
                    {
logger.Info("driverChange detected - new driver ({0})", parseStringValue(driver,"UserName"));
                        // driver changed - update driver details
                        SharedData.updateControls = true;
                        SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx)).Name = parseStringValue(driver, "UserName");
                        SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx)).Initials = parseStringValue(driver, "Initials");
                        if (parseStringValue(driver, "AbbrevName") != null)
                        {
                            string[] splitName = parseStringValue(driver, "AbbrevName").Split(',');
                            if (splitName.Length > 1)
                                SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx)).Shortname = splitName[1] + " " + splitName[0];
                            else
                                SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx)).Shortname = parseStringValue(driver, "AbbrevName");
                        }
                        else
                            SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx)).Shortname = "";
                        SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx)).Club = parseStringValue(driver, "Club");
                        SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx)).SR = parseStringValue(driver, "SR");
                        SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx)).iRating = parseIntValue(driver, "iRating");
                        SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx)).UserId = newUserId;
logger.Info("driverChange - looking for external data", "");
                        string[] external_driver;
                        if ( SharedData.externalData.TryGetValue(newUserId, out external_driver) )
                        {
logger.Info("driverChange - external data found", "");
                            int ed_idx;
                            if ( ( ed_idx = Int32.Parse(SharedData.theme.getIniValue("General", "dataFullName") ) ) >= 0 && external_driver.Length > ed_idx )
                            {
                                SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx)).Name = external_driver[ed_idx];
                            }
                            if ( ( ed_idx = Int32.Parse(SharedData.theme.getIniValue("General", "dataShortName") ) ) >= 0 && external_driver.Length > ed_idx )
                            {
                                SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx)).Shortname = external_driver[ed_idx];
                            }
                            if ( ( ed_idx = Int32.Parse(SharedData.theme.getIniValue("General", "dataInitials") ) ) >= 0 && external_driver.Length > ed_idx )
                            {
                                SharedData.Drivers.Find(d => d.CarIdx.Equals(carIdx)).Initials = external_driver[ed_idx];
                            }
                        }
logger.Info("driverChange - data ready", "");
                    }
                }

                int userId = parseIntValue(driver, "UserID");
                if (userId < Int32.MaxValue && userId > 0)
                {
                    int index = SharedData.Drivers.FindIndex(d => d.UserId.Equals(userId));
                    if (index < 0 &&
                        parseStringValue(driver, "CarPath") != "safety pcfr500s" &&
                        parseStringValue(driver, "AbbrevName") != "Pace Car")
                    {
                        if (SharedData.settings.IncludeMe || (!SharedData.settings.IncludeMe && parseIntValue(driver, "CarIdx") != 63))
                        {
                            DriverInfo driverItem = new DriverInfo();
                            char[] charsToTrim = {'"'};

                            driverItem.Name = parseStringValue(driver, "UserName");

                            if (parseStringValue(driver, "AbbrevName") != null)
                            {
                                string[] splitName = parseStringValue(driver, "AbbrevName").Split(',');
                                if (splitName.Length > 1)
                                    driverItem.Shortname = splitName[1] + " " + splitName[0];
                                else
                                    driverItem.Shortname = parseStringValue(driver, "AbbrevName");
                            }
                            driverItem.Initials = parseStringValue(driver, "Initials");
                            driverItem.Club = parseStringValue(driver, "ClubName");
                            driverItem.NumberPlate = parseStringValue(driver, "CarNumber").Trim(charsToTrim);
                            driverItem.CarId = parseIntValue(driver, "CarID");
                            driverItem.CarClass = parseIntValue(driver, "CarClassID");
                            driverItem.UserId = parseIntValue(driver, "UserID");
                            driverItem.CarIdx = parseIntValue(driver, "CarIdx");
                            driverItem.CarClassName = ( SharedData.theme != null ? SharedData.theme.getCarClass(driverItem.CarId) : "unknown" );
                            driverItem.iRating = parseIntValue(driver, "IRating");
                            // KJ: teamID!
                            driverItem.TeamId = parseIntValue(driver, "TeamID");

                            int liclevel = parseIntValue(driver, "LicLevel");
                            int licsublevel = parseIntValue(driver, "LicSubLevel");

                            switch (liclevel)
                            {
                                case 0:
                                case 1:
                                case 2:
                                case 3:
                                case 4:
                                    driverItem.SR = "R" + ((double)licsublevel / 100).ToString("0.00");
                                    break;
                                case 5:
                                case 6:
                                case 7:
                                case 8:
                                    driverItem.SR = "D" + ((double)licsublevel / 100).ToString("0.00");
                                    break;
                                case 9:
                                case 10:
                                case 11:
                                case 12:
                                    driverItem.SR = "C" + ((double)licsublevel / 100).ToString("0.00");
                                    break;
                                case 14:
                                case 15:
                                case 16:
                                case 17:
                                    driverItem.SR = "B" + ((double)licsublevel / 100).ToString("0.00");
                                    break;
                                case 18:
                                case 19:
                                case 20:
                                case 21:
                                    driverItem.SR = "A" + ((double)licsublevel / 100).ToString("0.00");
                                    break;
                                case 22:
                                case 23:
                                case 24:
                                case 25:
                                    driverItem.SR = "P" + ((double)licsublevel / 100).ToString("0.00");
                                    break;
                                case 26:
                                case 27:
                                case 28:
                                case 29:
                                    driverItem.SR = "WC" + ((double)licsublevel / 100).ToString("0.00");
                                    break;
                                default:
                                    driverItem.SR = "Unknown";
                                    break;
                            }

                            driverItem.CarClass = -1;
                            int carclass = parseIntValue(driver, "CarClassID");
                            int freeslot = -1;

                            for (int i = 0; i < SharedData.Classes.Length; i++)
                            {
                                if (SharedData.Classes[i] == carclass)
                                {
                                    driverItem.CarClass = i;
                                }
                                else if (SharedData.Classes[i] == -1 && freeslot < 0)
                                {
                                    freeslot = i;
                                }
                            }

                            if (driverItem.CarClass < 0 && freeslot >= 0)
                            {
                                SharedData.Classes[freeslot] = carclass;
                                driverItem.CarClass = freeslot;
                            }

                            if (!SharedData.externalPoints.ContainsKey(userId) && driverItem.CarIdx < 60)
                                SharedData.externalPoints.Add(userId, 0);

                            // fix bugges
                            if (driverItem.NumberPlate == null)
                                driverItem.NumberPlate = "000";
                            if (driverItem.Initials == null)
                                driverItem.Initials = "";

                            // KJ: if we are team-racing: get the teamname or make one up ...
                            if (driverItem.TeamId > 0)
                            {
                                if (SharedData.externalTeamData.ContainsKey(driverItem.TeamId))
                                {
                                    // found teamname for teamid in teams.csv
                                    string[] td_result;
                                    SharedData.externalTeamData.TryGetValue(driverItem.TeamId, out td_result);
                                    driverItem.TeamName = td_result[0];
                                }
                                else if (SharedData.externalTeamData.ContainsKey(Int32.Parse(driverItem.NumberPlate)))
                                {
                                    // found teamname for carnum in teams.csv
                                    string[] td_result;
                                    SharedData.externalTeamData.TryGetValue(Int32.Parse(driverItem.NumberPlate), out td_result);
                                    driverItem.TeamName = td_result[0];
                                }
                                else
                                {
                                    // make up generic teamname (to be parametrized in future)
                                    driverItem.TeamName = "Team #" + driverItem.NumberPlate;
                                }
                            }

                            // KJ: if we have external data - perhaps we shall overload name data for the driver
                            string[] external_driver;
                            if (SharedData.externalData.TryGetValue(userId, out external_driver))
                            {
                                // found external data for userid
                                int ed_idx;
                                SharedData.theme.getIniValue("General", "dataFullName");
                                if ((ed_idx = Int32.Parse(SharedData.theme.getIniValue("General", "dataFullName"))) >= 0 && external_driver.Length > ed_idx )
                                {
                                    // fullname gets replaced with column of data.csv
                                    driverItem.Name = external_driver[ed_idx];
                                }
                                if ((ed_idx = Int32.Parse(SharedData.theme.getIniValue("General", "dataShortName"))) >= 0 && external_driver.Length > ed_idx )
                                {
                                    // shortname gets replaced with column of data.csv
                                    driverItem.Shortname = external_driver[ed_idx];
                                }
                                if ((ed_idx = Int32.Parse(SharedData.theme.getIniValue("General", "dataInitials"))) >= 0 && external_driver.Length > ed_idx )
                                {
                                    // initials get replaced with column of data.csv
                                    driverItem.Initials = external_driver[ed_idx];
                                }
                            }

                            SharedData.Drivers.Add(driverItem);
                        }
                    }
                }
            }

            length = yaml.Length;
            start = yaml.IndexOf("SessionInfo:\n", 0, length);
            end = yaml.IndexOf("\n\n", start, length - start);

            string SessionInfo = yaml.Substring(start, end - start);

            length = SessionInfo.Length;
            start = SessionInfo.IndexOf(" Sessions:\n", 0, length);
            end = length;

            string Sessions = SessionInfo.Substring(start, end - start);
            string[] sessionList = Sessions.Split(new string[] { "\n - " }, StringSplitOptions.RemoveEmptyEntries);

            // Get Current running Session
            int _CurrentSession = (int)sdk.GetData("SessionNum");

            foreach (string session in sessionList)
            {
                int sessionNum = parseIntValue(session, "SessionNum");
                if (sessionNum < Int32.MaxValue)
                {
                    int sessionIndex = SharedData.Sessions.SessionList.FindIndex(s => s.Id.Equals(sessionNum));
                    if (sessionIndex < 0) // add new session item
                    {
                        SessionInfo sessionItem = new SessionInfo();
                        sessionItem.Id = sessionNum;
                        sessionItem.LapsTotal = parseIntValue(session, "SessionLaps");
                        sessionItem.SessionLength = parseFloatValue(session, "SessionTime", "sec");
                        sessionItem.Type = sessionTypeMap[parseStringValue(session, "SessionType")];

                        if (sessionItem.Type == SessionTypes.race)
                        {
                            sessionItem.FinishLine = parseIntValue(session, "SessionLaps") + 1;
                        }
                        else
                        {
                            sessionItem.FinishLine = Int32.MaxValue;
                        }

                        if (sessionItem.FinishLine < 0)
                        {
                            sessionItem.FinishLine = Int32.MaxValue;
                        }

                        sessionItem.Cautions = parseIntValue(session, "ResultsNumCautionFlags");
                        sessionItem.CautionLaps = parseIntValue(session, "ResultsNumCautionLaps");
                        sessionItem.LeadChanges = parseIntValue(session, "ResultsNumLeadChanges");
                        sessionItem.LapsComplete = parseIntValue(session, "ResultsLapsComplete");

                        length = session.Length;
                        start = session.IndexOf("   ResultsFastestLap:\n", 0, length);
                        end = length;
                        string ResultsFastestLap = session.Substring(start, end - start);

                        sessionItem.FastestLap = parseFloatValue(ResultsFastestLap, "FastestTime");
                        int index = SharedData.Drivers.FindIndex(d => d.CarIdx.Equals(parseIntValue(ResultsFastestLap, "CarIdx")));
                        if (index >= 0)
                        {
                            sessionItem.FastestLapDriver = SharedData.Drivers[index];
                            sessionItem.FastestLapNum = parseIntValue(ResultsFastestLap, "FastestLap");
                        }
                        SharedData.Sessions.SessionList.Add(sessionItem);
                        sessionIndex = SharedData.Sessions.SessionList.FindIndex(s => s.Id.Equals(sessionNum));
                    }
                    else // update only non fixed fields
                    {
                        SharedData.Sessions.SessionList[sessionIndex].LeadChanges = parseIntValue(session, "ResultsNumLeadChanges");
                        SharedData.Sessions.SessionList[sessionIndex].LapsComplete = parseIntValue(session, "ResultsLapsComplete");

                        length = session.Length;
                        start = session.IndexOf("   ResultsFastestLap:\n", 0, length) + "   ResultsFastestLap:\n".Length;
                        end = length;
                        string ResultsFastestLap = session.Substring(start, end - start);

                        
                        SharedData.Sessions.SessionList[sessionIndex].FastestLap = parseFloatValue(ResultsFastestLap, "FastestTime");
                        int index = SharedData.Drivers.FindIndex(d => d.CarIdx.Equals(parseIntValue(ResultsFastestLap, "CarIdx")));
                        if (index >= 0)
                        {
                            SharedData.Sessions.SessionList[sessionIndex].FastestLapDriver = SharedData.Drivers[index];
                            SharedData.Sessions.SessionList[sessionIndex].FastestLapNum = parseIntValue(ResultsFastestLap, "FastestLap");
                        }
                    }
                    

                    length = session.Length;
                    start = session.IndexOf("   ResultsPositions:\n", 0, length);
                    end = session.IndexOf("   ResultsFastestLap:\n", start, length - start);

                    string Standings = session.Substring(start, end - start);
                    string[] standingList = Standings.Split(new string[] { "\n   - " }, StringSplitOptions.RemoveEmptyEntries);

                    Int32 position = 1;
                    List<DriverInfo> standingsDrivers = SharedData.Drivers.ToList();

                    foreach (string standing in standingList)
                    {
                        int carIdx = parseIntValue(standing, "CarIdx");
                        if (carIdx < Int32.MaxValue)
                        {
                            StandingsItem standingItem = new StandingsItem();
                            standingItem = SharedData.Sessions.SessionList[sessionIndex].FindDriver(carIdx);

                            standingsDrivers.Remove(standingsDrivers.Find(s => s.CarIdx.Equals(carIdx)));

                            if (parseFloatValue(standing, "LastTime") > 0)
                            {
                                if (parseFloatValue(standing, "LastTime") < SharedData.Sessions.SessionList[sessionIndex].FastestLap && SharedData.Sessions.SessionList[sessionIndex].FastestLap > 0)
                                {
                                    

                                    // Race Condition?
                                    //SharedData.Sessions.SessionList[sessionIndex].FastestLap = parseFloatValue(standing, "FastestTime");                                    
                                }
                            }

                            /*
                            if (parseFloatValue(standing, "FastestTime") < SharedData.Sessions.SessionList[sessionIndex].FastestLap ||
                                SharedData.Sessions.SessionList[sessionIndex].FastestLap <= 0)
                            {
                                SharedData.Sessions.SessionList[sessionIndex].FastestLap = parseFloatValue(standing, "FastestTime");
                            }
                            */
                            /*
                            if (standingItem.Finished == false)
                            {
                                standingItem.PreviousLap.LapTime = parseFloatValue(standing, "LastTime");

                                if (standingItem.PreviousLap.LapTime <= 1)
                                {
                                    standingItem.PreviousLap.LapTime = standingItem.CurrentLap.LapTime;
                                }
                            }
                            */

                            if (SharedData.Sessions.SessionList[sessionIndex].Type == SharedData.Sessions.CurrentSession.Type)
                            {
                                if ((standingItem.CurrentTrackPct % 1.0) > 0.1)
                                {
                                    standingItem.PreviousLap.Position = parseIntValue(standing, "Position");
                                    standingItem.PreviousLap.Gap = parseFloatValue(standing, "Time");
                                    standingItem.PreviousLap.GapLaps = parseIntValue(standing, "Lap");
                                    standingItem.CurrentLap.Position = parseIntValue(standing, "Position");
                                }
                            }

                            if (standingItem.Driver.CarIdx < 0)
                            {
                                // insert item
                                int driverIndex = SharedData.Drivers.FindIndex(d => d.CarIdx.Equals(carIdx));
                                standingItem.setDriver(carIdx);
                                standingItem.FastestLap = parseFloatValue(standing, "FastestTime");
                                standingItem.LapsLed = parseIntValue(standing, "LapsLed");
                                standingItem.CurrentTrackPct = parseFloatValue(standing, "LapsDriven");
                                standingItem.Laps = new List<LapInfo>();

                                LapInfo newLap = new LapInfo();
                                newLap.LapNum = parseIntValue(standing, "LapsComplete");
                                newLap.LapTime = parseFloatValue(standing, "LastTime");
                                newLap.Position = parseIntValue(standing, "Position");
                                newLap.Gap = parseFloatValue(standing, "Time");
                                newLap.GapLaps = parseIntValue(standing, "Lap");
                                newLap.SectorTimes = new List<Sector>(3);
                                standingItem.Laps.Add(newLap);

                                standingItem.CurrentLap = new LapInfo();
                                standingItem.CurrentLap.LapNum = parseIntValue(standing, "LapsComplete") + 1;
                                standingItem.CurrentLap.Position = parseIntValue(standing, "Position");
                                standingItem.CurrentLap.Gap = parseFloatValue(standing, "Time");
                                standingItem.CurrentLap.GapLaps = parseIntValue(standing, "Lap");

                                lock (SharedData.SharedDataLock)
                                {
                                    SharedData.Sessions.SessionList[sessionIndex].Standings.Add(standingItem);
                                    SharedData.Sessions.SessionList[sessionIndex].UpdatePosition();
                                }
                            }

                            int lapnum = parseIntValue(standing, "LapsComplete");
                            standingItem.FastestLap = parseFloatValue(standing, "FastestTime");
                            standingItem.LapsLed = parseIntValue(standing, "LapsLed");

                            if (SharedData.Sessions.SessionList[sessionIndex].Type == SharedData.Sessions.CurrentSession.Type)
                            {
                                standingItem.PreviousLap.LapTime = parseFloatValue(standing, "LastTime");
                            }

                            if (SharedData.Sessions.CurrentSession.State == SessionStates.cooldown)
                            {
                                standingItem.CurrentLap.Gap = parseFloatValue(standing, "Time");
                                standingItem.CurrentLap.GapLaps = parseIntValue(standing, "Lap");
                                standingItem.CurrentLap.Position = parseIntValue(standing, "Position");
                                standingItem.CurrentLap.LapNum = parseIntValue(standing, "LapsComplete");
                            }

                            standingItem.Position = parseIntValue(standing, "Position");
                            standingItem.NotifySelf();
                            standingItem.NotifyLaps();

                            position++;
                        }
                    }

                    // Trigger Overlay Event, but only in current active session
                    if ((SharedData.Sessions.SessionList[sessionIndex].FastestLap != SharedData.Sessions.SessionList[sessionIndex].PreviousFastestLap)
                        && (_CurrentSession == SharedData.Sessions.SessionList[sessionIndex].Id)
                        )
                    {
                        if (SharedData.Sessions.SessionList[sessionIndex].FastestLap > 0)
                        {
                            SessionEvent ev = new SessionEvent(
                                        SessionEventTypes.fastlap,
                                        (Int32)(((Double)sdk.GetData("SessionTime") * 60) + timeoffset),
                                         SharedData.Sessions.SessionList[sessionIndex].FastestLapDriver,
                                        "New session fastest lap (" + Utils.floatTime2String(SharedData.Sessions.SessionList[sessionIndex].FastestLap, 3, false) + ")",
                                        SharedData.Sessions.SessionList[sessionIndex].Type,
                                       SharedData.Sessions.SessionList[sessionIndex].FastestLapNum
                                    );

                            SharedData.Events.Add(ev);
                            // Push Event to Overlay
                            logger.Info("New fastest lap in Session {0} : {1}", _CurrentSession, SharedData.Sessions.SessionList[sessionIndex].FastestLap);
                            SharedData.triggers.Push(TriggerTypes.fastestlap);
                        }
                    }

                    // update/add position for drivers not in results
                    foreach (DriverInfo driver in standingsDrivers)
                    {
                        StandingsItem standingItem = SharedData.Sessions.SessionList[sessionIndex].FindDriver(driver.CarIdx);
                        if (standingItem.Driver.CarIdx < 0)
                        {
                            if (SharedData.settings.IncludeMe || (!SharedData.settings.IncludeMe && standingItem.Driver.CarIdx != 63))
                            {
                                standingItem.setDriver(driver.CarIdx);
                                standingItem.Position = position;
                                standingItem.Laps = new List<LapInfo>();
                                lock (SharedData.SharedDataLock)
                                {
                                    SharedData.Sessions.SessionList[sessionIndex].Standings.Add(standingItem);
                                }
                                position++;
                            }
                        }
                        else if (!SharedData.settings.IncludeMe && driver.CarIdx < 63)
                        {
                            standingItem.Position = position;
                            position++;
                        }
                    }
                }
            }

            // add qualify session if it doesn't exist when race starts and fill it with YAML QualifyResultsInfo
            SessionInfo qualifySession = SharedData.Sessions.findSessionByType(SessionTypes.qualify);
            if (qualifySession.Type == SessionTypes.none)
            {
                qualifySession.Type = SessionTypes.qualify;

                length = yaml.Length;
                start = yaml.IndexOf("QualifyResultsInfo:\n", 0, length);

                // if found
                if (start >= 0)
                {
                    end = yaml.IndexOf("\n\n", start, length - start);

                    string QualifyResults = yaml.Substring(start, end - start);

                    length = QualifyResults.Length;
                    start = QualifyResults.IndexOf(" Results:\n", 0, length);
                    end = length;

                    string Results = QualifyResults.Substring(start, end - start - 1);
                    string[] resultList = Results.Split(new string[] { "\n - " }, StringSplitOptions.RemoveEmptyEntries);

                    qualifySession.FastestLap = float.MaxValue;

                    foreach (string result in resultList)
                    {
                        if (result != " Results:")
                        {
                            StandingsItem qualStandingsItem = qualifySession.FindDriver(parseIntValue(result, "CarIdx"));

                            if (qualStandingsItem.Driver.CarIdx > 0) // check if driver is in quali session
                            {
                                qualStandingsItem.Position = parseIntValue(result, "Position") + 1;
                            }
                            else // add driver to quali session
                            {
                                qualStandingsItem.setDriver(parseIntValue(result, "CarIdx"));
                                qualStandingsItem.Position = parseIntValue(result, "Position") + 1;
                                qualStandingsItem.FastestLap = parseFloatValue(result, "FastestTime");
                                lock (SharedData.SharedDataLock)
                                {
                                    qualifySession.Standings.Add(qualStandingsItem);
                                }
                                // update session fastest lap
                                if (qualStandingsItem.FastestLap < qualifySession.FastestLap && qualStandingsItem.FastestLap > 0)
                                    qualifySession.FastestLap = qualStandingsItem.FastestLap;
                            }
                        }
                    }
                    SharedData.Sessions.SessionList.Add(qualifySession); // add quali session
                }
            }

            // get qualify results if race session standings is empty
            foreach (SessionInfo session in SharedData.Sessions.SessionList)
            {
                if (session.Type == SessionTypes.race && session.Standings.Count < 1)
                {
                    length = yaml.Length;
                    start = yaml.IndexOf("QualifyResultsInfo:\n", 0, length);

                    // if found
                    if (start >= 0)
                    {
                        end = yaml.IndexOf("\n\n", start, length - start);

                        string QualifyResults = yaml.Substring(start, end - start);

                        length = QualifyResults.Length;
                        start = QualifyResults.IndexOf(" Results:\n", 0, length);
                        end = length;

                        string Results = QualifyResults.Substring(start, end - start - 1);
                        string[] resultList = Results.Split(new string[] { "\n - " }, StringSplitOptions.RemoveEmptyEntries);

                        foreach (string result in resultList)
                        {
                            if (result != " Results:")
                            {
                                StandingsItem standingItem = new StandingsItem();
                                standingItem.setDriver(parseIntValue(result, "CarIdx"));
                                standingItem.Position = parseIntValue(result, "Position") + 1;
                                lock (SharedData.SharedDataLock)
                                {
                                    session.Standings.Add(standingItem);
                                }
                            }
                        }
                    }
                }
            }

            length = yaml.Length;
            start = yaml.IndexOf("CameraInfo:\n", 0, length);
            end = yaml.IndexOf("\n\n", start, length - start);

            string CameraInfo = yaml.Substring(start, end - start);

            length = CameraInfo.Length;
            start = CameraInfo.IndexOf(" Groups:\n", 0, length);
            end = length;

            string Cameras = CameraInfo.Substring(start, end - start - 1);
            string[] cameraList = Cameras.Split(new string[] { "\n - " }, StringSplitOptions.RemoveEmptyEntries);
            bool haveNewCam = false;
            foreach (string camera in cameraList)
            {
                int cameraNum = parseIntValue(camera, "GroupNum");
                if (cameraNum < Int32.MaxValue)
                {
                    CameraGroup camgrp = SharedData.Camera.FindId(cameraNum);
                    if (camgrp.Id < 0)
                    {
                        CameraGroup cameraGroupItem = new CameraGroup();
                        cameraGroupItem.Id = cameraNum;
                        cameraGroupItem.Name = parseStringValue(camera, "GroupName");
                        lock (SharedData.SharedDataLock)
                        {
                            SharedData.Camera.Groups.Add(cameraGroupItem);
                            haveNewCam = true;
                        }
                    }
                }
            }
            if (SharedData.settings.CamerasButtonColumn && haveNewCam) // If we have a new cam and want Camera Buttons, then forece a refresh of the main window buttons
                SharedData.refreshButtons = true;

            length = yaml.Length;
            start = yaml.IndexOf("SplitTimeInfo:\n", 0, length);
            end = yaml.IndexOf("\n\n", start, length - start);

            string SplitTimeInfo = yaml.Substring(start, end - start);

            length = SplitTimeInfo.Length;
            start = SplitTimeInfo.IndexOf(" Sectors:\n", 0, length);
            end = length;

            string Sectors = SplitTimeInfo.Substring(start, end - start - 1);
            string[] sectorList = Sectors.Split(new string[] { "\n - " }, StringSplitOptions.RemoveEmptyEntries);

            if (sectorList.Length != SharedData.Sectors.Count)
            {
                SharedData.Sectors.Clear();
                foreach (string sector in sectorList)
                {
                    int sectornum = parseIntValue(sector, "SectorNum");
                    if (sectornum < 100)
                    {
                        float sectorborder = parseFloatValue(sector, "SectorStartPct");
                        SharedData.Sectors.Add(sectorborder);
                    }
                }

                // automagic sector selection
                if (SharedData.SelectedSectors.Count == 0)
                {
                    SharedData.SelectedSectors.Clear();

                    // load sectors
                    CfgFile sectorsIni = new CfgFile(Directory.GetCurrentDirectory() + "\\sectors.ini");
                    string sectorValue = sectorsIni.getValue("Sectors", SharedData.Track.Id.ToString(),false,String.Empty,false);
                    string[] selectedSectors = sectorValue.Split(';');
                    Array.Sort(selectedSectors);

                    SharedData.SelectedSectors.Clear();
                    if (sectorValue.Length > 0)
                    {
                        foreach (string sector in selectedSectors)
                        {
                            float number;
                            if (Single.TryParse(sector, out number))
                            {
                                SharedData.SelectedSectors.Add(number);
                            }
                        }
                    }
                    else
                    {
                        if (SharedData.Sectors.Count == 2)
                        {
                            foreach (float sector in SharedData.Sectors)
                                SharedData.SelectedSectors.Add(sector);
                        }
                        else
                        {
                            float prevsector = 0;
                            foreach (float sector in SharedData.Sectors)
                            {

                                if (sector == 0 && SharedData.SelectedSectors.Count == 0)
                                {
                                    SharedData.SelectedSectors.Add(sector);
                                }
                                else if (sector >= 0.333 && SharedData.SelectedSectors.Count == 1)
                                {
                                    if (sector - 0.333 < Math.Abs(prevsector - 0.333))
                                    {
                                        SharedData.SelectedSectors.Add(sector);
                                    }
                                    else
                                    {
                                        SharedData.SelectedSectors.Add(prevsector);
                                    }
                                }
                                else if (sector >= 0.666 && SharedData.SelectedSectors.Count == 2)
                                {
                                    if (sector - 0.666 < Math.Abs(prevsector - 0.666))
                                    {
                                        SharedData.SelectedSectors.Add(sector);
                                    }
                                    else
                                    {
                                        SharedData.SelectedSectors.Add(prevsector);
                                    }
                                }

                                prevsector = sector;
                            }
                        }
                    }
                }
            }
        }