00001
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
00033
00034 #ifndef GROOVX_VISX_TIMINGHANDLER_CC_UTC20050626084016_DEFINED
00035 #define GROOVX_VISX_TIMINGHANDLER_CC_UTC20050626084016_DEFINED
00036
00037 #include "timinghandler.h"
00038
00039 #include "io/ioproxy.h"
00040 #include "io/reader.h"
00041 #include "io/writer.h"
00042
00043 #include "nub/ref.h"
00044
00045 #include "visx/trialevent.h"
00046
00047 #include "rutz/trace.h"
00048 #include "rutz/debug.h"
00049 GVX_DBG_REGISTER
00050
00051 namespace
00052 {
00053 const io::version_id TIMINGHANDLER_SVID = 2;
00054 }
00055
00057
00058
00059
00061
00062 TimingHandler* TimingHandler::make()
00063 {
00064 GVX_TRACE("TimingHandler::make");
00065 return new TimingHandler;
00066 }
00067
00068 TimingHandler::TimingHandler() :
00069 stimdur_start_id(0),
00070 timeout_start_id(0),
00071 iti_response_id(0),
00072 abortwait_abort_id(0)
00073 {
00074 GVX_TRACE("TimingHandler::TimingHandler");
00075 addEventByName("DrawEvent", IMMEDIATE, 0);
00076 stimdur_start_id = addEventByName("UndrawEvent", FROM_START, 2000);
00077 timeout_start_id = addEventByName("AbortTrialEvent", FROM_START, 4000);
00078 addEventByName("UndrawEvent", FROM_RESPONSE, 0);
00079 iti_response_id = addEventByName("EndTrialEvent", FROM_RESPONSE, 1000);
00080 abortwait_abort_id = addEventByName("EndTrialEvent", FROM_ABORT, 1000);
00081 }
00082
00083 TimingHandler::~TimingHandler() throw()
00084 {
00085 GVX_TRACE("TimingHandler::~TimingHandler");
00086 }
00087
00088 io::version_id TimingHandler::class_version_id() const
00089 {
00090 GVX_TRACE("TimingHandler::class_version_id");
00091 return TIMINGHANDLER_SVID;
00092 }
00093
00094 void TimingHandler::read_from(io::reader& reader)
00095 {
00096 GVX_TRACE("TimingHandler::read_from");
00097
00098 reader.ensure_version_id("TimingHandler", 2, "Try groovx0.8a4", SRC_POS);
00099
00100 reader.read_base_class("TimingHdlr", io::make_proxy<TimingHdlr>(this));
00101 }
00102
00103 void TimingHandler::write_to(io::writer& writer) const
00104 {
00105 GVX_TRACE("TimingHandler::write_to");
00106
00107 writer.ensure_output_version_id("TimingHandler",
00108 TIMINGHANDLER_SVID, 2, "Try groovx0.8a4", SRC_POS);
00109
00110 writer.write_base_class("TimingHdlr", io::make_const_proxy<TimingHdlr>(this));
00111 }
00112
00113 int TimingHandler::getAbortWait() const
00114 {
00115 return getEvent(FROM_ABORT, abortwait_abort_id)->getDelay();
00116 }
00117
00118 int TimingHandler::getInterTrialInterval() const
00119 {
00120 return getEvent(FROM_RESPONSE, iti_response_id)->getDelay();
00121 }
00122
00123 int TimingHandler::getStimDur() const
00124 {
00125 return getEvent(FROM_START, stimdur_start_id)->getDelay();
00126 }
00127
00128 int TimingHandler::getTimeout() const
00129 {
00130 return getEvent(FROM_START, timeout_start_id)->getDelay();
00131 }
00132
00133 void TimingHandler::setAbortWait(int msec)
00134 {
00135 getEvent(FROM_ABORT, abortwait_abort_id)->setDelay(msec);
00136 }
00137
00138 void TimingHandler::setInterTrialInterval(int msec)
00139 {
00140 getEvent(FROM_RESPONSE, iti_response_id)->setDelay(msec);
00141 }
00142
00143 void TimingHandler::setStimDur(int msec)
00144 {
00145 getEvent(FROM_START, stimdur_start_id)->setDelay(msec);
00146 }
00147
00148 void TimingHandler::setTimeout(int msec)
00149 {
00150 getEvent(FROM_START, timeout_start_id)->setDelay(msec);
00151 }
00152
00153 static const char __attribute__((used)) vcid_groovx_visx_timinghandler_cc_utc20050626084016[] = "$Id: timinghandler.cc 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00154 #endif // !GROOVX_VISX_TIMINGHANDLER_CC_UTC20050626084016_DEFINED