Beispiel #1
0
        /// <summary>
        /// Creates a cursor used for time measurements.
        /// </summary>
        internal static BoundCursor CreateTimeMeasurementCursor(
            MeasurementCursorViewModel cursorVM,
            GraphbaseViewModel graphbaseVM,
            bool isReferenceCursor,
            Func <double> deltaReferenceLevelProvider,
            Func <double> referenceLevelProvider)
        {
            Func <ScopeCursor, ValueConverter <double, double>, PB.Binding> bindingProvider =
                (cursor, valueConverter) => PB.Binding.Create(() =>
                                                              cursor.Position.X == valueConverter.DerivedValue &&
                                                              valueConverter.OriginalValue == cursorVM.Value);

            var influencingObjects = new INotifyPropertyChanged[]
            {
                graphbaseVM,
                graphbaseVM.TriggerVM,
            };

            return(CreateMeasurementCursor(
                       MeasurementAxis.X,
                       isReferenceCursor,
                       () => cursorVM.Value,
                       bindingProvider,
                       deltaReferenceLevelProvider,
                       () => graphbaseVM.ScaleFactor,
                       () => graphbaseVM.TriggerVM.HorizontalPosition,
                       referenceLevelProvider,
                       graphbaseVM.BaseUnitString,
                       graphbaseVM.Color,
                       influencingObjects));
        }
Beispiel #2
0
        /// <summary>
        /// Configures the main scope screen viewmodel.
        /// </summary>
        private void ConfigureMainScopeScreenVM(IScopeScreenViewModel scopeScreenVM,
                                                IEnumerable <SampleSequence> sampleSequences)
        {
            // === Channels configuration ===

            var timeScaleFactor = 1;
            var channelVMs      = new[]
            {
                new ChannelViewModel("V", new Position(0, 1), timeScaleFactor, 1,
                                     BuildChannelCaptionFromIndex(0), _channelColors[0]),
                new ChannelViewModel("V", new Position(0, -2), timeScaleFactor, 1,
                                     BuildChannelCaptionFromIndex(1), _channelColors[1]),
            };

            var index = 0;

            channelVMs[index].MeasurementCursor1VM.Visible = true;
            channelVMs[index].MeasurementCursor2VM.Visible = true;
            channelVMs[index].MeasurementCursor1VM.Value   = 2.0;
            channelVMs[index].MeasurementCursor2VM.Value   = 3.0;
            //            index++;
            //            channelVMs[index].MeasurementCursor1VM.Visible = true;
            //            channelVMs[index].MeasurementCursor2VM.Visible = true;
            //            channelVMs[index].MeasurementCursor1VM.Value = -0.5;
            //            channelVMs[index].MeasurementCursor2VM.Value = 0.5;
            scopeScreenVM.ChannelVMs = channelVMs;

            // === Graphbase configuration ===

            var graphbaseVM = new GraphbaseViewModel("s", 1, _baseColor);

            var trigger             = new LevelTrigger(LevelTriggerMode.RisingEdge, 0.5);
            var triggerChannelIndex = 0;

            graphbaseVM.TriggerVM =
                new LevelTriggerViewModel(trigger, channelVMs[triggerChannelIndex]);
            graphbaseVM.MeasurementCursor1VM.Visible = true;
            graphbaseVM.MeasurementCursor2VM.Visible = true;
            graphbaseVM.MeasurementCursor1VM.Value   = 2.0;
            graphbaseVM.MeasurementCursor2VM.Value   = 3.0;
            scopeScreenVM.GraphbaseVM = graphbaseVM;

            // === Sample Sequences ===

            var sampleSequenceProviders =
                sampleSequences.Select(ss => new Func <SampleSequence>(() => ss));

            var sampler = new Sampler(sampleSequenceProviders, trigger, triggerChannelIndex);

            scopeScreenVM.SampleSequenceProviders = sampler.SampleSequenceProviders;
        }
Beispiel #3
0
        /// <summary>
        /// Configures the FFT scope screen viewmodel.
        /// </summary>
        private void ConfigureFFTScopeScreenVM(IScopeScreenViewModel scopeScreenVM,
                                               IEnumerable <SampleSequence> sampleSequences)
        {
            // === Channels configuration ===

            var frequencyScaleFactor = 1;
            var channelVMs           = new[]
            {
                new ChannelViewModel("dB?", new Position(0, 1), frequencyScaleFactor, 0.5,
                                     BuildChannelCaptionFromIndex(0), _channelColors[0]), //TODO Unit
                new ChannelViewModel("dB?", new Position(0, -2), frequencyScaleFactor, 0.5,
                                     BuildChannelCaptionFromIndex(1), _channelColors[1]), //TODO Unit
            };

            var index = 0;

            channelVMs[index].MeasurementCursor1VM.Visible = true;
            channelVMs[index].MeasurementCursor2VM.Visible = true;
            channelVMs[index].MeasurementCursor1VM.Value   = -0.5;
            channelVMs[index].MeasurementCursor2VM.Value   = 0.5;
            //            index++;
            //            channelVMs[index].MeasurementCursor1VM.Visible = true;
            //            channelVMs[index].MeasurementCursor2VM.Visible = true;
            //            channelVMs[index].MeasurementCursor1VM.Value = -0.5;
            //            channelVMs[index].MeasurementCursor2VM.Value = 0.5;
            scopeScreenVM.ChannelVMs = channelVMs;

            // === Graphbase configuration ===

            var graphbaseVM = new GraphbaseViewModel("Hz", 0.2, _baseColor);

            graphbaseVM.MeasurementCursor1VM.Visible = true;
            graphbaseVM.MeasurementCursor2VM.Visible = true;
            graphbaseVM.MeasurementCursor1VM.Value   = 2.0;
            graphbaseVM.MeasurementCursor2VM.Value   = 3.0;
            scopeScreenVM.GraphbaseVM = graphbaseVM;

            // === Sample Sequences ===

            var sampleSequenceProviders =
                sampleSequences.Select(ss =>
            {
                var fftSamples = DoFourierTransform(ss);
                return(new Func <SampleSequence>(() => fftSamples));
            });

            scopeScreenVM.SampleSequenceProviders = sampleSequenceProviders;
        }
Beispiel #4
0
        /// <summary>
        /// Creates a trigger point cursor.
        /// </summary>
        internal static BoundCursor CreateTriggerPointCursor(GraphbaseViewModel graphbaseVM)
        {
            var triggerVM = graphbaseVM.TriggerVM;

            Func <String> triggerStateCaptionProvider = () =>
                                                        triggerVM.State == TriggerState.Armed ? _armedCaption
                : triggerVM.State == TriggerState.Triggered ? _triggeredCaption
                : "";

            Func <String> positionTextProvider = () =>
                                                 UnitHelper.BuildValueText(graphbaseVM.BaseUnitString,
                                                                           triggerVM.HorizontalPosition / graphbaseVM.ScaleFactor);

            var markerColor = CairoHelpers.ToCairoColor(graphbaseVM.Color);

            var cursor = new ScopeCursor
            {
                Lines           = ScopeCursorLines.X,
                LineWeight      = ScopeCursorLineWeight.Low,
                SelectableLines = ScopeCursorLines.X,
                Markers         = ScopeCursorMarkers.XFull,
                Color           = markerColor,
                Captions        = new []
                {
                    new ScopePositionCaption(triggerStateCaptionProvider, ScopeHorizontalAlignment.Left, ScopeVerticalAlignment.Top, ScopeAlignmentReference.XPositionAndVerticalRangeEdge, true, markerColor),
                    new ScopePositionCaption(triggerStateCaptionProvider, ScopeHorizontalAlignment.Left, ScopeVerticalAlignment.Bottom, ScopeAlignmentReference.XPositionAndVerticalRangeEdge, true, markerColor),
                    new ScopePositionCaption(positionTextProvider, ScopeHorizontalAlignment.Right, ScopeVerticalAlignment.Top, ScopeAlignmentReference.XPositionAndVerticalRangeEdge, true, markerColor),
                },
            };

            // === Create bindings. ===

            // Bind the cursor's position.
            var binding = PB.Binding.Create(() => cursor.Position.X == triggerVM.HorizontalPosition);

            return(new BoundCursor(cursor, new [] { binding }));
        }