Reactive-Extensions/RxToBand

Name: RxToBand

Owner: Reactive Extensions

Description: Reactive Extensions (Rx) support for the Microsoft Band

Created: 2015-02-28 00:48:43.0

Updated: 2018-04-20 14:35:36.0

Pushed: 2015-05-18 13:19:36.0

Homepage: null

Size: 504

Language: C#

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

RxToBand

Reactive Extensions (Rx) support for the Microsoft Band

Adds a few extension methods for the IBandSensor interface in the Microsoft Band SDK to enable writing reactive queries against the sensors. This is a quick preview of what's possible with Rx and the Band SDK; the APIs provided here are subject to change.

A simple example of a reactive query is shown below:

lockedHeartrate = from h in heartRate.OnlyWhenWorn(contact)
                  where h.Quality == HeartRateQuality.Locked
                  select h.HeartRate;

Thanks to the compositional nature of Rx, one can write elaborate sensor data analyses in very few lines of code. For example, computing statistics of heart rate using Window and aggregation operators:

heartrateStats = (from w in lockedHeartrate.Window(TimeSpan.FromSeconds(60),
                                                   TimeSpan.FromSeconds(10))
                  let d = w.DefaultIfEmpty()
                  from s in Observable.CombineLatest(d.Average(), d.Min(), d.Max(),
                                                     (avg, min, max) => new
                                                     {
                                                         Average = avg,
                                                         Min = min,
                                                         Max = max
                                                     })
                  select s.ToString())
                 .StartWith("Hold on for a minute...");

Have fun!


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.