Exemplo n.º 1
0
        public IEnumerable <View> RunTrial(int index, string tst, string ans, int numstim, StreamWriter dataWriter, StreamWriter logWriter, StreamWriter anslog, List <EEGDataEntry> currentTrialEntries, RandomizedQueue <string> pres)
        {
            yield return(new RestView(this.settings.BlinkTime));

            yield return(new FixationView(this.settings.FixationTime));

            IViewResult result;
            var         vocabView = new VocabView(tst, ans, settings.DisplayTime, settings.DelayTime, false, anslog, out result);

            vocabView.DoOnDeploy(c => this.dataSource.Marker = index + 1);
            bool noWrite = false;

            vocabView.DoOnFinishing(() =>
            {
                this.dataSource.Marker = EEGDataEntry.MARKER_DEFAULT;
                lock (currentTrialEntries)
                {
                    var trialsDuringDelay = currentTrialEntries.Where(e => e.RelativeTimeStamp <= settings.DelayTime);
                    if (this.settings.ArtifactDetectionSettings.HasMotionArtifact(trialsDuringDelay))
                    {
                        //logWriter.WriteLine("Motion Artifact Detected");
                        noWrite = true;
                    }
                    else
                    {
                        if (this.settings.SaveTrialData)
                        {
                            foreach (var entry in trialsDuringDelay)
                            {
                                dataWriter.WriteLine(entry + ", {0}", numstim);
                            }
                        }
                    }
                    currentTrialEntries.Clear();
                }
            });
            yield return(vocabView);

            //No feedback in original Karpicke and Roediger, but I'm leaving the option
            //yield return new TextView((bool)result.Value ? "Correct" : "Incorrect", settings.FeedbackTime, GUIUtils.Constants.DISPLAY_FONT);
            int towrite = 0;

            if ((bool)result.Value)
            {
                pres.Remove(tst + Environment.NewLine + ans);
                towrite = 1;
            }
            if (!noWrite)
            {
                logWriter.WriteLine(numstim + ", " + towrite + ", " + index + 1);
            }
            //if (needToRerun)
            //{
            //    foreach (var view in RunTrial(index, tst, ans, dataWriter, logWriter, currentTrialEntries, pres))
            //    {
            //        yield return view;
            //    }
            //}
        }