Exemple #1
0
 public void UpdateCalibrationData(RideProcessor rideProcessor, Spot spot)
 {
     _calibrationData.Add(spot.Copy());
 }
Exemple #2
0
        public void AbandonRider(RideProcessor rp)
        {
            try
            {
                _RaceSpotLock.EnterWriteLock();
                // set this rider as abandoned
                _RaceSpots[rp.UserId].a = true;
                // Remove the handlers
                rp.RiderInactiveEvent -= this.AbandonRider;
                rp.SpotDataEvent -= this.UpdateSpotData;

            }
            finally
            {
                Debug.WriteLine("Rider Abandoned " + this.Race.Name + "  " + rp.UserId);

                _RaceSpotLock.ExitWriteLock();
            }
        }
Exemple #3
0
 private RideProcessor ActivateUserRider(string userId)
 {
     RideProcessor processor = null;
       try
       {
     _rideProcessLock.EnterWriteLock();
     // rideprocessor lock should already be in write mode
     processor = new RideProcessor(userId);
       //       check if already registered
     if (!_RideProcessors.ContainsKey(userId)) {
     _RideProcessors.Add(userId, processor);
     }
       }
       finally
       {
     _rideProcessLock.ExitWriteLock();
       }
       return processor;
 }
Exemple #4
0
        public void UpdateSpotData(RideProcessor rideProcessor)
        {
            // This method is called by any attached ride processor
            // ride processor is only attached at race start if rider status flag is set
            // to started, so we can update spots without checking started flag here

            try
            {
                _SpotLock.EnterWriteLock();
                // return true if finished
                Spot sp = rideProcessor.SpotData;
                // careful here - it's possible for sp.t to have been set before the racestartticks
                // due to locking, so we have to allow for deltaticks to be negative
                // which, as this is all unsigned, with give a massive number!!
                // only process if sp.t > Racestartticks
                if (sp.t > RaceStartTicks)
                {

                    if (IsRiderFinished(sp.id))
                    {
                        rideProcessor.SpotDataEvent -= this.UpdateSpotData;
                        rideProcessor.RiderInactiveEvent -= this.AbandonRider;
                    }
                    else
                    {
                        _Spots[sp.id] = sp;
                    }
                }
            }
            finally
            {
                _SpotLock.ExitWriteLock();
            }
        }