psycho-3D-proto.C
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "Component/ModelManager.H"
00040 #include "Image/Image.H"
00041 #include "Psycho/PsychoDisplay.H"
00042 #include "Psycho/EyeTrackerConfigurator.H"
00043 #include "Psycho/EyeTracker.H"
00044 #include "Psycho/PsychoOpts.H"
00045 #include "Component/EventLog.H"
00046 #include "Component/ComponentOpts.H"
00047 #include "Raster/Raster.H"
00048 #include "Util/MathFunctions.H"
00049 #include "Util/Types.H"
00050 #include "GameBoard/basic-graphics.H"
00051 #include <sys/types.h>
00052 #include <dirent.h>
00053 #include <errno.h>
00054 #include <vector>
00055 #include <string>
00056 #include <iostream>
00057 #include <SDL/SDL.h>
00058 #include <SDL/SDL_image.h>
00059 #include <SDL/SDL_mixer.h>
00060 #include <stdio.h>
00061 #include <stdlib.h>
00062 #include <sstream>
00063 #include <time.h>
00064 #include "Image/DrawOps.H"
00065 #include "GameBoard/resize.h"
00066 #include <iostream>
00067 #include <fstream>
00068 #include <set>
00069 #include <algorithm>
00070 #include <ctime>
00071 #include "Util/LEDcontroller.H"
00072
00073
00074
00075
00076
00077 using namespace std;
00078 template <class T> std::string stringify(T i)
00079 {
00080 ostringstream o ;
00081 o << i ;
00082 return o.str();
00083 }
00084
00085
00086
00087 extern "C" int main(const int argc, char** argv)
00088 {
00089 MYLOGVERB = LOG_INFO;
00090
00091
00092 ModelManager manager("Psycho 3D");
00093
00094
00095 nub::soft_ref<PsychoDisplay> d(new PsychoDisplay(manager));
00096 manager.addSubComponent(d);
00097
00098 nub::ref<LEDcontroller> itsledcon(new LEDcontroller(manager));
00099 manager.addSubComponent(itsledcon);
00100
00101 nub::soft_ref<EyeTrackerConfigurator>
00102 etc(new EyeTrackerConfigurator(manager));
00103 manager.addSubComponent(etc);
00104
00105 nub::soft_ref<EventLog> el(new EventLog(manager));
00106 manager.addSubComponent(el);
00107
00108 manager.setOptionValString(&OPT_EventLogFileName, "psycho3DET.psy");
00109
00110 manager.setOptionValString(&OPT_EyeTrackerType, "EL");
00111
00112
00113 if (manager.parseCommandLine(argc, argv,
00114 " ", 0, 0)==false)
00115 return(1);
00116
00117
00118 nub::soft_ref<EyeTracker> et = etc->getET();
00119 d->setEyeTracker(et);
00120 d->setEventLog(el);
00121 et->setEventLog(el);
00122
00123
00124 manager.start();
00125
00126
00127
00128 int eFlag = 0 ;
00129
00130 d->clearScreen();
00131 d->displayText("<SPACE> for Eye-Link calibration; other key for skipping");
00132 int c = d->waitForKey();
00133 if (c == ' ') {et->calibrate(d);}
00134
00135 d->clearScreen();
00136
00137
00138
00139
00140 d->displayText("<SPACE> for off screen eye-trakin; other key for skipping");
00141 c = d->waitForKey();
00142 if (c == ' ') {eFlag=1;}
00143
00144
00145
00146 for (int j=0;j<1;j++){
00147 d->pushEvent("round: "+ stringify(j));
00148 d->clearScreen();
00149 if(eFlag==1) d->displayText("get ready for a round of LED calibration ");
00150
00151 for(int i=1;i<5;i++){
00152 d->clearScreen();
00153 string s = stringify(i);
00154 d->displayText(s);
00155 itsledcon -> setLED(i,true);
00156 usleep(1000000);
00157 if(eFlag==1) {
00158 if(j==0){
00159 d->pushEvent("displayEvent start LEDCALIB" +s);
00160 }else{
00161 d->pushEvent("displayEvent start LEDVALID" +s+"_"+stringify(j));
00162 }
00163 et->track(true);
00164
00165 }
00166 d->waitFrames(60);
00167 if(eFlag==1) {
00168 if(j==0){
00169 d->pushEvent("displayEvent stop LEDCALIB" +s);
00170 }else{
00171 d->pushEvent("displayEvent stop LEDVALID" +s+"_"+stringify(j));
00172 }
00173 et->track(false);
00174 }
00175 itsledcon -> setLED(i,false);
00176 d->waitForKey();
00177 }
00178 }
00179
00180 d->clearScreen();
00181 d->displayText("get ready for first trial");
00182 d->waitForKey();
00183 d->clearScreen();
00184
00185 d->pushEvent("displayEvent start TRIAL1");
00186 et->track(true);
00187 d->waitForKey();
00188 d->pushEvent("displayEvent stop TRIAL1");
00189 et->track(false);
00190 d->clearScreen();
00191 d->displayText("get ready for second trial");
00192 d->waitForKey();
00193 d->clearScreen();
00194
00195 d->pushEvent("displayEvent start TRIAL2");
00196 et->track(true);
00197 d->waitForKey();
00198 d->pushEvent("displayEvent stop TRIAL2");
00199 et->track(false);
00200 d->clearScreen();
00201 d->displayText("get ready for third trial");
00202 d->waitForKey();
00203 d->clearScreen();
00204
00205 d->pushEvent("displayEvent start TRIAL3");
00206 et->track(true);
00207 d->waitForKey();
00208 d->pushEvent("displayEvent stop TRIAL3");
00209 et->track(false);
00210 d->clearScreen();
00211 d->displayText("get ready for third trial");
00212 d->waitForKey();
00213 d->clearScreen();
00214
00215 d->pushEvent("displayEvent start TRIAL4");
00216 et->track(true);
00217 d->waitForKey();
00218 d->pushEvent("displayEvent stop TRIAL4");
00219 et->track(false);
00220
00221 d->clearScreen();
00222 d->displayText("Experiment is complete. Thank you!");
00223 d->waitForKey();
00224
00225
00226
00227 manager.stop();
00228
00229
00230 return 0;
00231 }
00232