/// <summary> /// Erzeugt eine neue Planung. /// </summary> /// <param name="resource">Das zugehörige Gerät.</param> /// <param name="schedulePlan">Die zugehörige Gesamtplanung.</param> /// <param name="decryptionCounter">Die Zähler für die Entschlüsselung.</param> /// <param name="allocations">Optional alle bereits vorgenommenen Zuordnungen.</param> /// <param name="planTime">Der aktuelle Planungsbeginn, sofern bekannt.</param> /// <exception cref="ArgumentNullException">Es wurde kein Gerät angegeben.</exception> public ResourcePlan(IScheduleResource resource, SchedulePlan schedulePlan, HashSet <Guid> decryptionCounter = null, AllocationMap allocations = null, DateTime?planTime = null) { // Remember SchedulePlan = schedulePlan; Resource = resource; // Register a single decryption counter DecryptionCounters = decryptionCounter ?? new HashSet <Guid> { schedulePlan.RegisterDecryption(Resource.Decryption.MaximumParallelSources) }; // Check for allocation if (allocations != null) { // Just clone Allocations = allocations.Clone(planTime); } else { // Number of sources we may use var sourceLimit = resource.SourceLimit; if (sourceLimit < 1) { sourceLimit = int.MaxValue; } // Create brand new Allocations = new AllocationMap(sourceLimit, CheckForSourceGroupMatch); } }
/// <summary> /// Erzeugt eine neue Beschreibung. /// </summary> /// <param name="map">Die zugehörige Verwaltung einer Ressource.</param> /// <param name="source">Die Quelle, die verwendet werden soll.</param> /// <param name="plan">Die ursprüngliche Planung.</param> /// <param name="index">Der erste Eintrag in der Verwaltung, der belegt werden soll.</param> public AllocationPlan(AllocationMap map, IScheduleSource source, SuggestedPlannedTime plan, int index) { // Remember m_allocationIndex = index; m_source = source; m_plan = plan; m_map = map; }
/// <summary> /// Erzeugt eine Arbeitskopie. /// </summary> /// <param name="original">Die ursprüngliche Zuordnung.</param> private AllocationMap(AllocationMap original) { // Just copy references - will be cloned on demand TotalNumberOfSources = original.TotalNumberOfSources; m_Allocations = original.m_Allocations.ToList(); m_Sources = original.m_Sources.ToList(); m_MergeTest = original.m_MergeTest; }
/// <summary> /// Erzeugt eine neue Beschreibung. /// </summary> /// <param name="from">Der Beginn des Zeitraums.</param> /// <param name="to">Das Ende des Zeitraums.</param> /// <param name="map">Die zugehörige Gesamtverwaltung.</param> public AllocatedRange(DateTime from, DateTime to, AllocationMap map) { // Validate if (to <= from) { throw new ArgumentOutOfRangeException("to"); } // Finish Sources = new List <IScheduleSource>(); // Remember Start = from; m_Map = map; End = to; }
/// <summary> /// Erzeugt eine Kopie. /// </summary> /// <param name="planTime">Der aktuelle Planungsbeginn, sofern bekannt.</param> /// <returns>Die gewünschte Kopie.</returns> public AllocationMap Clone(DateTime?planTime) { // Create var clone = new AllocationMap(this); // No check needed if (!planTime.HasValue) { return(clone); } // See who is below the limit var allocations = clone.m_Allocations; var index = allocations.FindIndex(allocation => allocation.End > planTime.Value); // Cut off if not the very first if (--index > 0) { // Collapse if only two are left if (index == allocations.Count - 2) { index++; } // Load the very start of it all var allocation = allocations[0]; // Update it's end time allocations[0] = allocation.Clone(allocation.Start, allocations[index].End); // Cleanup the rest allocations.RemoveRange(1, index); } // Report return(clone); }
/// <summary> /// Erzeugt eine Kopie. /// </summary> /// <param name="planTime">Der aktuelle Planungsbeginn, sofern bekannt.</param> /// <returns>Die gewünschte Kopie.</returns> public AllocationMap Clone(DateTime?planTime) { // Create var clone = new AllocationMap(this); // No check needed if (!planTime.HasValue) { return(clone); } // See who is below the limit var allocations = clone.m_Allocations; var index = allocations.FindIndex(allocation => allocation.End > planTime.Value); // Cut off if not the very first if (index > 1) { allocations.RemoveRange(0, index); } // Report return(clone); }