Beispiel #1
0
        /// <summary>
        /// Отображение сигнала в аналоговом виде
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="iter"></param>
        /// <param name="DataPres"></param>
        /// <param name="GetValue"></param>
        protected void RenderAnalogSimpleSignal <T>(Canvas canvas, IValueIterator iter, DataRepresentation DataPres, GetValueDelegateFromTime <T> GetValueFromTime, GetValueDelegateFromIterator <T> GetValueFromIterator) where T : IConvertible
        {
            canvas.Children.Clear();

            Polyline polyLine = new Polyline();

            polyLine.Stroke          = Brushes.Black;
            polyLine.StrokeThickness = 1;


            if (scaleManager.VisibleTimeDiapasone < (scaleManager.Width * 5.0))
            {
                iter.SetCurrentIndexByKey(scaleManager.VisibleStartTime);

                double min   = GetValueFromTime(ScaleManager.VisibleStartTime, DataPres).ToDouble(CultureInfo.InvariantCulture);;
                double max   = min;
                double value = 0;

                double height = canvas.ActualHeight;


                iter.SetCurrentIndexByKey(scaleManager.VisibleStartTime);
                value = GetValueFromTime(ScaleManager.VisibleStartTime, DataPres).ToDouble(CultureInfo.InvariantCulture);;
                polyLine.Points.Add(new Point(0, (double)(value)));

                //Рисование начала диаграммы
                UInt64 x1 = 0, x2 = 0;

                x1 = scaleManager.VisibleStartTime;
                UInt64 MinimumVisibleChange = scaleManager.MinimumVisibleChange * 2;

                iter.SetCurrentIndexByKey(scaleManager.VisibleStartTime);
                x2 = iter.LastEvent;
                if (x2 > scaleManager.VisibleEndTime)
                {
                    x2 = scaleManager.VisibleEndTime;
                }
                if (x2 < scaleManager.VisibleStartTime)
                {
                    x2 = scaleManager.VisibleStartTime;
                }
                while (true)
                {
                    value = GetValueFromIterator(iter, DataPres).ToDouble(CultureInfo.InvariantCulture);;

                    if (min > value)
                    {
                        min = value;
                    }

                    if (max < value)
                    {
                        max = value;
                    }

                    polyLine.Points.Add(new Point(scaleManager.GetOffset(x1), (double)(value)));
                    polyLine.Points.Add(new Point(scaleManager.GetOffset(x2), (double)(value)));

                    iter.MoveNext();

                    x1 = x2;
                    x2 = iter.LastEvent;

                    if ((iter.LastEvent >= scaleManager.VisibleEndTime) || (iter.IsEndOfIteration == true))
                    {
                        value = GetValueFromTime(ScaleManager.VisibleEndTime, DataPres).ToDouble(CultureInfo.InvariantCulture);;
                        if (min > value)
                        {
                            min = value;
                        }

                        if (max < value)
                        {
                            max = value;
                        }
                        polyLine.Points.Add(new Point(scaleManager.GetOffset(x1), (double)(value)));
                        polyLine.Points.Add(new Point(scaleManager.GetOffset(x2), (double)(value)));
                        break;
                    }

                    if (x2 > scaleManager.VisibleEndTime)
                    {
                        x2 = scaleManager.VisibleEndTime;
                    }
                    if (x2 < scaleManager.VisibleStartTime)
                    {
                        x2 = scaleManager.VisibleStartTime;
                    }
                }
                double DeltaY = (max != min) ? (height / (double)(max - min)) : 1;
                for (int i = 0; i < polyLine.Points.Count; i++)
                {
                    Point point = polyLine.Points[i];
                    point.Y            = ((double)max - point.Y) * DeltaY;
                    polyLine.Points[i] = point;
                }
            }
            else
            {
                iter.SetCurrentIndexByKey(scaleManager.VisibleStartTime);

                double min   = GetValueFromTime(ScaleManager.VisibleStartTime, DataPres).ToDouble(CultureInfo.InvariantCulture);;
                double max   = min;
                double value = 0;

                double height = canvas.ActualHeight;

                for (double x = 0; x < scaleManager.Width; x++)
                {
                    UInt64 time = scaleManager.GetTime(x);
                    iter.SetCurrentIndexByKey(time);
                    value = GetValueFromIterator(iter, DataPres).ToDouble(CultureInfo.InvariantCulture);;
                    if (min > value)
                    {
                        min = value;
                    }

                    if (max < value)
                    {
                        max = value;
                    }
                    polyLine.Points.Add(new Point(x, (double)(value)));
                }
                double DeltaY = (max != min) ? (height / (double)(max - min)) : 1;
                for (int i = 0; i < polyLine.Points.Count; i++)
                {
                    Point point = polyLine.Points[i];
                    point.Y            = ((double)max - point.Y) * DeltaY;
                    polyLine.Points[i] = point;
                }
            }

            canvas.Children.Add(polyLine);
        }
Beispiel #2
0
        /// <summary>
        /// Отображение шины в обычном виде
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="iter"></param>
        /// <param name="DrawValue"></param>
        protected void RenderSimpleBus(Canvas canvas, IValueIterator iter, DrawValueDelegate DrawValue)
        {
            canvas.Children.Clear();

            UInt64 MinimumVisibleChange = scaleManager.MinimumVisibleChange;

            //Рисование начала диаграммы
            UInt64 x1 = 0, x2 = 0;
            string value = string.Empty;

            x1 = scaleManager.VisibleStartTime;

            iter.SetCurrentIndexByKey(scaleManager.VisibleStartTime);
            x2 = iter.LastEvent;
            if (x2 > scaleManager.VisibleEndTime)
            {
                x2 = scaleManager.VisibleEndTime;
            }
            if (x2 < scaleManager.VisibleStartTime)
            {
                x2 = scaleManager.VisibleStartTime;
            }

            Markers.Add(new TimeMarker(x1, scaleManager.GetOffset(x1)));

            while (true)
            {
                //Началась "серая" область
                if ((x2 - x1) <= MinimumVisibleChange)
                {
                    UInt64 whitespace = x1;

                    while (true)
                    {
                        x1 = iter.LastEvent;
                        if (x1 > scaleManager.VisibleEndTime)
                        {
                            x1 = scaleManager.VisibleEndTime;
                        }
                        if (x1 < scaleManager.VisibleStartTime)
                        {
                            x1 = scaleManager.VisibleStartTime;
                        }
                        iter.MoveNext();
                        x2 = iter.LastEvent;
                        if (x2 > scaleManager.VisibleEndTime)
                        {
                            x2 = scaleManager.VisibleEndTime;
                        }
                        if (x2 < scaleManager.VisibleStartTime)
                        {
                            x2 = scaleManager.VisibleStartTime;
                        }
                        //закончилась "серая" область
                        if ((x2 - x1) >= scaleManager.MinimumVisibleChange)
                        {
                            AddWhitespace(canvas, whitespace, x1, scaleManager);
                            value = AbstractSignalDump.GetStringValue(iter);
                            Markers.Add(new TimeMarker(x1, scaleManager.GetOffset(x1)));
                            DrawValue(canvas, x1, x2, scaleManager, value);
                            break;
                        }

                        if ((iter.LastEvent >= scaleManager.VisibleEndTime) || (iter.IsEndOfIteration == true))
                        {
                            Markers.Add(new TimeMarker(whitespace, scaleManager.GetOffset(whitespace)));
                            AddWhitespace(canvas, whitespace, iter.LastEvent, scaleManager);
                            break;
                        }
                        iter.SetCurrentIndexByKey(x1 + MinimumVisibleChange);
                    }
                }
                else
                {
                    value = AbstractSignalDump.GetStringValue(iter);
                    Markers.Add(new TimeMarker(x1, scaleManager.GetOffset(x1)));
                    DrawValue(canvas, x1, x2, scaleManager, value);
                    iter.MoveNext();
                }

                x1 = x2;
                x2 = iter.LastEvent;

                if ((iter.LastEvent >= scaleManager.VisibleEndTime) || (iter.IsEndOfIteration == true))
                {
                    value = AbstractSignalDump.GetStringValue(iter);
                    Markers.Add(new TimeMarker(x1, scaleManager.GetOffset(x1)));
                    DrawValue(canvas, x1, scaleManager.VisibleEndTime, scaleManager, value);
                    break;
                }

                if (x2 > scaleManager.VisibleEndTime)
                {
                    x2 = scaleManager.VisibleEndTime;
                }
                if (x2 < scaleManager.VisibleStartTime)
                {
                    x2 = scaleManager.VisibleStartTime;
                }
            }
        }