Exemple #1
0
        protected async void AwaitChoreographer()
        {
            MeleeChoreographer = await InitChoreographer();

            //while (this.Choreographer == null)
            //    await Task.Delay(50);

            MeleeChoreographer.OnPromptCue += RespondToPromptCue;
            MeleeChoreographer.Activate();
            Speech.Say("Get ready.");
        }
Exemple #2
0
        public override bool OnKeyUp([GeneratedEnum] Keycode keyCode, KeyEvent e)
        {
            if (keyCode == Keycode.VolumeDown || keyCode == Keycode.VolumeUp)
            {
                if (_collectingData)
                {
                    lock (SelectedGestureClass)
                    {
                        // Respond to single-click events
                        if (SingleClickWatch.Elapsed < ((MeleeChoreographer == null) ? TimeSpan.FromSeconds(0.5) : TimeSpan.FromSeconds(0.2)))
                        {
                            RelayToast("Single-clicked.");
                            if (MeleeChoreographer == null)
                            {
                                AwaitChoreographer();
                            }
                            else
                            {
                                MeleeChoreographer.Deactivate();
                                Task.Delay(100).Wait();
                                MeleeChoreographer = null;
                                CurrentCue         = default(ChoreographyCue);
                                Speech.Say("Shutting down.");
                            }
                            // Either way, go no further handling this button-press (and discard the sequence unlooked-at).
                            CurrentStage.Deactivate();
                            Stopwatch.Reset();
                            _collectingData = false;
                            return(true);
                        }
                        //Log.Debug("MachineLearning", $"{keyCode} up");

                        if (MeleeChoreographer == null)
                        {
                            RelayToast("No choreographer.");
                            _collectingData = false;
                            return(true); // Long press without "Get Ready" first - ignore.
                        }

                        Task.Run(async() =>
                        {
                            await Task.Delay(250);

                            // Halt the gesture-collection stage and query it.
                            var resultData = await CurrentStage.StopAndReturnResultsAsync();
                            //RelayToast("Evaluating.");
                            var resultSeq = new Sequence <DKS>()
                            {
                                SourcePath = resultData
                            };
                            var meta           = CurrentStage.GetMetadata(GetAccelForDatapoint);
                            meta.Delay         = Delay;
                            resultSeq.Metadata = meta;
                            ResolveEndOfGesture(resultSeq);
                        });


                        //if (_userTrainingMode)
                        //{
                        //    // Halt the gesture-collection stage and query it.
                        //    var resultData = CurrentStage.StopAndReturnResults();
                        //    var resultSeq = new Sequence<DKS>() { SourcePath = resultData };
                        //    resultSeq.Metadata = CurrentStage.GetMetadata(GetAccelForDatapoint);
                        //    ResolveEndOfGesture(resultSeq);
                        //}
                        //else if (_singleMode)
                        //{
                        //    Choreographer = new Choreographer(Dataset);
                        //    Choreographer.OnSendCue += async (o, eargs) =>
                        //    {
                        //        await GimmeCue(eargs.Value);
                        //        Choreographer.Deactivate();
                        //    };
                        //    Choreographer.Activate();
                        //}
                        //else if (!_seriesModeActive)
                        //{
                        //    Choreographer = new Choreographer(Dataset);
                        //    Choreographer.OnSendCue += async (o, eargs) => { await GimmeCue(eargs.Value); };
                        //    Choreographer.Activate();
                        //}
                        //else
                        //{
                        //    Choreographer?.Deactivate();
                        //}

                        return(true); // Handled it, thanks.
                    }
                }
            }
            return(base.OnKeyUp(keyCode, e));
        }