示例#1
0
        public FlashDumpLoadVM(RUSDeviceId rusDevice, BusyObject isBusy)
        {
            IsBusy = isBusy;

            DataStorageVM = new FlashDataStorageVM(this);
            Load          = new ActionCommand(loadAsync, IsBusy);
            Cancel        = new ActionCommand(cancelAsync, () => _currentOperation != null, IsBusy);

            async Task loadAsync()
            {
                using (IsBusy.BusyMode)
                {
                    var path = IOUtils.RequestFileOpenPath("BIN (*.bin)|*.bin");
                    if (path == null)
                    {
                        return;
                    }

                    try
                    {
                        _currentOperation     = new AsyncOperationInfo().UseInternalCancellationSource();
                        _currentOperationTask = LoadAsync(path, _currentOperation);
                        Cancel.Update();
                        await _currentOperationTask;

                        Logger.LogOKEverywhere("Дамп Flash успешно загружен");
                    }
                    catch (OperationCanceledException)
                    {
                        Logger.LogInfoEverywhere("Чтение дампа Flash отменено");

                        PointsSource = null;
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError("Ошибка загрузки дампа", $"-MSG", ex);

                        PointsSource = null;
                    }
                    finally
                    {
                        _currentOperationTask = null;
                        _currentOperation     = null;
                    }
                }
            }

            async Task cancelAsync()
            {
                _currentOperation?.Cancel();
            }
        }
示例#2
0
 public DataViewSetingVM(IDataStorageVM storageVM, IGraphicViewSetingVM viewSetingVM, ICurvesExporterVM[] exporters)
 {
     StorageVM    = storageVM ?? throw new ArgumentNullException(nameof(storageVM));
     ViewSetingVM = viewSetingVM ?? throw new ArgumentNullException(nameof(viewSetingVM));
     Exporters    = exporters ?? throw new ArgumentNullException(nameof(exporters));
 }
示例#3
0
 public DataViewVM(IDataStorageVM deviceDataVM)
 {
     GraphicVM     = new GraphicVM(new GraphicViewSetingVM(), deviceDataVM);
     DataStorageVM = deviceDataVM ?? throw new ArgumentNullException(nameof(deviceDataVM));
 }