Example #1
0
    void SetState(TaskState aState)
    {
        _taskState = aState;
        Debug.Log($"task state: {_taskState}");

        if (_taskState == TaskState.NotStarted)
        {
            // do nothing
        }
        else if (_taskState == TaskState.First)
        {
            var gaze      = _trial.Gaze;
            var direction = _trial.Direction;
            var slide     = _trial.Slide;
            var color     = _trial.Color;
            var runCount  = _trial.RunCount;

            _hrClient.PlayingLadyStarts(runCount);

            _player.SetClips($"{gaze}_{direction}_{slide}_{color}", runCount.ToString());
            _player.PlayFirst();
        }
        else if (_taskState == TaskState.WaitingFaceGazed)
        {
            var slide = _trial.Slide;
            _hrClient.PlayingLadyPauses(slide);

            _focusDetector.SetTrackingObject(headArea);

            Invoke(nameof(NextState), maxGazeWaitingTime);
        }
        else if (_taskState == TaskState.Second)
        {
            var gaze      = _trial.Gaze;
            var direction = _trial.Direction;
            var slide     = _trial.Slide;

            if (gaze == PlayingLadyTrial.GazeDirections.Straight.ToString().ToLower())
            {
                _hrClient.PlayingLadyStraight(slide, direction);
            }
            else if (gaze == PlayingLadyTrial.GazeDirections.Down.ToString().ToLower())
            {
                _hrClient.PlayingLadyDown(slide, direction);
            }
            else
            {
                _hrClient.PlayingLadyAverted(slide, direction);
            }

            _player.PlaySecond();
        }
        else if (_taskState == TaskState.Finished)
        {
            _focusDetector.SetTrackingObject(null);
            _player.Stop();
            _log.TrialFinished(_trials.CurrentIndex);
            _hrClient.TrialFinished();

            DisplayRestingMedia();

            Invoke(nameof(ResetState), INTER_TRIAL_MIN_DURATION);
        }
        else
        {
            throw new IndexOutOfRangeException($"SetState: task is in unsupported state: {_taskState}");
        }
    }
Example #2
0
    void SetState(TaskState aState)
    {
        _taskState = aState;
        Debug.Log($"task state: {_taskState}");

        if (_taskState == TaskState.NotStarted)
        {
            // do nothing
        }
        else if (_taskState == TaskState.AttentionGrabber)
        {
            attentionGrabber.SetActive(true);
            attentionGrabber.GetComponent <AttentionGrabber>().Run();

            _focusDetector.SetTrackingObject(attentionGrabber);
            _hrClient.AttentionGrabber();
        }
        else if (_taskState == TaskState.GazeDown)
        {
            attentionGrabber.GetComponent <AttentionGrabber>().Stop();
            attentionGrabber.SetActive(false);

            var actor = _trial.Actor;
            var head  = _trial.Head;

            _image.Show($"{actor}-{head}-down");
            // _focusDetector.SetTrackingObject(_image.faceImage);

            _hrClient.OrientationGazeDownward(actor, head);

            Invoke(nameof(NextState), gazeDownwardDuration);
        }
        else if (_taskState == TaskState.GazeUp)
        {
            var actor = _trial.Actor;
            var head  = _trial.Head;
            var gaze  = _trial.Gaze;

            _image.Show($"{actor}-{head}-up-{gaze[0]}");
            // _focusDetector.SetTrackingObject(_image.faceImage);

            if (gaze == OrientationTrial.GazeDirections.Straight.ToString().ToLower() ||
                gaze == OrientationTrial.GazeDirections.Forward.ToString().ToLower())
            {
                _hrClient.OrientationGazeStraight(actor, head);
            }
            else
            {
                _hrClient.OrientationGazeAverted(actor, head);
            }

            Invoke(nameof(NextState), gazeUpwardDuration);
        }
        else if (_taskState == TaskState.Finished)
        {
            _image.Finish();
            _log.TrialFinished(_trials.CurrentIndex);
            _hrClient.TrialFinished();

            DisplayRestingMedia();

            Invoke(nameof(ResetState), INTER_TRIAL_MIN_DURATION);
        }
        else
        {
            throw new IndexOutOfRangeException($"SetState: task is in unsupported state: {_taskState}");
        }
    }