예제 #1
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 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);
        }
예제 #2
0
        /// <summary>
        /// Writes trial data (List of OrderedResultsDict) to file at fpath
        /// </summary>
        /// <param name="dataDict"></param>
        /// <param name="headers"></param>
        /// <param name="fpath"></param>
        public void WriteTrials(List <OrderedResultDict> dataDict, string[] headers, string fpath)
        {
            string[] csvRows = new string[dataDict.Count + 1];
            csvRows[0] = string.Join(",", headers.ToArray());
            object[] row = new object[headers.Length];

            for (int i = 1; i <= dataDict.Count; i++)
            {
                OrderedResultDict dict = dataDict[i - 1];
                if (dict != null)
                {
                    dict.Values.CopyTo(row, 0);
                    csvRows[i] = string.Join(",", row.Select(v => System.Convert.ToString(v)).ToArray());
                }
            }

            File.WriteAllLines(fpath, csvRows);
        }
        /// <summary>
        /// Writes trial data (List of OrderedResultsDict) to file at fpath
        /// </summary>
        /// <param name="dataDict"></param>
        /// <param name="headers"></param>
        /// <param name="fpath"></param>
        public void WriteTrials(List <OrderedResultDict> dataDict, string[] headers, WriteFileInfo writeFileInfo)
        {
            string[] csvRows = new string[dataDict.Count + 1];
            csvRows[0] = string.Join(",", headers.ToArray());
            object[] row = new object[headers.Length];

            for (int i = 1; i <= dataDict.Count; i++)
            {
                OrderedResultDict dict = dataDict[i - 1];
                if (dict != null)
                {
                    dict.Values.CopyTo(row, 0);
                    csvRows[i] = string.Join(",", row.Select(v => System.Convert.ToString(v)).ToArray());
                }
            }

            File.WriteAllLines(writeFileInfo.FullPath, csvRows);
            executeOnMainThreadQueue.Enqueue(() => onWriteFile.Invoke(writeFileInfo));
        }