public override void Tick()
        {
            var openCount = ParkingLocations.Count(r => !r.IsFull);

            if (openCount > 0)
            {
                while (InQueue.Count > 0)
                {
                    var location = FindOpenLocation();
                    if (location != null)
                    {
                        location.ParkAuto(InQueue.Dequeue());
                    }
                    else
                    {
                        break;
                    }
                }
            }

            var departing = ParkingLocations.Where(r => r.Occupant != null && r.Occupant.DateToDepart <= Simulator.Clock.Now);

            foreach (var item in departing)
            {
                AutoExitingFrom(item);
            }
            base.Tick();
            while (OutQueue.Count > 0)
            {
                Parent.OutQueue.Enqueue(OutQueue.Dequeue());
            }
        }
Exemple #2
0
        public override void Tick()
        {
            var openCount = Floors.Count(r => !r.IsFull);

            if (openCount > 0)
            {
                var gateCapacity = (int)(Simulator.Interval.TotalSeconds / 10.0);
                for (int i = 0; i < gateCapacity; i++)
                {
                    var floorsWithRoom = Floors.Where(r => !r.IsFull).ToList();
                    if (InQueue.Count > 0 && floorsWithRoom.Count > 0)
                    {
                        var floor = Simulator.Random.Next(floorsWithRoom.Count);
                        floorsWithRoom[floor].InQueue.Enqueue(InQueue.Dequeue());
                    }
                }
            }
            foreach (var item in Floors)
            {
                item.Tick();
            }
            base.Tick();
            while (OutQueue.Count > 0)
            {
                Parent.OutQueue.Enqueue(OutQueue.Dequeue());
            }
        }
Exemple #3
0
 public override void Tick()
 {
     if (!IsFull)
     {
         var gateCapacity = (int)(Simulator.Interval.TotalSeconds / 60.0 * 5);
         for (int i = 0; i < gateCapacity; i++)
         {
             if (InQueue.Count > 0 && !IsFull)
             {
                 var ramp = GetOpenRamp();
                 if (ramp != null)
                 {
                     ramp.InQueue.Enqueue(InQueue.Dequeue());
                 }
                 else
                 {
                     break;
                 }
             }
         }
     }
     foreach (var item in ParkingRamps)
     {
         item.Tick();
     }
     base.Tick();
     while (OutQueue.Count > 0)
     {
         var auto = OutQueue.Dequeue();
         Simulator.Notifier.Notify(new AutoDepartingFacility {
             Auto = auto
         });
     }
 }
        void WritePackets()
        {
            try {
                while (Running)
                {
                    Packet packet = null;
                    lock (WriteLock)
                        packet = OutQueue.Dequeue();

                    if (packet != null)
                    {
                        PacketWriter.WritePacket(packet);
                    }
                }
            }
            catch {
                CloseConnection();
            }

            CloseConnection();
        }
Exemple #5
0
 internal T Dequeue()
 {
     return(OutQueue.Dequeue());
 }