public override void AddServicePoint(ServicePoint s)
 {
     this.service_points.Add(s);
     s.getQueue().SetParent(this);
     if (s.getMaxItems() > this.maxItems)
     {
         this.maxItems = s.getMaxItems();
     }
 }
        private int totalItems(ServicePoint s)
        {
            int ti = 0;

            foreach (Client c in s.getClients())
            {
                ti += c.getNumItems();
            }

            return ti;
        }
        public override bool ContainsServicePoint(ServicePoint sp)
        {
            foreach (ServicePoint s in this.service_points)
            {
                if (s == sp)
                {
                    return true;
                }
            }

            return false;
        }
        public ServicePoint OpenServicePoint(StoreQueue queue)
        {
            int toOpen = DetermineServPointNumber();
            ServicePoint s = new ServicePoint(toOpen, store);
            queue.AddServicePoint(s);
            if (!this.store.getWaitQueues().Contains(queue))
            {
                this.store.AddQueue(queue);
            }
            store.AddServicePoint(s);
            store.fireServicePointOpenedEvent(s);

            return s;
        }
        public void MoveClientsToCash(ServicePoint sp)
        {
            /* if (c.currentQueue.GetSize() > 0)
            {
                while (sp.getClients().Count < Configs.MAX_CLIENTS_PER_CASH)
                {
                    if (store.getWaitingQueueSize() > 0)
                    {
                        Client c = store.getWaitQueue().ElementAt(0);
                        store.getWaitQueue().RemoveAt(0);
                        sp.AddClient(c);
                    }

                    else                             // Fail safe in case the wait queue ends up not having anyone in there when trying to fill up a new cash
                    {
                        break;
                    }
                }
            }*/

            List<Client> toMove = new List<Client>();

            foreach (StoreQueue queue in this.store.getWaitQueues())
            {
                if (queue.ContainsServicePoint(sp))
                {
                    foreach (Client c in queue.getClients())
                    {
                        if (sp.CanService(c))
                        {
                            toMove.Add(c);
                        }
                    }
                }
            }

            foreach (Client c in toMove)
            {
                c.MoveToQueue(sp.getQueue());
            }
        }
Example #6
0
 public void RemoveServicePoint(ServicePoint sp)
 {
     this.service_points.Remove(sp);
     foreach (StoreQueue q in this.queues)
     {
         foreach (ServicePoint s in q.getAvailableServicePoints())
         {
             if (s == sp)
             {
                 q.getAvailableServicePoints().Remove(s);
                 break;
             }
         }
     }
 }
Example #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());
 }
Example #8
0
 // Used for when the calling object is not in the store class
 public void fireServicePointOpenedEvent(ServicePoint sp)
 {
     OnServicePointOpened(new ServicePointArgs(sp, Timer.getTick()));
 }
Example #9
0
 public void AddServicePoint(ServicePoint sp)
 {
     if(this.service_points.Count < Configs.MAX_SERVICE_POINTS){
         this.service_points.Add(sp);
     }
 }
Example #10
0
 public abstract void RemoveServicePoint(ServicePoint s);
Example #11
0
 public abstract bool ContainsServicePoint(ServicePoint sp);
Example #12
0
 public abstract void AddServicePoint(ServicePoint s);
 public ServicePointArgs(ServicePoint sp, long t)
 {
     servicePoint = sp;
     tick = t;
 }
 public ClientServicePointEventArgs(Client c, long tick, ServicePoint sp)
     : base(c, tick, sp.getQueue())
 {
     this.servicePoint = sp;
 }
 public override void RemoveServicePoint(ServicePoint s)
 {
     s.getQueue().RemoveParent();
     this.service_points.Remove(s);
 }