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(); } }
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)); }
public DataViewVM(IDataStorageVM deviceDataVM) { GraphicVM = new GraphicVM(new GraphicViewSetingVM(), deviceDataVM); DataStorageVM = deviceDataVM ?? throw new ArgumentNullException(nameof(deviceDataVM)); }