Esempio n. 1
0
        /// <summary>
        /// <para> Adds spots to break. If multiple spots are being
        /// added then they're typically related. E.g. TOP & TAIL.
        /// </para>
        /// <para> The break sequence will be updated later when the break has
        /// been filled, will be updated to start from 1. For specific positions
        /// (FIB, SIB etc) then the break sequence is assigned as a large positive
        /// or negative number and everything else is inserted between.
        /// </para>
        /// </summary>
        public static List <SmoothSpot> AddSpotsToBreak(
            SmoothBreak smoothBreak,
            int smoothPassSequence,
            int smoothPassIterationSequence,
            IReadOnlyCollection <Spot> spots,
            SpotPositionRules passRequestedPositionInBreakRules,
            bool canMoveSpotToOtherBreak,
            ICollection <Guid> spotIdsUsed,
            string bestBreakFactorGroupName,
            IReadOnlyDictionary <Guid, SpotInfo> spotInfos,
            SponsorshipRestrictionService sponsorshipRestrictionService
            )
        {
            var smoothSpots = new List <SmoothSpot>();

            foreach (Spot spot in spots)
            {
                IReadOnlyDictionary <string, bool> hasSpotPositions = smoothBreak.GetSpotPositions();
                int breakSeq = SpotPositioning.GetBreakSequenceNumber(
                    smoothBreak,
                    passRequestedPositionInBreakRules,
                    spot,
                    hasSpotPositions
                    );

                // Default break sequence to middle of break
                if (breakSeq == 0)
                {
                    breakSeq = SpotPositioning.GetBreakSeqForMiddleOfBreak(smoothBreak);
                }

                smoothSpots.Add(
                    smoothBreak.AddSpot(
                        spot,
                        smoothPassSequence,
                        smoothPassIterationSequence,
                        breakSeq,
                        currentSpot: true,
                        canMoveSpotToOtherBreak,
                        bestBreakFactorGroupName,
                        spotInfos[spot.Uid].ExternalBreakRefAtRunStart
                        )
                    );

                sponsorshipRestrictionService.TriggerRecalculationOfAllowedRestrictionLimits(
                    SpotAction.AddSpot,
                    spot,
                    smoothBreak.TheBreak
                    );

                FlagSpotAsUsed(spot, spotIdsUsed);
            }

            return(smoothSpots);
        }
Esempio n. 2
0
        /// <summary>
        /// Add booked spots to break to stop overbooking
        /// </summary>
        public static List <SmoothSpot> AddBookedSpotsToBreak(
            SmoothBreak smoothBreak,
            IReadOnlyCollection <Spot> spots,
            IReadOnlyDictionary <Guid, SpotInfo> spotInfos,
            ISet <Guid> spotIdsUsed,
            SponsorshipRestrictionService sponsorshipRestrictionService
            )
        {
            if (smoothBreak is null)
            {
                throw new ArgumentNullException(nameof(smoothBreak));
            }

            if (spots is null)
            {
                throw new ArgumentNullException(nameof(spots));
            }

            if (spotInfos is null)
            {
                throw new ArgumentNullException(nameof(spotInfos));
            }

            if (spotIdsUsed is null)
            {
                throw new ArgumentNullException(nameof(spotIdsUsed));
            }

            var smoothSpots = new List <SmoothSpot>();

            foreach (var spot in spots)
            {
                int breakSeq;

                if (spot.IsMultipartSpot)
                {
                    breakSeq = SpotPositioning.GetBreakSeqFromMultipartSpotPosition(
                        spot.MultipartSpot,
                        spot.MultipartSpotPosition);
                }
                else
                {
                    breakSeq = SpotPositioning.GetBreakSeqFromRequestedPositionInBreakOrActualPositionInBreak(
                        spot.RequestedPositioninBreak,
                        spot.ActualPositioninBreak);
                }

                smoothSpots.Add(
                    smoothBreak.AddSpot(
                        spot,
                        smoothPassSequence: 0,
                        smoothPassIterationSequence: 0,
                        breakSeq,
                        currentSpot: false,
                        canMoveSpotToOtherBreak: false,
                        bestBreakFactorGroupName: null,
                        spotInfos[spot.Uid].ExternalBreakRefAtRunStart)
                    );

                sponsorshipRestrictionService.TriggerRecalculationOfAllowedRestrictionLimits(
                    SpotAction.AddSpot,
                    spot,
                    smoothBreak.TheBreak
                    );

                FlagSpotAsUsed(spot, spotIdsUsed);
            }

            return(smoothSpots);
        }