Esempio n. 1
0
        /// <summary>
        /// Appends header specific attributes to <paramref name="attributes"/> dictionary.
        /// </summary>
        /// <param name="attributes">Dictionary to append header specific attributes to.</param>
        internal void AppendHeaderAttributes(Dictionary <string, string> attributes)
        {
            attributes.Add("Frame Type", (ushort)TypeID + ": " + TypeID);
            attributes.Add("Frame Length", FrameLength.ToString());
            attributes.Add("Version", Version.ToString());
            attributes.Add("Second of Century", SecondOfCentury.ToString());
            attributes.Add("Fraction of Second", FractionOfSecond.ToString());

            uint timeQualityFlags = (uint)TimeQualityFlags;

            attributes.Add("Time Quality Flags", timeQualityFlags.ToString());

            if (timeQualityFlags > 0)
            {
                attributes.Add("Leap Second State", TimeQualityFlags.ToString());
            }
            else
            {
                attributes.Add("Leap Second State", "No leap second is currently pending");
            }

            attributes.Add("Time Quality Indicator Code", (uint)TimeQualityIndicatorCode + ": " + TimeQualityIndicatorCode);
            attributes.Add("Time Base", Timebase.ToString());
        }
Esempio n. 2
0
        public TriggerVM()
        {
            Activator = new ViewModelActivator();
            Protocol  = new TriggerProtocol(null);

            Sweep      = new ScopeCommand <string>(this, Protocol.Sweep, "AUTO");
            Mode       = new ScopeCommand <string>(this, Protocol.Mode, nameof(ModeStringOptions.Edge));
            EdgeSource = new ScopeCommand <string>(this, Protocol.Edge.Source, "CHAN1");
            EdgeSlope  = new ScopeCommand <string>(this, Protocol.Edge.Slope, "POS");
            EdgeLevel  = new ScopeCommand <double>(this, Protocol.Edge.Level, "0");

            AllScopeCommands = new List <IScopeCommand>()
            {
                Sweep, Mode, EdgeSource, EdgeSlope, EdgeLevel,
            };

            var GetAllMessage = ReactiveCommand.Create(() =>
                                                       Debug.WriteLine("------- Retrieving all TRIGGER values from device ---------"));

            GetAll = ReactiveCommand.CreateCombined(new[]
            {
                GetAllMessage,
                Sweep.GetCommand,
                Mode.GetCommand,
                EdgeSource.GetCommand,
                EdgeSlope.GetCommand,
                EdgeLevel.GetCommand,
            });

            var SetAllMessage = ReactiveCommand.Create(() =>
                                                       Debug.WriteLine("------- Setting all TRIGGER values on device ---------"));

            SetAll = ReactiveCommand.CreateCombined(new[]
            {
                SetAllMessage,
                Sweep.SetCommand,
                Mode.SetCommand,
                EdgeSource.SetCommand,
                EdgeSlope.SetCommand,
                EdgeLevel.SetCommand,
            });


            this.WhenActivated(disposables =>
            {
                this.HandleActivation();

                Disposable
                .Create(() => this.HandleDeactivation())
                .DisposeWith(disposables);

                foreach (var scopeCommand in AllScopeCommands)
                {
                    scopeCommand.WhenActivated(disposables);
                }

                // Make visible the panel that corresponds to the selected trigger mode
                this.WhenAnyValue(
                    x => x.Mode.Value,
                    x => x == nameof(ModeStringOptions.Edge))
                .ToPropertyEx(this, x => x.IsEdgeMode);

                // Range of edge level trigger is:
                //   (-5x Vertical Scale - Offset) to (+5x Vertical Scale - Offset)
                Timebase.WhenAnyValue(
                    vm => vm.Scale.Value,
                    vm => vm.Offset.Value,
                    (x, y) => {
                    Protocol.Edge.SetLevelRange(x, y);
                    return(0.0);
                });
            });
        }