Ejemplo n.º 1
0
        public static PatternValue[] GetPatternValuesParallel
        (
            this Antenna antenna,
            double f,
            double phi = 0 *Consts.ToRad,
            double th1 = -181 *Consts.ToRad,
            double th2 = 181 *Consts.ToRad,
            double dth = 1 *Consts.ToRad,
            CancellationToken Cancel = default
        )
        {
            var parallel_query = GetAngles(th1, th2, dth).AsParallel().AsOrdered();

            if (Cancel != default)
            {
                parallel_query = parallel_query.WithCancellation(Cancel);
            }
            return(parallel_query.Select(th => new PatternValue(th, antenna.Pattern(th, phi, f))).ToArray());
        }
Ejemplo n.º 2
0
        public static PatternValue[] GetPatternPhi
        (
            this Antenna antenna,
            double f,
            double phi = 0 *Consts.ToRad,
            double th1 = -180 *Consts.ToRad,
            double th2 = 180 *Consts.ToRad,
            double dth = 1 *Consts.ToRad
        )
        {
            var th = Math.Min(th1, th2);

            dth = Math.Abs(dth);
            var result = new PatternValue[(int)((Math.Max(th1, th2) - Math.Min(th1, th2)) / dth) + 1];

            for (var i = 0; i < result.Length; i++, th += dth)
            {
                result[i] = new PatternValue(th, antenna.Pattern(th, phi, f));
            }
            return(result);
        }
Ejemplo n.º 3
0
 public static Task <PatternValue[]> GetPatternPhiAsync
 (
     this Antenna antenna,
     double f,
     double phi = 0 *Consts.ToRad,
     double th1 = -180 *Consts.ToRad,
     double th2 = 180 *Consts.ToRad,
     double dth = 1 *Consts.ToRad,
     IProgress <PatternCalculationTaskProgressInfo> Progress = null,
     CancellationToken Cancel = default
 ) => Task.Factory.StartNew(() =>
 {
     var th     = Math.Min(th1, th2);
     dth        = Math.Abs(dth);
     var result = new PatternValue[(int)((Math.Max(th1, th2) - Math.Min(th1, th2)) / dth) + 1];
     for (int i = 0, len = result.Length; i < len && !Cancel.IsCancellationRequested; i++, th += dth)
     {
         var pattern_value = new PatternValue(th, antenna.Pattern(th, phi, f));
         result[i]         = pattern_value;
         Progress?.Report(new PatternCalculationTaskProgressInfo((double)i / len, pattern_value));
     }
     Cancel.ThrowIfCancellationRequested();
     return(result);
 }, Cancel);