public override void HandleSessionInitialisation() { base.HandleSessionInitialisation(); // New file for the performance data logger performanceDataLogger.CloseLog(); performanceDataLogger.AddNewLogFile(AvatarSystem.AvatarType.ToString(), sessionNumber, ablebodiedPerformanceDataFormat); // Add file // Clear ball gridManager.ResetBallSelection(); }
/// <summary> /// Handles procedures performed when initialising the next iteration. /// Updates iteration number, session number, resets the task time, and starts a new data log by default. /// Extend this method by doing your own implementation, with base.HandleSessionInitialisation() being called at the start. /// </summary> public override void HandleSessionInitialisation() { base.HandleSessionInitialisation(); #region Iteration settings // Set iterations variables for flow control. targetNumber = poseListManager.TargetNumber; iterationsPerSession[sessionNumber - 1] = targetNumber * iterationsPerTarget; // Create the list of target indexes and shuffle it. targetOrder.Clear(); //clear the target order for (int i = 0; i < targetNumber; i++) { for (int j = 0; j < iterationsPerTarget; j++) { targetOrder.Add(i); Debug.Log(targetOrder[targetOrder.Count - 1]); } } targetOrder.Shuffle(); // New file for the performance data logger performanceDataLogger.CloseLog(); performanceDataLogger.AddNewLogFile(AvatarSystem.AvatarType.ToString(), sessionNumber, performanceDataFormat); // Add file // Display task text StartCoroutine(DisplayTaskText(targetOrder[0])); if (debug) { foreach (int target in targetOrder) { Debug.Log("Pose:" + target); } } #endregion }
// Update is called once per frame void Update() { switch (experimentState) { /* ************************************************* * HelloWorld ************************************************* */ // Welcome subject to the virtual world. case ExperimentState.Welcome: if (WaitFlag) { HudManager.ClearText(); experimentState = ExperimentState.Initialising; } else { HudManager.DisplayText("Welcome!"); } break; /* ************************************************* * InitializingApplication ************************************************* */ // Perform initialization functions before starting experiment. case ExperimentState.Initialising: // // Perform experiment initialization procedures // // Enable colliders AvatarSystem.EnableAvatarColliders(); // Initialize arm guide guideManager.Initialize(startAngleList[angleNumber - 1], endAngleList[angleNumber - 1], movementTimeList[timeNumber - 1]); guideManager.GoToStart(); // // Initialize data logs // motionLogger.AddNewLogFile(startAngleList[angleNumber - 1] + "_" + endAngleList[angleNumber - 1] + "_" + movementTimeList[timeNumber - 1], iterationNumber, motionDataFormat); // // Go to training // experimentState = ExperimentState.Training; break; /* ************************************************* * Practice ************************************************* */ // Perform initialization functions before starting experiment. case ExperimentState.Training: // // Guide subject through training // // // Go to instructions // experimentState = ExperimentState.Instructions; break; /* ************************************************* * GivingInstructions ************************************************* */ case ExperimentState.Instructions: HudManager.DisplayText(movementTimeList[timeNumber - 1] + " sec. movement.", 2.0f); // Skip instructions when repeating sessions if (SkipInstructions) { //hudManager.DisplayText("Move to guide", 2.0f); experimentState = ExperimentState.WaitingForStart; break; } // // Give instructions // // // Go to waiting for start // experimentState = ExperimentState.WaitingForStart; break; /* ************************************************* * WaitingForStart ************************************************* */ case ExperimentState.WaitingForStart: // Check if pause requested UpdatePause(); switch (waitState) { // Waiting for subject to grab the object. case WaitState.Waiting: if (guideManager.StartGuiding()) { //StopAllCoroutines(); HudManager.ClearText(); taskTime = 0.0f; HUDCountDown(3); experimentState = ExperimentState.PerformingTask; } break; default: break; } break; /* ************************************************* * PerformingTask ************************************************* */ case ExperimentState.PerformingTask: // Task performance is handled deterministically in FixedUpdate. break; /* ************************************************* * AnalizingResults ************************************************* */ case ExperimentState.AnalizingResults: HudManager.DisplayText("Rest your arm.", 5.0f); // Allow 3 seconds after task end to do calculations SetWaitFlag(5.0f); // // Data analysis and calculations // // // Adaptive system update (when available) // // // Data logging and log management // motionLogger.CloseLog(); // // Flow managment // // Rest for some time when required if (IsRestTime()) { HudManager.ClearText(); HudManager.DisplayText("Rest your arm.", 2.0f); SetWaitFlag(RestTime); experimentState = ExperimentState.Resting; break; } else if (IsEndOfExperiment()) { experimentState = ExperimentState.End; break; } // Check whether the new session condition is met else if (IsEndOfSession()) { // // Update iterations and flow control // iterationNumber++; timeIterations++; totalIterations++; // Go to next experimentState = ExperimentState.InitializingNext; break; } else { experimentState = ExperimentState.UpdatingApplication; } break; /* ************************************************* * UpdatingApplication ************************************************* */ case ExperimentState.UpdatingApplication: if (WaitFlag) { // // Update iterations and flow control // iterationNumber++; timeIterations++; totalIterations++; // // Update experiment object // guideManager.GoToStart(); // // Update log requirements // motionLogger.AddNewLogFile(startAngleList[angleNumber - 1] + "_" + endAngleList[angleNumber - 1] + "_" + movementTimeList[timeNumber - 1], iterationNumber, motionDataFormat); // // Go to start of next iteration // HudManager.DisplayText("Move to guide", 2.0f); experimentState = ExperimentState.WaitingForStart; } break; /* ************************************************* * InitializingNext ************************************************* */ case ExperimentState.InitializingNext: if (WaitFlag) { // // Perform session closure procedures // // // Initialize new session variables and flow control // iterationNumber = 1; sessionNumber++; // Still doing the angle repetitions for the same time if (timeIterations < timeIterationLimit) { angleNumber++; } // Done all the angle repetitions for the given time, reset and go to next time else { angleNumber = 1; timeIterations = 1; timeNumber++; } // // Update experiment object // guideManager.GoToStart(); // // Initialize data logging // experimentState = ExperimentState.Initialising; // Initialize next session } break; /* ************************************************* * Resting ************************************************* */ case ExperimentState.Resting: // // Check for session change or end request from experimenter // if (UpdateNext()) { ConfigureNextSession(); break; } else if (UpdateEnd()) { EndExperiment(); break; } // // Restart after flag is set by wait coroutine // if (WaitFlag) { if (IsEndOfExperiment()) { experimentState = ExperimentState.End; break; } // Check whether the new session condition is met else if (IsEndOfSession()) { // // Update iterations and flow control // iterationNumber++; timeIterations++; totalIterations++; // Go to next experimentState = ExperimentState.InitializingNext; break; } else { HudManager.DisplayText("Get ready!", 3.0f); SetWaitFlag(3.0f); experimentState = ExperimentState.UpdatingApplication; } break; } break; /* ************************************************* * Paused ************************************************* */ case ExperimentState.Paused: // // Check for session change or end request from experimenter // UpdatePause(); if (UpdateNext()) { ConfigureNextSession(); break; } else if (UpdateEnd()) { EndExperiment(); break; } break; /* ************************************************* * End ************************************************* */ case ExperimentState.End: // // Update log data and close logs. // HudManager.DisplayText("Experiment end, thanks!", 5.0f); // // Return to main menu // break; default: break; } // // Update information displayed on monitor // string experimentInfoText = "Experiment info: \n"; experimentInfoText += "Iteration: " + iterationNumber + "/" + iterationsPerAngle + ".\n"; experimentInfoText += "Session: " + sessionNumber + "/" + startAngleList.Count * movementTimeList.Count + ".\n"; InstructionManager.DisplayText(experimentInfoText); // // Update information displayed for debugging purposes // if (debug) { string debugText = "Debug info: \n"; debugText += experimentState.ToString() + ".\n"; if (experimentState == ExperimentState.WaitingForStart) { debugText += waitState.ToString() + ".\n"; } debugText += "Angle number:" + angleNumber + ".\n"; debugText += "Time iterations:" + timeIterations + ".\n"; InstructionManager.DisplayText(debugText + "\n" + experimentInfoText); } }