Ejemplo n.º 1
0
 public virtual ISlicer NewSlicer()
 {
     return(new SimpleSlicer(
                SliceConfigurations.Get().PeakMinLength / 2,
                NewRuler(),
                NewAligner()));
 }
Ejemplo n.º 2
0
 public IAligner NewAligner()
 {
     if (SliceConfigurations.Get().CrestAtCenter)
     {
         return(new CenterAligner());
     }
     return(new LeftAligner());
 }
Ejemplo n.º 3
0
        private void BnPositive_OnClick(object sender, RoutedEventArgs e)
        {
            SliceConfigurations.Get().CrestAtCenter = CbPeakPosition.SelectedIndex == 0;
            var config = MiscellaneousConfigurations.Get();

            config.MaxPhaseStd                = double.Parse(TbMaxPhaseStd.Text);
            config.MinFlatPhasePtsNumCnt      = int.Parse(TbMinPhaseLength.Text);
            config.WaitEmptyProducerMsTimeout = int.Parse(TbProducerTimeout.Text);
            config.PythonPath             = TbPythonPath.Text;
            config.AutoFlip               = CkFlipMinusSpec.IsChecked.GetValueOrDefault(false);
            config.LockDipScanRadiusInMhz = double.Parse(TbDipLockScanRadius.Text);
            Close();
        }
Ejemplo n.º 4
0
        public OptionsWindow()
        {
            InitializeComponent();
            CbPeakPosition.ItemsSource   = new[] { "Center In Period", "Left In Period" };
            CbPeakPosition.SelectedIndex = SliceConfigurations.Get().CrestAtCenter ? 0 : 1;
            var config = MiscellaneousConfigurations.Get();

            TbMaxPhaseStd.Text        = "" + config.MaxPhaseStd;
            TbMinPhaseLength.Text     = "" + config.MinFlatPhasePtsNumCnt;
            TbProducerTimeout.Text    = "" + config.WaitEmptyProducerMsTimeout;
            TbPythonPath.Text         = config.PythonPath;
            TbDipLockScanRadius.Text  = config.LockDipScanRadiusInMhz + "";
            CkFlipMinusSpec.IsChecked = config.AutoFlip;
        }
Ejemplo n.º 5
0
        public IRuler NewRuler()
        {
            switch (SliceConfigurations.Get().RulerType)
            {
            case RulerType.MinLength:
                return(new MinCommonLengthRuler());

            case RulerType.AverageLength:
                return(new AverageLengthRuler());

            case RulerType.FixLength:
                return(new FixLengtherRuler(SliceConfigurations.Get().FixedLength));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 6
0
        public virtual ICrestFinder NewCrestFinder()
        {
            var          config      = GeneralConfigurations.Get();
            var          sliceConfig = SliceConfigurations.Get();
            ICrestFinder finder;

            if (sliceConfig.FindAbsoluteValue)
            {
                finder = new AbsoluteCrestFinder(
                    config.RepetitionRate, SamplingConfigurations.Get().SamplingRate,
                    sliceConfig.PeakMinLength / 2, sliceConfig.CrestAmplitudeThreshold);
            }
            else
            {
                finder = new SimpleCrestFinder(
                    config.RepetitionRate, SamplingConfigurations.Get().SamplingRate,
                    sliceConfig.PeakMinLength / 2, sliceConfig.CrestAmplitudeThreshold);
            }
            return(sliceConfig.AutoAdjust ? new AutoAdjustCrestFinder(finder) : finder);
        }
Ejemplo n.º 7
0
        public IConsumerV2 NewConsumer([NotNull] IProducerV2 <SampleRecord> producer, [NotNull] DisplayAdapterV2 adapter,
                                       int?targetCnt)
        {
            var timeout = MiscellaneousConfigurations.Get().WaitEmptyProducerMsTimeout;

            var configurations = GeneralConfigurations.Get();

            if (configurations.ViewPhase)
            {
                return(new PhaseVisualizer(producer.BlockingQueue, NewPhaseReader(), adapter as PhaseDisplayAdapter,
                                           null, timeout,
                                           targetCnt));
            }
            var threadNum = configurations.ThreadNum;

            if (SliceConfigurations.Get().Reference)
            {
                var splitters = new List <ISplitter>(threadNum);
                for (var i = 0; i < threadNum; i++)
                {
                    splitters.Add(NewRefProcessor());
                }
                return(new RefSpectroscopyVisualizer(producer.BlockingQueue, splitters,
                                                     adapter as SpectrumDisplayAdapter, NewSpectrumWriter(), timeout, targetCnt, configurations.SaveSpec,
                                                     configurations.SaveAcc));
            }
            var accumulators = new List <IAccumulator>(threadNum);

            for (var i = 0; i < threadNum; i++)
            {
                accumulators.Add(NewPulseSequenceProcessor());
            }
            return(new ParralelSpectroscopyVisualizerV2(producer.BlockingQueue, accumulators,
                                                        adapter as SpectrumDisplayAdapter, NewSpectrumWriter(), timeout, targetCnt, configurations.SaveSpec,
                                                        configurations.SaveAcc));
        }
Ejemplo n.º 8
0
 private Splitter NewRefProcessor()
 {
     return(new Splitter(NewCrestFinder(),
                         new RefSlicer(SliceConfigurations.Get().PeakMinLength / 2, NewRuler(), NewAligner()),
                         NewPulsePreprocessor(), NewCorrector()));
 }
Ejemplo n.º 9
0
        public MainWindow()
        {
            // init system components
            InitializeComponent();

            _possibleWrongLabels = new[] { LbPeakMinAmp, LbRangeStart, LbRangeEnd, LbRepRate };
            _originalThickness   = _possibleWrongLabels[0].BorderThickness;
            _originalBrush       = _possibleWrongLabels[0].BorderBrush;

            if (File.Exists(@"default.svcfg"))
            {
                ConfigsHolder.Load(@"default.svcfg");
            }
            else
            {
                // init configurations
                SamplingConfigurations.Initialize(
                    deviceName: "Dev3",
                    channel: 0,
                    samplingRateInMHz: 100,
                    recordLengthInM: 1,
                    range: 10);

                GeneralConfigurations.Initialize(
                    repetitionRate: 400,
                    threadNum: 4,
                    dispPoints: 1000,
                    directory: @"C:\buffer\captured\",
                    viewPhase: false,
                    saveType: SaveType.Magnitude,
                    queueSize: 48,
                    saveSample: false,
                    saveSpec: false,
                    saveAcc: false,
                    operationMode: OperationMode.Manual,
                    targetCnt: 100);

                SliceConfigurations.Initialize(
                    crestAmplitudeThreshold: 0.5,
                    peakMinLength: 2000,
                    crestAtCenter: true,
                    rulerType: RulerType.MinLength,
                    findAbs: true,
                    autoAdjust: true,
                    fixedLength: 232171,
                    reference: false
                    );

                CorrectorConfigurations.Initialize(
                    zeroFillFactor: 1,
                    centerSpanLength: 512,
                    correctorType: CorrectorType.Mertz,
                    apodizerType: ApodizerType.Hann,
                    phaseType: PhaseType.FullRange,
                    realPhase: false,
                    rangeStart: 3,
                    rangeEnd: 4,
                    lockDip: false,
                    lockDipFreqInMHz: 5
                    );

                MiscellaneousConfigurations.Initialize(
                    waitEmptyProducerMsTimeout: 5000,
                    minFlatPhasePtsNumCnt: 200,
                    maxPhaseStd: 0.34,
                    pythonPath: @"C:\Anaconda3\python.exe",
                    lockDipScanRadiusInMHz: 0.4,
                    autoFlip: false);
            }


            SliceConfigs     = SliceConfigurations.Get();
            CorrectorConfigs = CorrectorConfigurations.Get();
            SampleConfigs    = SamplingConfigurations.Get();
            GeneralConfigs   = GeneralConfigurations.Get();

            CbPhaseType.SelectionChanged += (sender, args) => {
                HideAllPhaseOptions();

                var selected = (PhaseType)args.AddedItems[0];
                HandleAdditionalPhaseOptions(selected);
            };

            CbSliceLength.SelectionChanged += (sender, args) => {
                var selected = (RulerType)args.AddedItems[0];
                TbFixedLength.Visibility = selected == RulerType.FixLength ? Visibility.Visible : Visibility.Hidden;
            };

            CbCorrector.SelectionChanged += (sender, args) => {
                var selected = (CorrectorType)args.AddedItems[0];
                switch (selected)
                {
                case CorrectorType.Fake:
                    Hide(CbPhaseType);
                    Hide(LbPhaseType);
                    HideAllPhaseOptions();
                    break;

                case CorrectorType.Mertz:
                    Show(CbPhaseType);
                    Show(LbPhaseType);
                    HandleAdditionalPhaseOptions((PhaseType?)CbPhaseType.SelectedItem ?? PhaseType.FullRange);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            };
            CbOperationMode.SelectionChanged += (sender, args) => {
                var selected = (OperationMode)args.AddedItems[0];
                switch (selected)
                {
                case OperationMode.Manual:
                    Hide(TbTargetCnt);
                    break;

                case OperationMode.Single:
                case OperationMode.Loop:
                    Show(TbTargetCnt);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            };
            RoutedEventHandler ckPhaseOnChecked = (sender, args) => {
                var correct = !CkPhase.IsChecked.GetValueOrDefault(false);
                if (correct)
                {
                    Show(LbCorrector);
                    Show(CbCorrector);
                    Show(CbApodizationType);
                    Show(LbApodize);
                    Show(CkLockDip);
                    Show(TbLockDip);
                    Show(LbLockDip);
                    Show(CkSpecReal);
                    if ((CorrectorType)CbCorrector.SelectedItem != CorrectorType.Fake)
                    {
                        Show(CbPhaseType);
                        Show(LbPhaseType);
                        HandleAdditionalPhaseOptions((PhaseType?)CbPhaseType.SelectedItem ?? PhaseType.FullRange);
                    }
                }
                else
                {
                    Hide(CbCorrector);
                    Hide(LbCorrector);
                    Hide(CbApodizationType);
                    Hide(LbApodize);
                    Hide(CkLockDip);
                    Hide(TbLockDip);
                    Hide(LbLockDip);
                    Hide(CkSpecReal);
                    Hide(CbPhaseType);
                    Hide(LbPhaseType);
                    HideAllPhaseOptions();
                }
            };

            CkPhase.Checked   += ckPhaseOnChecked;
            CkPhase.Unchecked += ckPhaseOnChecked;

            // bind configs to controls
            DataContext = this;

//            SamplingConfigurations.Get().Bind(TbDeviceName, TbChannel, TbSamplingRate, TbRecordLength, TbRange);
//            GeneralConfigurations.Get()
//                .Bind(TbRepRate, TbThreadNum, TbDispPoints, TbSavePath, CkPhase, CbSaveType, TbQueueSize,
//                    CkCaptureSample, CkCaptureSpec, CkCaptureAcc, CbOperationMode, TbTargetCnt);
//            SliceConfigurations.Get()
//                .Bind(TbPtsBeforeCrest, TbCrestMinAmp, CbSliceLength, CkAutoAdjust, CkFindAbs, TbFixedLength, CkRef);
//            CorrectorConfigurations.Get()
//                .Bind(TbZeroFillFactor, TbCenterSpanLength, CbCorrector, CbApodizationType, CbPhaseType, TbRangeStart,
//                    TbRangeEnd, CkAutoFlip, CkSpecReal);
            // init custom components

            SwitchButton          = new ToggleButtonV2(ToggleButton, false, "Stop", "Start");
            SwitchButton.TurnOn  += TurnOn;
            SwitchButton.TurnOff += ClearFromRunningState;
            SizeChanged          += (sender, args) => { Adapter?.OnWindowZoomed(); };
            // todo text disapeared

            CkCaptureSpec.Checked += (sender, args) => { CkCaptureAcc.IsChecked = true; };

            Closing += (sender, args) => { _statsWindow?.Close(); };

            LocationChanged += (sender, args) => {
                if (_statsWindow == null)
                {
                    return;
                }
                _statsWindow.Left = this.Left + this.Width - 15;
                _statsWindow.Top  = this.Top;
            };
        }