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(); }
/// <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)); }
/// <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); }