コード例 #1
0
ファイル: Band.cs プロジェクト: niuware/MSBandViewer
        public Band()
        {
            data = new SensorData();
            status = BandSyncStatus.UNKNOWN;
            SessionTrackInterval = 1000; // in milliseconds

            sessionData = new Dictionary<DateTime, SensorData>();

            sessionTrackIntervalTimer = new Timer(sessionTrackIntervalTimer_Callback, null, Timeout.Infinite, SessionTrackInterval);
        }
コード例 #2
0
        /// <summary>
        /// Update the dashboard data (band sensors, graphs, etc.)
        /// </summary>
        private async void UpdateDashboard()
        {
            if (band.Status == BandSyncStatus.SYNCED_TERMINATED || band.Status == BandSyncStatus.SYNCED_SUSCRIBING)
            {
                return;
            }

            BandData = band.Data;

            if (band.HeartRateLocked == HeartRateQuality.Locked)
            {
                MaxHeartBpm = (BandData.heartRate > MaxHeartBpm) ? BandData.heartRate : MaxHeartBpm;
                MinHeartBpm = (MinHeartBpm < BandData.heartRate) ? MinHeartBpm : BandData.heartRate;
            }

            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                heartRateStatusTextBlock.Text = band.HeartRateLocked.ToString();

                if (band.HeartRateLocked == HeartRateQuality.Locked)
                {
                    heartRatePath.Fill = new SolidColorBrush(Windows.UI.Colors.White);

                    // Update heart beat animation according to the real heart rate
                    heartRateStoryboard.SpeedRatio = Math.Round((band.Data.heartRate / 65.0), 2);
                }
                else
                {
                    heartRatePath.Fill = new SolidColorBrush(Windows.UI.Colors.Transparent);
                    heartRateStoryboard.SpeedRatio = 1.0;
                }

                accelerometerLineGraphCanvas.UpdateValues(new double[]
                {
                    BandData.accelerometer.X,
                    BandData.accelerometer.Y,
                    BandData.accelerometer.Z,
                });

                gyroscopeLineGraphCanvas.UpdateValues(new double[]
                {
                    BandData.gyroscopeAngVel.X,
                    BandData.gyroscopeAngVel.Y,
                    BandData.gyroscopeAngVel.Z,
                });

                if (band.IsWorn)
                {
                    syncGrid.Visibility = Visibility.Collapsed;
                    startOrStopSessionButtton.IsEnabled = true;
                }
                else
                {
                    gyroscopeLineGraphCanvas.Reset();
                    accelerometerLineGraphCanvas.Reset();

                    startOrStopSessionButtton.IsEnabled = false;

                    SetSyncMessage("Waiting for band user...");
                }
            });
        }