Exemple #1
0
 public FornecedoresController(IOptions <NAVConfigurations> appSettings, IOptions <NAVWSConfigurations> NAVWSConfigs, IOptions <GeneralConfigurations> appSettingsGeneral, IHostingEnvironment _hostingEnvironment)
 {
     _config                  = appSettings.Value;
     _configws                = NAVWSConfigs.Value;
     _generalConfig           = appSettingsGeneral.Value;
     this._hostingEnvironment = _hostingEnvironment;
 }
Exemple #2
0
 public ViaturasController(IOptions <NAVConfigurations> appSettings, IOptions <NAVWSConfigurations> NAVWSConfigs, IHostingEnvironment _hostingEnvironment, IOptions <GeneralConfigurations> appSettingsGeneral)
 {
     _config   = appSettings.Value;
     _configws = NAVWSConfigs.Value;
     this._hostingEnvironment = _hostingEnvironment;
     _generalConfig           = appSettingsGeneral.Value;
 }
        private void LoadFiles(bool compressed)
        {
            if (IsProgramRunning())
            {
                return;
            }

            var fileNames = SelectFiles();

            if (fileNames.IsEmpty())
            {
                return;
            }
            GeneralConfigurations.Get().Directory = Path.GetDirectoryName(fileNames[0]) + @"\";
            TbSavePath.Text = GeneralConfigurations.Get().Directory;
            var factory  = FactoryHolder.Get();
            var producer = factory.NewProducer(fileNames, compressed);

            Adapter = NewAdapterBinding();
            var consumer = factory.NewConsumer(producer, Adapter, fileNames.Length);

            consumer.SourceInvalid       += ConsumerOnSourceInvalid;
            consumer.Update              += ConsumerOnUpdate;
            consumer.ProducerEmpty       += OnConsumerStopped;
            consumer.TargetAmountReached += OnConsumerStopped;
            PbLoading.Maximum             = fileNames.Length;
            PbLoading.Value               = 0;
            Scheduler = new Scheduler(producer, consumer);
            SetButtonRunning();
            Scheduler.Start();
        }
        public IPhaseExtractor NewPhaseExtractor()
        {
            if (GeneralConfigurations.Get().ViewPhase)
            {
                return(new FourierOnlyPhaseExtractor());
            }
            var config    = CorrectorConfigurations.Get();
            var misConfig = MiscellaneousConfigurations.Get();

            switch (config.PhaseType)
            {
            case PhaseType.FullRange:
                return(new FourierOnlyPhaseExtractor());

            case PhaseType.CenterInterpolation:
                return(new CorrectCenterPhaseExtractor(NewApodizer(),
                                                       config.CenterSpanLength / 2));

            case PhaseType.SpecificRange:
                return(new SpecificRangePhaseExtractor((int)config.RangeStart, (int)config.RangeEnd,
                                                       misConfig.MinFlatPhasePtsNumCnt, misConfig.MaxPhaseStd));

            case PhaseType.OldCenterInterpolation:
                return(new ClassicWrongPhaseExtractor(NewApodizer(),
                                                      config.CenterSpanLength / 2));

            case PhaseType.SpecificFreqRange:
                return(new SpecificFreqRangePhaseExtractor(config.RangeStart, config.RangeEnd,
                                                           SamplingConfigurations.Get().SamplingRateInMHz, misConfig.MinFlatPhasePtsNumCnt,
                                                           misConfig.MaxPhaseStd));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 public SpectrumDisplayAdapter NewSpectrumAdapter(CanvasView view, HorizontalAxisView horizontalAxisView,
                                                  VerticalAxisView verticalAxisView, TextBox tbX, TextBox tbDelta, double?dipLockFreq, double lockDipScanRadius)
 {
     return(new SpectrumDisplayAdapter(view, horizontalAxisView, verticalAxisView, tbX, tbDelta,
                                       GeneralConfigurations.Get().DispPoints,
                                       SamplingConfigurations.Get().SamplingRate, 0,
                                       (int)Math.Round(SamplingConfigurations.Get().SamplingRateInMHz / 2), dipLockFreq, lockDipScanRadius));
 }
 public PhaseDisplayAdapter NewPhaseAdapter(CanvasView view, HorizontalAxisView horizontalAxisView,
                                            VerticalAxisView verticalAxisView, TextBox tbX, TextBox tbDelta)
 {
     return(new PhaseDisplayAdapter(view, horizontalAxisView, verticalAxisView, tbX, tbDelta,
                                    GeneralConfigurations.Get().DispPoints,
                                    SamplingConfigurations.Get().SamplingRate, 0,
                                    (int)Math.Round(SamplingConfigurations.Get().SamplingRateInMHz / 2)));
 }
Exemple #7
0
        public RequisicoesSimplificadasController(IOptions <NAVConfigurations> appSettings, IOptions <NAVWSConfigurations> NAVWSConfigs, IHostingEnvironment _hostingEnvironment, IOptions <GeneralConfigurations> appSettingsGeneral)
        {
            this.configws            = NAVWSConfigs.Value;
            this._hostingEnvironment = _hostingEnvironment;
            _generalConfig           = appSettingsGeneral.Value;

            register = new ProjetosController(appSettings, NAVWSConfigs, _hostingEnvironment, appSettingsGeneral);
        }
Exemple #8
0
        public ActionResult Sidebar()
        {
            string role = "Administrator";
            GeneralConfigurations generalConfigurations = GetConfig(1);
            SidebarUserLevel      sidebarUserLevel      = generalConfigurations.menus.Where(w => w.role.Equals(role, System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
            List <SidebarItem>    SidebarItemList       = sidebarUserLevel.links;

            return(PartialView(SidebarItemList));
        }
        private void StartSample_OnClick(object sender, RoutedEventArgs e)
        {
            if (IsProgramRunning())
            {
                return;
            }
            var numberDialog = new NumberDialog();

            if (!numberDialog.ShowDialog().GetValueOrDefault(false))
            {
                return;
            }
            var total = numberDialog.Number;

            if (total <= 0)
            {
                MessageBox.Show("plz input the number of records to be sampled.");
                return;
            }

            var factory = FactoryHolder.Get();

            IProducerV2 <SampleRecord> producer;

            if (!factory.TryNewSampleProducer(out producer, total))
            {
                SwitchButton.State = false;
                MessageBox.Show("Sampler can't be initialized");
                return;
            }
            producer.ProductionFailed += exception => {
                Dispatcher.InvokeAsync(() => {
                    SwitchButton.State = false;
                    MessageBox.Show("Unable to sample data. Exception occured:\n\n" + exception.Message);
                });
            };
            //            producer.HitTarget += () => { Dispatcher.InvokeAsync(() => { SwitchButton.State = false; }); };
            PbLoading.Maximum = total;
            Adapter           = NewAdapterBinding();
            var threadNum = GeneralConfigurations.Get().ThreadNum;
            var workers   = new List <SpecialSampleWriter>(threadNum);

            for (var i = 0; i < threadNum; i++)
            {
                workers.Add(new SpecialSampleWriter(GeneralConfigurations.Get().Directory, "[Binary]"));
            }
            var consumer = new DataSerializer(producer.BlockingQueue, workers, total);

            consumer.SourceInvalid       += ConsumerOnSourceInvalid;
            consumer.Update              += ConsumerOnUpdate;
            consumer.TargetAmountReached += () => { Dispatcher.InvokeAsync(() => { SwitchButton.State = false; }); };
            CkCaptureSample.IsChecked     = true;
            Scheduler = new Scheduler(producer, consumer);
            SetButtonRunning();
            Scheduler.Start();
        }
        public IWriterV2 <TracedSpectrum> NewSpectrumWriter()
        {
            var prefix = "[Sum]";

            if (CorrectorConfigurations.Get().LockDip)
            {
                prefix += "[LockOn-" + CorrectorConfigurations.Get().LockDipFreqInMHz.ToString("F2") + "MHz]";
            }
            return(new SpectrumWriterV2(GeneralConfigurations.Get().Directory, prefix,
                                        GeneralConfigurations.Get().SaveType));
        }
        public GeneralConfigurations GetConfig(int id)
        {
            GeneralConfigurations generalConfigurations = new GeneralConfigurations();
            string TypeSidebar = "";

            TypeSidebar = "~/config.json";

            using (StreamReader r = new StreamReader(Server.MapPath(TypeSidebar)))
            {
                string json = r.ReadToEnd();
                generalConfigurations = JsonConvert.DeserializeObject <GeneralConfigurations>(json);
            }

            return(generalConfigurations);
        }
        private void BnPath_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new CommonOpenFileDialog {
                IsFolderPicker = true
            };
            var result = dialog.ShowDialog();

            if (result == CommonFileDialogResult.Ok)
            {
                foreach (var fileName in dialog.FileNames)
                {
                    TbSavePath.Text = fileName;
                }
            }
            GeneralConfigurations.Get().Directory = TbSavePath.Text;
        }
        public bool TryNewSampleProducer(out IProducerV2 <SampleRecord> newProducer, int?targetCnt = null)
        {
            Sampler sampler;

            if (TryNewSampler(out sampler))
            {
                newProducer = new SampleProducerV2(sampler, GeneralConfigurations.Get().QueueSize, targetCnt);
                if (GeneralConfigurations.Get().SaveSample)
                {
                    var newSampleWriter = FactoryHolder.Get().NewSampleWriter();
                    newProducer.NewProduct += record => { newSampleWriter.Write(record); };
                }
                return(true);
            }
            newProducer = null;
            return(false);
        }
        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);
        }
        private DisplayAdapterV2 NewAdapter()
        {
            if (GeneralConfigurations.Get().ViewPhase)
            {
                return(FactoryHolder.Get()
                       .NewPhaseAdapter(new CanvasView(ScopeCanvas), new HorizontalAxisView(HorAxisCanvas),
                                        new VerticalAxisView(VerAxisCanvas), TbXCoordinate, TbDistance));
            }
            double?lockDipFreq;

            if (CorrectorConfigs.LockDip)
            {
                lockDipFreq = CorrectorConfigs.LockDipFreqInMHz;
            }
            else
            {
                lockDipFreq = null;
            }
            return(FactoryHolder.Get()
                   .NewSpectrumAdapter(new CanvasView(ScopeCanvas), new HorizontalAxisView(HorAxisCanvas),
                                       new VerticalAxisView(VerAxisCanvas), TbXCoordinate, TbDistance,
                                       lockDipFreq, MiscellaneousConfigurations.Get().LockDipScanRadiusInMhz));
        }
        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));
        }
        private void DebugCmd_OnClick(object sender, RoutedEventArgs e)
        {
            if (IsProgramRunning())
            {
                return;
            }
            var fileNames = SelectFiles();

            if (fileNames.IsEmpty())
            {
                return;
            }

            GeneralConfigurations.Get().Directory = Path.GetDirectoryName(fileNames[0]) + @"\";
            TbSavePath.Text = GeneralConfigurations.Get().Directory;
            var factory  = FactoryHolder.Get();
            var producer = factory.NewProducer(fileNames, true);

            Adapter = NewAdapterBinding();

            var checkers = new List <PulseChecker>();

            for (var i = 0; i < 4; i++)
            {
                checkers.Add(new PulseChecker(factory.NewCrestFinder(), factory.NewSlicer(),
                                              factory.NewPulsePreprocessor(), factory.NewCorrector()));
            }
            var consumer = new PulseByPulseChecker(producer.BlockingQueue, checkers, fileNames.Length);

            consumer.Update  += ConsumerOnUpdate;
            PbLoading.Maximum = fileNames.Length;
            PbLoading.Value   = 0;
            Scheduler         = new Scheduler(producer, consumer);
            Scheduler.Start();
            SetButtonRunning();
        }
        private void TurnOn()
        {
            GC.Collect();

            if (_ultraFastMode)
            {
                var textBlock = new TextBlock {
                    Text       = "Happy 2016!",
                    Foreground = new SolidColorBrush(Colors.Wheat),
                    FontSize   = 30
                };
                var canvasView = new CanvasView(ScopeCanvas);
                Canvas.SetTop(textBlock, canvasView.ScopeHeight / 2);
                Canvas.SetLeft(textBlock, canvasView.ScopeWidth / 3);
                canvasView.Canvas.Children.Add(textBlock);
                SwitchButton.State = false;
                return;
            }

            var factory = FactoryHolder.Get();
            IProducerV2 <SampleRecord> producer;

            if (!factory.TryNewSampleProducer(out producer))
            {
                SwitchButton.State = false;
                MessageBox.Show("Sampler can't be initialized. Maybe another instance is running.");
                return;
            }
            producer.ProductionFailed += exception => {
                Dispatcher.InvokeAsync(() => {
                    SwitchButton.State = false;
                    MessageBox.Show("Unable to sample data. Exceptions occured, please read carefully:\n\n" +
                                    exception.Message);
                });
            };
            Adapter = NewAdapterBinding();
            int?targetCnt;
            var configs = GeneralConfigurations.Get();

            if (configs.OperationMode == OperationMode.Manual)
            {
                targetCnt = null;
            }
            else
            {
                targetCnt = configs.TargetCnt;
            }
            var consumer = factory.NewConsumer(producer, Adapter, targetCnt);

            try {
                Adapter.StartFreqInMHz = Convert.ToDouble(TbStartFreq.Text); // todo move to constructor
                Adapter.EndFreqInMHz   = Convert.ToDouble(TbEndFreq.Text);
            } catch (Exception) {
            }
            Scheduler = new Scheduler(producer, consumer);
            consumer.SourceInvalid += ConsumerOnSourceInvalid;
            consumer.Update        += ConsumerOnUpdate;
            switch (configs.OperationMode)
            {
            case OperationMode.Manual:
                PbLoading.IsIndeterminate = true;

                break;

            case OperationMode.Single:
                consumer.TargetAmountReached += OnConsumerStopped;
                PbLoading.IsIndeterminate     = false;
                PbLoading.Maximum             = targetCnt.Value;
                break;

            case OperationMode.Loop:
                PbLoading.IsIndeterminate     = false;
                PbLoading.Maximum             = targetCnt.Value;
                consumer.TargetAmountReached += () => {
                    OnConsumerStopped();

                    Dispatcher.Invoke(() => { SwitchButton.State = true; });
                };
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            PrepareStatsWinndow();
            Scheduler.Start();
        }
 public IWriterV2 <SampleRecord> NewSampleWriter()
 {
     return(new SampleWriterV2(GeneralConfigurations.Get().Directory, "[Binary]"));
 }
        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;
            };
        }
 private void BnOpenPath_OnClick(object sender, RoutedEventArgs e)
 {
     Process.Start(GeneralConfigurations.Get().Directory);
 }
 public TelemoveisEquipamentosController(IHostingEnvironment _hostingEnvironment, IOptions <GeneralConfigurations> appSettingsGeneral)
 {
     this._hostingEnvironment = _hostingEnvironment;
     _generalConfig           = appSettingsGeneral.Value;
 }
 public ActividadesPorFornecedorController(IHostingEnvironment _hostingEnvironment, IOptions <GeneralConfigurations> appSettingsGeneral)
 {
     this._hostingEnvironment = _hostingEnvironment;
     _generalConfig           = appSettingsGeneral.Value;
 }
 public ModelosReqSimplificadaController(IHostingEnvironment _hostingEnvironment, IOptions <GeneralConfigurations> appSettingsGeneral)
 {
     this._hostingEnvironment = _hostingEnvironment;
     _generalConfig           = appSettingsGeneral.Value;
 }