コード例 #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));
     }
 }
コード例 #2
0
        public override bool CanService(Client c)
        {
            if (c.getNumItems() > maxItems)
            {
                return false;
            }

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

            return true;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
 public abstract int IndexOf(Client c);
コード例 #5
0
 public abstract void AddClientInFront(Client c);
コード例 #6
0
ファイル: Store.cs プロジェクト: patpaquette/StoreSimulation
        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));
                }
            }
        }
コード例 #7
0
ファイル: Store.cs プロジェクト: patpaquette/StoreSimulation
 // 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());
 }
コード例 #8
0
ファイル: Store.cs プロジェクト: patpaquette/StoreSimulation
        public int getQueuePosition(Client c)
        {
            if (c.currentQueue != null)
            {
                return c.currentQueue.IndexOf(c);
            }

            return -1;
        }
コード例 #9
0
ファイル: Store.cs プロジェクト: patpaquette/StoreSimulation
        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;
        }
コード例 #10
0
 public override void Remove(Client c)
 {
     this.clients.Remove(c);
 }
コード例 #11
0
 public override int IndexOf(Client c)
 {
     return this.clients.IndexOf(c);
 }
コード例 #12
0
 public ClientStrategy(Store s, Client c)
 {
     store = s;
     client = c;
     type = -1;
 }
コード例 #13
0
 public SmallestQueueStrategy(Store s, Client c)
 {
     store = s;
     client = c;
     type = 0;
 }
コード例 #14
0
 public abstract void Remove(Client c);
コード例 #15
0
 public override void AddClient(Client c)
 {
     this.clients.Add(c);
     c.currentQueue = this;
 }
コード例 #16
0
 public FewestItemsStrategy(Store s, Client c)
 {
     store = s;
     client = c;
     type = 1;
 }
コード例 #17
0
 public override void AddClientInFront(Client c)
 {
     this.clients.Insert(0, c);
 }
コード例 #18
0
ファイル: Store.cs プロジェクト: patpaquette/StoreSimulation
        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;
        }
コード例 #19
0
 public ClientEventArgs(Client c, long tick, StoreQueue queue)
 {
     this.client = c;
     this.queue = queue;
     this.tick = tick;
 }
コード例 #20
0
ファイル: Store.cs プロジェクト: patpaquette/StoreSimulation
 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;
 }
コード例 #21
0
 public ClientServicePointEventArgs(Client c, long tick, ServicePoint sp)
     : base(c, tick, sp.getQueue())
 {
     this.servicePoint = sp;
 }
コード例 #22
0
ファイル: Store.cs プロジェクト: patpaquette/StoreSimulation
 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));
 }
コード例 #23
0
 public abstract bool AcceptClient(Client c);
コード例 #24
0
ファイル: Store.cs プロジェクト: patpaquette/StoreSimulation
 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());
 }
コード例 #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;
        }