예제 #1
0
        public ServicePoint(int i, Store store)
        {
            //clients = new List<Client>();

            queue = new StoreQueueListImpl(this.ToString(), Configs.MAX_CLIENTS_PER_CASH);
            queue.AddServicePoint(this);

            id = i;
            this.store = store;
            arrivalRate = 0.0f;
            timeOpened = Timer.getTick();
            this.type = "default";
            this.maxItems = Configs.MAX_ITEMS_PER_CLIENT;
        }
예제 #2
0
        public Store()
        {
            clients = new List<Client>();

            this.queues = new List<StoreQueue>();
            this.mainQueue = new StoreQueueListImpl("MainQueue", Configs.MAX_ITEMS_PER_CLIENT);
            this.queues.Add(this.mainQueue);
            supervisor = new Supervisor(this);
            service_points = new List<ServicePoint>();
            //waitQueue = new List<Client>();
            supervisor = new Supervisor(this);

            /*for (int i = 0; i < this.getServicePoints().Count; i++)
            {
                this.getServicePoints().ElementAt(i).ClientExitCashier += new ServicePoint.ClientExitCashierEventHandler(ClientExitServicePoint);
            }*/
        }
예제 #3
0
 public ServicePoint OpenSpecializedServicePoint(string type, int maxQueueSize, int maxItems, int itemProcessingTime, StoreQueue queue)
 {
     int toOpen = DetermineServPointNumber();
     ServicePoint s = new SpecializedServicePoint(toOpen, this.store, type, maxQueueSize, maxItems, itemProcessingTime);
     store.AddServicePoint(s);
     store.fireServicePointOpenedEvent(s);
     return s;
 }
예제 #4
0
        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;
        }
예제 #5
0
        // Transfer clients from one cash to another (not sure what parameters are needed yet)
        public void MoveClients(List<Client> clients, StoreQueue backup)
        {
            List<ServicePoint> sp = store.getServicePoints();

            // Since there could possibly be more clients int he queue removed than total number of service points
            while (clients.Count != 0)
            {

                // If the cashes are all full, then insert the remaining clients into the front of the wait queue
                if (store.AllCashesFull())
                {
                    clients.ElementAt(0).setWaitQueueStatus();
                    List<Client> toMove = new List<Client>();
                    foreach (Client c in clients)
                    {
                        toMove.Add(c);
                    }

                    foreach (Client c in toMove)
                    {
                        c.setWaitQueueStatus();
                        backup.AddClientInFront(c);
                    }
                    backup.PeekNext().setFrontOfWaitQueueStatus();
                    break;
                }

                foreach (ServicePoint s in sp)
                {
                    if (clients.Count == 0)
                        break;

                    if (!s.isFull())
                    {
                        Client c = clients.ElementAt(0);
                        if (s.CanService(c))
                        {
                            clients.RemoveAt(0);
                            s.AddClient(c);
                        }
                    }
                }

            }
        }
예제 #6
0
        public void init()
        {
            clients = new List<Client>();

            this.queues = new List<StoreQueue>();
            this.mainQueue = new StoreQueueListImpl("MainQueue", Configs.MAX_ITEMS_PER_CLIENT);
            this.queues.Add(this.mainQueue);
            supervisor = new Supervisor(this);
            service_points = new List<ServicePoint>();
            //waitQueue = new List<Client>();
            supervisor = new Supervisor(this);
        }
예제 #7
0
 public void AddQueue(StoreQueue queue)
 {
     this.queues.Add(queue);
 }
예제 #8
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;
        }
예제 #9
0
 public void RemoveFromCurrentQueue()
 {
     this.currentQueue.Remove(this);
     this.currentQueue = null;
 }
예제 #10
0
 public void MoveToQueue(StoreQueue queue)
 {
     this.RemoveFromCurrentQueue();
     queue.AddClient(this);
 }
예제 #11
0
 public abstract void SetParent(StoreQueue parent);
예제 #12
0
 public ClientEventArgs(Client c, long tick, StoreQueue queue)
 {
     this.client = c;
     this.queue = queue;
     this.tick = tick;
 }
 public override void SetParent(StoreQueue parent)
 {
     this.parent = parent;
 }
 public override void RemoveParent()
 {
     this.parent = null;
 }