Ejemplo n.º 1
0
 public void ConvertFromSerializationFormat()
 {
     foreach (LoadMetric loadMetric in this.Metrics)
     {
         long value;
         this.values.TryRemove(loadMetric, out value);
         foreach (LoadMetric loadMetric2 in LoadMetricRepository.DefaultMetrics)
         {
             if (loadMetric.Name.Equals(loadMetric2.Name))
             {
                 this[loadMetric2] = value;
             }
         }
         BandData bandData = loadMetric as BandData;
         if (bandData != null)
         {
             this[bandData.Band] = value;
         }
         else
         {
             Band band = loadMetric as Band;
             if (band != null)
             {
                 this[band] = value;
             }
         }
     }
 }
Ejemplo n.º 2
0
 public void ConvertToSerializationMetrics(bool convertBandToBandData)
 {
     foreach (LoadMetric loadMetric in this.Metrics)
     {
         long num;
         this.values.TryRemove(loadMetric, out num);
         Band       band = loadMetric as Band;
         LoadMetric metric;
         if (band != null)
         {
             if (convertBandToBandData)
             {
                 metric = new BandData(band)
                 {
                     TotalWeight = (int)num
                 };
             }
             else
             {
                 metric = band;
             }
         }
         else
         {
             metric = new LoadMetric(loadMetric.Name, loadMetric.IsSize);
         }
         this[metric] = num;
     }
 }
Ejemplo n.º 3
0
 private async void OnBandDataReceived(BandData data)
 => await WardAsync(async() =>
 {
     await TelemetryService.Default.SendAsync(data);
     HeartRate          = data.HeartRate;
     HeartRateTimestamp = data.Timestamp;
 },
                    "Error sending heart rate to telemetry service!");
Ejemplo n.º 4
0
        public BandData GetBandData(Band band)
        {
            Band     left     = this.Metrics.OfType <Band>().FirstOrDefault((Band bd) => object.Equals(band, bd));
            BandData bandData = new BandData(band)
            {
                TotalWeight = 0
            };

            if (left == null)
            {
                return(bandData);
            }
            bandData.TotalWeight = (int)this[band];
            return(bandData);
        }
        private async Task SetupBand()
        {
            try
            {
                // Loads in any previously saved health data
                this.RecordedData = await LoadRecordedData();
            }
            catch (Exception)
            {
                this.RecordedData = new List <BandData>();
            }

            // Gets the first available Band from the device
            this.bandInfo = (await BandClientManager.Instance.GetBandsAsync()).FirstOrDefault();

            if (this.bandInfo == null)
            {
                throw new InvalidOperationException("No Microsoft Band available to connect to.");
            }

            var isConnecting = false;

            using (new DisposableAction(() => isConnecting = true, () => isConnecting = false))
            {
                // Attempts to connect to the Band
                this.bandClient = await BandClientManager.Instance.ConnectAsync(this.bandInfo);

                if (this.bandClient == null)
                {
                    throw new InvalidOperationException("Could not connect to the Microsoft Band available.");
                }

                // This sample uses the Heart Rate sensor so the user must have granted access prior to the BG task running
                if (this.bandClient.SensorManager.HeartRate.GetCurrentUserConsent() != UserConsent.Granted)
                {
                    throw new InvalidOperationException(
                              "User has not granted access to the Microsoft Band heart rate sensor.");
                }

                this.ResetReceivedFlags();

                this.bandData = new BandData();

                await this.SetupSensors();
            }
        }
Ejemplo n.º 6
0
 public BandCore(BandData bandData)
 {
     _data = bandData;
 }
Ejemplo n.º 7
0
 public BandCore()
 {
     _data = new BandData(new Settings());
 }