void ListenForInterrupt() { foreach (KeyCode interruptKey in InterruptKeys) { if (Input.GetKeyDown(interruptKey)) { ExperimentEvents.InterruptTrial(); } } }
void ListenForGoToNextTrial() { foreach (KeyCode nextKey in NextKeys) { if (Input.GetKeyDown(nextKey)) { ExperimentEvents.SkipToNextTrial(); } } }
void ListenForGoBackTrial() { foreach (KeyCode backKey in BackKeys) { if (Input.GetKeyDown(backKey)) { ExperimentEvents.GoBackOneTrial(); } } }
/// <summary> /// Starts the Runner. The Runner does not start automatically, because it waits for an event to start it. /// </summary> /// <param name="currentSession"></param> void StartExperiment(Session currentSession) { if (!FinishedInitialization) { throw new NullReferenceException("Experiment started before FinishedInitialization"); } Running = true; outputManager = new OutputManager(currentSession.OutputFullPath); Debug.Log("Starting Runner"); ExperimentEvents.ExperimentStarted(); StartCoroutine(ConfigFile.ControlSettings.Run()); ExperimentEvents.StartPart(experiment); }
/// <summary> /// Display the Runner controls /// </summary> void ShowExperimentControls() { EditorGUILayout.Space(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.LabelField("Runner Controls:", EditorStyles.boldLabel); EditorGUI.indentLevel++; if (!runner.Running && !runner.Ended) { if (GUILayout.Button("Start Runner")) { ExperimentEvents.StartExperiment(session); } } else { EditorGUILayout.BeginHorizontal(); string runningText = runner.Running ? "Running" : "Not Running"; EditorGUILayout.LabelField($"Runner {runningText}."); int currentTrial = runner.Design.BlockCount * currentBlockIndex + currentTrialIndex + 1; if (currentTrial > runner.Design.TotalTrials) { currentTrial = runner.Design.TotalTrials; } EditorGUILayout.LabelField("Running Trial: " + $"{currentTrial}" + "/" + $"{runner.Design.TotalTrials} "); EditorGUILayout.EndHorizontal(); } string endedText = !runner.Ended ? "Not Finished" : "Ended"; EditorGUILayout.LabelField($"Runner is {endedText}."); EditorGUILayout.Space(); EditorGUI.indentLevel--; EditorGUILayout.EndVertical(); }
/// <summary> /// Updates the Runner's output /// </summary> void OutputUpdated() { ExperimentEvents.OutputUpdated(this); }
protected override void InternalPostMethod() { ExperimentEvents.BlockCompleted(this); }
void StartRunningExperiment(Session session) { ExperimentEvents.StartRunningExperiment(session); ExperimentStartPanel.gameObject.SetActive(false); ExperimentRunnerPanel.ShowPanel(); }
/// <summary> /// Displays tables of all trials /// </summary> void ShowTrialTables() { EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.Space(); EditorGUILayout.LabelField("NumberOfTrials:", EditorStyles.boldLabel); foreach (Block block in runner.Design.Blocks) { int blockIndex = runner.Design.Blocks.IndexOf(block); EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", IndentWidth); EditorGUILayout.TextArea($"Block Values: {block.Identity}", BlockIdentityWidth); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", IndentWidth); EditorGUILayout.LabelField("", RunningTrialIndicatorWidth); EditorGUILayout.LabelField("", JumpToButtonWidth); EditorGUILayout.LabelField("", CompleteIndicatorWidth); EditorGUILayout.TextArea(block.TrialTable.HeaderAsString()); EditorGUILayout.EndHorizontal(); for (int indexOfRow = 0; indexOfRow < block.TrialTable.Rows.Count; indexOfRow++) { DataRow trialRow = block.TrialTable.Rows[indexOfRow]; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", IndentWidth); if (currentTrialIndex == indexOfRow && currentBlockIndex == blockIndex) { EditorGUILayout.LabelField("Running", RunningTrialIndicatorWidth); } else { EditorGUILayout.LabelField("", RunningTrialIndicatorWidth); } if (blockIndex == currentBlockIndex) { // can't jump between blocks, only allow jumping with block. if (GUILayout.Button("Go", JumpToButtonWidth)) { ExperimentEvents.JumpToTrial(indexOfRow); } } else { EditorGUILayout.LabelField("", JumpToButtonWidth); } Trial trial = block.Trials[indexOfRow]; Color color = trial.CompletedSuccessfully ? Color.green : Color.red; color = trial.Skipped ? Color.yellow : color; EditorGUILayout.ColorField(GUIContent.none, color, false, false, false, CompleteIndicatorWidth); EditorGUILayout.TextArea(trialRow.AsString()); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } EditorGUI.indentLevel--; EditorGUILayout.EndVertical(); }
void TrialUpdated(List <Trial> trials, int index) { ExperimentEvents.UpdateOutput(this); }