/// <summary>
        /// Begins the trial, updating the current trial and block number, setting the status to in progress, starting the timer for the trial, and beginning recording positions of every object with an attached tracker
        /// </summary>
        public void Begin()
        {
            session.currentTrialNum = number;
            session.currentBlockNum = block.number;

            status    = TrialStatus.InProgress;
            startTime = Time.time;
            result    = new OrderedResultDict();
            foreach (string h in session.headers)
            {
                result.Add(h, string.Empty);
            }

            result["experiment"]         = session.experimentName;
            result["ppid"]               = session.ppid;
            result["session_num"]        = session.number;
            result["trial_num"]          = number;
            result["block_num"]          = block.number;
            result["trial_num_in_block"] = numberInBlock;
            result["start_time"]         = startTime;

            foreach (Tracker tracker in session.trackedObjects)
            {
                tracker.StartRecording();
            }
            session.onTrialBegin.Invoke(this);
        }
Beispiel #2
0
        /// <summary>
        /// Begins the trial, updating the current trial and block number, setting the status to in progress, starting the timer for the trial, and beginning recording positions of every object with an attached tracker
        /// </summary>
        public void Begin()
        {
            if (session.InTrial)
            {
                session.CurrentTrial.End();
            }

            session.currentTrialNum = number;
            session.currentBlockNum = block.number;

            status    = TrialStatus.InProgress;
            startTime = Time.time;
            result    = new ResultsDictionary(session.Headers, true);

            result["experiment"]         = session.experimentName;
            result["ppid"]               = session.ppid;
            result["session_num"]        = session.number;
            result["trial_num"]          = number;
            result["block_num"]          = block.number;
            result["trial_num_in_block"] = numberInBlock;
            result["start_time"]         = startTime;

            foreach (Tracker tracker in session.trackedObjects)
            {
                try
                {
                    tracker.StartRecording();
                }
                catch (NullReferenceException)
                {
                    Utilities.UXFDebugLogWarning("An item in the Tracked Objects field of the UXF session if empty (null)!");
                }
            }
            session.onTrialBegin.Invoke(this);
        }
Beispiel #3
0
        public void TestCurrentEndTrialOnBeginNext()
        {
            (Session session, FileSaver fileSaver) = CreateSession("endonbegin");
            session.endOnDestroy = true;

            foreach (var t in session.Trials)
            {
                t.Begin();
            }

            foreach (var t in session.Trials)
            {
                TrialStatus expectedStatus = t == session.LastTrial ? TrialStatus.InProgress : TrialStatus.Done;
                Assert.AreEqual(t.status, expectedStatus);
            }

            GameObject.DestroyImmediate(session.gameObject);
        }
Beispiel #4
0
        /// <summary>
        /// Ends the Trial, queues up saving results to output file, stops and saves tracked object data.
        /// </summary>
        public void End()
        {
            status             = TrialStatus.Done;
            endTime            = Time.time;
            result["end_time"] = endTime;

            // log tracked objects
            foreach (Tracker tracker in session.trackedObjects)
            {
                SaveDataTable(tracker.data, tracker.dataName, dataType: UXFDataType.Trackers);
            }

            // log any settings we need to for this trial
            foreach (string s in session.settingsToLog)
            {
                result[s] = settings.GetObject(s);
            }

            session.onTrialEnd.Invoke(this);
        }
        /// <summary>
        /// Ends the Trial, queues up saving results to output file, stops and saves tracked object data.
        /// </summary>
        public void End()
        {
            status             = TrialStatus.Done;
            endTime            = Time.time;
            result["end_time"] = endTime;

            // log tracked objects
            foreach (Tracker tracker in session.trackedObjects)
            {
                tracker.StopRecording();
                string dataName = session.SaveTrackerData(tracker);
                result[tracker.pathHeader] = dataName;
            }

            // log any settings we need to for this trial
            foreach (string s in session.settingsToLog)
            {
                result[s] = settings[s];
            }
            session.onTrialEnd.Invoke(this);
        }
Beispiel #6
0
        /// <summary>
        /// Ends the Trial, queues up saving results to output file, stops and saves tracked object data.
        /// </summary>
        public void End()
        {
            status             = TrialStatus.Done;
            endTime            = Time.time;
            result["end_time"] = endTime;

            // check no duplicate trackers
            List <string> duplicateTrackers = session.trackedObjects.Where(tracker => tracker != null)
                                              .GroupBy(tracker => tracker.dataName)
                                              .Where(g => g.Count() > 1)
                                              .Select(y => y.Key)
                                              .ToList();

            if (duplicateTrackers.Any())
            {
                throw new InvalidOperationException(string.Format("Two or more trackers in the Tracked Objects field in the Session Inspector have the following object name and descriptor pair, please change the object name fields on the trackers to make them unique: {0}", string.Join(",", duplicateTrackers)));
            }

            // log tracked objects
            foreach (Tracker tracker in session.trackedObjects)
            {
                try
                {
                    tracker.StopRecording();
                    SaveDataTable(tracker.data, tracker.dataName, dataType: UXFDataType.Trackers);
                }
                catch (NullReferenceException)
                {
                    Utilities.UXFDebugLogWarning("An item in the Tracked Objects field of the UXF session if empty (null)!");
                }
            }

            // log any settings we need to for this trial
            foreach (string s in session.settingsToLog)
            {
                result[s] = settings.GetObject(s);
            }

            session.onTrialEnd.Invoke(this);
        }
Beispiel #7
0
        /// <summary>
        /// Begins the trial, updating the current trial and block number, setting the status to in progress, starting the timer for the trial, and beginning recording positions of every object with an attached tracker
        /// </summary>
        public void Begin()
        {
            if (!session.hasInitialised)
            {
                throw new InvalidOperationException("Cannot begin trial, session is is not ready! Session has not been started yet with session.Begin() (or via the UI), or session has already ended.");
            }
            if (session.InTrial)
            {
                session.CurrentTrial.End();
            }

            session.currentTrialNum = number;
            session.currentBlockNum = block.number;

            status    = TrialStatus.InProgress;
            startTime = Time.time;
            result    = new ResultsDictionary(session.Headers, true);

            result["experiment"]         = session.experimentName;
            result["ppid"]               = session.ppid;
            result["session_num"]        = session.number;
            result["trial_num"]          = number;
            result["block_num"]          = block.number;
            result["trial_num_in_block"] = numberInBlock;
            result["start_time"]         = startTime;

            foreach (Tracker tracker in session.trackedObjects)
            {
                try
                {
                    tracker.StartRecording();
                }
                catch (NullReferenceException)
                {
                    Utilities.UXFDebugLogWarning("An item in the Tracked Objects field of the UXF session if empty (null)!");
                }
            }
            session.onTrialBegin.Invoke(this);
        }
Beispiel #8
0
        /// <summary>
        /// Begins the trial, updating the current trial and block number, setting the status to in progress, starting the timer for the trial, and beginning recording positions of every object with an attached tracker
        /// </summary>
        public void Begin()
        {
            session.currentTrialNum = number;
            session.currentBlockNum = block.number;

            status    = TrialStatus.InProgress;
            startTime = Time.time;
            result    = new ResultsDictionary(session.Headers, true);

            result["experiment"]         = session.experimentName;
            result["ppid"]               = session.ppid;
            result["session_num"]        = session.number;
            result["trial_num"]          = number;
            result["block_num"]          = block.number;
            result["trial_num_in_block"] = numberInBlock;
            result["start_time"]         = startTime;

            foreach (Tracker tracker in session.trackedObjects)
            {
                tracker.StartRecording();
            }
            session.onTrialBegin.Invoke(this);
        }
Beispiel #9
0
        /// <summary>
        /// Begins the trial, updating the current trial and block number, setting the status to in progress, starting the timer for the trial, and beginning recording positions of every object with an attached tracker
        /// </summary>
        public void Begin()
        {
            session.currentTrialNum = number;
            session.currentBlockNum = block.number;

            status    = TrialStatus.InProgress;
            startTime = Time.time;
            result    = new ResultsDictionary(session.Headers, session.adHocHeaderAdd);

            result["directory"]          = Extensions.CombinePaths(session.experimentName, session.ppid, session.FolderName).Replace('\\', '/');
            result["experiment"]         = session.experimentName;
            result["ppid"]               = session.ppid;
            result["session_num"]        = session.number;
            result["trial_num"]          = number;
            result["block_num"]          = block.number;
            result["trial_num_in_block"] = numberInBlock;
            result["start_time"]         = startTime;

            foreach (Tracker tracker in session.trackedObjects)
            {
                tracker.StartRecording();
            }
            session.onTrialBegin.Invoke(this);
        }
 /// <summary>
 /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider"
 /// /> and <see cref="ignoreCase" />
 /// </summary>
 /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param>
 /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param>
 /// <param name="formatProvider">not used by this TypeConverter.</param>
 /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param>
 /// <returns>
 /// an instance of <see cref="TrialStatus" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => TrialStatus.CreateFrom(sourceValue);