Exemple #1
0
        public BioDataViewModel(ICybaticaHandler cybaticaHandler = null)
        {
            _cybaticaHandler = cybaticaHandler ?? Locator.Current.GetService <ICybaticaHandler>();

            this.WhenAnyValue(x => x._cybaticaHandler.Acceleration)
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .Sample(TimeSpan.FromSeconds(1))
            .ObserveOn(RxApp.MainThreadScheduler)
            .ToPropertyEx(this, x => x.Acceleration);

            this.WhenAnyValue(x => x._cybaticaHandler.Bvp)
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .Sample(TimeSpan.FromSeconds(1))
            .ObserveOn(RxApp.MainThreadScheduler)
            .ToPropertyEx(this, x => x.Bvp);

            this.WhenAnyValue(x => x._cybaticaHandler.Gsr)
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .Sample(TimeSpan.FromSeconds(1))
            .ObserveOn(RxApp.MainThreadScheduler)
            .ToPropertyEx(this, x => x.Gsr);

            this.WhenAnyValue(x => x._cybaticaHandler.Hr)
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .Sample(TimeSpan.FromSeconds(1))
            .ObserveOn(RxApp.MainThreadScheduler)
            .ToPropertyEx(this, x => x.Hr);

            this.WhenAnyValue(x => x._cybaticaHandler.Ibi)
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .Sample(TimeSpan.FromSeconds(1))
            .ObserveOn(RxApp.MainThreadScheduler)
            .ToPropertyEx(this, x => x.Ibi);

            this.WhenAnyValue(x => x._cybaticaHandler.Temperature)
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .Sample(TimeSpan.FromSeconds(1))
            .ObserveOn(RxApp.MainThreadScheduler)
            .ToPropertyEx(this, x => x.Temperature);

            ChartCommand = ReactiveCommand.CreateFromTask(async() => { await Shell.Current.GoToAsync("bioChart"); });
        }
        public OcsChartViewModel(ICybaticaHandler cybaticaHandler = null)
        {
            _cybaticaHandler = cybaticaHandler ?? Locator.Current.GetService <ICybaticaHandler>();

            var ocs = _cybaticaHandler.OcsConnectable
                      .ObserveOn(RxApp.MainThreadScheduler)
                      .Bind(out _ocs)
                      .Subscribe();

            var nnMean = _cybaticaHandler.NnMeanConnectable
                         .ObserveOn(RxApp.MainThreadScheduler)
                         .Bind(out _nnMean)
                         .Subscribe();

            var meanEda = _cybaticaHandler.MeanEdaConnectable
                          .ObserveOn(RxApp.MainThreadScheduler)
                          .Bind(out _meanEda)
                          .Subscribe();

            _cleanUp = new CompositeDisposable(ocs, nnMean, meanEda);
        }
Exemple #3
0
        public BioDataChartViewModel(ICybaticaHandler cybaticaHandler = null)
        {
            _cybaticaHandler = cybaticaHandler ?? Locator.Current.GetService <ICybaticaHandler>();

            var bvp = _cybaticaHandler.BvpConnectable
                      .ObserveOn(RxApp.MainThreadScheduler)
                      .Bind(out _bvp)
                      .Subscribe();

            var gsr = _cybaticaHandler.GsrConnectable
                      .ObserveOn(RxApp.MainThreadScheduler)
                      .Bind(out _gsr)
                      .Subscribe();

            var temperature = _cybaticaHandler.TemperatureConnectable
                              .ObserveOn(RxApp.MainThreadScheduler)
                              .Bind(out _temperature)
                              .Subscribe();

            _cleanUp = new CompositeDisposable(bvp, gsr, temperature);
        }
Exemple #4
0
        public OcsViewModel(ICybaticaHandler cybaticaHandler = null)
        {
            _cybaticaHandler = cybaticaHandler ?? Locator.Current.GetService <ICybaticaHandler>();

            this.WhenAnyValue(x => x._cybaticaHandler.Ocs)
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .Sample(TimeSpan.FromSeconds(1))
            .ObserveOn(RxApp.MainThreadScheduler)
            .ToPropertyEx(this, x => x.Ocs);

            this.WhenAnyValue(x => x._cybaticaHandler.NnMean)
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .Sample(TimeSpan.FromSeconds(1))
            .ObserveOn(RxApp.MainThreadScheduler)
            .ToPropertyEx(this, x => x.NnMean);

            this.WhenAnyValue(x => x._cybaticaHandler.SdNn)
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .Sample(TimeSpan.FromSeconds(1))
            .ObserveOn(RxApp.MainThreadScheduler)
            .ToPropertyEx(this, x => x.SdNn);

            this.WhenAnyValue(x => x._cybaticaHandler.MeanEda)
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .Sample(TimeSpan.FromSeconds(1))
            .ObserveOn(RxApp.MainThreadScheduler)
            .ToPropertyEx(this, x => x.MeanEda);

            this.WhenAnyValue(x => x._cybaticaHandler.PeakEda)
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .Sample(TimeSpan.FromSeconds(1))
            .ObserveOn(RxApp.MainThreadScheduler)
            .ToPropertyEx(this, x => x.PeakEda);

            ChartCommand = ReactiveCommand.CreateFromTask(async() => { await Shell.Current.GoToAsync("ocsChart"); });
        }
Exemple #5
0
        public HomeViewModel(ICybaticaHandler cybaticaHandler = null)
        {
            _cybaticaHandler = cybaticaHandler ?? Locator.Current.GetService <ICybaticaHandler>();

            _cleanUp = this.WhenAnyValue(x => x._cybaticaHandler.ElapsedTime)
                       .SubscribeOn(RxApp.TaskpoolScheduler)
                       .ObserveOn(RxApp.MainThreadScheduler)
                       .ToPropertyEx(this, x => x.ElapsedTime);

            var canCaptureBaseExecute = this.WhenAnyValue(x => x.IsConnecting, x => x.IsCapturing,
                                                          (x, y) => x && !y);

            StartBaseSessionCommand = ReactiveCommand.CreateFromTask(
                async() => await StartSessionAsync(SessionType.Base), canCaptureBaseExecute);

            var canCaptureDataExecute = this.WhenAnyValue(x => x.IsConnecting, x => x.IsBaseStored, x => x.IsCapturing,
                                                          (x, y, z) => x && y && !z);

            StartDataSessionCommand = ReactiveCommand.CreateFromTask(
                async() => await StartSessionAsync(SessionType.Data), canCaptureDataExecute);

            var canStopExecute = this.WhenAnyValue(x => x.IsConnecting, x => x.IsCapturing,
                                                   (x, y) => x && y);

            StopSessionCommand = ReactiveCommand.CreateFromTask(StopSessionAsync, canStopExecute);

            var canConnectExecute = this.WhenAnyValue(x => x.IsConnecting, x => !x);

            ConnectCommand = ReactiveCommand.CreateFromTask(ConnectAsync, canConnectExecute);

            var canDisconnectExecute = this.WhenAnyValue(x => x.IsConnecting);

            DisconnectCommand = ReactiveCommand.CreateFromTask(DisconnectAsync, canDisconnectExecute);

            AboutCommand = ReactiveCommand.CreateFromTask(async() => { await Shell.Current.GoToAsync("homeAbout"); });
        }