Ejemplo n.º 1
0
        public TimingPoint GetLine(double offset)
        {
            var lines = TimingList.Where(t => t.Offset <= offset + 1 /*tolerance*/).ToArray();

            if (lines.Length == 0)
            {
                return(TimingList.First());
            }
            var         timing             = lines.Max(t => t.Offset);
            var         samePositionPoints = TimingList.Where(t => Math.Abs(t.Offset - timing) < 1).ToArray();
            TimingPoint point;

            if (samePositionPoints.Length > 1)
            {
                var greens = samePositionPoints.Where(k => k.Inherit);
                point = greens.LastOrDefault() ?? samePositionPoints.Last();
                // there might be possibility that two red lines at same time
            }
            else
            {
                point = samePositionPoints[0];
            }

            return(point);
        }
Ejemplo n.º 2
0
        public RawTimingPoint GetLine(double offset)
        {
            var lines = TimingList.Where(t => t.Offset <= offset + 1 /*tolerance*/).ToArray();

            if (lines.Length == 0)
            {
                return(TimingList.First());
            }
            double timing = lines.Max(t => t.Offset);

            RawTimingPoint[] points = TimingList.Where(t => Math.Abs(t.Offset - timing) < 1).ToArray();
            RawTimingPoint   point;

            if (points.Length > 1)
            {
                if (points.Length == 2)
                {
                    if (points[0].Inherit != points[1].Inherit)
                    {
                        point = points.First(t => t.Inherit);
                    }
                    else
                    {
                        throw new MultiTimingSectionException("存在同一时刻两条相同类型的Timing Section。");
                    }
                }
                else
                {
                    throw new MultiTimingSectionException("存在同一时刻多条Timing Section。");
                }
            }
            else
            {
                point = points[0];
            }

            return(point);
        }
Ejemplo n.º 3
0
        public TimingPoint GetLine(double offset)
        {
            var lines = TimingList.Where(t => t.Offset <= offset + 1 /*tolerance*/).ToArray();

            if (lines.Length == 0)
            {
                return(TimingList.First());
            }
            double timing = lines.Max(t => t.Offset);

            TimingPoint[] points = TimingList.Where(t => Math.Abs(t.Offset - timing) < 1).ToArray();
            TimingPoint   point;

            if (points.Length > 1)
            {
                var greens = points.Where(k => k.Inherit);
                point = greens.Last();
                //if (points.Length == 2)
                //{
                //    if (points[0].Inherit != points[1].Inherit)
                //    {
                //        point = points.First(t => t.Inherit);
                //    }
                //    else
                //        throw new RepeatTimingSectionException("存在同一时刻两条相同类型的Timing Section。");
                //}
                //else
                //    throw new RepeatTimingSectionException("存在同一时刻多条Timing Section。");
            }
            else
            {
                point = points[0];
            }

            return(point);
        }
Ejemplo n.º 4
0
 public TimingPoint GetRedLine(double offset)
 {
     TimingPoint[] points = TimingList.Where(t => !t.Inherit).Where(t => Math.Abs(t.Offset - offset) < 1).ToArray();
     return(points.Length == 0 ? TimingList.First(t => !t.Inherit) : points.Last());
 }