Exemplo n.º 1
0
        } /* onExperimentTrialBegin() */

        public virtual void onExperimentTrialEnd(object sender, ApollonEngine.EngineExperimentEventArgs arg)
        {
            // check if there is any trial left
            if (ApollonExperimentManager.Instance.Session.CurrentTrial == ApollonExperimentManager.Instance.Session.LastTrial)
            {
                // log
                UnityEngine.Debug.Log("<color=Blue>Info: </color> ApollonAbstractExperimentProfile.onExperimentTrialEnd() : final trial, session will exit ");

                // request end
                this._trial_requested_type = TrialType.End;
                this._trial_requested      = true;
            }
            else
            {
                // log
                UnityEngine.Debug.Log(
                    "<color=Blue>Info: </color> ApollonAbstractExperimentProfile.onExperimentTrialEnd() : there is stil trial to run, current: [ block:"
                    + ApollonExperimentManager.Instance.Session.currentBlockNum
                    + " / trial: "
                    + ApollonExperimentManager.Instance.Session.currentTrialNum
                    + " ]"
                    );

                // request next trial
                this._trial_requested_type = TrialType.Next;
                this._trial_requested      = true;
            } /* if() */
        }     /* onExperimentTrialEnd() */
Exemplo n.º 2
0
        public IHttpActionResult PutTrialType(int id, TrialType trialType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != trialType.TrialTypeID)
            {
                return(BadRequest());
            }

            db.Entry(trialType).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TrialTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 3
0
    /// <summary>
    /// Returns the header line for a CSV file deliniating the fields contained in the data.
    /// </summary>
    /// <param name="type">The type of trial.</param>
    /// <param name="trialData">The trial's TrialData.</param>
    /// <param name="numQuestions">The number of questions in questionnaires, returned as an out variable.</param>
    /// <returns>A string containing the CSV header for that Trial.</returns>
    public static string GetCsvHeader(TrialType type, TrialData [] trialData, out int numQuestions)
    {
        string header = "";

        numQuestions = 0;

        switch (type)
        {
        case TrialType.BasicTrial:
            header = BasicTrialManager.CSV_HEADER;
            for (int i = 0; i < trialData.Length; i++)
            {
                numQuestions += trialData [i].Questionnaire.Length;
                for (int j = 0; j < trialData[i].Questionnaire.Length; j++)
                {
                    header += "," + "\"" + trialData [i].Questionnaire [j].QuestionText + "\"";
                }
            }
            break;
        }

        header += System.Environment.NewLine;

        return(header);
    }
        internal static IEnumerable <TrialType> GetTrialTypes()
        {
            List <TrialType> trialtypes = new List <TrialType>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                try
                {
                    connection.Open();

                    SqlCommand    cmdGetCustomers = new SqlCommand("select * from TrialType order by Name ASC", connection);
                    SqlDataReader reader          = cmdGetCustomers.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            TrialType t = new TrialType(reader.GetString(1));
                            t.Id = reader.GetInt32(0);
                            trialtypes.Add(t);
                        }
                    }
                }
                catch (SqlException e)
                {
                }
                finally
                {
                    connection.Close();
                    connection.Dispose();
                }
            }

            return(trialtypes);
        }
Exemplo n.º 5
0
        /*
            FUNCTION: GetTrialDaysLeft()

            PURPOSE: Gets the number of remaining trial days.

            If the trial has expired or has been tampered, daysLeft is set to 0 days.

            PARAMETERS:
            * daysLeft - pointer to the integer that receives the value
            * trialType - depending upon whether your application uses verified trial or not,
              this parameter can have one of the following values: LA_V_TRIAL, LA_UV_TRIAL

            RETURN CODES: LA_OK, LA_FAIL, LA_E_GUID

            NOTE: The trial must be started by calling ActivateTrial() or  InitializeTrial() at least
            once in the past before calling this function.
        */

        public static int GetTrialDaysLeft(ref uint daysLeft, TrialType trialType)
        {
#if LA_ANY_CPU 
            return IntPtr.Size == 8 ? Native.GetTrialDaysLeft_x64(ref daysLeft, trialType) : Native.GetTrialDaysLeft(ref daysLeft, trialType);
#else 
            return Native.GetTrialDaysLeft(ref daysLeft, trialType); 
#endif
        }
Exemplo n.º 6
0
    // Standard constructor allowing for defining of robot type and trial type.
    public Trial(EnvironmentType environmentType, RobotType robotType, TrialType trialType)
    {
        this.environmentType = environmentType;
        this.robotType       = robotType;
        this.trialType       = trialType;

        // Set trial number to current number of trials, then increment the number of trials.
        // E.g. the first trial will have the trial number 0.
        trialNum = numTrials++;
    }
Exemplo n.º 7
0
    private static int numTrials = 0; // Static variable to keep track of the total number of trials.

    // Basic constructor that creates a trial of type test with no robot type.
    public Trial()
    {
        this.environmentType = EnvironmentType.OPEN;
        this.robotType       = RobotType.TEST;
        this.trialType       = TrialType.TEST;

        // Set trial number to current number of trials, then increment the number of trials.
        // E.g. the first trial will have the trial number 0.
        trialNum = numTrials++;
    }
Exemplo n.º 8
0
        public IHttpActionResult GetTrialType(int id)
        {
            TrialType trialType = db.TrialTypes.Find(id);

            if (trialType == null)
            {
                return(NotFound());
            }

            return(Ok(trialType));
        }
Exemplo n.º 9
0
        public IHttpActionResult PostTrialType(TrialType trialType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TrialTypes.Add(trialType);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = trialType.TrialTypeID }, trialType));
        }
Exemplo n.º 10
0
        }     /* onUpdate() */

        public virtual void onExperimentSessionBegin(object sender, ApollonEngine.EngineExperimentEventArgs arg)
        {
            // call config factories
            this.DoSessionConfiguration(arg.Session);

            // request
            this._trial_requested_type = TrialType.First;
            this._trial_requested      = true;

            // inactivate everything first
            frontend.ApollonFrontendManager.Instance.setInactive(frontend.ApollonFrontendManager.FrontendIDType.All);
            gameplay.ApollonGameplayManager.Instance.setInactive(gameplay.ApollonGameplayManager.GameplayIDType.All);
        } /* onExperimentSessionBegin() */
Exemplo n.º 11
0
        public IHttpActionResult DeleteTrialType(int id)
        {
            TrialType trialType = db.TrialTypes.Find(id);

            if (trialType == null)
            {
                return(NotFound());
            }

            db.TrialTypes.Remove(trialType);
            db.SaveChanges();

            return(Ok(trialType));
        }
Exemplo n.º 12
0
 protected override void OnTrialSetup()
 {
     if (_trialNumberWithinBlock >= Settings.NumberOfTrainingGoals)
     {
         _currentTrialType = TrialType.Pointing;
     }
     if (_currentTrialType == TrialType.Training)
     {
         SetupTraining();
     }
     else
     {
         SetupPointing();
     }
 }
Exemplo n.º 13
0
    void Awake()
    {
        _gameManager = TaskSettingsManager.TaskSettings;
        int.TryParse(_gameManager.SetBaselineBlockLength, out _baselineBlockLength);
        int.TryParse(_gameManager.SetReversalBlockLength, out _reversalBlockLength);
        int.TryParse(_gameManager.TrialLengthLimit, out _trialLengthLimit);

        if (_gameManager.EnableBaselineBlock && _gameManager.EnableReversalBlock)
        {
            _trialType = TrialType.Both;
        }

        if (_gameManager.EnableBaselineBlock && !_gameManager.EnableReversalBlock)
        {
            _trialType = TrialType.Baseline;
        }

        if (_gameManager.EnableReversalBlock && !_gameManager.EnableBaselineBlock)
        {
            _trialType = TrialType.Reversal;
        }

        if (_gameManager.EnableBaselineBlock == false && _gameManager.EnableReversalBlock == false)
        {
            _trialType = TrialType.Reversal;
        }

        Random.seed = (int)(Time.time * 10000);

        _rectsFilled   = new GameObject[] { Rect1, Rect2, Rect3, Rect4 };
        _rectsOutlined = new GameObject[] { RectOutline1, RectOutline2, RectOutline3, RectOutline4 };
        _checks        = new GameObject[] { Check1, Check2, Check3, Check4 };
        _crosses       = new GameObject[] { Cross1, Cross2, Cross3, Cross4 };

        _currentTaskState = TaskState.StartTrial;

        if (_gameManager.EnableTriggerOnScanner == true)
        {
            _currentTaskState  = TaskState.WaitForTrigger;
            _scannerDelayStart = DateTime.Now;
        }

        Debug.Log(TaskSettingsManager.TaskSettings.SubjectId);
    }
Exemplo n.º 14
0
        private void button3_Click(object sender, EventArgs e)
        {
            //Loops through all comboBoxes and TextBoxes and assigns values to Paramaters class
            stimParams = new Parameters[Int32.Parse(comboBox1.Text)];
            IEnumerable <Control> stimGroups = GetAll(this, typeof(GroupBox));
            float convFactor = float.Parse(textBox68.Text);
            int   triL       = Int32.Parse(textBox65.Text);
            int   stimL      = Int32.Parse(textBox66.Text);
            int   triI       = Int32.Parse(textBox67.Text);
            bool  velo       = checkBox1.Checked;

            for (int i = 0; i < stimParams.Length; i++)
            {
                GroupBox  nextgroup = stimGroups.OfType <GroupBox>().ElementAt <GroupBox>(i);
                TrialType nextType  = (nextgroup.Controls.OfType <ComboBox>().ElementAt <ComboBox>(0).Text == "Radial") ? TrialType.Radial : TrialType.Approach;
                if (veloWalkBox.Checked)
                {
                    nextType = TrialType.VeloWalk;
                }
                IEnumerable <Control> tBoxes = GetAll(nextgroup, typeof(TextBox));
                float[] vars  = new float[6];
                int     count = 0;
                foreach (TextBox nextbox in tBoxes)
                {
                    if (nextbox.Visible)
                    {
                        vars[count] = float.Parse(nextbox.Text);
                        count++;
                    }
                }
                stimParams[i] = new Parameters(nextType, vars[0], vars[1], vars[2], vars[3], vars[4], vars[5], triL, stimL, triI, velo, convFactor);
            }
            //MessageBox.Show("Trial Type: " + stimParams[0].trialType.ToString() + " start Size: " + stimParams[0].begRadSize.ToString() +
            //    " End Size: " + stimParams[0].endRadSize.ToString() + " Speed: " + stimParams[0].radSpeed.ToString() + " Contrast: " +
            //    stimParams[0].contrast.ToString() + " Distoff: " + stimParams[0].distoff.ToString() + " Angle: " + stimParams[0].angle.ToString());

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 15
0
    // Public method called externally telling the OverlayManager to display a certain type of loading screen.
    public void DisplayLoadingScreen(TrialType trialType)
    {
        // The load is starting, signal that the load is not finished.
        GameObject.Find("SharedVariableManager").GetComponent <SharedVariableManager>().loadIsFinished = false;

        // Decide which type of loading screen to display.
        switch (trialType)
        {
        case TrialType.TEST:
            StartCoroutine(DrawLoadingScreen(testTitle, testText, testLoadDuration));
            break;

        case TrialType.AI:
            StartCoroutine(DrawLoadingScreen(AITitle, AIText, AILoadDuration));
            break;

        case TrialType.HUMAN:
            // Generate random wait time.
            float humanLoadDuration = humanMeanLoadDuration + Random.Range(-humanLoadDurationRange, humanLoadDurationRange);
            StartCoroutine(DrawLoadingScreen(humanTitle, humanText, humanLoadDuration));
            break;
        }
    }
Exemplo n.º 16
0
 public Parameters(TrialType _trialType, float _angle, float _param1, float _param3, float _param2, float _distoff, float _contrast, int _tLength, int _sLength, int _tInterval, bool _veloshut, float _cFactor)
 {
     trialType = _trialType;
     if (trialType == TrialType.Radial)
     {
         radSpeed   = _param1;
         begRadSize = _param2;
         endRadSize = _param3;
     }
     else
     {
         appSpeed = _param2;
         appSize  = _param1;
         appDist  = _param3;
     }
     angle     = _angle;
     contrast  = _contrast;
     distoff   = _distoff;
     tLength   = _tLength;
     sLength   = _sLength;
     tInterval = _tInterval;
     veloshut  = _veloshut;
     cFactor   = _cFactor;
 }
Exemplo n.º 17
0
 public static extern int GetTrialDaysLeft_x64(ref uint daysLeft, TrialType trialType);
Exemplo n.º 18
0
 protected override void OnExperimentInitialise()
 {
     _currentTrialType    = TrialType.Training;
     _totalNumberOfTrials = Settings.NumberOfBlocks * Settings.GoalOrder.Length;
 }
Exemplo n.º 19
0
 void StartNewBlock()
 {
     _trialNumberWithinBlock = 0;
     _currentTrialType       = TrialType.Training;
 }
Exemplo n.º 20
0
    public void MakeInputDecision(InputData inputData = null, bool windowExpired = false)
    {
        string entry = urn.ReadEntry();

        trialGoal   = (TrialType)System.Enum.Parse(typeof(TrialType), entry);
        trialResult = TrialType.RejInput;

        if (inputData != null)
        {
            if (inputData.type == InputType.FabInput)
            {
                if (trialGoal == TrialType.FabInput)
                {
                    trialResult = TrialType.FabInput;
                    CloseInputWindow();
                }
                else if (trialGoal == TrialType.ExplicitSham)
                {
                    trialResult = TrialType.ExplicitSham;
                    CloseInputWindow();
                }
            }
            else if (trialGoal == TrialType.AccInput)
            {
                if (inputData.validity == InputValidity.Accepted)
                {
                    trialResult = TrialType.AccInput;
                    CloseInputWindow();
                }
                else
                {
                    trialResult = TrialType.RejInput;
                }
            }
            else if (trialGoal == TrialType.RejInput)
            {
                trialResult = TrialType.RejInput;
                // ignore the input.
            }
            else if (trialGoal == TrialType.AssistSuccess)
            {
                if (inputData.validity == InputValidity.Accepted)
                {
                    trialResult = TrialType.AssistSuccess;
                    CloseInputWindow();
                }
                else
                {
                    trialResult = TrialType.RejInput;
                }
            }
            else if (trialGoal == TrialType.AssistFail)
            {
                trialResult = TrialType.AssistFail;
                // ignore the input.
            }
        }
        else if (windowExpired)
        {
            CloseInputWindow();
        }
    }
Exemplo n.º 21
0
        } /* DoSleep() */

        #endregion

        #region abstract method

        public virtual void onUpdate(object sender, ApollonEngine.EngineEventArgs arg)
        {
            // check request
            if (_trial_requested)
            {
                // start chrono
                this._trial_chrono.Start();

                // inactivate everything first
                // frontend.ApollonFrontendManager.Instance.setInactive(frontend.ApollonFrontendManager.FrontendIDType.All);
                // gameplay.ApollonGameplayManager.Instance.setInactive(gameplay.ApollonGameplayManager.GameplayIDType.All);

                // reset request & raise running
                this._trial_requested         = false;
                this._trial_chrono_is_running = true;

                // dbg
                UnityEngine.Debug.Log(
                    "<color=Blue>Info: </color> ApollonAbstractExperimentProfile.onUpdate() : trial requested ["
                    + this._trial_sleep_duration
                    + "ms]"
                    );
            } /* if () */

            // check chrono && start a certain amount of time after session begin exept for the first one
            if ((this._trial_chrono_is_running) &&
                (
                    (this._trial_chrono.ElapsedMilliseconds >= this._trial_sleep_duration) ||
                    (this._trial_requested_type == TrialType.First)
                )
                )
            {
                // stop & reset chrono then fall running
                this._trial_chrono.Stop();
                this._trial_chrono.Reset();
                this._trial_chrono_is_running = false;

                // raise corresponding signal
                switch (this._trial_requested_type)
                {
                case TrialType.First:
                {
                    // dbg
                    UnityEngine.Debug.Log(
                        "<color=Blue>Info: </color> ApollonAbstractExperimentProfile.onUpdate() : first trial will begin now !"
                        );
                    // call
                    ApollonExperimentManager.Instance.Session.FirstTrial.Begin();
                    break;
                }         /* case TrialType.First */

                case TrialType.Next:
                {
                    // dbg
                    UnityEngine.Debug.Log(
                        "<color=Blue>Info: </color> ApollonAbstractExperimentProfile.onUpdate() : next trial will begin now !"
                        );
                    // call
                    ApollonExperimentManager.Instance.Session.BeginNextTrial();
                    break;
                }         /* case TrialType.Next */

                case TrialType.End:
                {
                    // dbg
                    UnityEngine.Debug.Log(
                        "<color=Blue>Info: </color> ApollonAbstractExperimentProfile.onUpdate() : session will end now !"
                        );
                    // call
                    ApollonExperimentManager.Instance.Session.End();
                    break;
                }         /* case TrialType.End */

                case TrialType.Undefined:
                default:
                {
                    // dbg
                    UnityEngine.Debug.LogError(
                        "<color=Red>Info: </color> ApollonAbstractExperimentProfile.onUpdate() : switch on Undefined value, this should never happen..."
                        );
                    break;
                }         /* case TrialType.Undefined || default */
                } /* switch() */

                // finally, reset
                this._trial_requested_type = TrialType.Undefined;
            } /* if () */
        }     /* onUpdate() */