Ejemplo n.º 1
0
 public void AddClient(Client c)
 {
     this.queue.AddClient(c);
     OnClientEnteredCashier(new ClientServicePointEventArgs(c, Timer.getTick(), this));
     if (this.queue.PeekNext() == c)
     {
         this.queue.PeekNext().startPurchase();
         OnClientInFrontOfQueueCashier(new ClientServicePointEventArgs(c, Timer.getTick(), this));
     }
 }
        public override bool CanService(Client c)
        {
            if (c.getNumItems() > maxItems)
            {
                return false;
            }

            if (this.queue.GetSize() >= maxQueueSize)
            {
                return false;
            }

            return true;
        }
        public override bool AcceptClient(Client c)
        {
            foreach (ServicePoint s in this.service_points)
            {
                if (c.getNumItems() > s.getMaxItems())
                {
                    return false;
                }
            }

            if (this.IsFull() && this.maxClients != -1)
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 4
0
 public abstract int IndexOf(Client c);
Ejemplo n.º 5
0
 public abstract void AddClientInFront(Client c);
Ejemplo n.º 6
0
        public void RemoveClientFromWaitQueue(Client c)
        {
            //Logger.Info("Removed client " + waitQueue.ElementAt(0).getId().ToString() + " from the wait queue at " + DateTime.Now.ToString());
            //waitQueue.Remove(c);

            //queue.Remove(c);
            if (c.InQueue())
            {
                StoreQueue queue = c.currentQueue;
                c.RemoveFromCurrentQueue();

                OnClientRemovedFromQueue(new ClientEventArgs(c, Timer.getTick(), queue));

                if (queue.GetSize() > 0)
                {
                    this.OnClientInFrontOfQueue(new ClientEventArgs(queue.PeekNext(), Timer.getTick(), queue));
                }
            }
        }
Ejemplo n.º 7
0
 // takes client from the wait queue and moves it to the cash at "index"
 public void MoveClientToCash(Client c, ServicePoint sp)
 {
     int index = this.service_points.IndexOf(sp);
     this.RemoveClientFromWaitQueue(c);
     service_points.ElementAt(index).AddClient(c);
     //Logger.Info("Added customer " + c.getId().ToString() + " to the " + index.ToString() + " cash at " + DateTime.Now.ToString());
 }
Ejemplo n.º 8
0
        public int getQueuePosition(Client c)
        {
            if (c.currentQueue != null)
            {
                return c.currentQueue.IndexOf(c);
            }

            return -1;
        }
Ejemplo n.º 9
0
        public int AddClientToWaitQueue(Client c, StoreQueue queue)
        {
            if (queue != null)
            {
                //waitQueue.Add(c);
                queue.AddClient(c);

                OnClientAddedToQueue(new ClientEventArgs(c, Timer.getTick(), c.currentQueue));

                //index = waitQueue.IndexOf(c);

                if (queue.PeekNext() == c)
                {
                    this.OnClientInFrontOfQueue(new ClientEventArgs(c, Timer.getTick(), c.currentQueue));
                }
                return queue.IndexOf(c);
                //Logger.Info("Added client " + c.getId().ToString() + " to the wait queue at " + DateTime.Now.ToString());
            }
            return -1;
        }
 public override void Remove(Client c)
 {
     this.clients.Remove(c);
 }
 public override int IndexOf(Client c)
 {
     return this.clients.IndexOf(c);
 }
Ejemplo n.º 12
0
 public ClientStrategy(Store s, Client c)
 {
     store = s;
     client = c;
     type = -1;
 }
 public SmallestQueueStrategy(Store s, Client c)
 {
     store = s;
     client = c;
     type = 0;
 }
Ejemplo n.º 14
0
 public abstract void Remove(Client c);
 public override void AddClient(Client c)
 {
     this.clients.Add(c);
     c.currentQueue = this;
 }
 public FewestItemsStrategy(Store s, Client c)
 {
     store = s;
     client = c;
     type = 1;
 }
 public override void AddClientInFront(Client c)
 {
     this.clients.Insert(0, c);
 }
Ejemplo n.º 18
0
        public List<ServicePoint> CheckForAvailableCashes(Client c)
        {
            //int toReturn = -1;
            //int minimumQueueSize = 1000;
            //int count = 0;
            //List<int> possibilities = new List<int>();
            List<ServicePoint> spList = new List<ServicePoint>();

            foreach (ServicePoint s in c.currentQueue.getAvailableServicePoints())
            {
                /*// if the cash is empty then just return that immediately
                if (s.getClients().Count == 0)
                    return count;
                // if the size of the queue is smaller than the available spots and
                if (!s.isFull())       // Will probably want to take into account average wait times or something
                {                                                                             // but for now this is fine. (Goes to the one with the smallest line)
                    possibilities.Add(count);
                    toReturn = count;
                    minimumQueueSize = s.getClients().Count;
                }
                count++;
            }

            if (possibilities.Count > 1)
            {
                if (previousChoice == 0)
                {
                    previousChoice = 1;
                    return 1;
                }
                else
                {
                    previousChoice = 0;
                    return 0;
                }*/

                if (s.CanService(c))
                {
                    spList.Add(s);
                }
            }
            return spList;
        }
Ejemplo n.º 19
0
 public ClientEventArgs(Client c, long tick, StoreQueue queue)
 {
     this.client = c;
     this.queue = queue;
     this.tick = tick;
 }
Ejemplo n.º 20
0
 public ServicePoint getWhichServicePointAt(Client client)
 {
     foreach (ServicePoint s in service_points)
     {
         foreach (Client c in s.getClients())
         {
             if (client.getId() == c.getId())
             {
                 return s;
             }
         }
     }
     return null;
 }
Ejemplo n.º 21
0
 public ClientServicePointEventArgs(Client c, long tick, ServicePoint sp)
     : base(c, tick, sp.getQueue())
 {
     this.servicePoint = sp;
 }
Ejemplo n.º 22
0
 public void RemoveClient(Client c)
 {
     //Logger.Info("A client has left the store at: " + DateTime.Now.ToString() + ", whos ID was " + clients.ElementAt(index).getId().ToString());
     clients.Remove(c);
     OnClientLeftStore(new ClientEventArgs(c, Timer.getTick(), null));
 }
Ejemplo n.º 23
0
 public abstract bool AcceptClient(Client c);
Ejemplo n.º 24
0
 public void AddClient(int numItems)
 {
     Client c = new Client(numItems, this);
     clients.Add(c);
     OnClientEnteredStore(new ClientEventArgs(c, Timer.getTick(), null));
     //Logger.Info("A new client has entered the store at: " + DateTime.Now.ToString());
 }
Ejemplo n.º 25
0
        public virtual bool CanService(Client c)
        {
            if (c.getNumItems() > Configs.MAX_SP_ITEMS)
            {
                return false;
            }

            if (this.queue.GetSize() >= Configs.MAX_CLIENTS_PER_CASH)
            {
                return false;
            }

            return true;
        }