Beispiel #1
0
        internal ViewModel(IAppState appState, IAppService appService, IAppSettings appSettings)
        {
            _appState   = appState;
            _appService = appService;
            _simulation = appState.Target.AssertSome("No simulation");
            _evidence   = appState.SimEvidence;

            Import = ReactiveCommand.Create(HandleImport);

            _moduleState = ModuleState.LoadOrCreate(_simulation, _evidence);

            _browseViewModel = new BrowseViewModel(appState, appSettings, appService, _moduleState);
            _manageViewModel = new ManageViewModel(appState, appService, _moduleState);

            _reactiveSafeInvoke = appService.GetReactiveSafeInvoke();

            _subscriptions = new CompositeDisposable(
                _moduleState.ObservationsChanges.Subscribe(
                    _reactiveSafeInvoke.SuspendAndInvoke <(Arr <SimObservations>, ObservableQualifier)>(
                        ObserveModuleStateObservationsChange
                        )
                    ),
                _appState.SimSharedState.ObservationsSharedStateChanges.Subscribe(
                    _reactiveSafeInvoke.SuspendAndInvoke <(Arr <SimObservationsSharedState>, ObservableQualifier)>(
                        ObserveSharedStateObservationsChange
                        )
                    )
                );
        }
Beispiel #2
0
        internal BrowseViewModel(IAppState appState, IAppSettings appSettings, IAppService appService, ModuleState moduleState)
        {
            _appState    = appState;
            _appSettings = appSettings;
            _moduleState = moduleState;

            var evidence = _appState.SimEvidence;

            var simulation = _appState.Target.AssertSome();
            var ivElement  = simulation.SimConfig.SimOutput.IndependentVariable;

            _observationsScatterPlot = new PlotModel();
            _observationsScatterPlot.AssignDefaultColors(appSettings.IsBaseDark, PLOT_COLOR_COUNT);
            _observationsScatterPlot.AddAxes(ivElement.GetFQName(), default, default, default, default, default);
Beispiel #3
0
        internal ManageViewModel(IAppState appState, IAppService appService, ModuleState moduleState)
        {
            _evidence    = appState.SimEvidence;
            _sharedState = appState.SimSharedState;
            _moduleState = moduleState;

            DeleteEvidenceSource = ReactiveCommand.Create(
                HandleDeleteEvidenceSource,
                this.WhenAny(
                    vm => vm.SelectedEvidenceSourceViewModel,
                    _ => SelectedEvidenceSourceViewModel != default
                    )
                );

            DeleteObservations = ReactiveCommand.Create(
                HandleDeleteObservations,
                this.WhenAny(
                    vm => vm.SelectedObservationsViewModel,
                    _ => SelectedObservationsViewModel != default
                    )
                );

            _reactiveSafeInvoke = appService.GetReactiveSafeInvoke();

            _subscriptions = new CompositeDisposable(
                this
                .ObservableForProperty(vm => vm.SelectedEvidenceSourceViewModel)
                .Subscribe(_reactiveSafeInvoke.SuspendAndInvoke <object>(ObserveSelectedEvidenceSourceViewModel)),
                _moduleState
                .ObservableForProperty(ms => ms.SelectedEvidenceSource)
                .Subscribe(_reactiveSafeInvoke.SuspendAndInvoke <object>(ObserveModuleStateSelectedEvidenceSource)),
                _evidence.EvidenceSourcesChanges
                .Subscribe(
                    _reactiveSafeInvoke.SuspendAndInvoke <(SimEvidenceSource, ObservableQualifier)>(ObserveEvidenceSourceChanges)
                    )
                );

            EvidenceSourceViewModels = new ObservableCollection <IEvidenceSourceViewModel>(
                _evidence.EvidenceSources.Map(
                    es => new EvidenceSourceViewModel(es.ID, es.Name, es.Description)
                    )
                );
        }
Beispiel #4
0
 public static void Save(ModuleState instance, Simulation simulation, ISimEvidence evidence)
 {
     simulation.SavePrivateData(
         new _ModuleStateDTO
     {
         SelectedObservationsReferences = instance.SelectedObservations
                                          .Map(o => evidence.GetReference(o))
                                          .ToArray(),
         SelectedSubject = instance.SelectedObservationsSet
                           .MatchUnsafe <string?>(os => os.Subject, () => default),
         SelectedEvidenceSourceReference = instance.SelectedEvidenceSource
                                           .MatchUnsafe <string?>(es => es.GetReference(), () => default),
         AutoApplyParameterSharedState    = instance.AutoApplyParameterSharedState,
         AutoShareParameterSharedState    = instance.AutoShareParameterSharedState,
         AutoApplyElementSharedState      = instance.AutoApplyElementSharedState,
         AutoShareElementSharedState      = instance.AutoShareElementSharedState,
         AutoApplyObservationsSharedState = instance.AutoApplyObservationsSharedState,
         AutoShareObservationsSharedState = instance.AutoShareObservationsSharedState
     },