private IEnumerable <View> GetViews(ISynchronizeInvoke invoker, StreamWriter logWriter, StreamWriter dataWriter, RandomizedQueue <StudyTestPair> study, RandomizedQueue <StudyTestPair> quiz, RandomizedQueue <StudyTestPair> done, Random numgen) { var currentTrialEntries = new List <EEGDataEntry>(); using (var artifactListener = new EEGDataListener(invoker, null, data => { foreach (var entry in data) { if (entry.HasStimulusMarker()) { lock (currentTrialEntries) { currentTrialEntries.Add(entry); } } } }, null)) { this.dataSource.AddListener(artifactListener); for (int index = 0; index < settings.NumRounds; index++) { double rand = numgen.NextDouble(); StudyTestPair stim; if (rand < .39) { if (!study.IsEmpty()) { stim = study.RemoveRandom(); quiz.Add(stim); logWriter.WriteLine("5"); logWriter.WriteLine(stim.test + "\\n" + stim.answer); yield return(new RestView(this.settings.BlinkTime)); yield return(new TextView(stim.test + "\n" + stim.answer, this.settings.PresentationTime, GUIUtils.Constants.DISPLAY_FONT_LARGE)); } else if (!quiz.IsEmpty()) { stim = quiz.RemoveRandom(); logWriter.WriteLine("7"); logWriter.WriteLine(stim.test); logWriter.WriteLine(stim.answer); foreach (var view in RunTrial(index, stim, dataWriter, logWriter, currentTrialEntries, study, quiz, done)) { yield return(view); } } else { stim = done.RemoveRandom(); logWriter.WriteLine("7"); logWriter.WriteLine(stim.test); logWriter.WriteLine(stim.answer); foreach (var view in RunTrial(index, stim, dataWriter, logWriter, currentTrialEntries, study, quiz, done)) { yield return(view); } } } else if (rand < .99) { if (!quiz.IsEmpty()) { stim = quiz.RemoveRandom(); logWriter.WriteLine("7"); logWriter.WriteLine(stim.test); logWriter.WriteLine(stim.answer); foreach (var view in RunTrial(index, stim, dataWriter, logWriter, currentTrialEntries, study, quiz, done)) { yield return(view); } } else if (!study.IsEmpty()) { stim = study.RemoveRandom(); quiz.Add(stim); logWriter.WriteLine("5"); logWriter.WriteLine(stim.test + "\\n" + stim.answer); yield return(new RestView(this.settings.BlinkTime)); yield return(new TextView(stim.test + "\n" + stim.answer, this.settings.PresentationTime, GUIUtils.Constants.DISPLAY_FONT_LARGE)); } else { stim = done.RemoveRandom(); logWriter.WriteLine("7"); logWriter.WriteLine(stim.test); logWriter.WriteLine(stim.answer); foreach (var view in RunTrial(index, stim, dataWriter, logWriter, currentTrialEntries, study, quiz, done)) { yield return(view); } } } else { if (!done.IsEmpty()) { stim = done.RemoveRandom(); logWriter.WriteLine("7"); logWriter.WriteLine(stim.test); logWriter.WriteLine(stim.answer); foreach (var view in RunTrial(index, stim, dataWriter, logWriter, currentTrialEntries, study, quiz, done)) { yield return(view); } } else if (!quiz.IsEmpty()) { stim = quiz.RemoveRandom(); logWriter.WriteLine("7"); logWriter.WriteLine(stim.test); logWriter.WriteLine(stim.answer); foreach (var view in RunTrial(index, stim, dataWriter, logWriter, currentTrialEntries, study, quiz, done)) { yield return(view); } } else { stim = study.RemoveRandom(); quiz.Add(stim); logWriter.WriteLine("5"); logWriter.WriteLine(stim.test + "\\n" + stim.answer); yield return(new RestView(this.settings.BlinkTime)); yield return(new TextView(stim.test + "\n" + stim.answer, this.settings.PresentationTime, GUIUtils.Constants.DISPLAY_FONT_LARGE)); } } } } }
private IEnumerable <View> GetViews(ISynchronizeInvoke invoker, StreamWriter logWriterV, StreamWriter logWriter, RandomizedQueue <StudyTestPair> studySoon, RandomizedQueue <StudyTestPair> testSoon, RandomizedQueue <StudyTestPair> testLate) { //Presents stimuli from the three categories randomly with set probabilities Random numgen = new Random(); for (int index = 0; index < settings.NumTrials; index++) { double choice = numgen.NextDouble(); if (choice < 0.01) { if (!testLate.IsEmpty()) { StudyTestPair currstp = testLate.RemoveRandom(); logWriterV.WriteLine("Question: " + currstp.test); logWriterV.WriteLine("Correct Answer: " + currstp.answer); foreach (var view in RunTrial(index, false, currstp, logWriter, logWriterV, studySoon, testSoon, testLate)) { yield return(view); } } else if (!studySoon.IsEmpty()) { StudyTestPair study = studySoon.RemoveRandom(); logWriterV.WriteLine("Study Trial"); logWriterV.WriteLine(study.test); logWriterV.WriteLine(study.answer); foreach (var view in RunTrial(index, true, study, logWriter, logWriterV, studySoon, testSoon, testLate)) { yield return(view); } } else { StudyTestPair currstp = testSoon.RemoveRandom(); logWriterV.WriteLine("Question: " + currstp.test); logWriterV.WriteLine("Correct Answer: " + currstp.answer); foreach (var view in RunTrial(index, false, currstp, logWriter, logWriterV, studySoon, testSoon, testLate)) { yield return(view); } } } else if (choice < 0.4) { if (!studySoon.IsEmpty()) { StudyTestPair study = studySoon.RemoveRandom(); logWriterV.WriteLine("Study Trial"); logWriterV.WriteLine(study.test); logWriterV.WriteLine(study.answer); foreach (var view in RunTrial(index, true, study, logWriter, logWriterV, studySoon, testSoon, testLate)) { yield return(view); } } else if (!testSoon.IsEmpty()) { StudyTestPair currstp = testSoon.RemoveRandom(); logWriterV.WriteLine("Question: " + currstp.test); logWriterV.WriteLine("Correct Answer: " + currstp.answer); foreach (var view in RunTrial(index, false, currstp, logWriter, logWriterV, studySoon, testSoon, testLate)) { yield return(view); } } else { StudyTestPair currstp = testLate.RemoveRandom(); logWriterV.WriteLine("Question: " + currstp.test); logWriterV.WriteLine("Correct Answer: " + currstp.answer); foreach (var view in RunTrial(index, false, currstp, logWriter, logWriterV, studySoon, testSoon, testLate)) { yield return(view); } } } else { if (!testSoon.IsEmpty()) { StudyTestPair currstp = testSoon.RemoveRandom(); logWriterV.WriteLine("Question: " + currstp.test); logWriterV.WriteLine("Correct Answer: " + currstp.answer); foreach (var view in RunTrial(index, false, currstp, logWriter, logWriterV, studySoon, testSoon, testLate)) { yield return(view); } } else if (!studySoon.IsEmpty()) { StudyTestPair study = studySoon.RemoveRandom(); logWriterV.WriteLine("Study Trial"); logWriterV.WriteLine(study.test); logWriterV.WriteLine(study.answer); foreach (var view in RunTrial(index, true, study, logWriter, logWriterV, studySoon, testSoon, testLate)) { yield return(view); } } else { StudyTestPair currstp = testLate.RemoveRandom(); logWriterV.WriteLine("Question: " + currstp.test); logWriterV.WriteLine("Correct Answer: " + currstp.answer); foreach (var view in RunTrial(index, false, currstp, logWriter, logWriterV, studySoon, testSoon, testLate)) { yield return(view); } } } } }