ExperimentManager.Start C# (CSharp) Method

Start() public method

public Start ( ) : void
return void
    void Start()
    {
        // Build base trial list
        int[,] trials = new int[totalTrials,tasksPerTrial];
        int trialIndex = 0;
        for (int i = 0; i < totalTrials; i++) {
            for (int j = 0; j < tasksPerTrial; j++) {
                trials[i,j] = trialIndex;
                trialIndex++;
            }
        }

        // Randomize trial order
        System.Random r = new System.Random();
        for (int i = totalTrials - 1; i > 0; i--) {
            int j = r.Next(i + 1);
            // Debug.Log("swapping trial " + i + " with trial " + j);
            for (int k = 0; k < tasksPerTrial; k++) {
                int temp = trials[i,k];
                trials[i,k] = trials[j,k];
                trials[j,k] = temp;
            }
        }

        // Randomize task order
        for (int i = 0; i < totalTrials; i++) {
            // Debug.Log ("randomizing trial " + i);
            for (int j = tasksPerTrial - 1; j > 0; j--) {
                int k = r.Next (j + 1);
                // Debug.Log("swapping task " + j + " with task " + k);
                int temp = trials[i,j];
                trials[i,j] = trials[i,k];
                trials[i,k] = temp;
            }
        }

        // Flatten ordering and save in trialList
        trialList = new int[totalTrials * tasksPerTrial];
        for (int i = 0; i < totalTrials; i++) {
            for (int j = 0; j < tasksPerTrial; j++) {
                int index = i * tasksPerTrial + j;
                trialList[index] = trials[i,j];
            }
        }

        // Setup subject data
        subjectData = CreateEmptySubjectData(tasksPerTrial * totalTrials);
    }

Usage Example

Ejemplo n.º 1
0
        //-------------------------------------------------------------------------------------------------//

        protected void Application_Start(object sender, EventArgs e)
        {
            const string STRLOG_MethodName = "Application_Start";

            //
            // Set the filepath for the log files
            //
            string rootFilePath = HostingEnvironment.ApplicationPhysicalPath;
            string logFilesPath = Utilities.GetAppSetting(Consts.STRCFG_LogFilesPath);

            Logfile.SetFilePath(Path.Combine(rootFilePath, logFilesPath));

            Logfile.Write("");
            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            //
            // Create the experiment manager
            //
            allowedServiceBrokers = new AllowedServiceBrokersDB();
            configuration         = new Library.LabServer.Configuration(rootFilePath);
            experimentManager     = new ExperimentManager(allowedServiceBrokers, configuration);
            experimentManager.Create();

            //
            // Now start the experiment manager
            //
            experimentManager.Start();

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);
        }