getSystemIsReady() public method

public getSystemIsReady ( ) : bool
return bool
Exemplo n.º 1
0
    public IEnumerator ShutDown()
    {
        StatusText.text = "Afsluiten...";
        LoadingButton.SetActive(false);
        HideAllBut(loadingPanel);

        Debug.Log("Disconnecting.");
        DisconnectServices();

        while (FTSInterface.getSystemIsReady())
        {
            yield return(new WaitForSeconds(1));
        }

        yield return(new WaitForSeconds(1));

        Debug.Log("Quitting.");
        Application.Quit();
        // Kill insurance
        System.Diagnostics.Process.GetCurrentProcess().Kill();
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (isEnabled && FTSInterface.getSystemIsReady())
        {
            float qualityCh1 = FTSInterface.getQualityCh1();
            float qualityCh2 = FTSInterface.getQualityCh2();

            // Judge current quality
            bool channel1Good = CheckChannel(qualityCh1, 1, QualityIndicatorL);
            bool channel2Good = CheckChannel(qualityCh2, 2, QualityIndicatorR);

            if (channel1Good && channel2Good)
            {
                curQualityDuration[0]       = 0;
                AdvanceButton.interactable  = true;
                curQualityStatusAllChannels = true;
            }
            else
            {
                if (curQualityStatusAllChannels)
                {
                    curQualityDuration[0]++;
                    //allow for brief drop in quality
                    if (curQualityDuration[0] > Config.qualityTimeOut)
                    {
                        AdvanceButton.interactable  = false;
                        curQualityStatusAllChannels = false;
                    }
                }
            }

            // Calculate rolling average
            float channelsAvg = (qualityCh1 + qualityCh2) / 2.0f;

            avgQualityAllChannels = (channelsAvg + avgQualityAllChannels * avgQualitySamples) / (avgQualitySamples + 1);
            avgQualitySamples++;

            //Debug.Log("Q1=" + qualityCh1.ToString() + ", Q2=" + qualityCh2.ToString() + ", QA=" + avgQualityAllChannels.ToString());
        }
    }
Exemplo n.º 3
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();
    }