Exemplo n.º 1
0
 /// <summary>
 /// Erzeugt eine neue Beschreibung.
 /// </summary>
 /// <param name="recording">Die zugehörige Aufzeichnung.</param>
 /// <param name="time">Die vorgesehene Ausführungszeit.</param>
 /// <param name="startsLate">Gesetzt, wenn die Aufzeichnung verspätet beginnt.</param>
 public _RecordingItem(IRecordingDefinition recording, PlannedTime time, bool startsLate)
 {
     // Remember
     StartsLate = startsLate;
     Recording  = recording;
     Time       = time;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Prüft, ob eine Aufzeichnung ergänzt werden kann.
        /// </summary>
        /// <param name="recording">Die neue Aufzeichnung.</param>
        /// <param name="time">Der Zeitraum der neuen Aufzeichnung.</param>
        /// <param name="minTime">Die Aufzeichnung darf auf keinen Fall vor diesem Zeitpunkt beginnen.</param>
        /// <returns>Gesetzt, wenn eine Aufzeichnung möglich war.</returns>
        /// <exception cref="ArgumentNullException">Es wurde keine Aufzeichnung übergeben.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Die Startzeit liegt vor der Aktivierung des Gerätes.</exception>
        public bool Add(IRecordingDefinition recording, SuggestedPlannedTime time, DateTime minTime)
        {
            // Validate
            if (recording == null)
            {
                throw new ArgumentNullException("recording");
            }

            // If the current resource can see the source we can do nothing at all
            var resource = Resource;

            if (!resource.CanAccess(recording.Source))
            {
                return(false);
            }

            // If the recording is bound to dedicated sources but not use we should not process
            var allowedResources = recording.Resources;

            if (allowedResources != null)
            {
                if (allowedResources.Length > 0)
                {
                    if (!allowedResources.Any(r => ReferenceEquals(r, resource)))
                    {
                        return(false);
                    }
                }
            }

            // See if we have to cut it off and load the corresponding end of the recording
            var initialPlan = time.Planned;

            // Clip to minimum allowed
            if (time.Planned.Start < minTime)
            {
                // Not possible at all - should never ever be requested but better be safe
                if (time.Planned.End <= minTime)
                {
                    return(false);
                }

                // Correct the parameters - end is calculated from start and duration
                time.Planned.Duration = time.Planned.End - minTime;
                time.Planned.Start    = minTime;
            }

            // See if device could at least receive
            var sourceAllocation = Allocations.PrepareAllocation(recording.Source, time);

            if (sourceAllocation == null)
            {
                return(false);
            }

            // Add it - will clip the time accordingly
            sourceAllocation.Allocate();

            // Time to check for encryption - technically it should not be possible to have a recording on a source which is for some time encypted and for some other time not but better be safe
            if (recording.Source.IsEncrypted)
            {
                // What to check for
                var counters = DecryptionCounters.Select(i => SchedulePlan.DecryptionCounters[i]).ToArray();

                // Check all
                foreach (var counter in counters)
                {
                    if (counter.PrepareAllocation(recording.Source, time) == null)
                    {
                        return(false);
                    }
                }

                // Now reserve all - this may manipulate the time slice for the recording as well
                foreach (var counter in counters)
                {
                    // Allocate again - we may only call the allocate immediatly after preparing
                    var allocation = counter.PrepareAllocation(recording.Source, time);
                    if (allocation == null)
                    {
                        throw new InvalidOperationException("PrepareAllocation");
                    }

                    // Process
                    allocation.Allocate();
                }
            }

            // Remember recording
            m_Recordings.Add(new _RecordingItem(recording, time.Planned, time.Planned.Start > initialPlan.Start));

            // Get cut time
            var delta = initialPlan.Duration - time.Planned.Duration;

            // Adjust cut time - this will be taken in account when checking weights to get the best plan
            TotalCut += delta;

            // Count failures
            if (delta.Ticks > 0)
            {
                CutRecordings += 1;
            }

            // We did it
            return(true);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Meldet eine Aufzeichnung zur Planung an.
 /// </summary>
 /// <param name="definition">Die gewünschte Aufzeichnung.</param>
 /// <param name="exceptions">Die Ausnahmeregeln zur Aufzeichnung.</param>
 /// <exception cref="ArgumentNullException">Es wurde keine Aufzeichnung angegeben.</exception>
 public void Add(IRecordingDefinition definition, params PlanException[] exceptions)
 {
     // Forward
     m_PlanItems.Add(new _Recording(definition, exceptions));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Erzeugt eine neue Verwaltung.
 /// </summary>
 /// <param name="plan">Die Definition der Aufzeichnung.</param>
 /// <param name="exceptions">Alle Ausnahmen zur Aufzeichnung.</param>
 public _Recording(IRecordingDefinition plan, IEnumerable <PlanException> exceptions)
     : base(plan, exceptions)
 {
 }
 /// <summary>
 /// Meldet eine Aufzeichnung zur Planung an.
 /// </summary>
 /// <param name="definition">Die gewünschte Aufzeichnung.</param>
 /// <param name="exceptions">Die Ausnahmeregeln zur Aufzeichnung.</param>
 /// <exception cref="ArgumentNullException">Es wurde keine Aufzeichnung angegeben.</exception>
 public void Add( IRecordingDefinition definition, params PlanException[] exceptions )
 {
     // Forward
     m_PlanItems.Add( new _Recording( definition, exceptions ) );
 }
 /// <summary>
 /// Erzeugt eine neue Verwaltung.
 /// </summary>
 /// <param name="plan">Die Definition der Aufzeichnung.</param>
 /// <param name="exceptions">Alle Ausnahmen zur Aufzeichnung.</param>
 public _Recording( IRecordingDefinition plan, IEnumerable<PlanException> exceptions )
     : base( plan, exceptions )
 {
 }