コード例 #1
1
    public void should_report_the_rate_of_change() {
      var minute = TimeSpan.FromMinutes(1);
      var config = new MetricConfig("counter1");
      var clock = new StepClock(TimeSpan.FromMinutes(1));
      var context = new MetricContext(clock);
      var counter = new StepCounter(config, context);
      
      clock.TickNow(1);
      counter.Increment(10);

      Measure measure = Testing.Sync<Measure>(counter, counter.GetMeasure,
        counter.context_);
      Assert.That(measure.Value, Is.EqualTo(10d/minute.Ticks));
      
      counter.OnStep();
      clock.TickNow(1);
      counter.Increment(10);

      measure = Testing.Sync<Measure>(counter, counter.GetMeasure,
        counter.context_);
      Assert.That(measure.Value, Is.EqualTo(10d/minute.Ticks),
        "Should report the same value as previously, since the rate was the same.");
      
      counter.OnStep();
      clock.TickNow(1);
      counter.Increment(20);

      measure = Testing.Sync<Measure>(counter, counter.GetMeasure,
        counter.context_);
      Assert.That(measure.Value, Is.EqualTo(10d/minute.Ticks*2),
        "Should report the double of the previously value, since the rate was doubled.");
    }
コード例 #2
0
        /// <summary>
        /// Gets number of steps for current day
        /// </summary>
        /// <returns><c>true</c> if steps were successfully fetched, <c>false</c> otherwise</returns>
        private async Task <bool> GetStepsAsync()
        {
            StepCounter stepCounter = null;

            try
            {
                stepCounter = await StepCounter.GetDefaultAsync();

                _steps = await stepCounter.GetStepCountForRangeAsync(
                    DateTime.Now.Date,
                    DateTime.Now - DateTime.Now.Date);
            }
            catch (Exception e)
            {
                _lastError = SenseHelper.GetSenseError(e.HResult);
                return(false);
            }
            finally
            {
                if (stepCounter != null)
                {
                    stepCounter.Dispose();
                }
            }
            return(true);
        }
コード例 #3
0
        public void should_report_the_rate_of_change()
        {
            var minute  = TimeSpan.FromMinutes(1);
            var config  = new MetricConfig("counter1");
            var clock   = new StepClock(TimeSpan.FromMinutes(1));
            var context = new MetricContext(clock);
            var counter = new StepCounter(config, context);

            clock.TickNow(1);
            counter.Increment(10);

            Measure measure = Testing.Sync <Measure>(counter, counter.GetMeasure,
                                                     counter.context_);

            Assert.That(measure.Value, Is.EqualTo(10d / minute.Ticks));

            counter.OnStep();
            clock.TickNow(1);
            counter.Increment(10);

            measure = Testing.Sync <Measure>(counter, counter.GetMeasure,
                                             counter.context_);
            Assert.That(measure.Value, Is.EqualTo(10d / minute.Ticks),
                        "Should report the same value as previously, since the rate was the same.");

            counter.OnStep();
            clock.TickNow(1);
            counter.Increment(20);

            measure = Testing.Sync <Measure>(counter, counter.GetMeasure,
                                             counter.context_);
            Assert.That(measure.Value, Is.EqualTo(10d / minute.Ticks * 2),
                        "Should report the double of the previously value, since the rate was doubled.");
        }
コード例 #4
0
ファイル: StepAction.cs プロジェクト: Gameford/Shematech
 public StepAction(ActionType type, IInteract subject, Point position)
 {
     Type        = type;
     Subject     = subject;
     Position    = position;
     CurrentStep = StepCounter.GetInstance().GetCounter();
 }
コード例 #5
0
        /// <summary>
        /// Makes sure necessary settings are enabled in order to use SensorCore
        /// </summary>
        /// <returns>Asynchronous task</returns>
        public static async Task ValidateSettingsAsync()
        {
            if (await StepCounter.IsSupportedAsync())
            {
                // Starting from version 2 of Motion data settings Step counter and Acitivity monitor are always available. In earlier versions system
                // location setting and Motion data had to be enabled.
                MotionDataSettings settings = await SenseHelper.GetSettingsAsync();

                if (settings.Version < 2)
                {
                    if (!settings.LocationEnabled)
                    {
                        MessageDialog dlg = new MessageDialog("In order to count steps you need to enable location in system settings. Do you want to open settings now? If not, application will exit.", "Information");
                        dlg.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async(cmd) => await SenseHelper.LaunchLocationSettingsAsync())));
                        dlg.Commands.Add(new UICommand("No", new UICommandInvokedHandler((cmd) => { Application.Current.Exit(); })));
                        await dlg.ShowAsync();
                    }
                    if (!settings.PlacesVisited)
                    {
                        MessageDialog dlg = new MessageDialog("In order to count steps you need to enable Motion data in Motion data settings. Do you want to open settings now? If not, application will exit.", "Information");
                        dlg.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async(cmd) => await SenseHelper.LaunchSenseSettingsAsync())));
                        dlg.Commands.Add(new UICommand("No", new UICommandInvokedHandler((cmd) => { Application.Current.Exit(); })));
                        await dlg.ShowAsync();
                    }
                }
            }
        }
コード例 #6
0
ファイル: OEMTask.cs プロジェクト: sorryb/UWP
        /// <summary>
        /// Gets number of steps for current day
        /// </summary>
        /// <returns><c>true</c> if steps were successfully fetched, <c>false</c> otherwise</returns>
        private async Task <bool> GetStepsAsync()
        {
            // First try the pedometer
            try
            {
                var readings = await Pedometer.GetSystemHistoryAsync(DateTime.Now.Date, DateTime.Now - DateTime.Now.Date);

                _steps = StepCountData.FromPedometerReadings(readings);
                return(true);
            }
            catch (Exception)
            {
                // Continue to the fallback
            }

            // Fall back to using Lumia Sensor Core.
            IStepCounter stepCounter = null;

            try
            {
                //var qualifiers = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().QualifierValues;

                if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Phone)
                {
                    stepCounter = await StepCounter.GetDefaultAsync();

                    StepCount count = await stepCounter.GetStepCountForRangeAsync(DateTime.Now.Date, DateTime.Now - DateTime.Now.Date);

                    _steps = StepCountData.FromLumiaStepCount(count);
                }
                else
                {
                    var obj = await SenseRecording.LoadFromFileAsync("Simulations\\short recording.txt");

                    if (!await CallSensorCoreApiAsync(async() => {
                        stepCounter = await StepCounterSimulator.GetDefaultAsync(obj, DateTime.Now - TimeSpan.FromHours(12));
                        StepCount count = await stepCounter.GetStepCountForRangeAsync(DateTime.Now.Date, DateTime.Now - DateTime.Now.Date);
                        _steps = StepCountData.FromLumiaStepCount(count);
                    }))
                    {
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                _lastError = SenseHelper.GetSenseError(e.HResult);
                return(false);
            }
            finally
            {
                if (stepCounter != null && typeof(StepCounter) == stepCounter.GetType())
                {
                    ((StepCounter)stepCounter).Dispose();
                }
            }
            return(true);
        }
コード例 #7
0
ファイル: NotGreedyPathFinder.cs プロジェクト: kajuga/CSU
        private static List <Unit> stepOvule(Diagramm dgrm, Dictionary <Gap, double> mass, Unit start, Unit end)
        {
            var clear = dgrm.Units.ToList();
            var way   = new Dictionary <Unit, StepCounter>();

            way[start] = new StepCounter {
                Price = 0, Previous = null
            };

            while (true)
            {
                Unit discover    = null;
                var  betterOffer = double.PositiveInfinity;
                foreach (var v in clear)
                {
                    if (way.ContainsKey(v) && way[v].Price < betterOffer)
                    {
                        betterOffer = way[v].Price;
                        discover    = v;
                    }
                }

                if (discover == null)
                {
                    return(null);
                }
                if (discover == end)
                {
                    break;
                }

                foreach (var e in discover.IncidentEdges.Where(z => z.From == discover))
                {
                    var currentPrice = way[discover].Price + mass[e];
                    var nextNode     = e.GetUnit(discover);
                    if (!way.ContainsKey(nextNode) || way[nextNode].Price > currentPrice)
                    {
                        way[nextNode] = new StepCounter {
                            Previous = discover, Price = currentPrice
                        }
                    }
                    ;
                }

                clear.Remove(discover);
            }

            var total = new List <Unit>();

            while (end != null)
            {
                total.Add(end);
                end = way[end].Previous;
            }
            total.Reverse();
            return(total);
        }
コード例 #8
0
 /// <summary>
 /// Initializes StepCounter
 /// </summary>
 private async Task InitializeSensorAsync()
 {
     if (_stepCounter == null)
     {
         await CallSensorCoreApiAsync(async() => { _stepCounter = await StepCounter.GetDefaultAsync(); });
     }
     else
     {
         await _stepCounter.ActivateAsync();
     }
     _sensorActive = true;
 }
コード例 #9
0
        /// <summary>
        /// Check motion data settings
        /// </summary>
        private async void CheckMotionDataSettings()
        {
            if (!(await StepCounter.IsSupportedAsync()))
            {
                MessageDialog dlg = new MessageDialog("Unfortunately this device does not support step counting");
                await dlg.ShowAsync();

                Application.Current.Exit();
            }
            else
            {
                // MotionDataSettings settings = await SenseHelper.GetSettingsAsync();
                // Starting from version 2 of Motion data settings Step counter and Acitivity monitor are always available. In earlier versions system
                // location setting and Motion data had to be enabled.
                uint apiSet = await SenseHelper.GetSupportedApiSetAsync();

                MotionDataSettings settings = await SenseHelper.GetSettingsAsync();

                if (apiSet > 2)
                {
                    if (!settings.LocationEnabled)
                    {
                        MessageDialog dlg = new MessageDialog("In order to count steps you need to enable location in system settings. Do you want to open settings now?", "Information");
                        dlg.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async(cmd) => await SenseHelper.LaunchLocationSettingsAsync())));
                        dlg.Commands.Add(new UICommand("No"));
                        await dlg.ShowAsync();
                    }
                    if (!settings.PlacesVisited)
                    {
                        MessageDialog dlg = null;
                        if (settings.Version < 2)
                        {
                            dlg = new MessageDialog("In order to count steps you need to enable Motion data collection in Motion data settings. Do you want to open settings now?", "Information");
                        }
                        else
                        {
                            dlg = new MessageDialog("In order to collect and view visited places you need to enable Places visited in Motion data settings. Do you want to open settings now? if no, application will exit", "Information");
                        }
                        dlg.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async(cmd) => await SenseHelper.LaunchSenseSettingsAsync())));
                        dlg.Commands.Add(new UICommand("No", new UICommandInvokedHandler((cmd) => { Application.Current.Exit(); })));
                        await dlg.ShowAsync();
                    }
                }
            }
        }
コード例 #10
0
    private void Awake()
    {
        MM = FindObjectOfType <MonsterManager>();
        M  = FindObjectOfType <Monster>();
        SUI.StatusShown        = false;
        SUI.tempHP             = SUI.tempSTR = SUI.tempSPD =
            SUI.pointUsedTotal = SUI.pointUsedHP = SUI.pointUsedSTR = SUI.pointUsedSPD = 0;

        AS = FindObjectOfType <AudioScript>();



        if (Application.loadedLevelName == "OpeningMenu")
        {
            IntroAlreadyHappen = PlayerPrefs.GetInt("Intro", 0);
            PlayOP();
        }
        else if (Application.loadedLevelName == "GameScreen")
        {
            PlayGS();
        }

        if (Application.loadedLevelName == "GameScreen")
        {
            tempPoint = ExpManager.instance.POINT;

            if (!PlayerPrefs.HasKey("isChosen"))
            {
                mainCanvas.SetActive(false);
                PreGame.SetActive(true);
            }
            else
            {
                PreGame.SetActive(false);
            }
        }

        if (Application.loadedLevelName == "StepCounter")
        {
            pb = FindObjectOfType <ParallaxBackground>();
            sc = FindObjectOfType <StepCounter>();
        }
    }
コード例 #11
0
        public async void isSupported(string options)
        {
            PluginResult result = new PluginResult(PluginResult.Status.OK);

            result.KeepCallback = true;

            try
            {
                bool available = await StepCounter.IsSupportedAsync();

                result.Message = JsonHelper.Serialize(available);
                DispatchCommandResult(result);
            }
            catch (Exception ex)
            {
                result.Message = JsonHelper.Serialize(new { error = "isSupported", message = ex.Message });
                DispatchCommandResult(result);
            }
        }
コード例 #12
0
        /// <summary>
        /// Makes sure necessary settings are enabled in order to use SensorCore
        /// </summary>
        /// <returns>Asynchronous task</returns>
        public async Task ValidateSettingsAsync()
        {
            if (!await StepCounter.IsSupportedAsync())
            {
                MessageBoxResult dlg = MessageBox.Show("Unfortunately this device does not support step counting");
                Application.Current.Terminate();
            }
            else
            {
                // Starting from version 2 of Motion data settings Step counter and Acitivity monitor are always available. In earlier versions system
                // location setting and Motion data had to be enabled.
                MotionDataSettings settings = await SenseHelper.GetSettingsAsync();

                if (settings.Version < 2)
                {
                    if (!settings.LocationEnabled)
                    {
                        MessageBoxResult dlg = MessageBox.Show("In order to count steps you need to enable location in system settings. Do you want to open settings now? If not, application will exit.", "Information", MessageBoxButton.OKCancel);
                        if (dlg == MessageBoxResult.OK)
                        {
                            await SenseHelper.LaunchLocationSettingsAsync();
                        }
                        else
                        {
                            Application.Current.Terminate();
                        }
                    }
                    if (!settings.PlacesVisited)
                    {
                        MessageBoxResult rc = MessageBox.Show("In order to count steps you need to enable Motion data collection in Motion data settings. Do you want to open settings now? If not, application will exit.", "Information", MessageBoxButton.OKCancel);
                        if (rc == MessageBoxResult.OK)
                        {
                            await SenseHelper.LaunchSenseSettingsAsync();
                        }
                        else
                        {
                            Application.Current.Terminate();
                        }
                    }
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// Gets number of steps for current day
        /// </summary>
        /// <returns><c>true</c> if steps were successfully fetched, <c>false</c> otherwise</returns>
        private async Task <bool> GetStepsAsync()
        {
            // First try the pedometer
            try
            {
                var readings = await Pedometer.GetSystemHistoryAsync(DateTime.Now.Date, DateTime.Now - DateTime.Now.Date);

                _steps = StepCountData.FromPedometerReadings(readings);
                return(true);
            }
            catch (Exception)
            {
                // Continue to the fallback
            }

            // Fall back to using Lumia Sensor Core.
            StepCounter stepCounter = null;

            try
            {
                stepCounter = await StepCounter.GetDefaultAsync();

                StepCount count = await stepCounter.GetStepCountForRangeAsync(
                    DateTime.Now.Date,
                    DateTime.Now - DateTime.Now.Date);

                _steps = StepCountData.FromLumiaStepCount(count);
            }
            catch (Exception e)
            {
                _lastError = SenseHelper.GetSenseError(e.HResult);
                return(false);
            }
            finally
            {
                if (stepCounter != null)
                {
                    stepCounter.Dispose();
                }
            }
            return(true);
        }
コード例 #14
0
        /// <summary>
        /// Initializes sensor
        /// </summary>
        /// <returns>Asynchronous task</returns>
        private async Task Initialize()
        {
            if (!await StepCounter.IsSupportedAsync())
            {
                MessageDialog dlg = new MessageDialog("Unfortunately this device does not support step counting");
                await dlg.ShowAsync();
            }
            else
            {
                MotionDataSettings settings = await SenseHelper.GetSettingsAsync();

                // Starting from version 2 of Motion data settings Step counter and Acitivity monitor are always available. In earlier versions system
                // location setting and Motion data had to be enabled.
                if (settings.Version < 2)
                {
                    if (!settings.LocationEnabled)
                    {
                        MessageDialog dlg = new MessageDialog("In order to count steps you need to enable location in system settings. Do you want to open settings now?", "Information");
                        dlg.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async(cmd) => await SenseHelper.LaunchLocationSettingsAsync())));
                        dlg.Commands.Add(new UICommand("No"));
                        await dlg.ShowAsync();
                    }
                    else if (!settings.PlacesVisited)
                    {
                        MessageDialog dlg = new MessageDialog("In order to count steps you need to enable Motion data collection in Motion data settings. Do you want to open settings now?", "Information");
                        dlg.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async(cmd) => await SenseHelper.LaunchSenseSettingsAsync())));
                        dlg.Commands.Add(new UICommand("No"));
                        await dlg.ShowAsync();
                    }
                }
            }

            if (!await CallSenseApiAsync(async() =>
            {
                _stepCounter = await StepCounter.GetDefaultAsync();
            }))
            {
                Application.Current.Exit();
            }
            await SetSelectedDayAsync(_selectedDay);
        }
コード例 #15
0
ファイル: Pedometer.cs プロジェクト: Grezzy/pedometer
        public async void initialize(string options)
        {
            PluginResult result = new PluginResult(PluginResult.Status.OK);
            result.KeepCallback = true;

            try
            {
                if (await StepCounter.IsSupportedAsync())
                {
                    stepCounter = await StepCounter.GetDefaultAsync();
                    isReady = true;
                }

                DispatchCommandResult(result);
            }
            catch (Exception ex)
            {
                result.Message = JsonHelper.Serialize(new { error = "init", message = ex.Message });
                DispatchCommandResult(result);
            }
        }
コード例 #16
0
        public ControlWordBitField GetControlWord(bool init = false)
        {
            // when computer is reset it already has step 0 loaded. so next time it gets control word it will step to the next step, unless it is initializing
            if (!init)
            {
                StepCounter.SetData();        // Increment Step counter by setting its value to 0x0000. It doesnt not affect its data "Load" signal is inactive
            }
            if ((Decoder & 0x20) == 0)
            {
                StepCounter.Reset();                        // if the decoded output is 0x00100000 then it reached step 5 and needs to reset
            }
            //there are better ways, but this mirrors Ben Eater's implementation

            //uCode address is defined by [FlagValue][InstructionValue][StepValue]
            //Get the uCode address
            byte FlagValue        = (byte)(FlagsRegister.Data & 0x03);
            byte InstructionValue = (byte)((InstructionRegister.Data & 0xF0) >> 4);
            byte StepValue        = (byte)(StepCounter.Data & 0x07);

            return((ControlWordBitField)uCode[FlagValue, InstructionValue, StepValue]); //return uCode
        }
コード例 #17
0
        private async Task InitializeSensorAsync()
        {
            Exception failure = null;

            if (!await StepCounter.IsSupportedAsync())
            {
                MessageBox.Show(
                    "Your device doesn't support Motion Data. Application will be closed",
                    "Information", MessageBoxButton.OK);
                Application.Current.Terminate();
            }

            try
            {
                _stepCounter = await StepCounter.GetDefaultAsync();
            }
            catch (Exception e)
            {
                failure = e;
            }

            if (failure != null)
            {
                switch (SenseHelper.GetSenseError(failure.HResult))
                {
                case SenseError.LocationDisabled:
                case SenseError.SenseDisabled:
                    NavigationService.Navigate(new Uri("/ActivateSensorCore;component/Pages/ActivateSensorCore.xaml", UriKind.Relative));
                    break;

                default:
                    throw (failure);
                }
            }
            else
            {
                await _stepCounter.ActivateAsync();
                await UpdateModelAsync();
            }
        }
コード例 #18
0
        public MainPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;

            Window.Current.VisibilityChanged += async(oo, ee) =>
            {
                if (ee.Visible)
                {
                    if (await CallSensorcoreApiAsync(async() =>
                    {
                        if (_stepCounter == null)
                        {
                            // Get sensor instance if needed...
                            _stepCounter = await StepCounter.GetDefaultAsync();
                        }
                        else
                        {
                            // ... otherwise just activate it
                            await _stepCounter.ActivateAsync();
                        }
                    }))
                    {
                        // Display current reading whenever application is brought to foreground
                        await ShowCurrentReading();
                    }
                }
                else
                {
                    // Sensor needs to be deactivated when application is put to background
                    if (_stepCounter != null)
                    {
                        await CallSensorcoreApiAsync(async() => await _stepCounter.DeactivateAsync());
                    }
                }
            };
        }
コード例 #19
0
        public async void initialize(string options)
        {
            PluginResult result = new PluginResult(PluginResult.Status.OK);

            result.KeepCallback = true;

            try
            {
                if (await StepCounter.IsSupportedAsync())
                {
                    stepCounter = await StepCounter.GetDefaultAsync();

                    isReady = true;
                }

                DispatchCommandResult(result);
            }
            catch (Exception ex)
            {
                result.Message = JsonHelper.Serialize(new { error = "init", message = ex.Message });
                DispatchCommandResult(result);
            }
        }
コード例 #20
0
ファイル: MainPage.xaml.cs プロジェクト: sumitkm/recorder
 /// <summary>
 /// Initialize SensorCore 
 /// </summary>
 /// <param name="rec">Recording instance</param>
 /// <param name="type">Sense type</param>
 /// <returns>Asynchronous task</returns>
 private async Task HandleSensorActivity(Recording rec, SenseType type)
 {           
     if (rec.Recorder == null)
     {
         if (await CallSensorcoreApiAsync(async () =>
         {
             switch (type)
             {
                 case SenseType.Activity:
                     _aMonitor = await ActivityMonitor.GetDefaultAsync();
                     break;
                 case SenseType.Places:
                     _pMonitor = await PlaceMonitor.GetDefaultAsync();
                     break;
                 case SenseType.Route:
                     _rTracker = await TrackPointMonitor.GetDefaultAsync();
                     break;
                 case SenseType.Steps:
                     _sCounter = await StepCounter.GetDefaultAsync();
                     break;
             }
         }))
         {
             Debug.WriteLine("Recorder initialized.");
             switch (type)
             {
                 case SenseType.Activity:
                     rec.Recorder = new SenseRecorder(_aMonitor);
                     break;
                 case SenseType.Places:
                     rec.Recorder = new SenseRecorder(_pMonitor);
                     break;
                 case SenseType.Route:
                     rec.Recorder = new SenseRecorder(_rTracker);
                     break;
                 case SenseType.Steps:
                     rec.Recorder = new SenseRecorder(_sCounter);
                     break;
             }
         }
         else return;
     }
     if (rec.Recorder == null)
         return;
     else
     {
         await ActivateAsync();
         switch (rec.ItemState)
         {
             case Status.Recording:
                 await rec.Recorder.StartAsync();
                 break;
             case Status.Stopped:
                 await rec.Recorder.StopAsync();
                 break;
             case Status.Empty:
                 await rec.Recorder.GetRecording().SaveAsync();
                 break;
         }
     }
 }
コード例 #21
0
        /// <summary>
        /// Initialize SensorCore
        /// </summary>
        /// <param name="rec">Recording instance</param>
        /// <param name="type">Sense type</param>
        /// <returns>Asynchronous task</returns>
        private async Task HandleSensorActivity(Recording rec, SenseType type)
        {
            if (rec.Recorder == null)
            {
                if (await CallSensorcoreApiAsync(async() =>
                {
                    switch (type)
                    {
                    case SenseType.Activity:
                        _aMonitor = await ActivityMonitor.GetDefaultAsync();
                        break;

                    case SenseType.Places:
                        _pMonitor = await PlaceMonitor.GetDefaultAsync();
                        break;

                    case SenseType.Route:
                        _rTracker = await TrackPointMonitor.GetDefaultAsync();
                        break;

                    case SenseType.Steps:
                        _sCounter = await StepCounter.GetDefaultAsync();
                        break;
                    }
                }))
                {
                    Debug.WriteLine("Recorder initialized.");
                    switch (type)
                    {
                    case SenseType.Activity:
                        rec.Recorder = new SenseRecorder(_aMonitor);
                        break;

                    case SenseType.Places:
                        rec.Recorder = new SenseRecorder(_pMonitor);
                        break;

                    case SenseType.Route:
                        rec.Recorder = new SenseRecorder(_rTracker);
                        break;

                    case SenseType.Steps:
                        rec.Recorder = new SenseRecorder(_sCounter);
                        break;
                    }
                }
                else
                {
                    return;
                }
            }
            if (rec.Recorder == null)
            {
                return;
            }
            else
            {
                await ActivateAsync();

                switch (rec.ItemState)
                {
                case Status.Recording:
                    await rec.Recorder.StartAsync();

                    break;

                case Status.Stopped:
                    await rec.Recorder.StopAsync();

                    break;

                case Status.Empty:
                    await rec.Recorder.GetRecording().SaveAsync();

                    break;
                }
            }
        }
コード例 #22
0
 private void Awake()
 {
     move = false;
     SC   = FindObjectOfType <StepCounter>();
 }
コード例 #23
0
 // Resetting the Control Sequencer
 public void Reset()
 {
     StepCounter.Reset();
 }
コード例 #24
0
        /// <summary>
        /// Check motion data settings
        /// </summary>
        private async void CheckMotionDataSettings()
        {
            if (!(await TrackPointMonitor.IsSupportedAsync()) || !(await PlaceMonitor.IsSupportedAsync()) || !(await StepCounter.IsSupportedAsync()) || !(await ActivityMonitor.IsSupportedAsync()))
            {
                MessageBoxResult dlg = MessageBox.Show("Unfortunately this device does not support SensorCore service");
                Application.Current.Terminate();
            }
            else
            {
                uint apiSet = await SenseHelper.GetSupportedApiSetAsync();

                MotionDataSettings settings = await SenseHelper.GetSettingsAsync();

                // Devices with old location settings
                if (!settings.LocationEnabled)
                {
                    MessageBoxResult dlg = MessageBox.Show("In order to recognize activities and view visited places you need to enable location in system settings. Do you want to open settings now? if no, applicatoin will exit", "Information", MessageBoxButton.OKCancel);
                    if (dlg == MessageBoxResult.OK)
                    {
                        await SenseHelper.LaunchLocationSettingsAsync();
                    }
                }
                if (!settings.PlacesVisited)
                {
                    MessageBoxResult dlg = new MessageBoxResult();
                    if (settings.Version < 2)
                    {
                        //device which has old motion data settings.
                        //this is equal to motion data settings on/off in old system settings(SDK1.0 based)
                        dlg = MessageBox.Show("In order to count steps you need to enable Motion data collection in Motion data settings. Do you want to open settings now?", "Information", MessageBoxButton.OKCancel);
                        if (dlg == MessageBoxResult.Cancel)
                        {
                            Application.Current.Terminate();
                        }
                    }
                    else
                    {
                        dlg = MessageBox.Show("In order to recognize activities you need to 'enable Places visited' and 'DataQuality to detailed' in Motion data settings. Do you want to open settings now? ", "Information", MessageBoxButton.OKCancel);
                    }
                    if (dlg == MessageBoxResult.OK)
                    {
                        await SenseHelper.LaunchSenseSettingsAsync();
                    }
                }
                else if (apiSet >= 3 && settings.DataQuality == DataCollectionQuality.Basic)
                {
                    MessageBoxResult dlg = MessageBox.Show("In order to recognize biking activity you need to enable detailed data collection in Motion data settings. Do you want to open settings now?", "Information", MessageBoxButton.OKCancel);
                    if (dlg == MessageBoxResult.OK)
                    {
                        await SenseHelper.LaunchSenseSettingsAsync();
                    }
                }
            }
        }