Exemplo n.º 1
0
        public void generate()
        {
            if (!isReady())
            {
                throw new ArgumentException("Cannot generate the Semaphore, because it is not ready yet");
            }
            if (alreadyGenerated || semaphore != null)
            {
                throw new ArgumentException("already generated the semaphore, now attempting to generate it a second time!");
            }
            semaphore = instance.CreateSemaphore(instance.RegisterSemaphoreID(), nBotsAllowedInSemaphore);
            generateEntryFromHall();
            generateNormalExit();
            if (!containsStationWaypoint())
            {
                generateExitShortcutWithinBuffer();
            }
            if (!isSemaphoreFurthestFromStationWaypoint)
            {
                generateEntryFromBuffer();
                generateEntryShortcutWithinBuffer();
            }
            alreadyGenerated = true;

            updateElevatorSemaphores();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Submits all this object to the instance.
        /// </summary>
        /// <param name="instance">The instance to submit to.</param>
        /// <returns>The original object created at the instance.</returns>
        public QueueGuard Submit(Instance instance)
        {
            Waypoint       from      = instance.GetWaypointByID(From);
            Waypoint       to        = instance.GetWaypointByID(To);
            QueueSemaphore semaphore = instance.GetSemaphoreByID(Semaphore);

            return(semaphore.RegisterGuard(from, to, Entry, Barrier));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new semaphore.
        /// </summary>
        /// <param name="id">The ID of the semaphore.</param>
        /// <param name="maximalCount">The maximal number of bots in the managed area.</param>
        /// <returns>The newly created semaphore.</returns>
        public QueueSemaphore CreateSemaphore(int id, int maximalCount)
        {
            QueueSemaphore semaphore = new QueueSemaphore(this, maximalCount)
            {
                ID = id
            };

            Semaphores.Add(semaphore);
            _idToSemaphore[semaphore.ID] = semaphore;
            return(semaphore);
        }