sendEvent() public method

public sendEvent ( string eventType, string eventData ) : void
eventType string
eventData string
return void
Esempio n. 1
0
    // game state controller to switch between stages of the experiment/game
    // N.B. you should never call this directly, but via the nextStage function
    private IEnumerable nextStageInner()
    {
        // Start screen
        HideAllBut(mainPanel);
        yield return(null); // wait to be called back when the stage has finished

        // Load connections, then wait for continue
        HideAllBut(loadingPanel);
        LoadingButton.SetActive(false);

        //ConnectServices();
        RefreshServices();  // BODGE: blindly stop services to make sure they aren't still running before starting a new instance
        yield return(null); // wait to be called back when the stage has finished

        // Quality check
        Quality.enable(true);
        HideAllBut(qualityPanel);
        yield return(null);

        if ((bool)Config.questionaire)
        {
            cueText.text   = Config.preQuestionnaireText;
            cueButton.text = "verder";
            HideAllBut(cuePanel);
            yield return(null);

            currentQuestion = 0;
            while (currentQuestion < Config.preQuestionnaire.GetLength(0))
            {
                if (moveForward)
                {
                    currentQuestion++;
                }
                else
                {
                    currentQuestion--;
                }
                createQuestion(Config.preQuestionnaire);

                yield return(null);

                string answer = string.Format("{0}, {1:N2}", currentQuestion, questionnaireSlider.value);
                FTSInterface.sendEvent(Config.preQuestionEventType, answer);
            }
        }

        else
        {
            cueText.text   = Config.introText;
            cueButton.text = "verder";
            HideAllBut(cuePanel);
            yield return(null);
        }

        if (Config.eyesOpenPre)
        {
            // quality check
            if (!Quality.getAvgQualityStatus())
            {
                HideAllBut(qualityPanel);
                yield return(null);
            }
            Quality.resetAverage();

            currentRestDuration = Config.eyesOpenDuration;
            cueText.text        = Config.eyesOpenText;
            cueButton.text      = "verder";
            HideAllBut(cuePanel);
            yield return(null);

            restCueText.text = Config.baselineCueText;
            HideAllBut(restStage);
            FTSInterface.sendEvent(Config.eyesOpenEventType, "start"); // first is pure rest, i.e. no baseline
            yield return(null);

            FTSInterface.sendEvent(Config.eyesOpenEventType, "end");
        }

        if (Config.eyesClosedPre)
        {
            // quality check
            if (!Quality.getAvgQualityStatus())
            {
                HideAllBut(qualityPanel);
                yield return(null);
            }
            Quality.resetAverage();

            currentRestDuration = Config.eyesClosedDuration;
            cueText.text        = Config.eyesClosedText;
            cueButton.text      = "ok";
            HideAllBut(cuePanel);
            yield return(null);

            restCueText.text = Config.eyesClosedCue;
            HideAllBut(restStage);
            FTSInterface.sendEvent(Config.eyesClosedEventType, "start"); // first is pure rest, i.e. no baseline
            yield return(null);

            FTSInterface.sendEvent(Config.eyesClosedEventType, "end");
            sfx_ding.Play();
        }

        // Trial Instructions
        cueText.text   = Config.experimentInstructText1;
        cueButton.text = "verder";
        HideAllBut(cuePanel);
        yield return(null);

        cueText.text = Config.experimentInstructText2;
        yield return(null);


        // Run Trial sessions
        string trialType = "";

        sessionScores = new float[Config.trainingBlocks];
        for (int si = 0; si < Config.trainingBlocks; si++)
        {
            // quality check
            if (!Quality.getAvgQualityStatus())
            {
                HideAllBut(qualityPanel);
                yield return(null);
            }
            Quality.resetAverage();

            // run the baseline stage
            currentRestDuration = Config.baselineDuration;
            cueText.text        = Config.baselineText;
            cueButton.text      = "ok";
            HideAllBut(cuePanel);
            yield return(null);

            restCueText.text = Config.baselineCueText;
            HideAllBut(restStage);
            FTSInterface.sendEvent(Config.baselineEventType, "start"); // rest is also baseline
            yield return(null);

            FTSInterface.sendEvent(Config.baselineEventType, "end");

            // quality check (now calibrated)
            Quality.setCalibration(true);
            if (!Quality.getAvgQualityStatus())
            {
                HideAllBut(qualityPanel);
                yield return(null);
            }
            Quality.resetAverage();

            // instructions before the control phase
            if (agenticControl && si % 2 == 1)
            {
                trialType = "avoid";
            }
            else
            {
                trialType = "approach";
            }
            if (trialType.Equals("avoid"))
            {
                cueText.text = Config.avoidCueText;
            }
            else if (trialType.Equals("approach"))
            {
                cueText.text = Config.approachCueText;
            }
            cueButton.text = "ok";
            HideAllBut(cuePanel);
            yield return(null);

            // run the training stage
            FTSInterface.sendEvent(Config.trialEventType, "start");
            FTSInterface.sendEvent(Config.targetEventType, trialType);
            HideAllBut(trainingStage);
            yield return(null);

            FTSInterface.sendEvent(Config.trialEventType, "end");
            currentSession += 1;
        }

        if (Config.eyesOpenPost)
        {
            // quality check
            if (!Quality.getAvgQualityStatus())
            {
                HideAllBut(qualityPanel);
                yield return(null);
            }
            Quality.resetAverage();

            currentRestDuration = Config.eyesOpenDuration;
            cueText.text        = Config.eyesOpenText;
            cueButton.text      = "verder";
            HideAllBut(cuePanel);
            yield return(null);

            restCueText.text = Config.baselineCueText;
            HideAllBut(restStage);
            FTSInterface.sendEvent(Config.eyesOpenEventType, "start"); // first is pure rest, i.e. no baseline
            yield return(null);

            FTSInterface.sendEvent(Config.eyesOpenEventType, "end");
        }

        if (Config.eyesClosedPost)
        {
            // quality check
            if (!Quality.getAvgQualityStatus())
            {
                HideAllBut(qualityPanel);
                yield return(null);
            }
            Quality.resetAverage();

            currentRestDuration = Config.eyesClosedDuration;
            cueText.text        = Config.eyesClosedPostText;
            cueButton.text      = "ok";
            HideAllBut(cuePanel);
            sfx_ding.Play();
            yield return(null);

            restCueText.text = Config.eyesClosedCue;
            HideAllBut(restStage);
            FTSInterface.sendEvent(Config.eyesClosedEventType, "start"); // first is pure rest, i.e. no baseline
            yield return(null);

            FTSInterface.sendEvent(Config.eyesClosedEventType, "end");
            sfx_ding.Play();
        }

        // turn off quality check to save resources
        Quality.enable(false);

        if ((bool)Config.questionaire)
        {
            cueText.text   = Config.postQuestionnaireText;
            cueButton.text = "verder";
            HideAllBut(cuePanel);
            yield return(null);

            currentQuestion = 0;
            while (currentQuestion < Config.postQuestionnaire.GetLength(0))
            {
                if (moveForward)
                {
                    currentQuestion++;
                }
                else
                {
                    currentQuestion--;
                }
                createQuestion(Config.postQuestionnaire);

                yield return(null);

                string answer = string.Format("{0}, {1}", currentQuestion, questionnaireSlider.value);
                FTSInterface.sendEvent(Config.postQuestionEventType, answer);
            }
        }

        if ((bool)Config.evaluation)
        {
            currentQuestion = 0;
            while (currentQuestion < Config.evalQuestionnaire.GetLength(0))
            {
                if (moveForward)
                {
                    currentQuestion++;
                }
                else
                {
                    currentQuestion--;
                }
                createQuestion(Config.evalQuestionnaire);

                yield return(null);

                string answer = string.Format("{0}, {1}", currentQuestion, questionnaireSlider.value);
                FTSInterface.sendEvent(Config.evalQuestionEventType, answer);
            }
        }

        //Say goodbye
        cueText.text   = Config.farewellText;
        cueButton.text = "sluiten";
        HideAllBut(cuePanel);
        yield return(null);

        //End
        Quit();
    }
Esempio n. 2
0
    // game state controller to switch between stages of the experiment/game
    // N.B. you should never call this directly, but via the nextStage function
    private IEnumerable nextStageInner()
    {
        while (!endAll)
        {
            // Start screen
            FTSInterface.setMenu(false);
            HideAllBut(mainPanel);
            yield return(null);            // wait to be called back when the stage has finished

            if (endAll)
            {
                break;                       // finish if quit from main-menu
            }
            // show the connection panel, start trying to connect to the buffer, wait for continue to be pressed
            HideAllBut(connectionPanel);
            FTSInterface.setMenu(true);             // BODGE: manually tell the FTS interface that it's visible.....
            //Connect (); // connect to Buffer
            yield return(null);

            if (endAll)
            {
                break;                       // finish if quit from main-menu
            }
            HideAllBut(userInfoPanel);       // ask user information
            yield return(null);

            if (userTxt.text != null)
            {
                FTSInterface.sendEvent(Config.userEventType, userTxt.text);
            }
            if (sessionTxt.text != null)
            {
                FTSInterface.sendEvent(Config.sessionEventType, sessionTxt.text);
            }
            agenticControl = agenticToggle.isOn;
            if (agenticControl)
            {
                FTSInterface.sendEvent(Config.agenticEventType, "agentic");
            }
            else
            {
                FTSInterface.sendEvent(Config.agenticEventType, "operant");
            }

            if (FTSInterface.getSystemIsReady())
            {
                FTSInterface.setMenu(false);
            }


            if (Config.preMeasure)
            {
                cueText.text = Config.premeasureText;
                HideAllBut(cuePanel);
                yield return(null);

                if (endAll)
                {
                    break;             // finish if quit from main-menu
                }
                HideAllBut(restStage);
                FTSInterface.sendEvent(Config.restEventType, "start");                  // first is pure rest, i.e. no baseline
                yield return(null);

                FTSInterface.sendEvent(Config.restEventType, "end");
            }
            if (Config.eyesOpenTest)
            {
                cueText.text = Config.eyesOpenText;
                HideAllBut(cuePanel);
                yield return(null);

                if (endAll)
                {
                    break;                     // finish if quit from main-menu
                }
                restCueText.text = Config.baselineCueText;
                HideAllBut(restStage);
                FTSInterface.sendEvent(Config.eyesOpenEventType, "start");                  // first is pure rest, i.e. no baseline
                yield return(null);

                FTSInterface.sendEvent(Config.eyesOpenEventType, "end");
            }
            if (Config.eyesClosedTest)
            {
                cueText.text = Config.eyesClosedText;
                HideAllBut(cuePanel);
                yield return(null);

                if (endAll)
                {
                    break;                     // finish if quit from main-menu
                }
                restCueText.text = Config.eyesClosedCue;
                HideAllBut(restStage);
                FTSInterface.sendEvent(Config.eyesClosedEventType, "start");                  // first is pure rest, i.e. no baseline
                yield return(null);

                FTSInterface.sendEvent(Config.eyesClosedEventType, "end");
                audio.Play();
            }

            cueText.text = Config.experimentInstructText;
            HideAllBut(cuePanel);
            yield return(0);

            if (endAll)
            {
                break;                       // finish if quit from main-menu
            }
            string trialType = "";
            for (int si = 0; si < Config.trainingBlocks; si++)
            {
                // run the baseline stage
                cueText.text = Config.baselineText;
                HideAllBut(cuePanel);
                yield return(null);

                restCueText.text = Config.baselineCueText;
                HideAllBut(restStage);
                FTSInterface.sendEvent(Config.baselineEventType, "start");                  // rest is also baseline
                yield return(null);

                if (endAll)
                {
                    break;                           // finish if quit from main-menu
                }
                FTSInterface.sendEvent(Config.baselineEventType, "end");

                // instructions before the control phase
                if (agenticControl && si % 2 == 1)
                {
                    trialType = "avoid";
                }
                else
                {
                    trialType = "approach";
                }
                if (trialType.Equals("avoid"))
                {
                    cueText.text = Config.avoidCueText;
                }
                else if (trialType.Equals("approach"))
                {
                    cueText.text = Config.approachCueText;
                }
                HideAllBut(cuePanel);
                yield return(0);

                if (endAll)
                {
                    break;                           // finish if quit from main-menu
                }
                // run the training stage
                FTSInterface.sendEvent(Config.trialEventType, "start");
                FTSInterface.sendEvent(Config.targetEventType, trialType);
                HideAllBut(trainingStage);
                yield return(null);

                FTSInterface.sendEvent(Config.trialEventType, "end");
                if (endAll)
                {
                    break;                           // finish if quit from main-menu
                }
            }

            if ((bool)Config.questionaire)
            {
                cueText.text = Config.questionaireText;
                HideAllBut(cuePanel);
                yield return(null);

                if (endAll)
                {
                    break;                           // finish if quit from main-menu
                }
                int questionaireStage = 0;
                while (questionaireStage < 3)
                {
                    if (moveForward)
                    {
                        questionaireStage++;
                    }
                    else
                    {
                        questionaireStage--;
                    }

                    if (questionaireStage == 1)
                    {
                        HideAllBut(questionairePanel1);
                    }
                    else if (questionaireStage == 2)
                    {
                        HideAllBut(questionairePanel2);
                    }
                    else if (questionaireStage == 3)
                    {
                        HideAllBut(questionairePanel3);
                    }
                    yield return(null);

                    if (endAll)
                    {
                        break;                               // finish if quit from main-menu
                    }
                }
            }

            if ((bool)Config.evaluation)
            {
                LoadEvaluationPage();
                yield return(null);

                if (endAll)
                {
                    break;                           // finish if quit from main-menu
                }
            }
        }

        splashText.text = Config.farwellText;
        HideAllBut(loadingPanel);
        Disconnect(true);
        Application.Quit();
    }