Exemple #1
0
        /// <summary>
        /// Constructor.
        ///
        /// Generates a list of laminations based on the given parameters.
        /// As of 03/15/2019 <paramref name="yokeRange"/> does nothing as the standard laminations have a supplied dimension and cut to length laminations will determine the yoke size using <see cref="Data.Constants.DetermineYoke(CoreShape, Phase, double)"/>
        /// </summary>
        /// <param name="rangeSkips">RangeCombinationSkips representing which combinations of grades and thickness should be skipped.</param>
        /// <param name="stdLaminationsRange">IterableRange representing if both standard and cut to length laminations should be created.</param>
        /// <param name="shapeRange">IterableRange representing the range of core shapes to create with.</param>
        /// <param name="phase">Which phase to create for.</param>
        /// <param name="gradeRange">IterableRange representing the range of grades to create with.</param>
        /// <param name="thicknessRange">IterableRange representing the range of thickness to create with.</param>
        /// <param name="tongueRange">IterableRange representing the range of tongues to create with.</param>
        /// <param name="yokeRange">IterableRange representing the range of yokes to create with.</param>
        /// <param name="windowWidthRange">IterableRange representing the range of window widths to create with.</param>
        /// <param name="windowHeightRange">IterableRange representing the range of window heights to create with.</param>
        /// <param name="func">Optional parameter, a function delegate that returns a boolean, and takes two integer inputs. As of 03/15/2019 only used with <see cref="Optimizer.IncrementCurrentProcessProgress(int, int)"/>.</param>
        protected internal LaminationFactory(RangeCombinationSkips <int> rangeSkips, RangeInteger stdLaminationsRange, RangeInteger shapeRange, Phase phase, RangeInteger gradeRange, RangeInteger thicknessRange, RangeDouble tongueRange, RangeDouble yokeRange, RangeDouble windowWidthRange, RangeDouble windowHeightRange, Func <int, int, bool> func = null)
        {
            if ((tongueRange.MinValue != tongueRange.MaxValue) && tongueRange.StepSize == 0)
            {
                throw new NoCoresFound("Tongue has different minimum and maximum values with a step size of zero.");
            }
            if ((windowWidthRange.MinValue != windowWidthRange.MaxValue) && windowWidthRange.StepSize == 0)
            {
                throw new NoCoresFound("Tongue has different minimum and maximum values with a step size of zero.");
            }
            if ((windowHeightRange.MinValue != windowHeightRange.MaxValue) && windowHeightRange.StepSize == 0)
            {
                throw new NoCoresFound("Tongue has different minimum and maximum values with a step size of zero.");
            }
            int i             = 0;
            int maxIterations = stdLaminationsRange.Iterations * shapeRange.Iterations * gradeRange.Iterations * thicknessRange.Iterations * tongueRange.Iterations * yokeRange.Iterations * windowWidthRange.Iterations * windowHeightRange.Iterations;

            Laminations = new List <Lamination>();
            windowHeightRange.NextRange = windowWidthRange;
            windowWidthRange.NextRange  = yokeRange;
            yokeRange.NextRange         = tongueRange;
            tongueRange.NextRange       = thicknessRange;
            thicknessRange.NextRange    = gradeRange;
            gradeRange.NextRange        = shapeRange;
            shapeRange.NextRange        = stdLaminationsRange;

            while (true)
            {
                try
                {
                    if (GetLaminationType(stdLaminationsRange.CurrentValue) == LaminationType.STANDARD)
                    {
                        if (GetGradeThickness(GetGrade(gradeRange.CurrentValue), thicknessRange.CurrentValue, out double thickness))
                        {
                            if (!rangeSkips.SkipValue(gradeRange.CurrentValue, thicknessRange.CurrentValue))
                            {
                                Laminations.AddRange(GetLaminations(GetCoreShape(shapeRange.CurrentValue), phase, GetGrade(gradeRange.CurrentValue), thickness, tongueRange.MinValue, tongueRange.MaxValue));
                            }
                        }
                        windowHeightRange.CurrentValue = windowHeightRange.MaxValue;
                        windowWidthRange.CurrentValue  = windowWidthRange.MaxValue;
                        yokeRange.CurrentValue         = yokeRange.MaxValue;
                        tongueRange.CurrentValue       = tongueRange.MaxValue;
                    }
                    else
                    {
                        if (GetGradeThickness(GetGrade(gradeRange.CurrentValue), thicknessRange.CurrentValue, out double thickness))
                        {
                            if (!rangeSkips.SkipValue(gradeRange.CurrentValue, thicknessRange.CurrentValue))
                            {
                                Laminations.Add(new Lamination(false, "Cut-to-length", GetCoreShape(shapeRange.CurrentValue), phase, GetGrade(gradeRange.CurrentValue), thickness, tongueRange.CurrentValue,
                                                               DetermineYoke(GetCoreShape(shapeRange.CurrentValue), phase, tongueRange.CurrentValue), windowWidthRange.CurrentValue, windowHeightRange.CurrentValue, 1, 1, 1, (double)GetMaterialDollarsPerPound(GetGrade(gradeRange.CurrentValue)), 0));
                            }
                        }
                    }
                    func?.Invoke(++i, maxIterations);
                    windowHeightRange.IncrementValue();
                }
                catch (IterationFinishedException) { break; }
            }
        }
Exemple #2
0
        /// <summary>
        /// Constructor.
        ///
        /// Generates a list of designs and pushes them into a concurrect queue.
        /// Each core finds the closest tube that fits on it and then each core and tube combination gets combined with each list of windings to create a design.
        ///
        /// If the core is a UI core, then depending on the selected UI styles either Series, Parallel, or Both styles of designs will be generated.
        /// </summary>
        /// <param name="specification">Specification containing base design information to be passed to designs.</param>
        /// <param name="cores">List of cores to be used.</param>
        /// <param name="windings">List of list of windings to be used.</param>
        /// <param name="uiStyles">IterableRange represnting the UI styles that should be generated as of 03/15/2019 only Series and Parallel are supported.</param>
        /// <param name="queue">Concurrent queue to push the completed designs into.</param>
        /// <param name="func">Optional parameter, a function delegate that returns a boolean, and takes two integer inputs. As of 03/15/2019 only used with <see cref="Optimizer.IncrementCurrentProcessProgress(int, int)"/>.</param>
        protected internal DesignFactory(Specification specification, List <Core> cores, List <List <Winding> > windings, RangeInteger uiStyles, ConcurrentQueue <Design> queue, Func <int, int, bool> func = null)
        {
            Designs = new List <Design>();

            bool rotatedTube;
            Tube tube;
            int  maxIterations = cores.Count * windings.Count();
            int  i             = 0;

            foreach (Core core in cores)
            {
                rotatedTube = GetTube(core.Lamination.Tongue, core.Stack, out tube);
                foreach (List <Winding> winding in windings)
                {
                    if (core.Lamination.Shape == CoreShape.UI)
                    {
                        foreach (int uiStyle in uiStyles)
                        {
                            Designs.Add(new Design(specification, core, rotatedTube, tube, winding, GetUIStyle(uiStyle)));
                            func?.Invoke(++i, maxIterations);
                            queue.Enqueue(Designs.Last());
                        }
                    }
                    else
                    {
                        Designs.Add(new Design(specification, core, rotatedTube, tube, winding));
                        func?.Invoke(++i, maxIterations);
                        queue.Enqueue(Designs.Last());
                    }
                }
            }
        }