Exemplo n.º 1
0
        public SelectSimulationViewModel(
            SimLibrary simLibrary,
            IAppState appState,
            IAppService appService
            )
        {
            _simLibrary = simLibrary;
            _appState   = appState;
            _appService = appService;

            SimulationVMs = new ObservableCollection <ISimulationViewModel>();
            PopulateSimulations();

            simLibrary.Loaded  += HandleSimLibraryLoaded;
            simLibrary.Deleted += HandleSimulationDeleted;

            var svmObservable = this.ObservableForProperty(vm => vm.SelectedSimulationVM, svm => null != svm);

            OpenSimulation   = ReactiveCommand.Create(HandleOpenSimulation, svmObservable);
            DeleteSimulation = ReactiveCommand.Create(HandleDeleteSimulation, svmObservable);

            var major = _appState.RVersion.Single(t => t.Name == "major").Value;
            var minor = _appState.RVersion.Single(t => t.Name == "minor").Value;

            RVersion = $"{major}.{minor}";
        }
Exemplo n.º 2
0
        public async Task TestSetExecutorAsync()
        {
            // arrange
            var pathToLibrary = TestData.SimLibraryDirectory.FullName;
            var simLibrary    = new SimLibrary();

            simLibrary.LoadFrom(pathToLibrary);
            var pathToCode = Path.Combine(pathToLibrary, "InspectExec", "inspect.R");

            // act
            using var managedImport = new ManagedImport(pathToCode, simLibrary);
            using var server        = new RVisServer();
            var client = await server.OpenChannelAsync();

            managedImport.InspectAsync(client).Wait();
            managedImport.SetExecutorAsync(managedImport.UnaryFunctions[0], managedImport.ScalarSets[0], client).Wait();

            // assert
            Assert.AreEqual(managedImport.ExecutorOutput?.NColumns, 3);
            Assert.AreEqual(managedImport.ExecutorParameterCandidates.Count, 2);
            Assert.AreEqual(managedImport.ExecutorValueCandidates.Count, 2);
            Assert.AreEqual(managedImport.ScalarSets.Count, 1);
            Assert.AreEqual(managedImport.UnaryFunctions.Count, 1);
            Assert.AreEqual(managedImport.ValueCandidates.Count, 1);
        }
Exemplo n.º 3
0
        public LibraryViewModel(
            SimLibrary simLibrary,
            IAppState appState,
            IAppService appService,
            IAppSettings appSettings
            )
        {
            _simLibrary  = simLibrary;
            _appState    = appState;
            _appService  = appService;
            _appSettings = appSettings;

            _location       = _appSettings.PathToSimLibrary;
            ChooseDirectory = ReactiveCommand.Create(HandleChooseDirectory);
        }
Exemplo n.º 4
0
        public DrugXSimpleAcatViewModel(IAppService appService, SimLibrary simLibrary)
        {
            _appService = appService;
            _simLibrary = simLibrary;

            _reactiveSafeInvoke = appService.GetReactiveSafeInvoke();

            this
            .GetWhenPropertyChanged()
            .Subscribe(
                _reactiveSafeInvoke.SuspendAndInvoke <string?>(
                    ObservePropertyChanged
                    )
                );
        }
Exemplo n.º 5
0
        public ImportMCSimViewModel(SimLibrary simLibrary, IAppState appState, IAppService appService)
        {
            _simLibrary = simLibrary;
            _appState   = appState;
            _appService = appService;

            BrowseForExecutable        = ReactiveCommand.Create(HandleBrowseForExecutable);
            BrowseForConfigurationFile = ReactiveCommand.Create(HandleBrowseForConfigurationFile);
            BrowseForTemplateInFile    = ReactiveCommand.Create(HandleBrowseForTemplateInFile);
            Import = ReactiveCommand.Create(
                HandleImport,
                this.ObservableForProperty(vm => vm.CanImport, _ => CanImport)
                );

            UpdateEnable();
        }
Exemplo n.º 6
0
        public ImportSimulationViewModel(
            SimLibrary simLibrary,
            IAppState appState,
            IAppService appService
            )
        {
            _simLibrary = simLibrary;
            _appState   = appState;
            _appService = appService;

            BrowseForRFile = ReactiveCommand.Create(HandleBrowseForRFile);

            InspectRFile = ReactiveCommand.Create(
                HandleInspectRFile,
                this.ObservableForProperty(vm => vm.PathToRFile, p => p.IsAString())
                );

            SelectExecutive = ReactiveCommand.Create(
                HandleSelectExec,
                this.WhenAny(
                    vm => vm.UnaryFuncs,
                    vm => vm.ScalarSets,
                    (ufs, sss) => ufs.Value.Count > 0 && sss.Value.Count > 0
                    )
                );

            ImportUsingExec = ReactiveCommand.Create(
                HandleImportUsingExec,
                this.ObservableForProperty(vm => vm.ExecutiveFunction, si => si != default)
                );

            ImportUsingTmpl = ReactiveCommand.Create(
                HandleImportUsingTmpl,
                this.ObservableForProperty(vm => vm.ManagedImport, mi => mi != default)
                );

            BusyCancel = ReactiveCommand.Create(HandleBusyCancel);
        }
Exemplo n.º 7
0
        public async Task TestInspectAsync()
        {
            // arrange
            var pathToLibrary = TestData.SimLibraryDirectory.FullName;
            var simLibrary    = new SimLibrary();

            simLibrary.LoadFrom(pathToLibrary);
            var pathToCode = Path.Combine(pathToLibrary, "InspectTmpl", "inspect.R");

            // act
            using var managedImport = new ManagedImport(pathToCode, simLibrary);
            using var server        = new RVisServer();
            var client = await server.OpenChannelAsync();

            managedImport.InspectAsync(client).Wait();

            // assert
            Assert.AreEqual(managedImport.Scalars.Count, 2);
            Assert.AreEqual(managedImport.ParameterCandidates.Count, 2);
            Assert.AreEqual(managedImport.DataSets.Count, 3);
            Assert.AreEqual(managedImport.ValueCandidates.Count, 3);
            Assert.AreEqual(managedImport.ValueCandidates.Single(vc => vc.Name == "o").ElementCandidates.Count, 3);
        }