Esempio n. 1
0
        public void SetUp()
        {
            gameObject    = new GameObject();
            fileIOManager = gameObject.AddComponent <FileIOManager>();
            sessionLogger = gameObject.AddComponent <SessionLogger>();
            session       = gameObject.AddComponent <Session>();

            session.AttachReferences(
                fileIOManager
                );

            sessionLogger.AttachReferences(
                fileIOManager,
                session
                );

            sessionLogger.Initialise();

            fileIOManager.debug = true;
            fileIOManager.Begin();

            string experimentName = "unit_test";
            string ppid           = "test_trials";

            session.Begin(experimentName, ppid, "example_output");
            session.customHeaders.Add("observation");
            session.customHeaders.Add("null_observation");

            // generate trials
            session.CreateBlock(2);
            session.CreateBlock(3);
        }
Esempio n. 2
0
        Session CreateSession(string ppidExtra)
        {
            GameObject    gameObject    = new GameObject();
            FileIOManager fileIOManager = gameObject.AddComponent <FileIOManager>();
            SessionLogger sessionLogger = gameObject.AddComponent <SessionLogger>();
            Session       session       = gameObject.AddComponent <Session>();

            session.AttachReferences(
                fileIOManager
                );

            sessionLogger.AttachReferences(
                fileIOManager,
                session
                );

            sessionLogger.Initialise();

            fileIOManager.debug = true;
            fileIOManager.Begin();

            string experimentName = "unit_test";
            string ppid           = "test_behaviour_" + ppidExtra;

            session.Begin(experimentName, ppid, "example_output");

            // generate trials
            session.CreateBlock(2);
            session.CreateBlock(3);

            return(session);
        }
        public void WriteManyFiles()
        {
            fileIOManager.Begin();

            // generate a large dictionary
            var dict = new Dictionary <string, object>();

            var largeArray = new int[10000];

            for (int i = 0; i < largeArray.Length; i++)
            {
                largeArray[i] = i;
            }

            dict["large_array"] = largeArray;


            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }


            // write lots of JSON files
            int n = 100;

            for (int i = 0; i < n; i++)
            {
                string        fileName = string.Format("{0:000}.json", i);
                WriteFileInfo fileInfo = new WriteFileInfo(WriteFileType.Test, path, fileName);
                Debug.LogFormat("Queueing {0}", fileName);
                fileIOManager.ManageInWorker(() => fileIOManager.WriteJson(dict, fileInfo));
            }

            fileIOManager.End();

            // cleanup files
            var files = System.IO.Directory.GetFiles(path, "*.json");

            foreach (var file in files)
            {
                System.IO.File.Delete(file);
            }
        }
Esempio n. 4
0
        public void SessionEndEvent()
        {
            gameObject    = new GameObject();
            fileIOManager = gameObject.AddComponent <FileIOManager>();
            sessionLogger = gameObject.AddComponent <SessionLogger>();
            session       = gameObject.AddComponent <Session>();

            session.AttachReferences(
                fileIOManager
                );

            sessionLogger.AttachReferences(
                fileIOManager,
                session
                );

            session.onSessionEnd.AddListener(UseSession);

            sessionLogger.Initialise();

            fileIOManager.debug = true;
            fileIOManager.Begin();

            string experimentName = "unit_test";
            string ppid           = "test_trials";

            session.Begin(experimentName, ppid, "example_output");
            session.customHeaders.Add("observation");

            // generate trials
            session.CreateBlock(2);
            session.CreateBlock(3);

            int i = 0;

            foreach (var trial in session.Trials)
            {
                trial.Begin();
                trial.result["observation"] = ++i;
                trial.End();
            }

            session.End();
        }
        public void SetUp()
        {
            gameObject    = new GameObject();
            fileIOManager = gameObject.AddComponent <FileIOManager>();
            sessionLogger = gameObject.AddComponent <SessionLogger>();
            session       = gameObject.AddComponent <Session>();

            session.AttachReferences(
                fileIOManager,
                sessionLogger
                );

            sessionLogger.AttachReferences(
                fileIOManager,
                session
                );

            sessionLogger.Initialise();

            fileIOManager.debug = true;
            fileIOManager.Begin();

            string experimentName = "unit_test";
            string ppid           = "test_trackers";

            session.Begin(experimentName, ppid, "example_output");


            for (int i = 0; i < 5; i++)
            {
                GameObject trackedObject = new GameObject();
                Tracker    tracker       = trackedObject.AddComponent <PositionRotationTracker>();
                tracker.objectName = string.Format("Tracker_{0}", i);

                session.trackedObjects.Add(tracker);
                tracked.Add(trackedObject);
            }


            // generate trials
            session.CreateBlock(10);
        }
        public void SetUp()
        {
            gameObject    = new GameObject();
            fileIOManager = gameObject.AddComponent <FileIOManager>();
            sessionLogger = gameObject.AddComponent <SessionLogger>();
            session       = gameObject.AddComponent <Session>();

            session.AttachReferences(
                fileIOManager,
                sessionLogger
                );

            sessionLogger.AttachReferences(
                fileIOManager,
                session
                );

            sessionLogger.Initialise();

            fileIOManager.debug = true;
            fileIOManager.Begin();
        }