Пример #1
0
 private double CalculateArrivingTime(IVehicle v, double distance)
 {
     if (v.state._freeDrive)
         {
         //double timeToArrive = (v.physics.desiredVelocity * Math2.Acosh (Math.Exp(v.a * distance / Math2.Square(v.physics.desiredVelocity)))) / (10 * v.a);
         return v.GetTimeToCoverDistance(distance, false);//timeToArrive;
         }
     else
         {
         return v.GetTimeToCoverDistance(distance, true);
         }
 }
Пример #2
0
        /// <summary>
        /// Registers that the given vehicle is going to cross this intersection via the given NodeConnection.
        /// </summary>
        /// <param name="v">Vehicle to cross intersection (must not be registered yet!).</param>
        /// <param name="nc">NodeConnection the vehicle is going to use (must participate on this Intersection!).</param>
        /// <param name="distance">Current distance of the vehicle to the Intersection</param>
        /// <param name="currentTime">current world time.</param>
        public void RegisterVehicle(IVehicle v, NodeConnection nc, double distance, double currentTime)
        {
            Debug.Assert(nc == _aConnection || nc == _bConnection);
            // TODO: add some safety space before and behind
            double blockingStartTime = currentTime + CalculateArrivingTime(v, distance - (_frontWaitingDistance / 2)) - v.SafetyTime/8;
            double blockingEndTime = currentTime + CalculateArrivingTime(v, distance + v.length) + v.SafetyTime/8;
            double originalArrivingTime = currentTime + v.GetTimeToCoverDistance(distance, false);

            if (nc == _aConnection)
                {
                    //if (aCrossingVehicles.ContainsKey(v))
                    //{
                        aCrossingVehicles.Add(v, new CrossingVehicleTimes(originalArrivingTime, distance, new Interval<double>(blockingStartTime, blockingEndTime), false));
                   // }
                }
            else
                {
            //                     if (bCrossingVehicles.ContainsKey(v))
            //                     {
                        bCrossingVehicles.Add(v, new CrossingVehicleTimes(originalArrivingTime, distance, new Interval<double>(blockingStartTime, blockingEndTime), false));
                /*    }	*/
                }
        }